Ejemplo n.º 1
0
def cmd_buildmod(args):
    output_dir = args.view + os.sep + '.ctx/obj'

    from contexo import ctx_cmod
    from contexo import ctx_base
    from contexo import ctx_envswitch
    from contexo.ctx_depmgr import CTXDepMgr

    # Switch to specified environment
    oldEnv = None
    if args.env != None:
        envLayout   = EnvironmentLayout( cfgFile,  args.env )
        oldEnv      = switchEnvironment( envLayout, True )

    if args.logfile != None:
        ctx_log.ctxlogStart()

    # Prepare all
    deprecated_repo_validation_warning(args)
    cview   = ctx_view.CTXView( args.view, getAccessPolicy(args), validate=False )
    modules = expand_list_files(cview, args.modules)
    bc      = getBuildConfiguration( cview,  args )
    deprecated_tolerate_missing_headers_warning(args)
    depmgr = CTXDepMgr ( codeModulePaths = cview.getItemPaths('modules'), failOnMissingHeaders = args.fail_on_missing_headers, archPath = bc.getArchPath(), legacyCompilingMod = args.legacy_compiling_mod )

    depmgr.addCodeModules( modules, args.tests )

    session = ctx_base.CTXBuildSession( bc )

    session.setDependencyManager( depmgr )



    # Register build configuration in log handler
    ctx_log.ctxlogSetBuildConfig( bc.getTitle(),
                                  bc.getCompiler().cdefTitle,
                                  bc.getBuildParams().cflags,
                                  bc.getBuildParams().prepDefines,
                                  "N/A" )

    output_path = os.path.join( args.output, args.libdir )

    buildmodules( depmgr, session, modules, args, output_path, bc.getTitle(),  libraryName = args.lib)

    header_path = os.path.join(args.output, args.headerdir )
    export_public_module_headers( depmgr, modules, header_path )

    # Write log if requested
    if args.logfile != None:
        logfilepath = os.path.join( args.output, args.logfile )
        logpath     = os.path.normpath(os.path.dirname( logfilepath ))
        if len(logpath) and not os.path.isdir(logpath):
            os.makedirs( logpath )

        ctx_log.ctxlogWriteToFile( logfilepath, appendToExisting=False )

    # Switch back to original environment
    if args.env != None:
        switchEnvironment( oldEnv, False )
Ejemplo n.º 2
0
def cmd_clean(args):

    from contexo import ctx_cmod
    from contexo.ctx_depmgr import CTXDepMgr
    from contexo import ctx_base
    from contexo import ctx_envswitch

    #
    # Get Code Module Paths from view.
    #

    cview = ctx_view.CTXView( args.view, getAccessPolicy(args), validate=bool(args.repo_validation) )

    exp_modules = expand_list_files(cview, args.modules)
    bc      = getBuildConfiguration( cview,  args )

    depmgr  = CTXDepMgr( cview.getItemPaths('modules') ,  args.tolerate_missing_headers)
    depmgr.addCodeModules( exp_modules, args.tests )

    session = ctx_base.CTXBuildSession( bc )

    session.setDependencyManager( depmgr )

    #
    # Determine which modules to clean.
    #

    if args.deps:
        module_names = depmgr.getCodeModulesWithDependencies ()
    else:
        module_names = exp_modules

    modules = depmgr.createCodeModules( set(exp_modules) | (set(module_names) - set(exp_modules) ) )

    print "cleaning modules:"

    for module in modules:
        print " " + module.getName()
        module.clean (bc.getTitle())
Ejemplo n.º 3
0
def cmd_info(args):
    output_dir = args.view + os.sep + '.ctx/obj'
    from contexo.ctx_depmgr import CTXDepMgr

    #
    # Get Code Module Paths from view.
    #

    cview = ctx_view.CTXView(args.view, ctx_view.AP_NO_REMOTE_ACCESS, False, False)

    #
    # Show info
    #

    print "Contexo version: ", ctx_sysinfo.CTX_DISPLAYVERSION
    print "Using build config file: ", CTX_DEFAULT_BCONF

    #
    # Module
    #

    # Prepare all
    bc      = getBuildConfiguration( cview,  args )

    if args.module != None:
        deprecated_tolerate_missing_headers_warning(args)
        depmgr = CTXDepMgr ( codeModulePaths = cview.getItemPaths('modules'), failOnMissingHeaders = args.fail_on_missing_headers, archPath = bc.getArchPath(), legacyCompilingMod = args.legacy_compiling_mod )
        depmgr.addCodeModules( args.module )
        module_names = depmgr.getCodeModulesWithDependencies ()
        module_names.sort ()
        if len ( module_names ) > 0:
            print "\nModules '" + args.module[0] + "' depends on:\n"
            for module in module_names:
                print "\t",module

        pub_headers = depmgr.getPublicHeaders ( args.module)
        pub_headers.sort()
        if len ( pub_headers ) > 0:
            print "\nPublic headers '" + args.module[0] + "' depends on:\n"
            for header in pub_headers:
                print "\t",header

        module_names = depmgr.getDependentModules( args.module[0] )
        if len ( module_names ) > 0:
            print "\nModule(s) that depend(s) on '" + args.module[0] + "':\n"
            for module in module_names:
                print "\t",module
Ejemplo n.º 4
0
def cmd_info(args):
    from contexo.ctx_depmgr import CTXDepMgr

    #
    # Get Code Module Paths from view.
    #

    cview = ctx_view.CTXView(args.view, ctx_view.AP_NO_REMOTE_ACCESS, False, False)

    #
    # Show info
    #

    print "Contexo version: ", ctx_sysinfo.CTX_DISPLAYVERSION
    print "Using build config file: ", CTX_DEFAULT_BCONF

    #
    # Module
    #

    if args.module != None:
        depmgr = CTXDepMgr ( cview.getItemPaths('modules') )
        depmgr.addCodeModules( args.module )
        module_names = depmgr.getCodeModulesWithDependencies ()
        module_names.sort ()
        if len ( module_names ) > 0:
            print "\nModules '" + args.module[0] + "' depends on:\n"
            for module in module_names:
                print "\t",module

        pub_headers = depmgr.getPublicHeaders ( args.module)
        pub_headers.sort()
        if len ( pub_headers ) > 0:
            print "\nPublic headers '" + args.module[0] + "' depends on:\n"
            for header in pub_headers:
                print "\t",header

        module_names = depmgr.getDependentModules( args.module[0] )
        if len ( module_names ) > 0:
            print "\nModule(s) that depend(s) on '" + args.module[0] + "':\n"
            for module in module_names:
                print "\t",module
Ejemplo n.º 5
0
def cmd_export(args):
    from contexo import ctx_cmod
    from contexo import ctx_base
    from contexo import ctx_envswitch
    from contexo.ctx_depmgr import CTXDepMgr
    from contexo.ctx_export import CTXExportData

    envLayout = None
    oldEnv = None
    if args.env != None:
        envLayout = EnvironmentLayout( cfgFile,  args.env )
        oldEnv    = switchEnvironment( envLayout, True )

    # Prepare all
    cview   = ctx_view.CTXView( args.view, getAccessPolicy(args), validate=bool(args.repo_validation) )
    bc      = getBuildConfiguration( cview,  args )
    deprecated_tolerate_missing_headers_warning(args)
    depmgr  = CTXDepMgr ( cview.getItemPaths('modules'),  args.fail_on_missing_headers, bc.getArchPath() )
    session = ctx_base.CTXBuildSession( bc )
    session.setDependencyManager( depmgr )

    export_items = expand_list_files( cview, args.export_items )

    # Make sure we have only one type of item to export
    component_export = True
    for item in export_items:
        if item.endswith( '.comp' ):
            if component_export == False:
                userErrorExit("An export operation can either export a list of components OR a list of modules, not both.")
        else:
            component_export = False

    components   = list()
    main_modules = list() # Excluding dependency modules
    if component_export:
        # Construct and validate component objects
        components = create_components( export_items, cview.getItemPaths('comp') )
        for comp in components:
            for library, compmodules in comp.libraries.items():
                depmgr.addCodeModules( compmodules, args.tests )
                main_modules.extend( compmodules )
    else:
        main_modules = export_items

    # Divert modules into main modules and dependency modules
    export_modules = depmgr.getCodeModulesWithDependencies() if args.deps else main_modules
    export_modules.sort()
    dep_modules = set(export_modules) - set(main_modules)

    ctx_modules = depmgr.createCodeModules( main_modules, args.tests )
    ctx_modules.extend ( depmgr.createCodeModules( dep_modules ) )

    module_map = dict()
    for mod in ctx_modules:
        module_map[mod.getName()] = mod

    depmgr.updateDependencyHash()

    # Dispatch export data to handler (through pipe)
    package = CTXExportData()
    package.setExportData( module_map, components, args.tests, session, depmgr,
                           cview, envLayout, args )
    package.dispatch()

    # Restore environment
    if args.env != None:
        switchEnvironment( oldEnv, False )
Ejemplo n.º 6
0
def cmd_build(args):
    from contexo import ctx_cmod
    from contexo import ctx_base
    from contexo import ctx_envswitch
    from contexo.ctx_depmgr import CTXDepMgr
    from contexo.ctx_export import CTXExportData

    envLayout = None
    oldEnv = None
    if args.env != None:
        envLayout = EnvironmentLayout( cfgFile,  args.env )
        oldEnv    = switchEnvironment( envLayout, True )

    absIncDirs = map(os.path.abspath,  args.incdirs)

    # Prepare all
    cview   = ctx_view.CTXView( args.view, getAccessPolicy(args), validate=bool(args.repo_validation) )
    bc      = getBuildConfiguration( cview,  args )
    bc.buildParams.incPaths.extend(     absIncDirs ) #TODO: accessing 'private' data?
    bc.buildParams.ldDirs.extend(args.libdirs)
    bc.buildParams.ldLibs.extend(args.libs)
    archPath = list()
    archPath = bc.getArchPath()
    deprecated_tolerate_missing_headers_warning(args)
    depmgr = CTXDepMgr ( codeModulePaths = cview.getItemPaths('modules'), failOnMissingHeaders = args.fail_on_missing_headers, archPath = bc.getArchPath(), additionalIncDirs = absIncDirs, legacyCompilingMod = args.legacy_compiling_mod )
    session = ctx_base.CTXBuildSession( bc )
    session.setDependencyManager( depmgr )

    items = expand_list_files( cview, args.items )

    # Make sure we have only one type of item to export
    #TODO:make a more robust recognition than file extention for .comp
    component_build = True
    for item in items:
        if item.endswith( '.comp' ):
            if component_build == False:
                userErrorExit("The operation can either work on a list of components OR a list of modules, not both.")
        else:
            component_build = False

   # Register build configuration in log handler
    ctx_log.ctxlogSetBuildConfig( bc.getTitle(),
                                  bc.getCompiler().cdefTitle,
                                  bc.getBuildParams().cflags,
                                  bc.getBuildParams().prepDefines,
                                  "N/A" )
    outputPath = args.output
    bin_dir = os.path.join( outputPath, args.bindir )
    header_dir = os.path.join( outputPath, args.headerdir )
    objs = list()
    # Process components
    if component_build:
        infoMessage("building components",  6)
        components = create_components( items, cview.getItemPaths('comp') )

        for comp in components:
            ctx_log.ctxlogBeginComponent( comp.name )

            # TODO: also unused, what does the workaround below fix?
            # Workaround to get header export to work
            #codemodule_map = dict()

            # Build component modules.
            for library, modules in comp.libraries.items():
                modules = expand_list_files( cview, modules )
                depmgr.addCodeModules( modules, args.tests )
                args.library_name = library
                infoMessage('args: %s'%args,  6)
                objs += buildmodules( depmgr, session,  modules,  args, bin_dir, session.bc.getTitle(),  args.library_name)

                if (args.all_headers):
                    header_path = os.path.join(args.output, args.headerdir )
                    export_public_module_headers( depmgr, modules, header_path )

                depmgr.emptyCodeModules()
            export_headers( depmgr, comp.publicHeaders, header_dir )
            ctx_log.ctxlogEndComponent()

    #Process modules
    else:
        infoMessage("building modules",  6)
        depmgr.addCodeModules( items, args.tests )
        objs += buildmodules( depmgr, session, items, args, outputPath, bc.getTitle(),  libraryName=args.library_name)
        export_public_module_headers( depmgr, items, header_dir )

    if args.executable_name:
            session.linkExecutable(objs, bin_dir, args.executable_name)

    # Write log if requested
    if args.logfile != None:
        logfilepath = os.path.join( args.output, args.logfile )
        logpath     = os.path.normpath(os.path.dirname( logfilepath ))
        if len(logpath) and not os.path.isdir(logpath):
            os.makedirs( logpath )

        ctx_log.ctxlogWriteToFile( logfilepath, appendToExisting=False )


    # Restore environment
    if args.env != None:
        switchEnvironment( oldEnv, False )
Ejemplo n.º 7
0
def cmd_buildcomp(args):
    from contexo import ctx_cmod
    from contexo import ctx_base
    from contexo import ctx_envswitch
    from contexo.ctx_depmgr import CTXDepMgr

    # Switch to specified environment
    oldEnv = None
    if args.env != None:
        envLayout = EnvironmentLayout( cfgFile,  args.env )
        oldEnv    = switchEnvironment( envLayout, True )

    if args.logfile != None:
        ctx_log.ctxlogStart()

    # Prepare all
    cview       = ctx_view.CTXView( args.view, getAccessPolicy(args), validate=bool(args.repo_validation) )
    components  = expand_list_files( cview, args.components )

    bc          = getBuildConfiguration( cview,  args )
    deprecated_tolerate_missing_headers_warning(args)
    depmgr = CTXDepMgr ( codeModulePaths = cview.getItemPaths('modules'), failOnMissingHeaders = args.fail_on_missing_headers, archPath = bc.getArchPath(), legacyCompilingMod = args.legacy_compiling_mod )
    session     = ctx_base.CTXBuildSession( bc )
    session.setDependencyManager( depmgr )

    # Register build configuration in log handler
    ctx_log.ctxlogSetBuildConfig( bc.getTitle(),
                                  bc.getCompiler().cdefTitle,
                                  bc.getBuildParams().cflags,
                                  bc.getBuildParams().prepDefines,
                                  "N/A" )

    # Process components
    components = create_components( components, cview.getItemPaths('comp') )
    for comp in components:
        ctx_log.ctxlogBeginComponent( comp.name )

        outputPath = args.output
        lib_dir = os.path.join( outputPath, args.libdir )
        header_dir = os.path.join( outputPath, args.headerdir )

	# TODO: this is unused, what does it fix?
	# Workaround to get header export to work
        #codemodule_map = dict()

        # Build component modules.
        for library, modules in comp.libraries.items():

            modules = expand_list_files( cview, modules )

            depmgr.addCodeModules( modules, args.tests )

            args.lib = library
            infoMessage('args: %s'%args,  6)
            buildmodules( depmgr, session,  modules,  args, lib_dir, session.bc.getTitle(),  libraryName = args.lib)

            depmgr.emptyCodeModules()

        export_headers( depmgr, comp.publicHeaders, header_dir )

        ctx_log.ctxlogEndComponent()

    # Write log if requested
    if args.logfile != None:
        logfilepath = os.path.join( args.output, args.logfile )
        logpath     = os.path.normpath(os.path.dirname( logfilepath ))
        if len(logpath) and not os.path.isdir(logpath):
            os.makedirs( logpath )

        ctx_log.ctxlogWriteToFile( logfilepath, appendToExisting=False )


    # Restore environment
    if args.env != None:
        switchEnvironment( oldEnv, False )
Ejemplo n.º 8
0
def cmd_build(args):
    launch_path = os.path.abspath('.')

    view_dir = get_view_dir(args.view)
    obj_dir = view_dir + os.sep + '.ctx/obj'
    # test if not absolute path
    if args.output[0] != '/' and args.output[0] != '\\' and args.output[1:3] != ':\\':
        lib_output = os.path.join(view_dir,args.output)
    else:
        lib_output = args.output

    lib_dirs = map(os.path.abspath, args.libdirs)

    from contexo import ctx_cmod
    from contexo import ctx_base
    from contexo import ctx_envswitch
    from contexo.ctx_depmgr import CTXDepMgr
    from contexo.ctx_export import CTXExportData

    envLayout = None
    oldEnv = None
    if args.env != None:
        envLayout = EnvironmentLayout( cfgFile,  args.env )
        oldEnv    = switchEnvironment( envLayout, True )

    absIncDirs = map(os.path.abspath,  args.incdirs)

    # Prepare all
    deprecated_nra_warning( args )
    deprecated_repo_validation_warning(args)
    cview   = ctx_view.CTXView( view_dir, validate=False )
    bc      = getBuildConfiguration( cview,  args )
    bc.buildParams.incPaths.extend(     absIncDirs ) #TODO: accessing 'private' data?
    bc.buildParams.ldDirs.extend(lib_dirs)
    bc.buildParams.ldLibs.extend(args.libs)
    archPath = list()
    archPath = bc.getArchPath()
    deprecated_tolerate_missing_headers_warning(args)
    depmgr = CTXDepMgr ( codeModulePaths = cview.getItemPaths('modules'), failOnMissingHeaders = args.fail_on_missing_headers, archPath = bc.getArchPath(), additionalIncDirs = absIncDirs, legacyCompilingMod = args.legacy_compiling_mod, legacyDuplicateSources = args.legacy_duplicate_sources, globalOutputDir = obj_dir, bc = bc  )
    session = ctx_base.CTXBuildSession( bc )
    session.setDependencyManager( depmgr )

    items = expand_list_files( cview, args.items )

    # Make sure we have only one type of item to export
    #TODO:make a more robust recognition than file extention for .comp
    component_build = True
    for item in items:
        if item.endswith( '.comp' ):
            if component_build == False:
                userErrorExit("The operation can either work on a list of components OR a list of modules, not both.")
        else:
            component_build = False

   # Register build configuration in log handler
    ctx_log.ctxlogSetBuildConfig( bc.getTitle(),
                                  bc.getCompiler().cdefTitle,
                                  bc.getBuildParams().cflags,
                                  bc.getBuildParams().prepDefines,
                                  "N/A" )
    outputPath = lib_output
    bin_dir = os.path.join( outputPath, args.bindir )
    header_dir = os.path.join( outputPath, args.headerdir )
    objs = list()
    ## TODO: place this in CTXCompiler where it belongs when the spaghetti code is gone
    ## changing working directory to .ctx/obj/[BUILDCONFIGNAME]
    dest_wd = os.path.join(obj_dir, bc.getTitle())
    try:
        os.makedirs(dest_wd)
    except:
        pass
    old_path = os.path.abspath('')
    os.chdir(dest_wd)
 
    # Process components
    if component_build:
        infoMessage("Building components...",  1)
        components = create_components( items, cview.getItemPaths('comp'), obj_dir, launch_path )

        allmods = set()
        for comp in components:
            for library, modules in comp.libraries.items():
                mods = expand_list_files( cview, modules )
                depmgr.addCodeModules( mods, args.tests )
                allmods |= set(modules)

        depMods = depmgr.getModuleDependencies(allmods)
        depmgr.emptyCodeModules()
        if len(depMods - set(allmods))  > 0:
            for module in depMods - set(allmods):
                warningMessage('The module \"'+module+'\" was not specified to be built in any specified .comp file, but at least one of its headers were included in another module, linker errors may arise')

        for comp in components:
            ctx_log.ctxlogBeginComponent( comp.name )

            # Build component modules.
            for library, modules in comp.libraries.items():
                modules = expand_list_files( cview, modules )
                depmgr.addCodeModules( modules, args.tests )
                args.library_name = library
                infoMessage('args: %s'%args,  6)
                objs += buildmodules( depmgr, session,  modules,  args, bin_dir, session.bc.getTitle(),  args.library_name)

                if (args.all_headers):
                    header_path = os.path.join(lib_output, args.headerdir )
                    export_public_module_headers( depmgr, modules, header_path )

                depmgr.emptyCodeModules()
            export_headers( depmgr, comp.publicHeaders, header_dir, cview )
            ctx_log.ctxlogEndComponent()

    #Process modules
    else:
        infoMessage("Building modules...",  1)
        depmgr.addCodeModules( items, args.tests )

        if args.deps:
            print >>sys.stderr, "Dependencies for:",
            print >>sys.stderr, items
            print >>sys.stderr, depmgr.getCodeModulesWithDependencies()
        objs += buildmodules( depmgr, session, items, args, outputPath, bc.getTitle(),  libraryName=args.library_name)
        export_public_module_headers( depmgr, items, header_dir )

    if args.executable_name:
            session.linkExecutable(objs, bin_dir, args.executable_name)

    # Write log if requested
    if args.logfile != None:
        logfilepath = os.path.join( lib_output, args.logfile )
        logpath     = os.path.normpath(os.path.dirname( logfilepath ))
        if len(logpath) and not os.path.isdir(logpath):
            os.makedirs( logpath )

        ctx_log.ctxlogWriteToFile( logfilepath, appendToExisting=False )

    os.chdir(old_path)

    # Restore environment
    if args.env != None:
        switchEnvironment( oldEnv, False )
Ejemplo n.º 9
0
def cmd_buildcomp(args):
    launch_path = os.path.abspath('.')
    view_dir = get_view_dir(args.view)
    obj_dir = view_dir + os.sep + '.ctx/obj'
    if args.output[0] == '/' or args.output[0] == '\\' or args.output[1:3] == ':\\':
        lib_output = args.output
    else:
        # relative to view root
        lib_output = os.path.join(view_dir,args.output)

    from contexo import ctx_cmod
    from contexo import ctx_base
    from contexo import ctx_envswitch
    from contexo.ctx_depmgr import CTXDepMgr
    absIncDirs = map(os.path.abspath,  args.incdirs)

    # Switch to specified environment
    oldEnv = None
    if args.env != None:
        envLayout = EnvironmentLayout( cfgFile,  args.env )
        oldEnv    = switchEnvironment( envLayout, True )

    if args.logfile != None:
        ctx_log.ctxlogStart()

    # Prepare all
    deprecated_nra_warning( args )
    deprecated_repo_validation_warning(args)
    cview       = ctx_view.CTXView( view_dir, validate=False )
    components  = expand_list_files( cview, args.components )

    bc          = getBuildConfiguration( cview,  args )
    bc.buildParams.incPaths.extend(     absIncDirs ) #TODO: accessing 'private' data?
    deprecated_tolerate_missing_headers_warning(args)
    depmgr = CTXDepMgr ( codeModulePaths = cview.getItemPaths('modules'), failOnMissingHeaders = args.fail_on_missing_headers, archPath = bc.getArchPath(), legacyCompilingMod = args.legacy_compiling_mod, legacyDuplicateSources = args.legacy_duplicate_sources, globalOutputDir = obj_dir, bc = bc  )
    session     = ctx_base.CTXBuildSession( bc )
    session.setDependencyManager( depmgr )

    # Register build configuration in log handler
    ctx_log.ctxlogSetBuildConfig( bc.getTitle(),
                                  bc.getCompiler().cdefTitle,
                                  bc.getBuildParams().cflags,
                                  bc.getBuildParams().prepDefines,
                                  "N/A" )
    ## TODO: place this in CTXCompiler where it belongs when the spaghetti code is gone
    ## changing working directory to .ctx/obj/[BUILDCONFIGNAME]
    dest_wd = os.path.join(obj_dir, bc.getTitle())
    try:
        os.makedirs(dest_wd)
    except:
        pass
    old_path = os.path.abspath('')
    os.chdir(dest_wd)

    deleteModuleSources = set()
 
    # Process components
    components = create_components( components, cview.getItemPaths('comp'), obj_dir, launch_path )
    infoMessage("Building components...", 1)
    allmods = set()
    for comp in components:
        for library, modules in comp.libraries.items():
            mods = expand_list_files( cview, modules )
            depmgr.addCodeModules( mods, args.tests )
            allmods |= set(modules)

    depMods = depmgr.getModuleDependencies(allmods)
    depmgr.emptyCodeModules()
    if len(depMods - set(allmods))  > 0:
        for module in depMods - set(allmods):
            warningMessage('The module \"'+module+'\" was not specified to be built in any specified .comp file, but at least one of its headers were included in another module, linker errors may arise')

    for comp in components:
        ctx_log.ctxlogBeginComponent( comp.name )

        lib_dir = os.path.join( lib_output, args.libdir )
        header_dir = os.path.join( lib_output, args.headerdir )

        # Build component modules.
        for library, modules in comp.libraries.items():
            modules = expand_list_files( cview, modules )

            depmgr.addCodeModules( modules, args.tests )

            args.lib = library
            infoMessage('args: %s'%args,  6)
            buildmodules( depmgr, session,  modules,  args, lib_dir, session.bc.getTitle(),  libraryName = args.lib)
            if args.deletesources == True:
                for module in modules:
                    modPath = depmgr.resolveCodeModulePath(module)
                    deleteModuleSources.add(modPath)

            depmgr.emptyCodeModules()

        export_headers( depmgr, comp.publicHeaders, header_dir, cview )

        ctx_log.ctxlogEndComponent()

    # Write log if requested
    if args.logfile != None:
        logfilepath = os.path.join( lib_output, args.logfile )
        logpath     = os.path.normpath(os.path.dirname( logfilepath ))
        if len(logpath) and not os.path.isdir(logpath):
            os.makedirs( logpath )

        ctx_log.ctxlogWriteToFile( logfilepath, appendToExisting=False )
    os.chdir(old_path)

    # Restore environment
    if args.env != None:
        switchEnvironment( oldEnv, False )

    if args.deletesources == True:
        modPath = depmgr.resolveCodeModulePath(module)
        for modpath in deleteModuleSources:
            try:
                srcdir = os.path.join(modpath, 'src')
                shutil.rmtree(srcdir)
                infoMessage("Removing source directory: " + srcdir, 1)
            except:
                pass
            try:
                incdir = os.path.join(modpath, 'inc')
                shutil.rmtree(incdir)
                infoMessage("Removing private include directory: " + incdir, 1)
            except:
                pass
            try:
                testdir = os.path.join(modpath, 'test')
                shutil.rmtree(testdir)
                infoMessage("Removing test source directory: " + testdir, 1)
            except:
                pass
Ejemplo n.º 10
0
def cmd_buildmod(args):
    launch_path = os.path.abspath('.')
    view_dir = get_view_dir(args.view)
    obj_dir = view_dir + os.sep + '.ctx/obj'
    if args.output[0] != '/' and args.output[0] != '\\' and args.output[1:3] != ':\\':
        lib_output = args.output
    else:
        # relative to view root
        lib_output = os.path.join( view_dir, args.output)

    from contexo import ctx_cmod
    from contexo import ctx_base
    from contexo import ctx_envswitch
    from contexo.ctx_depmgr import CTXDepMgr

    # Switch to specified environment
    oldEnv = None
    if args.env != None:
        envLayout   = EnvironmentLayout( cfgFile,  args.env )
        oldEnv      = switchEnvironment( envLayout, True )

    if args.logfile != None:
        ctx_log.ctxlogStart()

    # Prepare all
    deprecated_nra_warning( args )
    deprecated_repo_validation_warning(args)
    cview   = ctx_view.CTXView( view_dir, validate=False )
    modules = expand_list_files(cview, args.modules)
    bc      = getBuildConfiguration( cview,  args )


    deprecated_tolerate_missing_headers_warning(args)
    depmgr = CTXDepMgr ( codeModulePaths = cview.getItemPaths('modules'), failOnMissingHeaders = args.fail_on_missing_headers, archPath = bc.getArchPath(), legacyCompilingMod = args.legacy_compiling_mod, legacyDuplicateSources = args.legacy_duplicate_sources, globalOutputDir = obj_dir, bc = bc )

    depmgr.addCodeModules( modules, args.tests )

    session = ctx_base.CTXBuildSession( bc )

    session.setDependencyManager( depmgr )



    # Register build configuration in log handler
    ctx_log.ctxlogSetBuildConfig( bc.getTitle(),
                                  bc.getCompiler().cdefTitle,
                                  bc.getBuildParams().cflags,
                                  bc.getBuildParams().prepDefines,
                                  "N/A" )

    output_path = os.path.join( lib_output, args.libdir )
    print >>sys.stderr, output_path

    ## TODO: place this in CTXCompiler where it belongs when the spaghetti code is gone
    ## changing working directory to .ctx/obj/[BUILDCONFIGNAME]
    dest_wd = os.path.join(obj_dir, bc.getTitle())
    try:
        os.makedirs(dest_wd)
    except:
        pass
    old_path = os.path.abspath('')
    os.chdir(dest_wd)
    buildmodules( depmgr, session, modules, args, output_path, bc.getTitle(),  libraryName = args.lib)
    old_path = os.path.abspath('')

    header_path = os.path.join(lib_output, args.headerdir )
    export_public_module_headers( depmgr, modules, header_path )


    # Write log if requested
    if args.logfile != None:
        logfilepath = os.path.join( lib_output, args.logfile )
        logpath     = os.path.normpath(os.path.dirname( logfilepath ))
        if len(logpath) and not os.path.isdir(logpath):
            os.makedirs( logpath )

        ctx_log.ctxlogWriteToFile( logfilepath, appendToExisting=False )

    # Switch back to original environment
    if args.env != None:
        switchEnvironment( oldEnv, False )