def build_libxslt(): 'needed by webkit and lxml' from compiledeps import libxml2_dirname libxmlabs = abspath(libxml2_dirname) libxmlinc = pathjoin(libxmlabs, 'include') libxmllib = pathjoin(libxmlabs, 'win32', 'bin.msvc') iconvinc = pathjoin(abspath(iconv_dirname), 'include') libxslt_dir = libxslt.get() with cd(libxslt_dir): with cd('libxslt'): ensure_processonenode_is_public() with cd('win32'): patch_libxml2_h('..', 'libxslt') debug_flag = ['debug=yes'] if DEBUG else [] run([ 'cscript', 'configure.js', '//E:JavaScript', 'vcmanifest=yes' ] + debug_flag + [ 'include=%s' % os.pathsep.join([libxmlinc, iconvinc]), 'lib=%s' % libxmllib ]) filerepl('Makefile.msvc', '/O2', '/Os /GL /GS- /Zi') filerepl('Makefile.msvc', 'LDFLAGS = /nologo', 'LDFLAGS = /OPT:REF /OPT:ICF /nologo /DEBUG') run(['nmake', '-f', 'Makefile.msvc'] + (['clean'] if CLEAN else [])) return libxslt_dir
def build_libxslt(): 'needed by webkit and lxml' from compiledeps import libxml2_dirname libxmlabs = abspath(libxml2_dirname) libxmlinc = pathjoin(libxmlabs, 'include') libxmllib = pathjoin(libxmlabs, 'win32', 'bin.msvc') iconvinc = pathjoin(abspath(iconv_dirname), 'include') libxslt_dir = libxslt.get() with cd(libxslt_dir): with cd('libxslt'): ensure_processonenode_is_public() with cd('win32'): patch_libxml2_h('..', 'libxslt') debug_flag = ['debug=yes'] if DEBUG else [] run(['cscript', 'configure.js', '//E:JavaScript', 'vcmanifest=yes'] + debug_flag + ['include=%s' % os.pathsep.join([libxmlinc, iconvinc]), 'lib=%s' % libxmllib]) filerepl('Makefile.msvc', '/O2', '/Os /GL /GS- /Zi') filerepl('Makefile.msvc', 'LDFLAGS = /nologo', 'LDFLAGS = /OPT:REF /OPT:ICF /nologo /DEBUG') run(['nmake', '-f', 'Makefile.msvc'] + (['clean'] if CLEAN else [])) return libxslt_dir
def bench(pgo=None): if pgo is None: pgo = getattr(getattr(sys, 'opts', None), 'pgo', None) if not DEBUG and pgo: with cd(PYTHON_DIR): run([PYTHON_EXE, 'Tools/pybench/pybench.py', '-f', '26.bench.txt']) with cd(PCBUILD_DIR): run([ 'devenv', 'pcbuild.sln', '/build', "PGInstrument|Win32", '/project', '_ssl' ], checkret=False) run(['devenv', 'pcbuild.sln', '/build', "PGInstrument|Win32"], checkret=False) run([ PYTHON_EXE_PGI, 'Tools/pybench/pybench.py', '-f', '26pgi.bench.txt' ]) with cd(PCBUILD_DIR): run([ 'devenv', 'pcbuild.sln', '/build', "PGUpdate|Win32", '/project', '_ssl' ], checkret=False) run(['devenv', 'pcbuild.sln', '/build', "PGUpdate|Win32"], checkret=False) run([ PYTHON_EXE_PGO, 'Tools/pybench/pybench.py', '-f', '26pgo.bench.txt' ])
def sip(): sip_path_parent, sip_dir = os.path.split(os.path.abspath(sip_path)) # Get SIP needs_build = True with cd(sip_path_parent): if not isdir(sip_dir): inform('Could not find SIP directory at %r, downloading...' % sip_path) git.run(['clone', SIP_GIT_REPO, sip_dir]) if SIP_GIT_BRANCH != 'master': with cd(sip_dir): git.run([ 'checkout', '-b', SIP_GIT_BRANCH, SIP_GIT_REMOTE + '/' + SIP_GIT_BRANCH ]) else: pass # inform('SIP found at %r, updating...' % sip_path) # with cd(sip_dir): # git.run(['pull']) # if not git.sha_changed() and isfile(sip_exe) and isfile(sip_pyd): # inform('skipping SIP build') # needs_build = False # Build SIP if needs_build and 'nosip' not in sys.argv: with cd(sip_path): if not sys.platform.startswith("win"): dpy([ 'configure.py', '-b', 'sipgen', '-d', 'siplib', '-e', 'siplib', '-v', 'siplib' ]) # sip sets CC and CXX directly to cc and c++ rather than pulling the values # from the environment, which we don't want if we're forcing a 32-bit build # by using gcc 4.0. env = os.environ run([ 'make', 'CC=%s' % env['CC'], 'CXX=%s' % env['CXX'], 'LINK=%s' % env['CXX'] ]) else: dpy(['setup.py', 'build']) assert isfile(sip_exe), "setup.py did not create %s" % sip_exe if sys.platform.startswith("win"): from buildutil import copy_different, DEPS_DIR copy_different(sip_pyd, DEPS_DIR) copy_different(sip_pdb, DEPS_DIR)
def build(force_bakefile=False): abs_wxdir = abspath(WXDIR) os.environ.update( WXWIN=abspath(WXDIR), WXDIR=abspath(WXDIR), #CAIRO_ROOT = abspath(pathjoin(WXDIR, 'external', 'cairo-dev')), ) copy_setup_h() check_bakefile() msw_makefile = pathjoin(WXDIR, 'build', 'msw', 'makefile.vc') do_bakefile = False if force_bakefile: inform('forcing bakefile_gen') do_bakefile = True elif not isfile(msw_makefile): inform('makefile.vc missing, running bakefile') do_bakefile = True if do_bakefile: bakefile() assert isfile( msw_makefile ), "running bakefile_gen did not create %s" % msw_makefile make_cmd = ['nmake', '-f', 'makefile.vc'] + stropts(WX_MAKEFILE_ARGS) # build WX main libraries with cd(WXDIR, 'build', 'msw'): run(make_cmd) # build contribs if CONTRIB['STC']: with cd(WXDIR, 'contrib', 'build', 'stc'): run(make_cmd) inform('wxWidgets built successfully in %s' % abspath(WXDIR)) # install from buildutil import copy_different, DEPS_DIR bindir = pathjoin(abspath(WXDIR), 'lib', 'vc_dll') for dll in ('base28%s_net_vc base28%s_vc msw28%s_adv_vc ' 'msw28%s_core_vc msw28%s_stc_vc').split(): dll = dll % ('u' + WX_MAKEFILE_ARGS['WXDEBUGFLAG']) for ext in ('.dll', '.pdb'): src, dest = pathjoin(bindir, 'wx' + dll + ext), DEPS_DIR copy_different(src, dest)
def build(force_bakefile = False): abs_wxdir = abspath(WXDIR) os.environ.update( WXWIN = abspath(WXDIR), WXDIR = abspath(WXDIR), #CAIRO_ROOT = abspath(pathjoin(WXDIR, 'external', 'cairo-dev')), ) copy_setup_h() check_bakefile() msw_makefile = pathjoin(WXDIR, 'build', 'msw', 'makefile.vc') do_bakefile = False if force_bakefile: inform('forcing bakefile_gen') do_bakefile = True elif not isfile(msw_makefile): inform('makefile.vc missing, running bakefile') do_bakefile = True if do_bakefile: bakefile() assert isfile(msw_makefile), "running bakefile_gen did not create %s" % msw_makefile make_cmd = ['nmake', '-f', 'makefile.vc'] + stropts(WX_MAKEFILE_ARGS) # build WX main libraries with cd(WXDIR, 'build', 'msw'): run(make_cmd) # build contribs if CONTRIB['STC']: with cd(WXDIR, 'contrib', 'build', 'stc'): run(make_cmd) inform('wxWidgets built successfully in %s' % abspath(WXDIR)) # install from buildutil import copy_different, DEPS_DIR bindir = pathjoin(abspath(WXDIR), 'lib', 'vc_dll') for dll in ('base28%s_net_vc base28%s_vc msw28%s_adv_vc ' 'msw28%s_core_vc msw28%s_stc_vc').split(): dll = dll % ('u' + WX_MAKEFILE_ARGS['WXDEBUGFLAG']) for ext in ('.dll', '.pdb'): src, dest = pathjoin(bindir, 'wx' + dll + ext), DEPS_DIR copy_different(src, dest)
def bench(pgo = None): if pgo is None: pgo = getattr(getattr(sys, 'opts', None), 'pgo', None) if not DEBUG and pgo: with cd(PYTHON_DIR): run([PYTHON_EXE, 'Tools/pybench/pybench.py', '-f', '26.bench.txt']) with cd(PCBUILD_DIR): run(['devenv', 'pcbuild.sln', '/build', "PGInstrument|Win32", '/project', '_ssl'], checkret = False) run(['devenv', 'pcbuild.sln', '/build', "PGInstrument|Win32"], checkret = False) run([PYTHON_EXE_PGI, 'Tools/pybench/pybench.py', '-f', '26pgi.bench.txt']) with cd(PCBUILD_DIR): run(['devenv', 'pcbuild.sln', '/build', "PGUpdate|Win32", '/project', '_ssl'], checkret = False) run(['devenv', 'pcbuild.sln', '/build', "PGUpdate|Win32"], checkret = False) run([PYTHON_EXE_PGO, 'Tools/pybench/pybench.py', '-f', '26pgo.bench.txt'])
def build(): with cd(thisdir): lzma_dir = lzma_sdk.get() if not isdir(ppmd7_dir): git.run(['clone', ppmd7_git_url]) assert isdir(ppmd7_dir) with cd(ppmd7_dir): libname = 'ppmd7' config = 'Release' if not DEBUG else 'Debug' run(['vcbuild', 'libppmd7.sln', '%s|Win32' % config]) for ext in ('.dll', '.pdb'): copy_different(os.path.join(config, libname + ext), DEPS_DIR)
def build(): with cd(thisdir): lzma_dir = lzma_sdk.get() if not isdir(ppmd7_dir): git.run(["clone", ppmd7_git_url]) assert isdir(ppmd7_dir) with cd(ppmd7_dir): libname = "ppmd7" config = "Release" if not DEBUG else "Debug" run(["vcbuild", "libppmd7.sln", "%s|Win32" % config]) for ext in (".dll", ".pdb"): copy_different(os.path.join(config, libname + ext), DEPS_DIR)
def wxpy(rebuild = False, branch="master"): wxpy_path_parent, wxpy_dir = os.path.split(os.path.abspath(wxpy_path)) # must have wx and webkit directories wx_dir = buildDirs.wxWidgetsDir webkit_dir = buildDirs.wxWebKitDir sip_dir = os.path.abspath(sip_path) with cd(wxpy_path_parent): if not isdir(wxpy_dir): inform('Could not find wxpy directory at %r, downloading...' % wxpy_path) git.run(['clone', WXPY_GIT_REPO, wxpy_dir]) if branch != "master": with cd(wxpy_dir): git.run(['checkout', '-b', branch, 'origin/%s' % branch]) # else: # with cd(wxpy_dir): # git.run(['pull']) # wipe out the "wxpy/build" directory if we're rebuilding if rebuild: inform("rebuilding...removing old build directory") with cd(wxpy_dir): if os.path.isdir('build'): shutil.rmtree('build') sip_pyd_loc = pathjoin(sip_dir, 'siplib') sip_exe = 'sip%s.%s' % (DEBUG_POSTFIX, py_ext) assert os.path.isfile(pathjoin(sip_pyd_loc, sip_exe)), \ "could not find %s at %r" % (sip_exe, sip_pyd_loc) pp = os.pathsep.join([sip_dir, sip_pyd_loc]) os.environ['PYTHONPATH'] = pp print 'PYTHONPATH=' + pp with cd(wxpy_dir): dpy(['setup.py', '--wx=%s' % wx_dir, '--webkit=%s' % webkit_dir] + sys.argv[1:]) install_wxpy()
def install_stdlib(): 'Copies all the .py files in python/Lib' from buildutil import copy_different with cd(PYTHON_DIR): exclude = '.xcopy.exclude' # have to specify xcopy excludes in a file with open(exclude, 'w') as fout: fout.write('\n'.join(['.pyc', '.pyo', '.svn'])) try: run([ 'xcopy', 'Lib', r'%s\lib' % DPYTHON_DIR, '/EXCLUDE:%s' % exclude, '/I', '/E', '/D', '/Y' ]) run([ 'xcopy', 'Include', r'%s\Include' % DPYTHON_DIR, '/EXCLUDE:%s' % exclude, '/I', '/E', '/D', '/Y' ]) if not os.path.isdir(r'%s\libs' % DPYTHON_DIR): os.makedirs(r'%s\libs' % DPYTHON_DIR) for f in os.listdir(r'PCBuild'): if f.endswith('.lib'): copy_different(os.path.join('PCBuild', f), os.path.join(r'%s\libs' % DPYTHON_DIR, f)) finally: os.remove(exclude)
def commit(): print '\nEnter a commit message, or press enter to skip:', message = raw_input() if message: with cd(BINARIES_DEST_DIR): run(['svn', 'commit'] + artifacts + ['-m', message])
def copy_setup_h(): inform('copying include/wx/msw/setup0.h to include/wx/msw/setup.h with modifications') with cd(WXDIR, 'include', 'wx', 'msw'): # setup0.h is the "template" for setup.h. we use the setup_h_use_flags # dictionary above to set certain values in it for things we want to # customize (results in smaller binaries, since about 50% of wx we don't # use or need) f = open('setup0.h', 'rU') out = open('setup.h', 'w') flags = dict(setup_h_use_flags) define_use = '#define wxUSE_' for line in f: i = line.find(define_use) if i != -1: use_name = line[i+len(define_use):].split()[0] if use_name in flags: line = '%s%s %s\n' % (define_use, use_name, flags.pop(use_name)) out.write(line) # make sure there are no leftover flags if flags: leftover = '\n'.join(' wxUSE_%s' % key for key in flags.iterkeys()) raise AssertionError('invalid wxUSE_XXX flags (were not found in setup0.h):\n%s' % leftover) out.close() f.close()
def make_po_files(): toolsdir = download_i18n_tools() path = os.pathsep.join((toolsdir, os.environ.get('PATH', ''))) with cd(DIGSBY_ROOT): dpy(['mki18n.py', '-m', '-v', '--domain=Digsby', DIGSBY_ROOT], addenv=dict(PATH=path))
def __call__(self, parser, ns, value, option_string): if not value: return print 'running Po', id(self) with buildutil.cd(DIGSBYROOT): default_pot = TEMP_path('digsby_default.pot') sip_pot = TEMP_path('digsby_sip.pot') yaml_pot = TEMP_path('digsby_yaml.pot') tenjin_pot = TEMP_path('digsby_tenjin.pot') input_pots = [default_pot, sip_pot, yaml_pot, tenjin_pot] final_pot = POT_path('digsby') for pot in input_pots: if os.path.isfile(pot): os.remove(pot) xgettext(FIL_PATH, default_pot) # xgettext(FIL_SIP_PATH, sip_pot, '-C') xgettext_yaml(FIL_YAML_PATH, yaml_pot) xgettext(FIL_TENJIN_PATH, tenjin_pot, '-L', 'python') input_pots = filter(lambda pot: os.path.isfile(pot), input_pots) cat = pot_read_clean(input_pots[0]) for potfile in input_pots[1:]: cat_u = pot_read_clean(potfile) for msg in cat_u: cat[msg.id] = msg write_pot(final_pot, cat, version=True) pofiles = [os.path.join(PO_DIR, f) for f in os.listdir(PO_DIR) if f.endswith('.po')] for pofile in pofiles: buildutil.run(['msgmerge', '-F', '--no-wrap', pofile, final_pot, '-o', pofile])
def wxpy(rebuild=False, branch="master"): wxpy_path_parent, wxpy_dir = os.path.split(os.path.abspath(wxpy_path)) # must have wx and webkit directories wx_dir = buildDirs.wxWidgetsDir webkit_dir = buildDirs.wxWebKitDir sip_dir = os.path.abspath(sip_path) with cd(wxpy_path_parent): if not isdir(wxpy_dir): inform('Could not find wxpy directory at %r, downloading...' % wxpy_path) git.run(['clone', WXPY_GIT_REPO, wxpy_dir]) if branch != "master": with cd(wxpy_dir): git.run(['checkout', '-b', branch, 'origin/%s' % branch]) # else: # with cd(wxpy_dir): # git.run(['pull']) # wipe out the "wxpy/build" directory if we're rebuilding if rebuild: inform("rebuilding...removing old build directory") with cd(wxpy_dir): if os.path.isdir('build'): shutil.rmtree('build') sip_pyd_loc = pathjoin(sip_dir, 'siplib') sip_exe = 'sip%s.%s' % (DEBUG_POSTFIX, py_ext) assert os.path.isfile(pathjoin(sip_pyd_loc, sip_exe)), \ "could not find %s at %r" % (sip_exe, sip_pyd_loc) pp = os.pathsep.join([sip_dir, sip_pyd_loc]) os.environ['PYTHONPATH'] = pp print 'PYTHONPATH=' + pp with cd(wxpy_dir): dpy(['setup.py', '--wx=%s' % wx_dir, '--webkit=%s' % webkit_dir] + sys.argv[1:]) install_wxpy()
def post_build(): # copy pyconfig.h from PC/ to /Include and Python26.lib to make scripts # using distutils work with our PGO build without modification with cd(PYTHON_DIR): from buildutil import copy_different copy_different('PC/pyconfig.h', 'Include/pyconfig.h') install_stdlib() with cd(PYTHON_DIR): # install python executables with cd(PYTHON_LIBDIR): pydir = DPYTHON_DIR assert os.path.isdir(pydir), pydir def copylibs(): for f in ('''python%(dbg)s.exe python%(dbg)s.pdb pythonw%(dbg)s.exe pythonw%(dbg)s.pdb python%(ver)s%(dbg)s.dll python%(ver)s%(dbg)s.pdb sqlite3%(dbg)s.dll sqlite3%(dbg)s.pdb''' % dict(dbg=DEBUG_POSTFIX, ver=PYTHON_VER)).split(): copy_different(f, pydir) if not DEBUG and getattr(getattr(sys, 'opts', None), 'pgo', None): with cd(PYTHON_PGO_DIR): copylibs() else: copylibs() dlls_dir = os.path.join(pydir, 'DLLs') if not os.path.isdir(dlls_dir): os.mkdir(dlls_dir) libs = '''_ctypes _elementtree _hashlib _socket _sqlite3 _ssl bz2 pyexpat select unicodedata winsound'''.split() if int(PYTHON_VER) >= 26: libs.append('_multiprocessing') for f in libs: f += DEBUG_POSTFIX copy_different(f + '.pyd', dlls_dir) try: copy_different(f + '.pdb', dlls_dir) except Exception: print 'WARNING: could not copy %s.pdb' % f
def clean(): with cd(PYTHON_DIR, PCBUILD_DIR): config = 'Debug' if DEBUG else 'Release' if USE_DEVENV: run(['devenv', 'pcbuild.sln', '/clean', "%s|Win32" % config, '/project', '_ssl'], checkret = False) run(['devenv', 'pcbuild.sln', '/clean', "%s|Win32" % config], checkret = False) else: run(['vcbuild', 'pcbuild.sln', '/clean', '%s|Win32' % config], checkret = False)
def build_curl(): # relies on openssl-0.9.8g being in msw/ (should be there from # building Python) new = not os.path.exists(curl.dirname) with cd(curl.get()): if os.name == 'nt' and new: # after pulling a fresh tarball, apply the patch pointed to by curl_patch. # see the note above for an explanation. run([patch_cmd, '-p0', '-i', '../' + curl_patch]) filerepl('lib/Makefile.vc6', '/O2 /DNDEBUG', '/Zi /Ox /GL /GS- /GR- /DNDEBUG') filerepl('lib/Makefile.vc6', 'LFLAGS = /nologo /machine:$(MACHINE)', 'LFLAGS = /DEBUG /nologo /machine:$(MACHINE)') openssl_includes = "../../../../../digsby-venv" # point at includes filerepl( 'lib/Makefile.vc6', '/DUSE_SSLEAY /I "$(OPENSSL_PATH)/inc32"', '/DUSE_SSLEAY /I "%s/PC" /I "%s/PC/openssl" /I "$(OPENSSL_PATH)/inc32"' % (openssl_includes, openssl_includes)) # point at .libs filerepl('lib/Makefile.vc6', 'LFLAGSSSL = "/LIBPATH:$(OPENSSL_PATH)\out32dll"', 'LFLAGSSSL = "/LIBPATH:%s/libs"' % openssl_includes) with cd('lib'): run([ 'nmake', '/nologo', '/E', '/f', 'Makefile.vc6', 'cfg=%s-dll-ssl-dll-zlib-dll' % ('debug' if DEBUG else 'release'), 'ZLIBLIBSDLL=zlib1%s.lib' % ('d' if DEBUG else ''), 'IMPLIB_NAME=libcurl', 'IMPLIB_NAME_DEBUG=libcurld' ]) # copy libcurl.dll to digsby/build/msw/dependencies from buildutil import copy_different, DEPS_DIR copy_different('libcurl%s.dll' % curl_pfix, DEPS_DIR) copy_different('libcurl%s.pdb' % curl_pfix, DEPS_DIR)
def sip(): sip_path_parent, sip_dir = os.path.split(os.path.abspath(sip_path)) # Get SIP needs_build = True with cd(sip_path_parent): if not isdir(sip_dir): inform('Could not find SIP directory at %r, downloading...' % sip_path) git.run(['clone', SIP_GIT_REPO, sip_dir]) if SIP_GIT_BRANCH != 'master': with cd(sip_dir): git.run(['checkout', '-b', SIP_GIT_BRANCH, SIP_GIT_REMOTE + '/' + SIP_GIT_BRANCH]) else: pass # inform('SIP found at %r, updating...' % sip_path) # with cd(sip_dir): # git.run(['pull']) # if not git.sha_changed() and isfile(sip_exe) and isfile(sip_pyd): # inform('skipping SIP build') # needs_build = False # Build SIP if needs_build and 'nosip' not in sys.argv: with cd(sip_path): if not sys.platform.startswith("win"): dpy(['configure.py', '-b', 'sipgen', '-d', 'siplib', '-e', 'siplib', '-v', 'siplib']) # sip sets CC and CXX directly to cc and c++ rather than pulling the values # from the environment, which we don't want if we're forcing a 32-bit build # by using gcc 4.0. env = os.environ run(['make', 'CC=%s' % env['CC'], 'CXX=%s' % env['CXX'], 'LINK=%s' % env['CXX']]) else: dpy(['setup.py', 'build']) assert isfile(sip_exe), "setup.py did not create %s" % sip_exe if sys.platform.startswith("win"): from buildutil import copy_different, DEPS_DIR copy_different(sip_pyd, DEPS_DIR) copy_different(sip_pdb, DEPS_DIR)
def build_curl(): # relies on openssl-0.9.8g being in msw/ (should be there from # building Python) new = not os.path.exists(curl.dirname) with cd(curl.get()): if os.name == 'nt' and new: # after pulling a fresh tarball, apply the patch pointed to by curl_patch. # see the note above for an explanation. run([patch_cmd, '-p0', '-i', '../' + curl_patch]) filerepl('lib/Makefile.vc6', '/O2 /DNDEBUG', '/Zi /Ox /GL /GS- /GR- /DNDEBUG') filerepl('lib/Makefile.vc6', 'LFLAGS = /nologo /machine:$(MACHINE)', 'LFLAGS = /DEBUG /nologo /machine:$(MACHINE)') openssl_includes = "../../../../../digsby-venv" # point at includes filerepl('lib/Makefile.vc6', '/DUSE_SSLEAY /I "$(OPENSSL_PATH)/inc32"', '/DUSE_SSLEAY /I "%s/PC" /I "%s/PC/openssl" /I "$(OPENSSL_PATH)/inc32"' % (openssl_includes, openssl_includes)) # point at .libs filerepl('lib/Makefile.vc6', 'LFLAGSSSL = "/LIBPATH:$(OPENSSL_PATH)\out32dll"', 'LFLAGSSSL = "/LIBPATH:%s/libs"' % openssl_includes) with cd('lib'): run(['nmake', '/nologo', '/E', '/f', 'Makefile.vc6', 'cfg=%s-dll-ssl-dll-zlib-dll' % ('debug' if DEBUG else 'release'), 'ZLIBLIBSDLL=zlib1%s.lib' % ('d' if DEBUG else ''), 'IMPLIB_NAME=libcurl', 'IMPLIB_NAME_DEBUG=libcurld'] ) # copy libcurl.dll to digsby/build/msw/dependencies from buildutil import copy_different, DEPS_DIR copy_different('libcurl%s.dll' % curl_pfix, DEPS_DIR) copy_different('libcurl%s.pdb' % curl_pfix, DEPS_DIR)
def build_zlib(): copy_different('../../../builddeps/msvc2008/' + zlib.filename, '.') unzip(zlib.filename) with cd('zlib-1.2.3'): lib_dest_path = os.getcwd() with cd('projects/visualc9-x86'): configname = 'DLL ASM %s' % ('Debug' if DEBUG else 'Release') run(['vcbuild', 'zlib.vcproj', configname]) # install the ZLIB dll and pdb print 'DEPS_DIR here', DEPS_DIR with cd('Win32/' + configname): debug_flag = 'd' if DEBUG else '' for dest in (DEPS_DIR, lib_dest_path): copy_different('zlib1%s.dll' % debug_flag, dest) copy_different('zlib1%s.pdb' % debug_flag, dest) copy_different('zlib1%s.lib' % debug_flag, dest)
def update(): 'Updates the Python source tree.' with cd(PYTHON_DIR): if PYTHON_SVN_REVISION == 'HEAD' or svn_version('.') != int(PYTHON_SVN_REVISION): inform('updating python') run(['svn', 'update', '-r', PYTHON_SVN_REVISION]) return True else: return False
def patch_libxml2_h(*path): # msvc 2008 defines _vsnprintf as an intrinsic (or something like that) # but libxml2 wants to #define it as something else, and things go # boom with cd(*path): with open('win32config.h') as f: lines = [l for l in f if not l.startswith('#define vsnprintf')] with open('win32config.h', 'w') as f: f.write(''.join(lines))
def build_py2exe(): from buildutil import DEPS_DIR assert isdir(DEPS_DIR) with cd('DigsbyInstaller' + PY2EXE_DIR): # -i means the PYD will sit next to the files in py2exe/py2exe dpy(['setup.py', 'build', 'install', '--install-lib', str(DEPS_DIR)]) print print 'py2exe source and PYDs are in:' print abspath('.') print
def install_wxpy(): # install to dependencies dir from buildutil import DEPS_DIR install_dir = pathjoin(DEPS_DIR, 'wx') inform('\n\ninstalling wxpy to %s' % install_dir) def ffilter(f): return not any(map(f.endswith, ('.exp', '.idb', '.pyc', '.lib'))) with cd(wxpy_path): copytree_filter('wx', install_dir, filefilter = ffilter, only_different = True)
def clean(): if os.name == 'nt': def rmdir(p): p = os.path.abspath(p) if os.path.isdir(p): run(['cmd', '/c', 'rmdir', '/s', '/q', p], checkret=False) with cd(WXDIR, 'lib'): rmdir('vc_dll') # TODO: don't hardcode this debug flag dir = 'vc_mswu%sdll' % WX_MAKEFILE_ARGS['WXDEBUGFLAG'] with cd(WXDIR, 'build', 'msw'): rmdir(dir) with cd(WXDIR, 'contrib', 'build', 'stc'): rmdir(dir) else: raise AssertionError('clean not implemented for %s' % os.name)
def update(): 'Updates the Python source tree.' with cd(PYTHON_DIR): if PYTHON_SVN_REVISION == 'HEAD' or svn_version('.') != int( PYTHON_SVN_REVISION): inform('updating python') run(['svn', 'update', '-r', PYTHON_SVN_REVISION]) return True else: return False
def rename_new_pofiles(POT_DIR): with buildutil.cd(POT_DIR): for p in path('.').files('*.po.new'): pofile = path(p.namebase) if pofile.isfile(): oldfile = pofile + '.old' if oldfile.isfile(): oldfile.remove() print 'renaming', pofile, 'to', pofile + '.old' pofile.rename(pofile + '.old') print 'renaming', p, 'to', pofile p.rename(pofile)
def rename_new_pofiles(POT_DIR): with buildutil.cd(POT_DIR): for p in path('.').files('*.po.new'): pofile = path(p.namebase) if pofile.isfile(): oldfile = pofile+'.old' if oldfile.isfile(): oldfile.remove() print 'renaming', pofile, 'to', pofile+'.old' pofile.rename(pofile + '.old') print 'renaming', p, 'to', pofile p.rename(pofile)
def build_jpeg(): with cd(jpeg.get()): # setup for nmake build shutil.copy2('jconfig.vc', 'jconfig.h') # make sure libjpeg is built against the multithreaded C runtime # library. run(['nmake', '-f', 'makefile.vc', 'NODEBUG=' + ('0' if DEBUG else '1')]) lib = abspath('libjpeg.lib') assert exists(lib) return lib
def build(): check_tools() with cd(PYTHON_DIR, PCBUILD_DIR): # fix up files for SSL stuff fix_build_ssl_py() config = 'Debug' if DEBUG else 'Release' if USE_DEVENV: run(['devenv', 'pcbuild.sln', '/build', "%s|Win32" % config, '/project', '_ssl'], checkret = False) run(['devenv', 'pcbuild.sln', '/build', "%s|Win32" % config], checkret = False) else: run(['vcbuild', 'pcbuild.sln', '%s|Win32' % config], checkret = False)
def build_jpeg(): with cd(jpeg.get()): # setup for nmake build shutil.copy2('jconfig.vc', 'jconfig.h') # make sure libjpeg is built against the multithreaded C runtime # library. run([ 'nmake', '-f', 'makefile.vc', 'NODEBUG=' + ('0' if DEBUG else '1') ]) lib = abspath('libjpeg.lib') assert exists(lib) return lib
def install_wxpy(): # install to dependencies dir from buildutil import DEPS_DIR install_dir = pathjoin(DEPS_DIR, 'wx') inform('\n\ninstalling wxpy to %s' % install_dir) def ffilter(f): return not any(map(f.endswith, ('.exp', '.idb', '.pyc', '.lib'))) with cd(wxpy_path): copytree_filter('wx', install_dir, filefilter=ffilter, only_different=True)
def build(): # output the version of mt.exe--should be > 6 # run('mt /', checkret = False) 'Builds and deploys executables and debugging symbol files.' with cd(UPDATER_PROJECT_DIR): # remove the old Release directory run(['cmd', '/c', 'rmdir', '/s', '/q', 'Release'], checkret = False) # invoke MSVC2008 print run(['devenv', '/build', 'release', UPDATER_SOLUTION], checkret = False) bindir = UPDATER_PROJECT_DIR / 'Release' if not (bindir / 'Digsby PreUpdater.exe').isfile(): raise Exception('Visual Studio did not build the executables')
def clean(): with cd(PYTHON_DIR, PCBUILD_DIR): config = 'Debug' if DEBUG else 'Release' if USE_DEVENV: run([ 'devenv', 'pcbuild.sln', '/clean', "%s|Win32" % config, '/project', '_ssl' ], checkret=False) run(['devenv', 'pcbuild.sln', '/clean', "%s|Win32" % config], checkret=False) else: run(['vcbuild', 'pcbuild.sln', '/clean', '%s|Win32' % config], checkret=False)
def build_xmlextra(): '''Builds _xmlextra.pyd, a speedups module for pyxmpp.''' libxml2_dir = abspath(libxml2_dirname) iconv_dir = abspath(iconv_dirname) lxml2_libs = pathjoin(libxml2_dir, 'win32', 'bin.msvc') lxml2_inc = pathjoin(libxml2_dir, 'include') with cd(EXTDIR): import os dpy(['build_xmlextra.py', 'clean']) dpy(['build_xmlextra.py', 'build_ext'] + ([distutils_debug] if distutils_debug else []) + [ '-L' + os.pathsep.join(filter(None, [lxml2_libs] + os.environ.get('LIB', '').split(os.pathsep))), '-I' + os.pathsep.join(filter(None, [iconv_dir, lxml2_inc] + os.environ.get('INCLUDE', '').split(os.pathsep))), 'install', '--install-lib', DEPS_DIR])
def build(): # output the version of mt.exe--should be > 6 # run('mt /', checkret = False) 'Builds and deploys executables and debugging symbol files.' with cd(UPDATER_PROJECT_DIR): # remove the old Release directory run(['cmd', '/c', 'rmdir', '/s', '/q', 'Release'], checkret=False) # invoke MSVC2008 print run(['devenv', '/build', 'release', UPDATER_SOLUTION], checkret=False) bindir = UPDATER_PROJECT_DIR / 'Release' if not (bindir / 'Digsby PreUpdater.exe').isfile(): raise Exception('Visual Studio did not build the executables')
def checkout(): if exists(WXDIR): inform('already exists: %s' % WXDIR) else: #inform('checking out wxWebKitBranch-2.8...') #run(['svn', 'checkout', WXWIDGETS_28_SVN_DIR, WXDIR]) inform('cloning wxWebKitBranch-2.8') git.run(['clone', WX_GIT_REPO, abspath(WXDIR).replace('\\', '/'), '--depth=1']) with cd(WXDIR): # don't change newlines git.run(['config', 'core.autocrlf', 'false']) if WX_GIT_BRANCH != 'master': git.run(['fetch', 'origin']) # checkout our branch. git.run(['checkout', '-b', WX_GIT_BRANCH, 'origin/%s' % WX_GIT_BRANCH]) assert exists(WXDIR)
def build_lxml(): from compiledeps import libxml2_dirname libxml2_dir = abspath(libxml2_dirname) iconv_dir = abspath(iconv_dirname) lxml2_libs = pathjoin(libxml2_dir, 'win32', 'bin.msvc') if not isdir(lxml2_libs): fatal('could not find libxml2.lib in %s' % lxml2_libs) lxml2_inc = pathjoin(libxml2_dir, 'include') if not isdir(lxml2_inc): fatal('could not find libxml2 includes directory at %s' % lxml2_inc) if not isdir(iconv_dir): fatal('could not find iconv at %s' % iconv_dir) libxslt_dir = abspath(libxslt.dirname) if not isdir(libxslt_dir): fatal('could not find libxslt at %s' % libxslt_dir) libxslt_lib = pathjoin(libxslt_dir, 'win32', 'bin.msvc') zlib_dir = abspath('zlib-1.2.3') from compiledeps import lxml new = not os.path.exists(lxml.dirname) with cd(lxml.get()): if os.name == 'nt' and new: # after pulling a fresh tarball, apply the patch pointed to by lxml_patch. run([ patch_cmd, '--ignore-whitespace', '-p0', '-i', '../%s' % lxml_patch ]) dpy([ 'setup.py', 'build_ext', '-I' + os.pathsep.join( (lxml2_inc, libxslt_dir, pathjoin(iconv_dir, 'include'))), '-L' + os.pathsep.join((libxslt_lib, lxml2_libs, pathjoin(iconv_dir, 'lib'), zlib_dir)) ] + (['--debug'] if DEBUG else []) + ['install', '--install-lib', DEPS_DIR]) build_libxml2
def install_stdlib(): 'Copies all the .py files in python/Lib' from buildutil import copy_different with cd(PYTHON_DIR): exclude = '.xcopy.exclude' # have to specify xcopy excludes in a file with open(exclude, 'w') as fout: fout.write('\n'.join(['.pyc', '.pyo', '.svn'])) try: run(['xcopy', 'Lib', r'%s\lib' % DPYTHON_DIR, '/EXCLUDE:%s' % exclude, '/I','/E','/D','/Y']) run(['xcopy', 'Include', r'%s\Include' % DPYTHON_DIR, '/EXCLUDE:%s' % exclude, '/I','/E','/D','/Y']) if not os.path.isdir(r'%s\libs' % DPYTHON_DIR): os.makedirs(r'%s\libs' % DPYTHON_DIR) for f in os.listdir(r'PCBuild'): if f.endswith('.lib'): copy_different(os.path.join('PCBuild', f), os.path.join(r'%s\libs' % DPYTHON_DIR, f)) finally: os.remove(exclude)
def checkout(): if isdir(WEBKITDIR): inform('skipping checkout, %s already exists' % WEBKITDIR) else: inform('cloning WebKit') makedirs(WEBKITDIR) with cd(WEBKITDIR): git.run(['init']) # turn off auto CRLF conversion, so that cygwin bash # doesn't complain about line endings git.run(['config', 'core.autocrlf', 'false']) # Add our remote source git.run(['remote', 'add', WEBKIT_GIT_REMOTE, WEBKIT_GIT_REPO]) git.run(['fetch', WEBKIT_GIT_REMOTE, '--depth', '1']) # checkout a local tracking branch of the remote branch we're interested in with timed(): git.run(['checkout', '-b', WEBKIT_GIT_BRANCH, WEBKIT_GIT_REMOTE + '/' + WEBKIT_GIT_BRANCH])
def build(): check_tools() with cd(PYTHON_DIR, PCBUILD_DIR): # fix up files for SSL stuff fix_build_ssl_py() config = 'Debug' if DEBUG else 'Release' if USE_DEVENV: run([ 'devenv', 'pcbuild.sln', '/build', "%s|Win32" % config, '/project', '_ssl' ], checkret=False) run(['devenv', 'pcbuild.sln', '/build', "%s|Win32" % config], checkret=False) else: run(['vcbuild', 'pcbuild.sln', '%s|Win32' % config], checkret=False)
def build(): # find WX directory from build_wx import WXDIR wxdir = abspath(WXDIR) # find WXPY directory, and SIP directory from build_wxpy import wxpy_path, sip_path sipdir, wxpydir = abspath(sip_path), abspath(wxpy_path) assert isdir(wxdir) assert isdir(sipdir) assert isdir(wxpydir) from buildutil import tardep boost = tardep('http://iweb.dl.sourceforge.net/project/boost/boost/1.42.0/', 'boost_1_42_0', '.tar.gz', 40932853) boost.get() # place these directories on the PYTHONPATH os.environ['PYTHONPATH'] = os.pathsep.join([wxpydir, sipdir]) with cd('../../ext'): dpy(['buildbkl.py', '--wx=%s' % wxdir] + sys.argv[1:])
def __call__(self, parser, ns, value, option_string): if not value: return print 'running Po', id(self) with buildutil.cd(DIGSBYROOT): default_pot = TEMP_path('digsby_default.pot') sip_pot = TEMP_path('digsby_sip.pot') yaml_pot = TEMP_path('digsby_yaml.pot') tenjin_pot = TEMP_path('digsby_tenjin.pot') input_pots = [default_pot, sip_pot, yaml_pot, tenjin_pot] final_pot = POT_path('digsby') for pot in input_pots: if os.path.isfile(pot): os.remove(pot) xgettext(FIL_PATH, default_pot) # xgettext(FIL_SIP_PATH, sip_pot, '-C') xgettext_yaml(FIL_YAML_PATH, yaml_pot) xgettext(FIL_TENJIN_PATH, tenjin_pot, '-L', 'python') input_pots = filter(lambda pot: os.path.isfile(pot), input_pots) cat = pot_read_clean(input_pots[0]) for potfile in input_pots[1:]: cat_u = pot_read_clean(potfile) for msg in cat_u: cat[msg.id] = msg write_pot(final_pot, cat, version=True) pofiles = [ os.path.join(PO_DIR, f) for f in os.listdir(PO_DIR) if f.endswith('.po') ] for pofile in pofiles: buildutil.run([ 'msgmerge', '-F', '--no-wrap', pofile, final_pot, '-o', pofile ])
def copy_setup_h(): inform( 'copying include/wx/msw/setup0.h to include/wx/msw/setup.h with modifications' ) with cd(WXDIR, 'include', 'wx', 'msw'): # setup0.h is the "template" for setup.h. we use the setup_h_use_flags # dictionary above to set certain values in it for things we want to # customize (results in smaller binaries, since about 50% of wx we don't # use or need) f = open('setup0.h', 'rU') out = open('setup.h', 'w') flags = dict(setup_h_use_flags) define_use = '#define wxUSE_' for line in f: i = line.find(define_use) if i != -1: use_name = line[i + len(define_use):].split()[0] if use_name in flags: line = '%s%s %s\n' % (define_use, use_name, flags.pop(use_name)) out.write(line) # make sure there are no leftover flags if flags: leftover = '\n'.join(' wxUSE_%s' % key for key in flags.iterkeys()) raise AssertionError( 'invalid wxUSE_XXX flags (were not found in setup0.h):\n%s' % leftover) out.close() f.close()
def checkout(): 'Checks out Python source.' run(['svn', 'co', PYTHON_SVN_URL, PYTHON_DIR]) patch_cmd = get_patch_cmd() def banner_msg(s): print print s print def apply_patch(patchfile, strip_prefixes=0): assert os.path.isfile(patchfile) run([patch_cmd, '-p%d' % strip_prefixes, '-i', patchfile]) with cd(PYTHON_DIR): if sys.opts.use_computed_goto: banner_msg('applying computed goto patch') apply_patch('../python26-computed-goto.patch') banner_msg('applying assert mode patch') # this patch restores c assert()s and is made with # svn diff http://svn.python.org/projects/python/trunk@69494 http://svn.python.org/projects/python/trunk@69495 apply_patch('../python26-assert-mode.patch') banner_msg('applying file object close bug patch') # http://bugs.python.org/issue7079 -- remove once we update to a newer version of 2.6 apply_patch('../python26-file-object-close-7079.patch') if USE_DEVENV and sys.opts.intel: banner_msg('applying intel project patch') apply_patch('../vs2008+intel.patch', 3) banner_msg('applying common controls patch') apply_patch('../python-common-controls.patch')
def checkout(): if isdir(WEBKITDIR): inform('skipping checkout, %s already exists' % WEBKITDIR) else: inform('cloning WebKit') makedirs(WEBKITDIR) with cd(WEBKITDIR): git.run(['init']) # turn off auto CRLF conversion, so that cygwin bash # doesn't complain about line endings git.run(['config', 'core.autocrlf', 'false']) # Add our remote source git.run(['remote', 'add', WEBKIT_GIT_REMOTE, WEBKIT_GIT_REPO]) git.run(['fetch', WEBKIT_GIT_REMOTE, '--depth', '1']) # checkout a local tracking branch of the remote branch we're interested in with timed(): git.run([ 'checkout', '-b', WEBKIT_GIT_BRANCH, WEBKIT_GIT_REMOTE + '/' + WEBKIT_GIT_BRANCH ])
def deploy(): with cd(UPDATER_PROJECT_DIR / 'Release'): dest = BINARIES_DEST_DIR.abspath() # deploy EXEs and PDBs to BINARIES_DEST_DIR for a in artifacts: p = path(a) print 'copying %s to %s' % (p, dest) destfile = dest / p.name if destfile.isfile(): print 'removing old %r' % destfile destfile.remove() assert not destfile.isfile() p.copy2(dest) destfile = dest / p.name assert destfile.isfile() # sign all executables if a.lower().endswith('.exe'): Authenticode(destfile) return dest
def checkout(): if exists(WXDIR): inform('already exists: %s' % WXDIR) else: #inform('checking out wxWebKitBranch-2.8...') #run(['svn', 'checkout', WXWIDGETS_28_SVN_DIR, WXDIR]) inform('cloning wxWebKitBranch-2.8') git.run([ 'clone', WX_GIT_REPO, abspath(WXDIR).replace('\\', '/'), '--depth=1' ]) with cd(WXDIR): # don't change newlines git.run(['config', 'core.autocrlf', 'false']) if WX_GIT_BRANCH != 'master': git.run(['fetch', 'origin']) # checkout our branch. git.run([ 'checkout', '-b', WX_GIT_BRANCH, 'origin/%s' % WX_GIT_BRANCH ]) assert exists(WXDIR)
def build_lxml(): from compiledeps import libxml2_dirname libxml2_dir = abspath(libxml2_dirname) iconv_dir = abspath(iconv_dirname) lxml2_libs = pathjoin(libxml2_dir, 'win32', 'bin.msvc') if not isdir(lxml2_libs): fatal('could not find libxml2.lib in %s' % lxml2_libs) lxml2_inc = pathjoin(libxml2_dir, 'include') if not isdir(lxml2_inc): fatal('could not find libxml2 includes directory at %s' % lxml2_inc) if not isdir(iconv_dir): fatal('could not find iconv at %s' % iconv_dir) libxslt_dir = abspath(libxslt.dirname) if not isdir(libxslt_dir): fatal('could not find libxslt at %s' % libxslt_dir) libxslt_lib = pathjoin(libxslt_dir, 'win32', 'bin.msvc') zlib_dir = abspath('zlib-1.2.3') from compiledeps import lxml new = not os.path.exists(lxml.dirname) with cd(lxml.get()): if os.name == 'nt' and new: # after pulling a fresh tarball, apply the patch pointed to by lxml_patch. run([patch_cmd, '--ignore-whitespace', '-p0', '-i', '../%s' % lxml_patch]) dpy(['setup.py', 'build_ext', '-I' + os.pathsep.join((lxml2_inc, libxslt_dir, pathjoin(iconv_dir, 'include'))), '-L' + os.pathsep.join((libxslt_lib, lxml2_libs, pathjoin(iconv_dir, 'lib'), zlib_dir))] + (['--debug'] if DEBUG else []) + ['install', '--install-lib', DEPS_DIR]) build_libxml2