示例#1
0
def create_distribution(dist_dir, build_dir, data):
    """Creates a release by copying files needed for the given platform."""
    if not os.path.exists(dist_dir):
        os.makedirs(dist_dir)

    licensing = Licensing(build_dir, get_qemu_root())

    # Let's find the set of
    zip_set = zip_sets[data["config"]]

    # First we create the individual zip sets using the regular expressions.
    for zip_fname, params in zip_set.iteritems():
        zip_fname = os.path.join(dist_dir, zip_fname.format(**data))
        logging.info("Creating %s", zip_fname)

        files = []
        with zipfile.ZipFile(zip_fname,
                             "w",
                             zipfile.ZIP_DEFLATED,
                             allowZip64=True) as zipf:
            # Include the notice files
            zipf.writestr("emulator/NOTICE.txt", licensing.notice_file())
            zipf.writestr("emulator/NOTICE.csv", licensing.to_csv())

            for param in params:
                start_dir, regex, dest = param
                search_dir = os.path.normpath(
                    start_dir.format(build_dir=build_dir,
                                     src_dir=get_qemu_root()))
                for fname in recursive_glob(search_dir, regex.format(data)):
                    arcname = os.path.relpath(fname[len(search_dir):], "/")
                    arcname = os.path.join(dest, arcname)
                    files.append(arcname)
                    zipf.write(fname, arcname)
def run_tests(out_dir, jobs, check_symbols, additional_opts):
    if check_symbols:
        run_symbols_test(out_dir)

    if platform.system() == "Windows":

        if "--skip-emulator-check" in additional_opts:
            pass
        else:
            run_binary_exists(out_dir)

        run_emugen_test(out_dir)
        run_ctest(out_dir, jobs)
    else:
        with TemporaryDirectory() as tmpdir:
            logging.info("Running tests with TMPDIR=%s", tmpdir)
            run(
                [
                    os.path.join(get_qemu_root(), "android", "scripts", "unix",
                                 "run_tests.sh"),
                    "--out-dir=%s" % out_dir,
                    "--verbose",
                    "--verbose",
                    "-j",
                    jobs,
                ] + additional_opts,
                out_dir,
                {"TMPDIR": tmpdir},
            )
def get_system_env():
    # Configure the paths for the various development environments
    global _CACHED_ENV
    if _CACHED_ENV != None:
        return _CACHED_ENV

    local_env = os.environ.copy()
    if platform.system() == "Windows":
        vs = get_visual_studio()
        env_lines = subprocess.check_output([vs, "&&", "set"]).splitlines()
        for env_line in env_lines:
            line = str(env_line)
            if "=" in line:
                env = line.split("=")
                # Variables in windows are case insensitive, but not in python dict!
                local_env[env[0].upper()] = env[1]
    else:
        local_env["PATH"] = (
            os.path.join(
                get_qemu_root(), "android", "third_party", "chromium", "depot_tools"
            )
            + os.pathsep
            + local_env["PATH"]
        )

    _CACHED_ENV = local_env
    return local_env
示例#4
0
def create_distribution(dist_dir, build_dir, data):
    """Creates a release by copying files needed for the given platform."""
    if not os.path.exists(dist_dir):
        os.makedirs(dist_dir)

    # Let's find the set of
    zip_set = zip_sets[data['config']]

    # First we create the individual zip sets using the regular expressions.
    for zip_fname, params in zip_set.iteritems():
        zip_fname = os.path.join(dist_dir, zip_fname.format(**data))
        logging.info('Creating %s', zip_fname)

        files = []
        with zipfile.ZipFile(zip_fname,
                             'w',
                             zipfile.ZIP_DEFLATED,
                             allowZip64=True) as zipf:
            start_dir, regex = params
            search_dir = os.path.normpath(
                start_dir.format(build_dir=build_dir, src_dir=get_qemu_root()))
            for fname in recursive_glob(search_dir, regex.format(data)):
                arcname = fname[len(search_dir):]
                files.append(arcname)
                zipf.write(fname, arcname)

            # add a notice file.
            notice = _construct_notice_file(files, data['aosp'])
            zipf.writestr('emulator/NOTICE.txt', notice)
示例#5
0
文件: cmake.py 项目: taehoon1/qemu
def configure():
    """Configures the cmake project."""

    # Clear out the existing directory.
    if FLAGS.clean:
        if os.path.exists(FLAGS.out):
            logging.info('Clearing out %s', FLAGS.out)
            shutil.rmtree(FLAGS.out)
        if not os.path.exists(FLAGS.out):
            os.makedirs(FLAGS.out)

    # Configure..
    cmake_cmd = [get_cmake(), '-B%s' % FLAGS.out]

    # Setup the right toolchain/compiler configuration.
    cmake_cmd += Toolchain.from_string(FLAGS.target).to_cmd()
    cmake_cmd += Crash.from_string(FLAGS.crash).to_cmd()
    cmake_cmd += BuildConfig.from_string(FLAGS.config).to_cmd()

    # Make darwin and msvc builds have QtWebEngine support for the default
    # build.
    if FLAGS.target == "darwin" or FLAGS.target == "windows":
        FLAGS.qtwebengine = True
    cmake_cmd += ['-DQTWEBENGINE=%s' % FLAGS.qtwebengine]

    if FLAGS.cmake_option:
        flags = ['-D%s' % x for x in FLAGS.cmake_option]
        logging.warn('Dangerously adding the following flags to cmake: %s',
                     flags)
        cmake_cmd += flags

    if FLAGS.sdk_revision:
        sdk_revision = FLAGS.sdk_revision
    else:
        sdk_revision = read_simple_properties(
            os.path.join(get_aosp_root(), 'external', 'qemu',
                         'source.properties'))['Pkg.Revision']
    cmake_cmd += ['-DOPTION_SDK_TOOLS_REVISION=%s' % sdk_revision]

    if FLAGS.sdk_build_number:
        cmake_cmd += [
            '-DOPTION_SDK_TOOLS_BUILD_NUMBER=%s' % FLAGS.sdk_build_number
        ]
    if FLAGS.sanitizer:
        cmake_cmd += ['-DOPTION_ASAN=%s' % (','.join(FLAGS.sanitizer))]

    if FLAGS.minbuild:
        cmake_cmd += ['-DOPTION_MINBUILD=%s' % FLAGS.minbuild]

    if FLAGS.gfxstream:
        cmake_cmd += ['-DGFXSTREAM=%s' % FLAGS.gfxstream]

    cmake_cmd += Generator.from_string(FLAGS.generator).to_cmd()
    cmake_cmd += [get_qemu_root()]

    # Make sure we fixup clang in windows builds
    if platform.system() == 'Windows':
        fixup_windows_clang()

    run(cmake_cmd, FLAGS.out)
示例#6
0
def run_emugen_test(out_dir):
    emugen = os.path.abspath(os.path.join(out_dir, 'emugen%s' % EXE_POSTFIX))
    if platform.system() != 'Windows':
        cmd = [
            os.path.join(get_qemu_root(), 'android', 'android-emugl', 'host',
                         'tools', 'emugen', 'tests', 'run-tests.sh'),
            '--emugen=%s' % emugen
        ]
        run(cmd, out_dir)
    else:
        logging.info('gen_tests not supported on windows yet.')
def main(argv=None):
    del argv  # Unused.

    version = sys.version_info
    logging.info(
        "Running under Python {0[0]}.{0[1]}.{0[2]}, Platform: {1}".format(
            version, platform.platform()))

    configure()
    if FLAGS.build == "config":
        print("You can now build with: %s " % " ".join(get_build_cmd()))
        return

    # Build
    run(get_build_cmd())

    # Test.
    if FLAGS.tests:
        cross_compile = platform.system().lower() != FLAGS.target
        if not cross_compile:
            run_tests_opts = []
            if FLAGS.gfxstream or FLAGS.crosvm or FLAGS.gfxstream_only:
                run_tests_opts.append("--skip-emulator-check")

            run_tests(FLAGS.out, FLAGS.test_jobs, FLAGS.crash != "none",
                      run_tests_opts)
        else:
            logging.info("Not running tests for cross compile.")

    # Create a distribution if needed.
    if FLAGS.dist:
        data = {
            "aosp": get_aosp_root(),
            "target": FLAGS.target,
            "sdk_build_number": FLAGS.sdk_build_number,
            "config": FLAGS.config,
        }

        create_distribution(FLAGS.dist, FLAGS.out, data)

    if platform.system() != "Windows" and FLAGS.config == "debug":
        overrides = open(
            os.path.join(get_qemu_root(), "android", "asan_overrides")).read()
        print("Debug build enabled.")
        print(
            "ASAN may be in use; recommend disabling some ASAN checks as build is not"
        )
        print("universally ASANified. This can be done with")
        print()
        print(". android/envsetup.sh")
        print("")
        print("or export ASAN_OPTIONS=%s" % overrides)
示例#8
0
def run_tests(out_dir, jobs, additional_opts):
    if platform.system() == 'Windows':
        run_binary_exists(out_dir)
        run_emugen_test(out_dir)
        run_ctest(out_dir, jobs)
    else:
        with TemporaryDirectory() as tmpdir:
            logging.info("Running tests with TMPDIR=%s", tmpdir)
            run([
                os.path.join(get_qemu_root(), 'android', 'scripts', 'unix',
                             'run_tests.sh'),
                '--out-dir=%s' % out_dir, '--verbose', '--verbose', '-j', jobs
            ] + additional_opts, out_dir, {'TMPDIR': tmpdir})
示例#9
0
文件: cmake.py 项目: taehoon1/qemu
def main(argv=None):
    del argv  # Unused.

    version = sys.version_info
    logging.info(
        'Running under Python {0[0]}.{0[1]}.{0[2]}, Platform: {1}'.format(
            version, platform.platform()))

    configure()
    if FLAGS.build == 'config':
        print('You can now build with: %s ' % ' '.join(get_build_cmd()))
        return

    # Build
    run(get_build_cmd())

    # Test.
    if FLAGS.tests:
        cross_compile = platform.system().lower() != FLAGS.target
        if not cross_compile:
            run_tests(FLAGS.out, FLAGS.test_jobs)
        else:
            logging.info("Not running tests for cross compile.")

    # Create a distribution if needed.
    if FLAGS.dist:
        data = {
            'aosp': get_aosp_root(),
            'target': FLAGS.target,
            'sdk_build_number': FLAGS.sdk_build_number,
            'config': FLAGS.config
        }

        create_distribution(FLAGS.dist, FLAGS.out, data)

    if platform.system() != 'Windows' and FLAGS.config == 'debug':
        overrides = open(
            os.path.join(get_qemu_root(), 'android', 'asan_overrides')).read()
        print("Debug build enabled.")
        print(
            "ASAN may be in use; recommend disabling some ASAN checks as build is not"
        )
        print("universally ASANified. This can be done with")
        print()
        print(". android/envsetup.sh")
        print("")
        print("or export ASAN_OPTIONS=%s" % overrides)
示例#10
0
def get_system_env():
    # Configure the paths for the various development environments
    global _CACHED_ENV
    if _CACHED_ENV != None:
        return _CACHED_ENV

    local_env = os.environ.copy()
    if platform.system() == 'Windows':
        env_lines = subprocess.check_output(["cmd", "/c", get_visual_studio(), "&&",  "set"]).splitlines()
        for env_line in env_lines:
            if '=' in env_line:
                env = env_line.split('=')
                # Variables in windows are case insensitive, but not in python dict!
                local_env[env[0].upper()] = env[1]
    else:
        local_env['PATH'] = os.path.join(get_qemu_root(), 'android', 'third_party', 'chromium', 'depot_tools') + os.pathsep + local_env['PATH']

    _CACHED_ENV = local_env
    return local_env
def run_emugen_test(out_dir):
    emugen = os.path.abspath(os.path.join(out_dir, "emugen%s" % EXE_POSTFIX))
    if platform.system() != "Windows":
        cmd = [
            os.path.join(
                get_qemu_root(),
                "android",
                "android-emugl",
                "host",
                "tools",
                "emugen",
                "tests",
                "run-tests.sh",
            ),
            "--emugen=%s" % emugen,
        ]
        run(cmd, out_dir)
    else:
        logging.info("gen_tests not supported on windows yet.")