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.") blob_filename = runDataComposer(source_dir) Plugins.onDataComposerResult(blob_filename) for filename, source_code in Plugins.getExtraCodeFiles().items(): target_dir = os.path.join(source_dir, "plugins") if not os.path.isdir(target_dir): makePath(target_dir) writeSourceCode( filename=os.path.join(target_dir, filename), source_code=source_code ) 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 runDataComposer(source_dir): from nuitka.plugins.Plugins import Plugins Plugins.onDataComposerRun() blob_filename = _runDataComposer(source_dir=source_dir) Plugins.onDataComposerResult(blob_filename)