import TestSCons _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe test.file_fixture('mylink.py') test.file_fixture(['fixture', 'myas_args.py']) o = ' -x' o_c = ' -x -c' if sys.platform == 'win32': import SCons.Tool.MSCommon as msc if msc.msvc_exists(): o_c = ' -x' test.write( 'SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], ASPP = r'%(_python_)s myas_args.py', ASPPFLAGS = '-x', CC = r'%(_python_)s myas_args.py') env.Program(target = 'test1', source = 'test1.spp') env.Program(target = 'test2', source = 'test2.SPP') """ % locals()) test.write('test1.spp', r"""This is a .spp file. #as #link
import TestSCons _python_ = TestSCons._python_ test = TestSCons.TestSCons() _exe = TestSCons._exe test.file_fixture('mylink.py') test.file_fixture(os.path.join('fixture', 'myas_args.py')) o = ' -x' o_c = ' -x -c' if sys.platform == 'win32': import SCons.Tool.MSCommon as msc if msc.msvc_exists(): o_c = ' -x' test.write('SConstruct', """ env = Environment(LINK = r'%(_python_)s mylink.py', LINKFLAGS = [], ASPP = r'%(_python_)s myas_args.py', ASPPFLAGS = '-x', CC = r'%(_python_)s myas_args.py') env.Program(target = 'test1', source = 'test1.spp') env.Program(target = 'test2', source = 'test2.SPP') """ % locals()) test.write('test1.spp', r"""This is a .spp file. #as #link """)
print(env.subst('$CXXCOM')) print(env.subst('$CXXCOMSTR')) print(env.subst('$SHCXXCOM')) print(env.subst('$SHCXXCOMSTR')) """) test.run(arguments = '.') test.must_not_contain_any_line(test.stdout(), ["-xyz"]) test.must_contain_all_lines(test.stdout(), ["-abc"]) _obj = TestSCons._obj # Test passing CFLAGS to C compiler by actually compiling programs if sys.platform == 'win32': import SCons.Tool.MSCommon as msc if not msc.msvc_exists(): fooflags = '-DFOO' barflags = '-DBAR' else: fooflags = '/nologo -DFOO' barflags = '/nologo -DBAR' else: fooflags = '-DFOO' barflags = '-DBAR' test.write('SConstruct', """ foo = Environment(CFLAGS = '%s') bar = Environment(CFLAGS = '%s') foo.Object(target = 'foo%s', source = 'prog.c') bar.Object(target = 'bar%s', source = 'prog.c')
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # __revision__ = "test/Libs/LIBPREFIXES.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog" import os import sys import TestSCons if sys.platform == 'win32': _lib = '.lib' import SCons.Tool.MSCommon as msc if not msc.msvc_exists(): _lib = '.a' else: _lib = '.a' test = TestSCons.TestSCons() test.write( 'SConstruct', """ env = Environment(LIBPREFIX = 'xxx-', LIBPREFIXES = ['xxx-']) lib = env.Library(target = 'foo', source = 'foo.c') env.Program(target = 'prog', source = ['prog.c', lib]) """) test.write(
Also make sure changing CPPPATH causes rebuild. """ import os import sys import TestSConsMSVS test = TestSConsMSVS.TestSConsMSVS() if sys.platform != 'win32': msg = "Skipping Visual Studio test on non-Windows platform '%s'\n" % sys.platform test.skip_test(msg) import SCons.Tool.MSCommon as msc if not msc.msvs_exists(): msg = "No MSVS toolchain found...skipping test\n" test.skip_test(msg) SConscript_contents = """\ env = Environment() sources = ['main.cpp'] program = env.Program(target = 'hello', source = sources) if ARGUMENTS.get('moreincludes'): env.AppendUnique(CPPPATH = [env.Dir('.'), env.Dir('myincludes')]) else: env.AppendUnique(CPPPATH = [env.Dir('.')])