def main(args): if iswindows: for f in 'hnjalloc.c hyphen.c'.split(): run(f'"{CL}" /c /nologo /MD /W3 /DWIN32 -c ' + f) run(f'"{LIB}" -nologo hnjalloc.obj hyphen.obj -OUT:hyphen.lib') install_binaries('hyphen.lib') copy_headers('hyphen.h') return run('./configure', f'--prefix={build_dir()}', '--disable-static') run('make', 'install-libLTLIBRARIES') run('make', 'install-includeHEADERS')
def main(args): if iswindows: run(f'"{NMAKE}" /f Makefile.vc CFG=release-dynamic' ' RTLIBCFG=dynamic OBJDIR=output') install_binaries('output/release-dynamic/*/bin/*.dll', 'bin') install_binaries('output/release-dynamic/*/lib/*.lib', 'lib') copy_headers('src/webp') else: # mux/demux are needed for webengine simple_build('--disable-dependency-tracking --disable-static' ' --enable-libwebpmux --enable-libwebpdemux')
def main(args): if iswindows: # On windows we dont actually build sqlite as the python build script # downloads its own version locked sqlite. We just install the headers copy_headers('sqlite3*.h') return cflags = CFLAGS if ismacos: cflags += ' -O2 -DSQLITE_ENABLE_LOCKING_STYLE' with ModifiedEnv(CFLAGS=cflags): simple_build('--disable-dependency-tracking --disable-static')
def windows_python2(args): replace_in_file( 'PCbuild\\build.bat', re.compile(r'^\s*%1\s+%2', re.MULTILINE), f'"/p:PlatformToolset={get_platform_toolset()}" ' f'"/p:WindowsTargetPlatformVersion={get_windows_sdk()}"') # We create externals/nasm-2.11.06 below so that the # python build script does not try to download its own nasm instead # using the one we built instead (the python build script fails to # mark its nasm as executable, and therefore errors out) os.makedirs('externals/nasm-2.11.06') # os.makedirs('externals/openssl-1.0.2h') # os.makedirs('externals/sqlite-3.8.11.0') # os.makedirs('externals/bzip2-1.0.6') # dont need python 3 to get externals, use git instead replace_in_file('PCbuild\\get_externals.bat', re.compile(br'^call.+find_python.bat.+$', re.MULTILINE), '') try: run('PCbuild\\build.bat', '-e', '--no-tkinter', '--no-bsddb', '-c', 'Release', '-m', '-p', ('x64' if is64bit else 'Win32'), '-v', '-t', 'Build') # Run the tests # run('PCbuild\\amd64\\python.exe', 'Lib/test/regrtest.py', '-u', # 'network,cpu,subprocess,urlfetch') # Do not read mimetypes from the registry replace_in_file( 'Lib\\mimetypes.py', re.compile(br'try:.*?import\s+_winreg.*?None', re.DOTALL), r'_winreg = None') bindir = 'PCbuild\\amd64' if is64bit else 'PCbuild' install_binaries(bindir + os.sep + '*.exe', 'private\\python') install_binaries(bindir + os.sep + 'python*.dll', 'private\\python') install_binaries(bindir + os.sep + '*.pyd', 'private\\python\\DLLs') install_binaries(bindir + os.sep + '*.dll', 'private\\python\\DLLs') for x in glob.glob( os.path.join(build_dir(), 'private\\python\\DLLs\\python*.dll')): os.remove(x) install_binaries(bindir + os.sep + '*.lib', 'private\\python\\libs') copy_headers('PC\\pyconfig.h', 'private\\python\\include') copy_headers('Include\\*.h', 'private\\python\\include') shutil.copytree('Lib', os.path.join(build_dir(), 'private\\python\\Lib')) finally: # bloody git creates files with no write permission import stat for path in walk('externals'): os.chmod(path, stat.S_IWRITE) os.remove(path)
def main(args): if iswindows: for f in 'hnjalloc.c hyphen.c'.split(): run(f'"{CL}" /c /nologo /MD /W3 /DWIN32 -c ' + f) run(f'"{LIB}" -nologo hnjalloc.obj hyphen.obj -OUT:hyphen.lib') install_binaries('hyphen.lib') copy_headers('hyphen.h') return simple_build( ('--disable-static', ), make_args=('install-libLTLIBRARIES', 'install-includeHEADERS'), do_install=False, )
def main(args): if iswindows: shutil.rmtree('lib'), shutil.rmtree('lib64') os.mkdir('lib'), os.mkdir('lib64') msbuild('libiconv.vcxproj') copy_headers('include/iconv.h') install_binaries('./lib*/libiconv.dll', 'bin') install_binaries('./lib*/libiconv.lib', 'lib') # from bypy.utils import run_shell # run_shell() else: simple_build( '--disable-dependency-tracking --disable-static --enable-shared')
def main(args): if iswindows: # On windows we dont actually build sqlite as the python build script # downloads its own version locked sqlite. We just install the headers copy_headers('sqlite3*.h') return configure = '--disable-dependency-tracking --disable-static'.split() if ismacos: configure.append(f'CFLAGS={CFLAGS} -O2 -DSQLITE_ENABLE_LOCKING_STYLE') if len(UNIVERSAL_ARCHES) > 1: configure.append('CC=' + 'clang ' + ' '.join(f'-arch {x}' for x in UNIVERSAL_ARCHES)) configure.append('CPP=clang -E') simple_build(configure)
def main(args): replace_in_file('dll.cpp', 'WideToChar', 'WideToUtf') if iswindows: # see https://github.com/microsoft/vcpkg/pull/8053 replace_in_file( 'UnRARDll.vcxproj', '<StructMemberAlignment>4Bytes</StructMemberAlignment>', '') msbuild('UnRARDll.vcxproj') install_binaries('./build/*/Release/unrar.dll', 'bin') install_binaries('./build/*/Release/UnRAR.lib', 'lib') # from bypy.utils import run_shell # run_shell() else: if ismacos: replace_in_file('makefile', 'libunrar.so', 'libunrar.dylib') run('make -j4 lib CXXFLAGS=-fPIC') install_binaries('libunrar.' + ('dylib' if ismacos else 'so'), 'lib') copy_headers('*.hpp', destdir='include/unrar')
def main(args): apply_patch('chmlib-empty-file-not-dir.patch', level=1) # needed for aarch64 if iswindows: os.chdir('src') for f in 'chm_lib.c lzx.c'.split(): copy_headers(f, 'src') run(f'"{CL}" /c /nologo /MD /W3 /DWIN32 -c ' + f) run(f'"{LIB}" -nologo chm_lib.obj lzx.obj -OUT:chmlib.lib') install_binaries('chmlib.lib') copy_headers('chm_lib.h') copy_headers('lzx.h', 'src') else: # test for malloc breaks on macos universal. # All system we care about have malloc anyway replace_in_file('configure', 'if test $ac_cv_func_malloc_0_nonnull = yes; then', 'if test 1; then') replace_in_file('src/chm_lib.c', 'pread64', 'pread') apply_patch('chmlib-integer-types.patch', level=1) # needed for aarch64 # updated config.guess is needed for aarch64 with open('config.guess', 'wb') as dest, open(os.path.join(PATCHES, 'config.guess'), 'rb') as src: dest.write(src.read()) if ismacos and is_arm_half_of_lipo_build(): with open('config.sub', 'w') as dest: dest.write('echo arm-apple-darwin') conf = '--disable-dependency-tracking' if ismacos: conf += ' --disable-pread --disable-io64' simple_build(conf)
def main(args): if iswindows: with current_dir('msvc'): msbuild('Hunspell.sln', configuration='Release_dll') dll = lib = False for f in walk('.'): if os.path.basename(f) == 'libhunspell.dll': install_binaries(f, 'bin') dll = True elif os.path.basename(f) == 'libhunspell.lib': install_binaries(f, 'lib') lib = True if not dll or not lib: raise Exception('Failed to find the hunspell dlls') # from bypy.utils import run_shell # run_shell() copy_headers('src/hunspell/*.hxx', destdir='include/hunspell') copy_headers('src/hunspell/*.h', destdir='include/hunspell') copy_headers('msvc/*.h', destdir='include/hunspell') else: env = {} if ismacos: env['PATH'] = BIN + os.pathsep + os.environ['PATH'] env['LIBTOOLIZE'] = 'glibtoolize' env['LIBTOOL'] = 'glibtool' with ModifiedEnv(**env): run('autoreconf -fiv') conf = '--disable-dependency-tracking' env = {} if ismacos: conf += ' --host x86_64-apple-darwin' simple_build(conf)
def main(args): add_dll_exports() objects = [] cc = CL if iswindows else ('clang' if ismacos else 'gcc') cppflags = shlex.split(CPPFLAGS) cflags = shlex.split(CFLAGS) ldflags = shlex.split(LDFLAGS) if is_arm_half_of_lipo_build(): cflags += ['-arch', current_build_arch()] for c in read_sources(): obj = c.replace('.c', '.obj' if iswindows else '.o') objects.append(obj) if not iswindows: args = [cc] + cppflags + cflags + [ '-O2', '-Iinclude', '-fPIC', '-fvisibility=hidden', '-c', c, '-o', obj] run(*args) if iswindows: dll = 'libstemmer.dll' args = ['/LD'] + list(read_sources()) + ['/Fe:' + dll] run(cc, *args) install_binaries(dll, 'bin') install_binaries('libstemmer.lib') else: ext = 'dylib' if ismacos else 'so' dll = f'libstemmer.0.{ext}' if ismacos else f'libstemmer.{ext}.0' args = ldflags if not ismacos: args += ['-Wl,-soname,libstemmer.so.0'] if is_arm_half_of_lipo_build(): args += ['-arch', current_build_arch()] run( cc, '-shared', '-o', dll, *args, *objects ) os.symlink(dll, f'libstemmer.{ext}') install_binaries(dll) install_binaries(f'libstemmer.{ext}') copy_headers('include/libstemmer.h') if iswindows: os.chdir('/')
def windows_python(args): with open('PCbuild/msbuild.rsp', 'w') as f: print(f'/p:PlatformToolset={get_platform_toolset()}', file=f) print(f'/p:WindowsTargetPlatformVersion={get_windows_sdk()}', file=f) # dont need python 3 to get externals, use git instead replace_in_file('PCbuild\\get_externals.bat', re.compile(br'^call.+find_python.bat.+$', re.MULTILINE), '') env = {} if is64bit: env['PROCESSOR_ARCHITECTURE'] = env['PROCESSOR_ARCHITEW6432'] = 'AMD64' try: run( 'PCbuild\\build.bat', '-e', '--no-tkinter', '-c', 'Release', '-m', '-p', ('x64' if is64bit else 'Win32'), '-v', '-t', 'Build', '--pgo', env=env ) # Run the tests # run('PCbuild\\amd64\\python.exe', 'Lib/test/regrtest.py', '-u', # 'network,cpu,subprocess,urlfetch') # Do not read mimetypes from the registry replace_in_file( 'Lib\\mimetypes.py', re.compile(br'try:.*?import\s+winreg.*?None', re.DOTALL), r'_winreg = None') bindir = 'PCbuild\\amd64' if is64bit else 'PCbuild\\win32' install_binaries(bindir + os.sep + '*.exe', 'private\\python') install_binaries(bindir + os.sep + 'python*.dll', 'private\\python') install_binaries(bindir + os.sep + '*.pyd', 'private\\python\\DLLs') install_binaries(bindir + os.sep + '*.dll', 'private\\python\\DLLs') for x in glob.glob( os.path.join(build_dir(), 'private\\python\\DLLs\\python*.dll')): os.remove(x) install_binaries(bindir + os.sep + '*.lib', 'private\\python\\libs') copy_headers('PC\\pyconfig.h', 'private\\python\\include') copy_headers('Include\\*.h', 'private\\python\\include') copy_headers('Include\\cpython', 'private\\python\\include') with open('Lib/sitecustomize.py', 'w') as f: f.write(''' import os for path in ('{p}/bin', '{p}/qt/bin'): if os.path.exists(path): os.add_dll_directory(path) '''.format(p=PREFIX.replace('\\', '/'))) shutil.copytree('Lib', os.path.join(build_dir(), 'private\\python\\Lib')) finally: # bloody git creates files with no write permission import stat for path in walk('externals'): os.chmod(path, stat.S_IWRITE) os.remove(path)
def main(args): if iswindows: # cmake cannot find openssl replace_in_file('CMakeLists.txt', 'FIND_PACKAGE(LIBCRYPTO)', ('SET(LIBCRYPTO_FOUND "1")\n' 'SET(LIBCRYPTO_INCLUDE_DIR "{0}/include")\n' 'SET(LIBCRYPTO_LIBRARIES "{0}/lib/libcrypto.lib")\n' 'SET(PODOFO_HAVE_OPENSSL_1_1 "1")\n').format( PREFIX.replace(os.sep, '/'))) windows_cmake_build(WANT_LIB64='FALSE', PODOFO_BUILD_SHARED='TRUE', PODOFO_BUILD_STATIC='False', FREETYPE_INCLUDE_DIR=f"{PREFIX}/include/freetype2", nmake_target='podofo_shared') copy_headers('build/podofo_config.h', 'include/podofo') copy_headers('src/podofo/*', 'include/podofo') for f in walk(): if f.endswith('.dll'): install_binaries(f, 'bin') elif f.endswith('.lib'): install_binaries(f, 'lib') else: if ismacos: replace_in_file( 'CMakeLists.txt', 'FIND_PACKAGE(FREETYPE REQUIRED)', ('SET(FREETYPE_FOUND "1")\n' 'SET(FREETYPE_INCLUDE_DIR "{0}/include/freetype2")\n' 'SET(FREETYPE_LIBRARIES "{0}/lib/libfreetype.dylib")' ).format(PREFIX)) replace_in_file('src/podofo/base/PdfDate.cpp', 'struct tm _tm{}', 'struct tm _tm = {0}') cmake_build( make_args='podofo_shared', PODOFO_BUILD_LIB_ONLY='TRUE', PODOFO_BUILD_SHARED='TRUE', PODOFO_BUILD_STATIC='FALSE', )
def main(args): cmake_args = dict(BUILD_CODEC='OFF') if iswindows: windows_cmake_build(**cmake_args) install_binaries('build/bin/*.dll', 'bin') install_binaries('build/bin/*.lib', 'lib') copy_headers('src/lib/openjp2/opj_*.h', 'include/openjpeg') copy_headers('build/src/lib/openjp2/opj_*.h', 'include/openjpeg') copy_headers('src/lib/openjp2/openjpeg.h', 'include/openjpeg') else: cmake_build(**cmake_args)
def main(args): if iswindows: os.chdir('src') for f in 'chm_lib.c lzx.c'.split(): copy_headers(f, 'src') run(f'"{CL}" /c /nologo /MD /W3 /DWIN32 -c ' + f) run(f'"{LIB}" -nologo chm_lib.obj lzx.obj -OUT:chmlib.lib') install_binaries('chmlib.lib') copy_headers('chm_lib.h') copy_headers('lzx.h', 'src') else: conf = '--disable-dependency-tracking' if ismacos: conf += ' --disable-pread --disable-io64' simple_build(conf)
def main(args): run(f'"{NMAKE}" -f win32/Makefile.msc') run(f'"{NMAKE}" -f win32/Makefile.msc test') install_binaries('zlib1.dll*', 'bin') install_binaries('zlib.lib'), install_binaries('zdll.*') copy_headers('zconf.h'), copy_headers('zlib.h')
def main(args): run('make -f Makefile-libbz2_so') install_binaries('libbz2*.so*', do_symlinks=True) copy_headers('bzlib.h')