def main(): all_build_start_time = time.time() parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter, epilog=get_help()) parser.add_argument('--lto', action='store_const', const='full', help='build bitcode object for LTO') parser.add_argument('--lto=thin', dest='lto', action='store_const', const='thin', help='build bitcode object for ThinLTO') parser.add_argument( '--pic', action='store_true', help='build relocatable objects for suitable for dynamic linking') parser.add_argument('--force', action='store_true', help='force rebuild of target (by removing it first)') parser.add_argument('--verbose', action='store_true', help='show build commands') parser.add_argument('--wasm64', action='store_true', help='use wasm64 architecture') parser.add_argument( 'operation', help='currently only "build" and "clear" are supported') parser.add_argument('targets', nargs='+', help='see below') args = parser.parse_args() if args.operation not in ('build', 'clear'): shared.exit_with_error('unfamiliar operation: ' + args.operation) # process flags # Check sanity so that if settings file has changed, the cache is cleared here. # Otherwise, the cache will clear in an emcc process, which is invoked while building # a system library into the cache, causing trouble. shared.check_sanity() if args.lto: settings.LTO = args.lto if args.verbose: shared.PRINT_STAGES = True if args.pic: settings.RELOCATABLE = 1 if args.wasm64: settings.MEMORY64 = 2 MINIMAL_TASKS[:] = [t for t in MINIMAL_TASKS if 'emmalloc' not in t] do_build = args.operation == 'build' do_clear = args.operation == 'clear' if args.force: do_clear = True # process tasks auto_tasks = False tasks = args.targets system_libraries, system_tasks = get_system_tasks() if 'SYSTEM' in tasks: tasks = system_tasks auto_tasks = True elif 'USER' in tasks: tasks = PORTS auto_tasks = True elif 'MINIMAL' in tasks: tasks = MINIMAL_TASKS auto_tasks = True elif 'MINIMAL_PIC' in tasks: tasks = MINIMAL_PIC_TASKS auto_tasks = True elif 'ALL' in tasks: tasks = system_tasks + PORTS auto_tasks = True if auto_tasks: # There are some ports that we don't want to build as part # of ALL since the are not well tested or widely used: skip_tasks = ['cocos2d'] tasks = [x for x in tasks if x not in skip_tasks] print('Building targets: %s' % ' '.join(tasks)) for what in tasks: for old, new in legacy_prefixes.items(): if what.startswith(old): what = what.replace(old, new) if do_build: logger.info('building ' + what) else: logger.info('clearing ' + what) start_time = time.time() if what in system_libraries: library = system_libraries[what] if do_clear: library.erase() if do_build: library.get_path() elif what == 'sysroot': if do_clear: shared.Cache.erase_file('sysroot_install.stamp') if do_build: system_libs.ensure_sysroot() elif what == 'struct_info': if do_clear: emscripten.clear_struct_info() if do_build: emscripten.generate_struct_info() elif what in PORTS: if do_clear: clear_port(what) if do_build: build_port(what) else: logger.error('unfamiliar build target: ' + what) return 1 time_taken = time.time() - start_time logger.info( '...success. Took %s(%.2fs)' % (('%02d:%02d mins ' % (time_taken // 60, time_taken % 60) if time_taken >= 60 else ''), time_taken)) if len(tasks) > 1: all_build_time_taken = time.time() - all_build_start_time logger.info( 'Built %d targets in %s(%.2fs)' % (len(tasks), ('%02d:%02d mins ' % (all_build_time_taken // 60, all_build_time_taken % 60) if all_build_time_taken >= 60 else ''), all_build_time_taken)) return 0
def main(): global force parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter, epilog=get_help()) parser.add_argument('--lto', action='store_true', help='build bitcode object for LTO') parser.add_argument('--pic', action='store_true', help='build relocatable objects for suitable for dynamic linking') parser.add_argument('--force', action='store_true', help='force rebuild of target (by removing it first)') parser.add_argument('operation', help='currently only "build" is supported') parser.add_argument('targets', nargs='+', help='see below') args = parser.parse_args() if args.operation != 'build': shared.exit_with_error('unfamiliar operation: ' + args.operation) # process flags # Check sanity so that if settings file has changed, the cache is cleared here. # Otherwise, the cache will clear in an emcc process, which is invoked while building # a system library into the cache, causing trouble. shared.check_sanity() if args.lto: shared.Settings.LTO = "full" if args.pic: shared.Settings.RELOCATABLE = 1 if args.force: force = True # process tasks auto_tasks = False tasks = args.targets if 'SYSTEM' in tasks: tasks = SYSTEM_TASKS auto_tasks = True elif 'USER' in tasks: tasks = USER_TASKS auto_tasks = True elif 'MINIMAL' in tasks: tasks = MINIMAL_TASKS auto_tasks = True elif 'ALL' in tasks: tasks = SYSTEM_TASKS + USER_TASKS auto_tasks = True if auto_tasks: # cocos2d: must be ported, errors on # "Cannot recognize the target platform; are you targeting an unsupported platform?" skip_tasks = ['cocos2d'] tasks = [x for x in tasks if x not in skip_tasks] print('Building targets: %s' % ' '.join(tasks)) for what in tasks: logger.info('building and verifying ' + what) if what in SYSTEM_LIBRARIES: library = SYSTEM_LIBRARIES[what] if force: library.erase() library.get_path() elif what == 'sysroot': if force: shared.Cache.erase_file('sysroot_install.stamp') system_libs.ensure_sysroot() elif what == 'struct_info': if force: shared.Cache.erase_file('generated_struct_info.json') emscripten.generate_struct_info() elif what == 'icu': build_port('icu', 'libicuuc.a') elif what == 'zlib': shared.Settings.USE_ZLIB = 1 build_port('zlib', 'libz.a') shared.Settings.USE_ZLIB = 0 elif what == 'bzip2': build_port('bzip2', 'libbz2.a') elif what == 'bullet': build_port('bullet', 'libbullet.a') elif what == 'vorbis': build_port('vorbis', 'libvorbis.a') elif what == 'ogg': build_port('ogg', 'libogg.a') elif what == 'giflib': build_port('giflib', 'libgif.a') elif what == 'libjpeg': build_port('libjpeg', 'libjpeg.a') elif what == 'libpng': build_port('libpng', 'libpng.a') elif what == 'sdl2': build_port('sdl2', 'libSDL2.a') elif what == 'sdl2-mt': shared.Settings.USE_PTHREADS = 1 build_port('sdl2', 'libSDL2-mt.a') shared.Settings.USE_PTHREADS = 0 elif what == 'sdl2-gfx': build_port('sdl2_gfx', 'libSDL2_gfx.a') elif what == 'sdl2-image': build_port('sdl2_image', 'libSDL2_image.a') elif what == 'sdl2-image-png': shared.Settings.SDL2_IMAGE_FORMATS = ["png"] build_port('sdl2_image', 'libSDL2_image_png.a') shared.Settings.SDL2_IMAGE_FORMATS = [] elif what == 'sdl2-image-jpg': shared.Settings.SDL2_IMAGE_FORMATS = ["jpg"] build_port('sdl2_image', 'libSDL2_image_jpg.a') shared.Settings.SDL2_IMAGE_FORMATS = [] elif what == 'sdl2-net': build_port('sdl2_net', 'libSDL2_net.a') elif what == 'sdl2-mixer': old_formats = shared.Settings.SDL2_MIXER_FORMATS shared.Settings.SDL2_MIXER_FORMATS = [] build_port('sdl2_mixer', 'libSDL2_mixer.a') shared.Settings.SDL2_MIXER_FORMATS = old_formats elif what == 'sdl2-mixer-ogg': old_formats = shared.Settings.SDL2_MIXER_FORMATS shared.Settings.SDL2_MIXER_FORMATS = ["ogg"] build_port('sdl2_mixer', 'libSDL2_mixer_ogg.a') shared.Settings.SDL2_MIXER_FORMATS = old_formats elif what == 'sdl2-mixer-mp3': old_formats = shared.Settings.SDL2_MIXER_FORMATS shared.Settings.SDL2_MIXER_FORMATS = ["mp3"] build_port('sdl2_mixer', 'libSDL2_mixer_mp3.a') shared.Settings.SDL2_MIXER_FORMATS = old_formats elif what == 'freetype': build_port('freetype', 'libfreetype.a') elif what == 'harfbuzz': build_port('harfbuzz', 'libharfbuzz.a') elif what == 'harfbuzz-mt': shared.Settings.USE_PTHREADS = 1 build_port('harfbuzz', 'libharfbuzz-mt.a') shared.Settings.USE_PTHREADS = 0 elif what == 'sdl2-ttf': build_port('sdl2_ttf', 'libSDL2_ttf.a') elif what == 'cocos2d': build_port('cocos2d', 'libcocos2d.a') elif what == 'regal': build_port('regal', 'libregal.a') elif what == 'regal-mt': shared.Settings.USE_PTHREADS = 1 build_port('regal', 'libregal-mt.a') shared.Settings.USE_PTHREADS = 0 elif what == 'boost_headers': build_port('boost_headers', 'libboost_headers.a') else: logger.error('unfamiliar build target: ' + what) return 1 logger.info('...success') return 0
def main(): global force all_build_start_time = time.time() parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter, epilog=get_help()) parser.add_argument('--lto', action='store_true', help='build bitcode object for LTO') parser.add_argument( '--pic', action='store_true', help='build relocatable objects for suitable for dynamic linking') parser.add_argument('--force', action='store_true', help='force rebuild of target (by removing it first)') parser.add_argument('operation', help='currently only "build" is supported') parser.add_argument('targets', nargs='+', help='see below') args = parser.parse_args() if args.operation != 'build': shared.exit_with_error('unfamiliar operation: ' + args.operation) # process flags # Check sanity so that if settings file has changed, the cache is cleared here. # Otherwise, the cache will clear in an emcc process, which is invoked while building # a system library into the cache, causing trouble. shared.check_sanity() if args.lto: settings.LTO = "full" if args.pic: settings.RELOCATABLE = 1 if args.force: force = True # process tasks auto_tasks = False tasks = args.targets if 'SYSTEM' in tasks: tasks = SYSTEM_TASKS auto_tasks = True elif 'USER' in tasks: tasks = PORTS auto_tasks = True elif 'MINIMAL' in tasks: tasks = MINIMAL_TASKS auto_tasks = True elif 'ALL' in tasks: tasks = SYSTEM_TASKS + PORTS auto_tasks = True if auto_tasks: # cocos2d: must be ported, errors on # "Cannot recognize the target platform; are you targeting an unsupported platform?" skip_tasks = ['cocos2d'] tasks = [x for x in tasks if x not in skip_tasks] print('Building targets: %s' % ' '.join(tasks)) for what in tasks: for old, new in legacy_prefixes.items(): if what.startswith(old): what = what.replace(old, new) logger.info('building and verifying ' + what) start_time = time.time() if what in SYSTEM_LIBRARIES: library = SYSTEM_LIBRARIES[what] if force: library.erase() library.get_path() elif what == 'sysroot': if force: shared.Cache.erase_file('sysroot_install.stamp') system_libs.ensure_sysroot() elif what == 'struct_info': if force: shared.Cache.erase_file('generated_struct_info.json') emscripten.generate_struct_info() elif what in PORTS: build_port(what) else: logger.error('unfamiliar build target: ' + what) return 1 time_taken = time.time() - start_time logger.info( '...success. Took %s(%.2fs)' % (('%02d:%02d mins ' % (time_taken // 60, time_taken % 60) if time_taken >= 60 else ''), time_taken)) if len(tasks) > 1: all_build_time_taken = time.time() - all_build_start_time logger.info( 'Built %d targets in %s(%.2fs)' % (len(tasks), ('%02d:%02d mins ' % (all_build_time_taken // 60, all_build_time_taken % 60) if all_build_time_taken >= 60 else ''), all_build_time_taken)) return 0