def compileTree(): source_dir = OutputDirectories.getSourceDirectoryPath() general.info("Completed Python level compilation and optimization.") if not Options.shallOnlyExecCCompilerCall(): general.info("Generating source code for C backend compiler.") if Options.isShowProgress() or Options.isShowMemory(): general.info( "Total memory usage before generating C code: {memory}:". format( memory=MemoryUsage.getHumanReadableProcessMemoryUsage())) # Now build the target language code for the whole tree. makeSourceDirectory() bytecode_accessor = ConstantAccessor(data_filename="__bytecode.const", top_level_name="bytecode_data") # This should take all bytecode values, even ones needed for frozen or # not produce anything. loader_code = LoaderCodes.getMetapathLoaderBodyCode(bytecode_accessor) writeSourceCode(filename=os.path.join(source_dir, "__loader.c"), source_code=loader_code) else: source_dir = OutputDirectories.getSourceDirectoryPath() if not os.path.isfile(os.path.join(source_dir, "__helpers.h")): general.sysexit("Error, no previous build directory exists.") if Options.isShowProgress() or Options.isShowMemory(): general.info( "Total memory usage before running scons: {memory}:".format( memory=MemoryUsage.getHumanReadableProcessMemoryUsage())) if Options.isShowMemory(): InstanceCounters.printStats() if Options.is_debug: Reports.doMissingOptimizationReport() if Options.shallNotDoExecCCompilerCall(): return True, {} general.info( "Running data composer tool for optimal constant value handling.") # TODO: On Windows, we could run this in parallel to Scons, on Linux we need it # for linking. runDataComposer(source_dir) general.info("Running C level backend compilation via Scons.") # Run the Scons to build things. result, options = runSconsBackend(quiet=not Options.isShowScons()) return result, options
def compileTree(main_module): source_dir = getSourceDirectoryPath(main_module) if not Options.shallOnlyExecCCompilerCall(): # Now build the target language code for the whole tree. makeSourceDirectory( main_module = main_module ) frozen_code = generateBytecodeFrozenCode() if frozen_code is not None: writeSourceCode( filename = os.path.join( source_dir, "__frozen.c" ), source_code = frozen_code ) writeBinaryData( filename = os.path.join( source_dir, "__constants.bin" ), binary_data = ConstantCodes.stream_data.getBytes() ) else: source_dir = getSourceDirectoryPath(main_module) if not os.path.isfile(os.path.join(source_dir, "__helpers.h")): sys.exit("Error, no previous build directory exists.") if Options.isShowProgress() or Options.isShowMemory(): info( "Total memory usage before running scons: {memory}:".format( memory = MemoryUsage.getHumanReadableProcessMemoryUsage() ) ) if Options.isShowMemory(): InstanceCounters.printStats() if Options.isDebug(): Reports.doMissingOptimizationReport() if Options.shallNotDoExecCCompilerCall(): return True, {} # Run the Scons to build things. result, options = runScons( main_module = main_module, quiet = not Options.isShowScons() ) return result, options
def compileTree(main_module): source_dir = getSourceDirectoryPath(main_module) if not Options.shallOnlyExecCppCall(): # Now build the target language code for the whole tree. makeSourceDirectory( main_module = main_module ) if Options.isStandaloneMode(): for module in detectLateImports(): ModuleRegistry.addUncompiledModule(module) frozen_code = generateBytecodeFrozenCode() if frozen_code is not None: writeSourceCode( filename = Utils.joinpath( source_dir, "__frozen.cpp" ), source_code = frozen_code ) writeBinaryData( filename = Utils.joinpath(source_dir, "__constants.bin"), binary_data = ConstantCodes.stream_data.getBytes() ) else: source_dir = getSourceDirectoryPath(main_module) if not Utils.isFile(Utils.joinpath(source_dir, "__helpers.hpp")): sys.exit("Error, no previous build directory exists.") if Options.isShowProgress() or Options.isShowMemory(): Tracing.printLine( "Total memory usage before running scons: {memory}:".format( memory = Utils.getHumanReadableProcessMemoryUsage() ) ) if Options.isShowMemory(): InstanceCounters.printStats() if Options.shallNotDoExecCppCall(): return True, {} # Run the Scons to build things. result, options = runScons( main_module = main_module, quiet = not Options.isShowScons() ) return result, options
def compileTree(main_module): source_dir = getSourceDirectoryPath(main_module) if not Options.shallOnlyExecCCompilerCall(): # Now build the target language code for the whole tree. makeSourceDirectory(main_module=main_module) frozen_code = generateBytecodeFrozenCode() if frozen_code is not None: writeSourceCode( filename=os.path.join(source_dir, "__frozen.c"), source_code=frozen_code ) writeBinaryData( filename=os.path.join(source_dir, "__constants.bin"), binary_data=ConstantCodes.stream_data.getBytes(), ) else: source_dir = getSourceDirectoryPath(main_module) if not os.path.isfile(os.path.join(source_dir, "__helpers.h")): sys.exit("Error, no previous build directory exists.") if Options.isShowProgress() or Options.isShowMemory(): info( "Total memory usage before running scons: {memory}:".format( memory=MemoryUsage.getHumanReadableProcessMemoryUsage() ) ) if Options.isShowMemory(): InstanceCounters.printStats() if Options.isDebug(): Reports.doMissingOptimizationReport() if Options.shallNotDoExecCCompilerCall(): return True, {} # Run the Scons to build things. result, options = runScons(main_module=main_module, quiet=not Options.isShowScons()) return result, options