5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 from TestCmd
import IS_WINDOWS
, IS_MACOS
30 from TestSCons
import _exe
, _lib
, lib_
, _dll
, dll_
32 test
= TestSCons
.TestSCons()
37 test
.skip_test("Could not find ninja module. Skipping test.\n")
39 ninja_bin
= os
.path
.abspath(os
.path
.join(
46 test
.dir_fixture('ninja-fixture')
48 win32
= ", 'WIN32'" if IS_WINDOWS
else ""
50 test
.write('SConstruct', """
51 SetOption('experimental', 'ninja')
52 DefaultEnvironment(tools=[])
55 env['NINJA'] = r"%(ninja_bin)s"
57 shared_lib = env.SharedLibrary(target='test_impl', source='test_impl.c', CPPDEFINES=['LIBRARY_BUILD'%(win32)s])
58 env.Program(target='test', source='test1.c', LIBS=['test_impl'], LIBPATH=['.'], RPATH='.')
59 static_obj = env.Object(target='test_impl_static', source='test_impl.c')
60 static_lib = env.StaticLibrary(target='test_impl_static', source=static_obj)
61 static_obj = env.Object(target='test_static', source='test1.c')
62 env.Program(target='test_static', source=static_obj, LIBS=[static_lib], LIBPATH=['.'])
65 # generate simple build
67 test
.must_contain_all_lines(test
.stdout(), ['Generating: build.ninja'])
68 test
.must_contain_all(test
.stdout(), 'Executing:')
69 test
.must_contain_all(test
.stdout(), 'ninja%(_exe)s -f' % locals())
70 test
.run(program
=test
.workpath('test'), stdout
="library_function")
71 test
.run(program
=test
.workpath('test_static'), stdout
="library_function")
73 # clean build and ninja files
74 test
.run(arguments
='-c', stdout
=None)
75 test
.must_contain_all_lines(
78 ('Removed %stest_impl' % dll_
) + _dll
,
79 'Removed test' + _exe
,
80 ('Removed %stest_impl_static' % lib_
) + _lib
,
81 'Removed test_static' + _exe
,
82 'Removed build.ninja',
86 # only generate the ninja file
87 test
.run(arguments
='--disable-execute-ninja', stdout
=None)
88 test
.must_contain_all_lines(test
.stdout(), ['Generating: build.ninja'])
89 test
.must_not_exist(test
.workpath('test'))
90 test
.must_not_exist(test
.workpath('test_static'))
92 # run ninja independently
93 program
= test
.workpath('run_ninja_env.bat') if IS_WINDOWS
else ninja_bin
94 test
.run(program
=program
, stdout
=None)
95 test
.run(program
=test
.workpath('test'), stdout
="library_function")
96 test
.run(program
=test
.workpath('test_static'), stdout
="library_function")
102 # indent-tabs-mode:nil
104 # vim: set expandtab tabstop=4 shiftwidth=4: