Lines Matching +full:os +full:- +full:release
3 # Use of this source code is governed by a BSD-style license that can be
6 """Builds crosvm in debug/release mode on all supported target architectures.
11 To test changes more quickly, set the --noclean option. This prevents the target directories from
14 For easy binary size comparison, use the --size-only option to only do builds that will result in a
15 binary size output, which are non-test release builds.
18 structure with Cargo.toml files. Only top-level crates are tested directly. To skip a top-level
20 tests run single-threaded, add an empty .build_test_serial file to the directory.
27 import os
32 sys.path.append(os.path.dirname(sys.path[0]))
39 IS_WINDOWS = os.name == "nt"
41 ARM_TRIPLE = os.getenv("ARM_TRIPLE", "armv7a-cros-linux-gnueabihf")
42 AARCH64_TRIPLE = os.getenv("AARCH64_TRIPLE", "aarch64-cros-linux-gnu")
43 X86_64_TRIPLE = os.getenv("X86_64_TRIPLE", "x86_64-unknown-linux-gnu")
44 X86_64_WIN_MSVC_TRIPLE = os.getenv("X86_64_WIN_MSVC_TRIPLE", "x86_64-pc-windows-msvc")
72 triple: Target triple. Example: 'x86_64-unknown-linux-gnu'.
73 kind: 'debug' or 'release'.
76 target_path = os.path.abspath(os.path.join(os.sep, "tmp", "{}_{}".format(triple, kind)))
83 kind = "release" if is_release else "debug"
85 binary_path = os.path.join(target_path, triple, kind, crosvm_binary_name())
99 """Does a cargo build for the triple in release or debug mode.
102 triple: Target triple. Example: 'x86_64-unknown-linux-gnu'.
103 is_release: True to build a release version.
107 args = ["cargo", "build", "--target=%s" % triple]
110 args.append("--release")
117 args.append("-p")
120 args.append("--features")
135 triple: Target triple. Example: 'x86_64-unknown-linux-gnu'.
136 is_release: True to build a release version.
138 no_run: True to pass --no-run flag to cargo test.
142 args = ["cargo", "test", "--target=%s" % triple]
145 args.append("--release")
148 args.append("--no-run")
151 args.append("-p")
154 args.append("--features")
158 args.append("--")
159 args.append("--test-threads=1")
167 triple: Target triple. Example: 'x86_64-unknown-linux-gnu'.
168 is_release: True to build a release version.
170 no_run: True to pass --no-run flag to cargo test.
198 triple: Target triple. Example: 'x86_64-unknown-linux-gnu'.
199 kind: 'debug' or 'release'.
209 if not os.path.isdir(sysroot) and not IS_WINDOWS:
217 is_release = kind == "release"
219 env = os.environ.copy()
220 env["TARGET_CC"] = "%s-clang" % triple
226 # which one is valid, just add both and let the dynamic linker and pkg-config search.
227 libdir = os.path.join(sysroot, "usr", "lib")
228 lib64dir = os.path.join(sysroot, "usr", "lib64")
229 libdir_pc = os.path.join(libdir, "pkgconfig")
230 lib64dir_pc = os.path.join(lib64dir, "pkgconfig")
238 if "KOKORO_JOB_NAME" not in os.environ:
239 env["RUSTFLAGS"] = "-C linker=" + env["TARGET_CC"]
241 env["RUSTFLAGS"] += " -Cembed-bitcode=yes -Clto"
245 env["RUSTFLAGS"] = env.get("RUSTFLAGS", "") + " -C link-args=/EXPORT:{}".format(symbol)
247 deps_dir = os.path.join(target_path, triple, kind, "deps")
248 if not os.path.exists(deps_dir):
249 os.makedirs(deps_dir)
253 os.makedirs(os.path.join(copy_directory, kind), exist_ok=True)
255 target_dirs.append(os.path.join(copy_directory, kind))
257 copy_dlls(os.getcwd(), target_dirs, kind)
284 # We only care about the non-test binaries, so only copy the output from cargo build.
286 binary_src = os.path.join(target_path, triple, kind, crosvm_binary_name())
288 binary_dst = os.path.join(copy_directory, kind)
301 if IS_WINDOWS and not os.path.isfile(skip_file_name):
307 file_in_crate = lambda file_name: os.path.isfile(os.path.join(crate.path, file_name))
309 with os.scandir() as it:
326 """Returns the formatted size of the given triple's release binary.
329 triple: Target triple. Example: 'x86_64-unknown-linux-gnu'.
331 target_path = get_target_path(triple, "release", False)
332 bin_path = os.path.join(target_path, triple, "release", crosvm_binary_name())
333 proc = subprocess.Popen(["%s-strip" % triple, bin_path])
338 return "%dKiB" % (os.path.getsize(bin_path) / 1024)
346 "--x86_64-msvc-sysroot",
347 default="build/amd64-msvc",
352 "--arm-sysroot",
353 default="/build/arm-generic",
357 "--aarch64-sysroot",
358 default="/build/arm64-generic",
362 "--x86_64-sysroot",
363 default="/build/amd64-generic",
368 "--noclean",
375 "--copy",
380 "--copy-directory",
382 help="Destination of .exe files when using --copy",
385 "--serial",
393 "--x86_64-only",
399 "--only-build-targets",
405 "--size-only",
409 help="Only perform builds that output their binary size (i.e. release non-test).",
412 "--job_type",
418 "--skip_file_name",
428 "--build_mode",
429 default="release",
430 choices=["release", "debug"],
439 os.environ["RUST_BACKTRACE"] = "1"
441 if opts.build_mode == "release":
443 # (sysroot path, target triple, debug/release, skip_file_name, should test?)
447 "release",
454 "release",
471 # (sysroot path, target triple, debug/release, skip_file_name, should test?)
473 (opts.x86_64_sysroot, X86_64_TRIPLE, "release", opts.skip_file_name, False),
475 (opts.x86_64_sysroot, X86_64_TRIPLE, "release", opts.skip_file_name, True),
479 # (sysroot path, target triple, debug/release, skip_file_name, should test?)
481 (opts.arm_sysroot, ARM_TRIPLE, "release", opts.skip_file_name, False),
492 "release",
497 os.chdir(os.path.dirname(sys.argv[0]))
500 # Only include non-test release builds
502 case for case in build_test_cases if case[2] == "release" and not case[4]
512 build_dlls(os.getcwd(), mode, opts.job_type, BUILD_FEATURES)
539 # Run tests serially. We set clean=False so it re-uses the results of the build phase.
561 print("---")
565 title = "%s_%s" % (triple.split("-")[0], kind)
580 and kind == "release"