Пример #1
0
    def test_local_options(self):
        env = make_env('winnt', clear_variables=True,
                       variables={'CXX': 'nonexist'})
        build, context = self._make_context(env)
        with mock.patch('bfg9000.tools.c_family._builders', (MsvcBuilder,)), \
             mock.patch('logging.log'):
            context['global_options'](opts.debug(), lang='c++')
            src = context['source_file']('main.cpp')
            result = context['object_file'](file=src, options=[opts.static()])

        ninjafile = ninja.NinjaFile(None)
        with mock.patch.object(ninja.NinjaFile, 'build') as mbuild, \
             mock.patch.object(ninja.NinjaFile, 'variable',
                               wraps=ninjafile.variable) as mvar:
            compile.ninja_compile(result.creator, build, ninjafile, env)
            mbuild.assert_called_once_with(
                output=[result], rule='cxx', inputs=[src], implicit=[],
                variables={ninja.var('cxxflags'): [
                    ninja.var('global_cxxflags'), '/MTd'
                ]},
            )
            mvar.assert_any_call('global_cxxflags', ['/Zi'],
                                 ninja.Section.flags, True)
Пример #2
0
 def _variables(self, lang='c++'):
     linker = self.env.builder(lang).linker('executable')
     libs = linker.lib_flags(linker.always_libs(True))
     if libs:
         return {ninja.var('ldlibs'): [ninja.var('global_ldlibs')] + libs}
     return {}