From 2fbaeb2f6fd97eff1af290de7a043d11e7bd0ed5 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Thu, 20 Sep 2001 12:51:39 +0000 Subject: [PATCH] Add support for Default() targets. git-svn-id: http://scons.tigris.org/svn/scons/trunk@57 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/script/scons.py | 9 ++++++ test/Default.py | 67 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 test/Default.py diff --git a/src/script/scons.py b/src/script/scons.py index 8736787c..9dc41e65 100644 --- a/src/script/scons.py +++ b/src/script/scons.py @@ -61,6 +61,7 @@ class Taskmaster: # Global variables +default_targets = [] local_help = None num_jobs = 1 Scripts = [] @@ -104,6 +105,11 @@ def Conscript(filename): global Scripts Scripts.append(filename) +def Default(*targets): + for t in targets: + for s in string.split(t): + default_targets.append(s) + def Help(text): global local_help if local_help: @@ -534,6 +540,9 @@ def main(): PrintUsage() sys.exit(0) + if not targets: + targets = default_targets + taskmaster = Taskmaster(map( lambda x: SCons.Node.FS.default_fs.File(x), targets)) diff --git a/test/Default.py b/test/Default.py new file mode 100644 index 00000000..0666a770 --- /dev/null +++ b/test/Default.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('one', 'two', 'three') + +test.write(['one', 'SConstruct'], """ +env = Environment() +env.Program(target = 'foo', source = 'foo.c') +env.Program(target = 'bar', source = 'bar.c') +Default('foo') +""") + +test.write(['two', 'SConstruct'], """ +env = Environment() +env.Program(target = 'foo', source = 'foo.c') +env.Program(target = 'bar', source = 'bar.c') +Default('foo', 'bar') +""") + +test.write(['three', 'SConstruct'], """ +env = Environment() +env.Program(target = 'foo', source = 'foo.c') +env.Program(target = 'bar', source = 'bar.c') +Default('foo bar') +""") + +for dir in ['one', 'two', 'three']: + + foo_c = os.path.join(dir, 'foo.c') + bar_c = os.path.join(dir, 'bar.c') + + test.write(foo_c, """ +int +main(int argc, char *argv[]) +{ + printf("%s\n"); + exit (0); +} +""" % foo_c) + + test.write(bar_c, """ +int +main(int argc, char *argv[]) +{ + printf("%s\n"); + exit (0); +} +""" % bar_c) + + test.run(chdir = dir) # no arguments, use the Default + +test.run(program = test.workpath('one', 'foo'), stdout = "one/foo.c\n") +test.fail_test(os.path.exists(test.workpath('one', 'bar'))) + +test.run(program = test.workpath('two', 'foo'), stdout = "two/foo.c\n") +test.run(program = test.workpath('two', 'bar'), stdout = "two/bar.c\n") + +test.run(program = test.workpath('three', 'foo'), stdout = "three/foo.c\n") +test.run(program = test.workpath('three', 'bar'), stdout = "three/bar.c\n") + +test.pass_test() -- 2.26.2