def makeMainSource( tree ):
    generator_module = Generator.PythonModuleGenerator(
        module_name = "__main__",
    )

    other_modules = TreeBuilding.getOtherModules()

    if tree in other_modules:
        other_modules.remove( tree )

    for module in other_modules:
        _prepareCodeGeneration( module )

    _prepareCodeGeneration( tree )

    source_code = CodeGeneration.generateExecutableCode(
        main_module   = tree,
        other_modules = other_modules,
        generator     = generator_module
    )

    return source_code