python - How to specify standard input file for SCons -


i have c program "add.c", input file "input.txt". wish compile program using scons , store standard output file called "output.txt". how achieve using scons build utility? how can make python script work?

compute(input_source_code,input_file_for_input_source_code) {//generate output file} 

i read documentation scons , talks multiple input source files, not able understand how specify inputs(stdin) compiled source files.

to clarify further - trying build online assignment grader using python/django. wish accomplish specific task is: compile given c programs - feed c programs predefined input, store outputs generated executing c program file. if understand correctly, scons allows me build/make c program file, how instruct scons fetch input specific file specific c program. c program trying build via scons should fetch input specific file.

compile c/c++ program , store standard output in file via python 1 of answers here sam noir addresses query works in mac/linux not work in windows - why i'm trying use scons build utility accomplish task.

just thought add example:

c file (add.c)

#include <stdio.h> int main() { int a,b; scanf("%d", &a); scanf("%d", &b); printf("%d", a+b); return 0; } 

input.txt:

3 7 

python script:

build(add.c - fetch required input input.txt) ,  store output file output.txt  

(so should printing 10 in output.txt).

so want use scons build , run file add.c , generate output.txt ensuring whatever input required add.c fetched input.txt.

for given example try like:

env = environment() # build program , store reference prog = env.program("cl_add", "add.c") # create command run, relies on shell redirection out = env.command('output.txt','input.txt','%s < $source > $target' % str(prog[0])) # let command depend on program created above env.depends(out, prog) 

in sconstruct. see userguide @ http://scons.org/doc/production/html/scons-user.html , chap. 19. "not writing builder: command builder".


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -