Exemple #1
0
 def run_process(self, cmdlist):
     cmdlist = [shutil.which(environment.detect_ninja())] + cmdlist
     dialog = ProcessRunner(self.build.environment.build_dir, cmdlist)
     dialog.run()
     # All processes (at the moment) may change cache state
     # so reload.
     self.respawner.respawn()
Exemple #2
0
 def run_process(self, cmdlist):
     cmdlist = [shutil.which(environment.detect_ninja())] + cmdlist
     dialog = ProcessRunner(self.build.environment.build_dir, cmdlist)
     dialog.run()
     # All processes (at the moment) may change cache state
     # so reload.
     self.respawner.respawn()
Exemple #3
0
    def generate_ending(self, outfile):
        targetlist = [self.get_target_filename(t) for t in self.build.get_targets().values()\
                      if not isinstance(t, build.RunTarget)]

        elem = NinjaBuildElement('all', 'phony', targetlist)
        elem.write(outfile)

        default = 'default all\n\n'
        outfile.write(default)

        ninja_command = environment.detect_ninja()
        if ninja_command is None:
            raise RuntimeError('Could not detect ninja command')
        elem = NinjaBuildElement('clean', 'CUSTOM_COMMAND', '')
        elem.add_item('COMMAND', [ninja_command, '-t', 'clean'])
        elem.add_item('description', 'Cleaning')
        if self.environment.coredata.coverage:
            self.generate_gcov_clean(outfile)
            elem.add_dep('clean-gcda')
            elem.add_dep('clean-gcno')
        elem.write(outfile)

        deps = [os.path.join(self.build_to_src, df) \
                for df in self.interpreter.get_build_def_files()]
        if self.environment.is_cross_build():
            deps.append(os.path.join(self.build_to_src,
                                     self.environment.coredata.cross_file))
        deps.append('meson-private/coredata.dat')
        if os.path.exists(os.path.join(self.environment.get_source_dir(), 'meson_options.txt')):
            deps.append(os.path.join(self.build_to_src, 'meson_options.txt'))
        for sp in self.build.subprojects.keys():
            fname = os.path.join(self.environment.get_source_dir(), sp, 'meson_options.txt')
            if os.path.isfile(fname):
                deps.append(os.path.join(self.build_to_src, sp, 'meson_options.txt'))
        elem = NinjaBuildElement('build.ninja', 'REGENERATE_BUILD', deps)
        elem.write(outfile)

        elem = NinjaBuildElement(deps, 'phony', '')
        elem.write(outfile)
Exemple #4
0
def setup_commands(backend):
    global backend_flags, compile_commands, test_commands, install_commands
    msbuild_exe = shutil.which('msbuild')
    if backend == 'vs2010' or (backend is None and msbuild_exe is not None):
        backend_flags = ['--backend=vs2010']
        compile_commands = ['msbuild']
        test_commands = ['msbuild', 'RUN_TESTS.vcxproj']
        install_commands = []
    elif backend == 'xcode' or (backend is None and mesonlib.is_osx()):
        backend_flags = ['--backend=xcode']
        compile_commands = ['xcodebuild']
        test_commands = ['xcodebuild', '-target', 'RUN_TESTS']
        install_commands = []
    else:
        backend_flags = []
        ninja_command = environment.detect_ninja()
        if ninja_command is None:
            raise RuntimeError('Could not find Ninja executable.')
        if print_debug:
            compile_commands = [ninja_command, '-v']
        else:
            compile_commands = [ninja_command]
        test_commands = [ninja_command, 'test']
        install_commands = [ninja_command, 'install']
Exemple #5
0
def setup_commands(backend):
    global backend_flags, compile_commands, test_commands, install_commands
    msbuild_exe = shutil.which('msbuild')
    if backend == 'vs2010' or (backend is None and msbuild_exe is not None):
        backend_flags = ['--backend=vs2010']
        compile_commands = ['msbuild']
        test_commands = ['msbuild', 'RUN_TESTS.vcxproj']
        install_commands = []
    elif backend == 'xcode' or (backend is None and mesonlib.is_osx()):
        backend_flags = ['--backend=xcode']
        compile_commands = ['xcodebuild']
        test_commands = ['xcodebuild', '-target', 'RUN_TESTS']
        install_commands = []
    else:
        backend_flags = []
        ninja_command = environment.detect_ninja()
        if ninja_command is None:
            raise RuntimeError('Could not find Ninja executable.')
        if print_debug:
            compile_commands = [ninja_command, '-v']
        else:
            compile_commands = [ninja_command]
        test_commands = [ninja_command, 'test', 'benchmark']
        install_commands = [ninja_command, 'install']
Exemple #6
0
unity_flags = []
msbuild_exe = shutil.which('msbuild')

if msbuild_exe is not None:
    backend_flags = ['--backend=vs2010']
    compile_commands = ['msbuild']
    test_commands = ['msbuild', 'RUN_TESTS.vcxproj']
    install_commands = []
elif environment.is_osx():
    backend_flags = ['--backend=xcode']
    compile_commands = ['xcodebuild']
    test_commands = ['xcodebuild', '-target', 'RUN_TESTS']
    install_commands = []
else:
    backend_flags = []
    ninja_command = environment.detect_ninja()
    if ninja_command is None:
        raise RuntimeError('Could not find Ninja executable.')
    if print_debug:
        compile_commands = [ninja_command, '-v']
    else:
        compile_commands = [ninja_command]
    test_commands = [ninja_command, 'test']
    install_commands = [ninja_command, 'install']

def platform_fix_filename(fname):
    if platform.system() == 'Darwin':
        if fname.endswith('.so'):
            return fname[:-2] + 'dylib'
        return fname.replace('.so.', '.dylib.')
    elif platform.system() == 'Windows':
Exemple #7
0
1) setup of the cross build is platform specific
2) it can be slow (e.g. when invoking test apps via wine)

Eventually migrate to something fancier.'''

import os, subprocess, shutil, sys
import environment

from run_tests import gather_tests

test_build_dir = 'work area'
install_dir = os.path.join(os.path.split(os.path.abspath(__file__))[0], 'install dir')
meson_command = './meson.py'

extra_flags = ['--cross-file', sys.argv[1]]
ninja_command = environment.detect_ninja()
if ninja_command is None:
    raise RuntimeError('Could not find Ninja executable.')
compile_commands = [ninja_command]
test_commands = [ninja_command, 'test']
install_commands = [ninja_command, 'install']

def run_test(testdir, should_succeed=True):
    shutil.rmtree(test_build_dir)
    shutil.rmtree(install_dir)
    os.mkdir(test_build_dir)
    os.mkdir(install_dir)
    print('Running test: ' + testdir)
    gen_command = [sys.executable, meson_command, '--prefix', install_dir, '--libdir', 'lib', testdir, test_build_dir] + extra_flags
    p = subprocess.Popen(gen_command)
    p.wait()