C/C++: I there a way to use Gradle to drive SCons?

Currently, I have a Makefile whose targets drive SCons commands. Although I am slowly converting to Gradle, I can’t just get rid of SCons because Gradle currently does not handle parallel builds for native code. So, is there a recommended way and/or best practice way and/or example showing how I can use Gradle to call SCons?


        scons --jobs=8 -f SConstruct_FileServer --deploydir=$(PKGDESTDIR) $(FILESERVER_ARGS);
  hoststats: fileclient
        scons --jobs=8 -f SConstruct_Hoststats --hadoopdir=$(HADOOP_DIR) --deploydir=$(PKGDESTDIR) $(FILESERVER_ARGS);
        scons --jobs=8 -f SConstruct_Hoststats --hadoopdir=$(HADOOP_DIR) --deploydir=$(PKGDESTDIR) $(FILESERVER_ARGS) ;
  oozieexecute-cc = cd fs/.. &&\
        scons --jobs=8 -f SConstruct_OozieExecute --hadoopdir=$(HADOOP_DIR) --deploydir=$(PKGDESTDIR) $(FILECLIENT_ARGS) ;

Yes, I know it’s a mess. Yes, I’m trying to fix it.

You’d have to use an ‘Exec’ task. (See ‘Exec’ in the Gradle Build Language Reference.)

Is the lack of parallel compile the only thing preventing you from switching away from SCons? We expect to have this feature implemented fairly soon.

Note that in a multi-project build scenario, running with ‘–parallel’ can provide a fair amount of parallelization, even without parallel compilation of C/C++ sources.

Yes, but this is one of many reason why we haven’t switched from SCons. I am one person trying to convert our steaming pile of technology to Gradle. Benjamin Muschko knows of my C/C++ woes.