c++ - Scons: how to check file before compilation with commands which doesn't product any output file? -


i work project in every object files being built 3 times:

  1. with newest g++ lots of flags in order find every possible errors , warnings
  2. with clang in order above , check style.
  3. with g++ compatible 3rdpart libraries (no newer version, entire product based of libraries) works way: if object file should recompiled: steps 1, if success 2, if success 3 being done. done makefile, i'm planning use scons its. problem in current solution object file 1 , 2 being saved /dev/null.

i've tried line this: 3 files in same directory: hello.cc, sconstruct, sconscript

sconstruct

#!python  warningflags = ' -wall -wextra -werror' # , many more  env = environment(cxx = 'g++-4.8', parse_flags = warningflags, cpppath = '.')  builtobjects = env.sconscript('sconscript', variant_dir='built', duplicate=0, exports='env')  env.program(target = 'hello', source = builtobjects) 

sconscript

#!python  import('env')  builtobjects = env.object(source = 'hello.cc') checkwithclang = env.command('/dev/null', builtobjects, 'clang -o $target -wall -werror') env.depends(checkwithclang, builtobjects)  return('builtobjects') 

the output scons is:

scons: reading sconscript files ... scons: done reading sconscript files. scons: building targets ... scons: building associated variantdir targets: built g++-4.8 -o built/hello.o -c -wall -wextra -werror -ibuilt -i. hello.cc g++-4.8 -o hello built/hello.o scons: done building targets. 

edit: possible somehow check in scons: if object file should rebuilt? pseudo code:

src = 'hello.cc' if shouldobjectfileberebuilt(src):     checkwithclang = env.command('/dev/null', builtobjects, 'clang -o $target -wall -werror')     builtobjects = env.object(source = src)     env.depends(checkwithclang, builtobjects) 

try

src = "hello.cc" builtobjects = env.object(source = src) checkwithclang = env.command('/dev/null', src, 'clang -o $target -wall -werror') env.depends(builtobjects, checkwithclang) 
  1. buildobjects represent '.o' files, should put '.c' files clang
  2. you want buildobjects built after clang objects - change order

still - building /dev/null break dependency tree, might consider like:

checkwithclang = env.object(source = src, cc="clang", objprefix="clang-") 

this build .c files clang , store .o files, allowing scons rebuild necessarry


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -