Search code examples
c++pythonmingwwxwidgetsscons

scons ParseConfig behaving incorrectly with wx-config on windows


I am trying to use wx-widgets with scons on Windows using MinGW. This is the offending line of my SConstruct:

env.ParseConfig("wx-config --cxxflags --libs")

Immediately after this, printing env['CPPPATH'] gives:

['C:software_libwxWidgets2.8libgcc_dllmsw', 'C:software_libwxWidgets2.8include']

which, obviously, appears to be missing some very important slashes. I think it might have something to do with wx-config's windows port giving backslashes in its output.

These paths get passed verbatim to the compiler later, leading to errors. Everything else works great.

What can I do to resolve this issue?


Solution

  • Solved the problem with brute force. Wrote a helper python script consisting of the following:

    import subprocess, sys
    
    p = subprocess.Popen(["wx-config", "--cxxflags", "--libs"], stdout=subprocess.PIPE)
    out, err = p.communicate()
    
    san = out.replace("\\", "/")
    
    sys.stdout.write(san)
    sys.exit(0)
    

    And ended up calling

    env.ParseConfig("python sanitize-wx-config.py")
    

    in the SConscript file. This solved the problem: