Exemple #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 )
Exemple #2
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 )
Exemple #3
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
Exemple #4
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 )