Search code examples
xcodescons

Skip build altogether but generate platform dependant sources in SCons


I have a project that uses SCons to generate platform dependent source files which are compiled together with other shipped source files into static libraries and linked into the final executable, and that's it, no project files are generated for my IDE (Xcode)

I managed to add SCons as an external build system in a new Xcode project to build and debug the executable

What I want now is to customize the source code and add a few libraries removing Scons altogether as external build system. Scons is not practical in my case, too slow, and I don't want to mess with the scripts.

So the question is whether there is a feature in SCons to skip the build process but just generate the platform dependent source files?

Edit:

I would like to make some customizations to the project and not mess with SCons at least until I need to do pull requests, that was my workfow with a previous project that used CMake to generate the Xcode project, SCons would require to modify the scripts.


Solution

  • Overriding Export() in SConstruct like the the code from below and adding the parameter skip_build to the script, which sets the value of __SkipBuild, I was able to skip the build process altogether (i.e. compiling and linking), generating only the platform dependent sources

    SConstruct

    __Export = Export
    __CommandsList = ['CC','CXX','AR','RANLIB','AS','LINK'] # The commands to skip from the build process
    __SkipBuild = False
    
    def Export(*vars, **kw):
        for var in vars:
            locals()[var] = call_stack[-1].globals[var]
            if (call_stack[-1].globals['__SkipBuild']):
                for command in __CommandsList:
                    if locals()[var].has_key(command):
                        locals()[var][command] = 'echo ' + locals()[var][command]
        call_stack[-1].globals.update(kw)
        __Export(locals(), kw)