Commits

Anonymous committed a216862

Add LINKFLAGS support.

  • Participants
  • Parent commits 94009f3

Comments (0)

Files changed (3)

File src/engine/SCons/Defaults.py

                                suffix='.o')
 
 Program = SCons.Builder.Builder(name = 'Program',
-                                action = '$CC -o $target $sources',
+                                action = '$LINK $LINKFLAGS -o $target $sources',
                                 builders = [ Object ])
 
 Library = SCons.Builder.Builder(name = 'Library',
 ConstructionEnvironment = {
 	'CC' : 'cc',
 	'CCFLAGS' : '',
+	'LINK' : '$CC',
+	'LINKFLAGS' : '',
 	'BUILDERS' : [Object, Program, Library],
 	'ENV' : { 'PATH' : '/usr/local/bin:/bin:/usr/bin' },
 }

File test/LINK.py

 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+import os
 import TestSCons
 
 test = TestSCons.TestSCons()
 
-test.pass_test()	#XXX Short-circuit until this is implemented.
+test.write("ccwrapper.py",
+"""import os
+import string
+import sys
+open('%s', 'w').write("ccwrapper.py\\n")
+os.system(string.join(["cc"] + sys.argv[1:], " "))
+""" % test.workpath('ccwrapper.out'))
 
 test.write('SConstruct', """
+foo = Environment()
+bar = Environment(LINK = 'python ccwrapper.py')
+foo.Program(target = 'foo', source = 'foo.c')
+bar.Program(target = 'bar', source = 'bar.c')
 """)
 
-test.run(arguments = '.')
+test.write('foo.c', """
+int
+main(int argc, char *argv[])
+{
+	argv[argc++] = "--";
+	printf("foo.c\n");
+	exit (0);
+}
+""")
+
+test.write('bar.c', """
+int
+main(int argc, char *argv[])
+{
+	argv[argc++] = "--";
+	printf("foo.c\n");
+	exit (0);
+}
+""")
+
+
+test.run(arguments = 'foo')
+
+test.fail_test(os.path.exists(test.workpath('ccwrapper.out')))
+
+test.run(arguments = 'bar')
+
+test.fail_test(test.read('ccwrapper.out') != "ccwrapper.py\n")
 
 test.pass_test()

File test/LINKFLAGS.py

 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+import os
 import TestSCons
 
 test = TestSCons.TestSCons()
 
-test.pass_test()	#XXX Short-circuit until this is implemented.
+test.write("ccwrapper.py",
+"""import os
+import string
+import sys
+open('%s', 'w').write("ccwrapper.py\\n")
+os.system(string.join(["cc"] + sys.argv[1:], " "))
+""" % test.workpath('ccwrapper.out'))
 
 test.write('SConstruct', """
+foo = Environment()
+bar = Environment(LINK = '', LINKFLAGS = 'python ccwrapper.py')
+foo.Program(target = 'foo', source = 'foo.c')
+bar.Program(target = 'bar', source = 'bar.c')
 """)
 
-test.run(arguments = '.')
+test.write('foo.c', """
+int
+main(int argc, char *argv[])
+{
+	argv[argc++] = "--";
+	printf("foo.c\n");
+	exit (0);
+}
+""")
+
+test.write('bar.c', """
+int
+main(int argc, char *argv[])
+{
+	argv[argc++] = "--";
+	printf("foo.c\n");
+	exit (0);
+}
+""")
+
+
+test.run(arguments = 'foo')
+
+test.fail_test(os.path.exists(test.workpath('ccwrapper.out')))
+
+test.run(arguments = 'bar')
+
+test.fail_test(test.read('ccwrapper.out') != "ccwrapper.py\n")
 
 test.pass_test()