From 91a4e0e80d7a431d1683dc18414be3256e171b2a Mon Sep 17 00:00:00 2001 From: stevenknight Date: Fri, 12 Oct 2001 22:20:00 +0000 Subject: [PATCH] Add LINKFLAGS support. git-svn-id: http://scons.tigris.org/svn/scons/trunk@98 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Defaults.py | 4 +++- test/LINK.py | 42 ++++++++++++++++++++++++++++++++++-- test/LINKFLAGS.py | 42 ++++++++++++++++++++++++++++++++++-- 3 files changed, 83 insertions(+), 5 deletions(-) diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index af08fc28..eeaa02a8 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -43,7 +43,7 @@ Object = SCons.Builder.Builder(name = 'Object', 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', @@ -55,6 +55,8 @@ 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' }, } diff --git a/test/LINK.py b/test/LINK.py index dec523df..f2ac661d 100644 --- a/test/LINK.py +++ b/test/LINK.py @@ -24,15 +24,53 @@ __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() diff --git a/test/LINKFLAGS.py b/test/LINKFLAGS.py index dec523df..06c14823 100644 --- a/test/LINKFLAGS.py +++ b/test/LINKFLAGS.py @@ -24,15 +24,53 @@ __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() -- 2.26.2