-1

How would a 'SConstruct' file in Scons look like that does what the following code does in GNU Make?

target: dependency0 dependency1
     shell command 1  # Not java, cc or the like
     shell command 2
     shell command 3
Frank-Rene Schäfer
  • 3,182
  • 27
  • 51
  • How much of your homework have you done? Have you read through the tutorial? The man page? I think much of what you're wondering is addressed there... – skyking Apr 27 '17 at 11:44
  • This is difficult to answer without a more concrete example. If it's not java, or C/C++, what is it? Depending on the type of build, a different approach might be required... – dirkbaechle Apr 27 '17 at 11:50
  • @skyking: I need to write a small example build system in Scons--among others--and wanted to spare some hours googling for the answer. This should not be considered unethical. If you know the answer, why are you not willing to get the 25 reputation points straight away? – Frank-Rene Schäfer Apr 27 '17 at 14:11
  • Related: http://stackoverflow.com/questions/43633442/convert-makefile-content-to-appache-ant – dirkbaechle Apr 27 '17 at 16:02
  • @Frank-ReneSchäfer I don't say it's unethical to ask stackoverflow instead of google. What I wanted to check is how much of the official documentation you've read, I would at least think that the "User Guide" (http://scons.org/doc/production/HTML/scons-user/index.html) is mandatory, but also the manpage (http://scons.org/doc/production/HTML/scons-man.html) is a good resource. I think especially the "User Guide" since it contains things one ought to know about SCons, I think it also contains the information. – skyking Apr 28 '17 at 05:02

1 Answers1

1

I suggest that you at least read the User Guide. It contains an introduction to SCons, things that every writer of SCons-scripts need to know.

Especially there's the Command builder that allows you to write rules that have specified prerequisites, target and action. The action itself can be a shell command. What it doesn't say perhaps is that you can provide a list of actions which means that they are executed in sequence (just like make does). That brings us to the SCons equivalent:

Command("target", ["dependency0", "dependency1"], [
       "shell command 1",
       "shell command 2",
       "shell command 3",
       ])

There is also special variables that can be used to expand the target and sources of the command, but that is explained in the user guide (and in more detail in the man page).

skyking
  • 13,817
  • 1
  • 35
  • 57
  • Thanks you saved me a lot of time! While SCons seems to be a great build system, at that point in time I was not intending to dive deeper into it. I just had to provide a small demo of how to use SCons with the HWUT Unit Test framework. – Frank-Rene Schäfer Apr 28 '17 at 08:02