def detect_system_compiler(options):
    global system_compiler

    with AutoDeletedDir(tempfile.mkdtemp(prefix='b ', dir='.')) as build_dir:
        fake_opts = get_fake_options('/')
        if options.cross_file:
            fake_opts.cross_file = [options.cross_file]
        env = environment.Environment(None, build_dir, fake_opts)
        print()
        for lang in sorted(compilers.all_languages):
            try:
                comp = env.compiler_from_language(lang, MachineChoice.HOST)
                details = '%s %s' % (' '.join(
                    comp.get_exelist()), comp.get_version_string())
            except mesonlib.MesonException:
                comp = None
                details = 'not found'
            print('%-7s: %s' % (lang, details))

            # note C compiler for later use by platform_fix_name()
            if lang == 'c':
                if comp:
                    system_compiler = comp.get_id()
                else:
                    raise RuntimeError("Could not find C compiler.")
        print()
Exemple #2
0
def main() -> None:
    parser = argparse.ArgumentParser()
    parser.add_argument('case', type=pathlib.Path, help='The test case to run')
    parser.add_argument('--subtest',
                        type=int,
                        action='append',
                        dest='subtests',
                        help='which subtests to run')
    parser.add_argument('--backend',
                        action='store',
                        help="Which backend to use")
    args = T.cast('ArgumentType', parser.parse_args())

    test = TestDef(args.case, args.case.stem, [])
    tests = load_test_json(test, False)
    if args.subtests:
        tests = [t for i, t in enumerate(tests) if i in args.subtests]

    with mesonlib.TemporaryDirectoryWinProof() as build_dir:
        fake_opts = get_fake_options('/')
        env = environment.Environment(None, build_dir, fake_opts)
        try:
            comp = env.compiler_from_language(
                'c', mesonlib.MachineChoice.HOST).get_id()
        except mesonlib.MesonException:
            raise RuntimeError('Could not detect C compiler')

    backend, backend_args = guess_backend(args.backend,
                                          shutil.which('msbuild'))
    _cmds = get_backend_commands(backend, False)
    commands = (_cmds[0], _cmds[1], _cmds[3], _cmds[4])

    results = [
        run_test(t, t.args, comp, backend, backend_args, commands, False, True)
        for t in tests
    ]
    failed = False
    for test, result in zip(tests, results):
        if result is None:
            msg = mlog.yellow('SKIP:')
        elif result.msg:
            msg = mlog.red('FAIL:')
            failed = True
        else:
            msg = mlog.green('PASS:'******'reason:', result.msg)
            if result.step is BuildStep.configure:
                # For configure failures, instead of printing stdout,
                # print the meson log if available since it's a superset
                # of stdout and often has very useful information.
                mlog.log(result.mlog)
            else:
                mlog.log(result.stdo)
            for cmd_res in result.cicmds:
                mlog.log(cmd_res)
            mlog.log(result.stde)

    exit(1 if failed else 0)
Exemple #3
0
def detect_system_compiler():
    global system_compiler

    with AutoDeletedDir(tempfile.mkdtemp(prefix='b ', dir='.')) as build_dir:
        env = environment.Environment(None, build_dir, get_fake_options('/'))
        try:
            comp = env.detect_c_compiler(env.is_cross_build())
        except:
            raise RuntimeError("Could not find C compiler.")
        system_compiler = comp.get_id()
Exemple #4
0
def detect_system_compiler():
    global system_compiler

    with AutoDeletedDir(tempfile.mkdtemp(prefix='b ', dir='.')) as build_dir:
        env = environment.Environment(None, build_dir, get_fake_options('/'))
        try:
            comp = env.detect_c_compiler(env.is_cross_build())
        except:
            raise RuntimeError("Could not find C compiler.")
        system_compiler = comp.get_id()
Exemple #5
0
def have_objcpp_compiler():
    with AutoDeletedDir(tempfile.mkdtemp(prefix='b ', dir='.')) as build_dir:
        env = environment.Environment(None, build_dir, get_fake_options('/'))
        try:
            objcpp_comp = env.detect_objcpp_compiler(False)
        except mesonlib.MesonException:
            return False
        if not objcpp_comp:
            return False
        try:
            objcpp_comp.sanity_check(env.get_scratch_dir(), env)
        except mesonlib.MesonException:
            return False
    return True
Exemple #6
0
def have_objcpp_compiler():
    with AutoDeletedDir(tempfile.mkdtemp(prefix='b ', dir='.')) as build_dir:
        env = environment.Environment(None, build_dir, get_fake_options('/'))
        try:
            objcpp_comp = env.detect_objcpp_compiler(False)
        except mesonlib.MesonException:
            return False
        if not objcpp_comp:
            return False
        try:
            objcpp_comp.sanity_check(env.get_scratch_dir(), env)
        except mesonlib.MesonException:
            return False
    return True
Exemple #7
0
def have_objcpp_compiler():
    with AutoDeletedDir(tempfile.mkdtemp(prefix='b ', dir='.')) as build_dir:
        env = environment.Environment(None, build_dir, get_fake_options('/'))
        try:
            objcpp_comp = env.detect_objcpp_compiler(MachineChoice.HOST)
        except mesonlib.MesonException:
            return False
        if not objcpp_comp:
            return False
        env.coredata.process_new_compiler('objcpp', objcpp_comp, env)
        try:
            objcpp_comp.sanity_check(env.get_scratch_dir(), env)
        except mesonlib.MesonException:
            return False
    return True
Exemple #8
0
def main() -> None:
    parser = argparse.ArgumentParser()
    parser.add_argument('case', type=pathlib.Path, help='The test case to run')
    parser.add_argument('--subtest',
                        type=int,
                        action='append',
                        dest='subtests',
                        help='which subtests to run')
    parser.add_argument('--backend',
                        action='store',
                        help="Which backend to use")
    args = T.cast('ArgumentType', parser.parse_args())

    test = TestDef(args.case, args.case.stem, [])
    tests = load_test_json(test, False)
    if args.subtests:
        tests = [t for i, t in enumerate(tests) if i in args.subtests]

    with mesonlib.TemporaryDirectoryWinProof() as build_dir:
        fake_opts = get_fake_options('/')
        env = environment.Environment(None, build_dir, fake_opts)
        try:
            comp = env.compiler_from_language(
                'c', mesonlib.MachineChoice.HOST).get_id()
        except mesonlib.MesonException:
            raise RuntimeError('Could not detect C compiler')

    backend, backend_args = guess_backend(args.backend,
                                          shutil.which('msbuild'))
    _cmds = get_backend_commands(backend, False)
    commands = (_cmds[0], _cmds[1], _cmds[3], _cmds[4])

    results = [
        run_test(t, t.args, comp, backend, backend_args, commands, False, True)
        for t in tests
    ]
    failed = False
    for test, result in zip(tests, results):
        if (result is None) or (
            ('MESON_SKIP_TEST' in result.stdo) and
            (skippable(str(args.case.parent), test.path.as_posix()))):
            msg = mlog.yellow('SKIP:')
        elif result.msg:
            msg = mlog.red('FAIL:')
            failed = True
def detect_system_compiler():
    global system_compiler

    with AutoDeletedDir(tempfile.mkdtemp(prefix='b ', dir='.')) as build_dir:
        env = environment.Environment(None, build_dir, get_fake_options('/'))
        print()
        for lang in sorted(compilers.all_languages):
            try:
                comp = env.compiler_from_language(lang, env.is_cross_build())
                details = '%s %s' % (' '.join(comp.get_exelist()), comp.get_version_string())
            except mesonlib.MesonException:
                comp = None
                details = 'not found'
            print('%-7s: %s' % (lang, details))

            # note C compiler for later use by platform_fix_name()
            if lang == 'c':
                if comp:
                    system_compiler = comp.get_id()
                else:
                    raise RuntimeError("Could not find C compiler.")
        print()