Add -I support.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 11 Sep 2001 17:04:00 +0000 (17:04 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 11 Sep 2001 17:04:00 +0000 (17:04 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@43 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/scons.py
test/option--I.py

index 500910d759243c6bd31a1762f15da701a059aa5b..f515beaf56e511ffed7136cc45cf426ec96f5057 100644 (file)
@@ -59,6 +59,7 @@ class Taskmaster:
 local_help = None
 num_jobs = 1
 Scripts = []
+include_dirs = []
 
 # utility functions
 
@@ -315,7 +316,11 @@ def options_init():
        short = 'i', long = ['ignore-errors'],
        help = "Ignore errors from build actions.")
 
-    Option(func = opt_not_yet,
+    def opt_I(opt, arg):
+       global include_dirs
+       include_dirs = include_dirs + [arg]
+
+    Option(func = opt_I,
        short = 'I', long = ['include-dir'], arg = 'DIRECTORY',
        help = "Search DIRECTORY for imported Python modules.")
 
@@ -504,6 +509,8 @@ def main():
     #
     #sys.path = dirlist
 
+    sys.path = include_dirs + sys.path
+
     # initialize node factory
     init()
 
index f205a76b4a6dcf5e9cb794549b046c9341b13d9b..80de4678f5e533f9ef763495b4a0c8a904090d7e 100644 (file)
@@ -10,17 +10,36 @@ test = TestCmd.TestCmd(program = 'scons.py',
                        workdir = '',
                        interpreter = 'python')
 
-test.write('SConstruct', "")
+test.subdir('sub1', 'sub2')
 
-test.run(chdir = '.', arguments = '-I foo')
+test.write(['sub1', 'foo.py'], """
+variable = "sub1/foo"
+""")
 
-test.fail_test(test.stderr() !=
-               "Warning:  the -I option is not yet implemented\n")
+test.write(['sub2', 'foo.py'], """
+variable = "sub2/foo"
+""")
 
-test.run(chdir = '.', arguments = '--include-dir=foo')
+test.write(['sub2', 'bar.py'], """
+variable = "sub2/bar"
+""")
 
-test.fail_test(test.stderr() !=
-               "Warning:  the --include-dir option is not yet implemented\n")
+test.write('SConstruct', """
+import foo
+print foo.variable
+import bar
+print bar.variable
+""")
+
+test.run(chdir = '.', arguments = '-I sub1 -I sub2')
+
+test.fail_test(test.stdout() != "sub1/foo\nsub2/bar\n")
+test.fail_test(test.stderr() != "")
+
+test.run(chdir = '.', arguments = '--include-dir=sub2 --include-dir=sub1')
+
+test.fail_test(test.stdout() != "sub2/foo\nsub2/bar\n")
+test.fail_test(test.stderr() != "")
 
 test.pass_test()