~ubuntu-branches/ubuntu/intrepid/miro/intrepid

« back to all changes in this revision

Viewing changes to platform/windows-xul/setup.py

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2008-02-09 13:37:10 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080209133710-9rs90q6gckvp1b6i
Tags: 1.1.2-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
17
#
 
18
# In addition, as a special exception, the copyright holders give
 
19
# permission to link the code of portions of this program with the OpenSSL
 
20
# library.
 
21
#
 
22
# You must obey the GNU General Public License in all respects for all of
 
23
# the code used other than OpenSSL. If you modify file(s) with this
 
24
# exception, you may extend this exception to your version of the file(s),
 
25
# but you are not obligated to do so. If you do not wish to do so, delete
 
26
# this exception statement from your version. If you delete this exception
 
27
# statement from all source files in the program, then also delete it here.
17
28
 
18
29
import os.path
19
30
import os
45
56
# below.
46
57
defaultBinaryKitRoot = os.path.join(os.path.dirname(sys.argv[0]), \
47
58
                                    '..', '..', '..', 'dtv-binary-kit')
48
 
BINARY_KIT_ROOT = defaultBinaryKitRoot
 
59
BINARY_KIT_ROOT = os.path.abspath(defaultBinaryKitRoot)
49
60
 
50
 
# Set BOOST_LIB, BOOST_INCLUDE_PATH, and BOOST_RUNTIMES as appropriate
51
 
# for the location of Boost, the version you built, and the compiler
52
 
# you used. If you are unsure, search your hard drive for a file named
53
 
# "boost_python*". If there is more than one, you probably already
54
 
# know what you're doing.
55
 
# NEEDS: better accomodate non-vc71 compilers in binary kit?
56
61
BOOST_ROOT = os.path.join(BINARY_KIT_ROOT, 'boost', 'win32')
57
62
BOOST_LIB_PATH = os.path.join(BOOST_ROOT, 'lib')
58
 
 
59
 
# Hack so we don't break things for people who haven't updated their binary kit
60
 
if os.path.exists(os.path.join(BOOST_ROOT, 'include', 'boost-1_33_1')):
61
 
    BOOST_LIB = os.path.join(BOOST_LIB_PATH, 'boost_python-vc71-mt-1_33_1.lib')
62
 
    BOOST_INCLUDE_PATH = os.path.join(BOOST_ROOT, 'include', 'boost-1_33_1')
63
 
    BOOST_RUNTIMES = [
64
 
        os.path.join(BOOST_LIB_PATH, 'boost_python-vc71-mt-1_33_1.dll'),
65
 
        ]
66
 
else:
67
 
    BOOST_LIB = os.path.join(BOOST_LIB_PATH, 'boost_python-vc71-mt-1_33.lib')
68
 
    BOOST_INCLUDE_PATH = os.path.join(BOOST_ROOT, 'include', 'boost-1_33')
69
 
    BOOST_RUNTIMES = [
70
 
        os.path.join(BOOST_LIB_PATH, 'boost_python-vc71-mt-1_33.dll'),
71
 
        ]
 
63
BOOST_INCLUDE_PATH = os.path.join(BOOST_ROOT, 'include')
 
64
BOOST_LIBRARIES = [os.path.splitext(os.path.basename(f))[0] for f in
 
65
        glob(os.path.join(BOOST_LIB_PATH, '*.lib'))]
 
66
BOOST_RUNTIMES = glob(os.path.join(BOOST_LIB_PATH, '*.dll'))
 
67
 
 
68
ZLIB_INCLUDE_PATH = os.path.join(BINARY_KIT_ROOT, 'zlib', 'include')
 
69
ZLIB_LIB_PATH = os.path.join(BINARY_KIT_ROOT, 'zlib', 'lib')
 
70
ZLIB_RUNTIME_LIBRARY_PATH = os.path.join(BINARY_KIT_ROOT, 'zlib')
 
71
ZLIB_RUNTIMES = [os.path.join(ZLIB_RUNTIME_LIBRARY_PATH, 'zlib1.dll')]
 
72
 
 
73
OPENSSL_INCLUDE_PATH = os.path.join(BINARY_KIT_ROOT, 'openssl', 'include')
 
74
OPENSSL_LIB_PATH = os.path.join(BINARY_KIT_ROOT, 'openssl', 'lib')
 
75
OPENSSL_LIBRARIES = [ 'ssleay32', 'libeay32']
 
76
 
 
77
 
72
78
 
73
79
# The 'Democracy.exe' launcher stub, currently provided only in the
74
80
# binary kit.
166
172
 
167
173
# Find the top of the source tree and set search path
168
174
root = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), '..', '..')
 
175
platform_dir = os.path.join(root, 'platform', 'windows-xul')
 
176
portable_dir = os.path.join(root, 'portable')
169
177
sys.path[0:0] = [
170
 
    os.path.join(root, 'platform', platform),
171
 
    os.path.join(root, 'platform'),
172
 
    os.path.join(root, 'portable'),
 
178
    platform_dir,
 
179
    portable_dir,
173
180
]
174
181
root = os.path.normpath(root)
175
182
 
 
183
#### The database extension ####
 
184
database_ext = Extension("database", 
 
185
        sources=[os.path.join(root, 'portable', 'database.pyx')])
 
186
 
176
187
#### The fasttypes extension ####
177
188
 
178
189
fasttypes_ext = \
179
190
    Extension("fasttypes", 
180
191
        sources = [os.path.join(root, 'portable', 'fasttypes.cpp')],
181
 
        extra_objects = [BOOST_LIB],
 
192
        library_dirs = [BOOST_LIB_PATH],
182
193
        include_dirs = [BOOST_INCLUDE_PATH]
183
194
    )
184
195
 
185
 
os.environ['PATH'] = r'%s;%s' % (os.environ['PATH'], BOOST_LIB_PATH)
 
196
# Setting the path here allows py2exe to find the DLLS
 
197
os.environ['PATH'] = r'%s;%s;%s;%s' % (os.environ['PATH'], BOOST_LIB_PATH,
 
198
        ZLIB_RUNTIME_LIBRARY_PATH, OPENSSL_LIB_PATH)
 
199
 
 
200
##### The libtorrent extension ####
 
201
 
 
202
def fetchCpp():
 
203
    for root,dirs,files in os.walk(os.path.join(portable_dir, 'libtorrent')):
 
204
        if '.svn' in dirs:
 
205
            dirs.remove('.svn')
 
206
        if '_svn' in dirs:
 
207
            dirs.remove('_svn')
 
208
        for file in files:
 
209
            if file.endswith('.cpp'):
 
210
                yield os.path.join(root,file)
 
211
 
 
212
libtorrent_sources=list(fetchCpp())
 
213
libtorrent_sources.remove(os.path.join(portable_dir, 'libtorrent\\src\\file.cpp'))
 
214
 
 
215
print [ BOOST_LIB_PATH, OPENSSL_LIB_PATH, ZLIB_LIB_PATH]
 
216
libtorrent_ext = Extension(
 
217
        "libtorrent", 
 
218
        include_dirs = [
 
219
            os.path.join(portable_dir, 'libtorrent', 'include'),
 
220
            os.path.join(portable_dir, 'libtorrent', 'include', 'libtorrent'),
 
221
            BOOST_INCLUDE_PATH, 
 
222
            ZLIB_INCLUDE_PATH, 
 
223
            OPENSSL_INCLUDE_PATH,
 
224
        ],
 
225
        library_dirs = [ BOOST_LIB_PATH, OPENSSL_LIB_PATH, ZLIB_LIB_PATH],
 
226
        libraries = OPENSSL_LIBRARIES + BOOST_LIBRARIES + [
 
227
            'wsock32', 'gdi32', 'ws2_32', 'zdll'
 
228
            ],
 
229
        extra_compile_args = [  '-DBOOST_WINDOWS',
 
230
            '-DWIN32_LEAN_AND_MEAN',
 
231
            '-D_WIN32_WINNT=0x0500',
 
232
            '-D__USE_W32_SOCKETS',
 
233
            '-D_WIN32',
 
234
            '-DWIN32',
 
235
            '-DBOOST_ALL_NO_LIB',
 
236
            '-D_FILE_OFFSET_BITS=64',
 
237
            '-DBOOST_THREAD_USE_LIB',
 
238
            '-DTORRENT_USE_OPENSSL=1',
 
239
            '-DNDEBUG=1',
 
240
            '/EHa', '/GR',
 
241
            ],
 
242
        sources = libtorrent_sources)
186
243
 
187
244
# Private extension modules to build.
188
245
ext_modules = [
189
246
    fasttypes_ext,
 
247
    libtorrent_ext,
 
248
    database_ext,
190
249
 
191
250
    # Pyrex sources.
192
251
    #Extension("vlc", [os.path.join(root, 'platform',platform, 'vlc.pyx')],libraries=["simplevlc"]),
193
 
    Extension("database", [os.path.join(root, 'portable', 'database.pyx')]),
194
252
    Extension("sorts", [os.path.join(root, 'portable', 'sorts.pyx')]),
195
253
    #Extension("template", [os.path.join(root, 'portable', 'template.pyx')]),
196
254
]
475
533
        # current directory set appropriately.]
476
534
#        dllDistDir = self.xulrunnerOut
477
535
        dllDistDir = self.dist_dir
478
 
        allRuntimes = PYTHON_RUNTIMES + BOOST_RUNTIMES + COMPILER_RUNTIMES
 
536
        allRuntimes = (PYTHON_RUNTIMES + BOOST_RUNTIMES + COMPILER_RUNTIMES +
 
537
                ZLIB_RUNTIMES)
479
538
        for runtime in allRuntimes:
480
539
            shutil.copy2(runtime, dllDistDir)
481
540
 
487
546
        self.copyMovieDataUtil()
488
547
        shutil.copy2("Democracy.nsi", self.dist_dir)
489
548
        shutil.copy2("Miro.ico", os.path.join(self.dist_dir, "%s.ico" % (self.getTemplateVariable('shortAppName'))))
 
549
        shutil.copy2("iHeartMiro-installer-page.ini", self.dist_dir)
 
550
#        copyTreeExceptSvn(os.path.join(platform_dir, "iHeartMiro"), os.path.join(self.dist_dir, "iHeartMiro"))
490
551
 
491
552
 
492
553
        locale_dir = os.path.join (self.appResources, "locale")
508
569
        os.rename(os.path.join(self.xulrunnerOut, "xulrunner.exe"),
509
570
                  os.path.join(self.xulrunnerOut, "%s.exe" % (self.getTemplateVariable('shortAppName'))))
510
571
        os.remove(os.path.join(self.xulrunnerOut, "xulrunner-stub.exe"))
511
 
 
 
572
        
512
573
        # Finally, build the download daemon
513
574
        self.buildDownloadDaemon(self.dist_dir)
514
575
        
594
655
 
595
656
    def buildDownloadDaemon(self, baseDir):
596
657
        print "building download daemon"
597
 
        os.system("%s setup_daemon.py py2exe --dist-dir daemon --bundle-files 1" % PYTHON_BINARY)
598
 
        shutil.copy2(os.path.join("daemon","%s_Downloader.exe" % (self.getTemplateVariable('shortAppName'))), baseDir)
 
658
        os.system("%s setup_daemon.py py2exe --dist-dir %s" % 
 
659
                (PYTHON_BINARY, self.dist_dir))
599
660
 
600
661
    def buildMovieDataUtil(self):
601
662
        print "building movie data utility"
883
944
            self.addFile ("python24.dll")
884
945
        else: # We must be using Python 2.5
885
946
            self.addFile ("python25.dll")
886
 
        for boostFile in BOOST_RUNTIMES:
887
 
            self.addFile (os.path.basename(boostFile))
888
947
 
889
948
        self.addDirectory ("chrome")
890
949
        self.addDirectory ("components")