leave out toolchain changes for now because of build issues on android/linux
This commit is contained in:
+4
-4
@@ -39,15 +39,15 @@ template("cargo_build") {
|
||||
"--target=" + target,
|
||||
"--toolchain=" + rustc_toolchain, # defined by //brave/build/rust/config.gni,
|
||||
"--is_debug=$is_debug",
|
||||
"--sysroot=" + rebase_path(sysroot, root_build_dir),
|
||||
"--clang_prefix",
|
||||
rebase_path(clang_base_path, "", root_build_dir),
|
||||
|
||||
]
|
||||
|
||||
if (is_mac) {
|
||||
args += [ "--mac_deployment_target=" + mac_deployment_target ]
|
||||
}
|
||||
|
||||
if (defined(rust_flags)) {
|
||||
args += [ "--rust_flags=$rust_flags" ]
|
||||
}
|
||||
}
|
||||
|
||||
config_target = target_name + "_staticlib_config"
|
||||
|
||||
@@ -9,10 +9,12 @@ rustc_target = ""
|
||||
rustc_toolchain = ""
|
||||
cargo_lib_prefix = ""
|
||||
cargo_lib_suffix = ""
|
||||
rust_flags = ""
|
||||
|
||||
# See https://forge.rust-lang.org/release/platform-support.html for possible targets
|
||||
if (is_win) {
|
||||
if (current_cpu == "x86") {
|
||||
rust_flags += " --codegen target-feature=+crt-static "
|
||||
rustc_target = "i686-pc-windows-msvc"
|
||||
} else if (current_cpu == "x64") {
|
||||
rustc_target = "x86_64-pc-windows-msvc"
|
||||
@@ -24,6 +26,10 @@ if (is_win) {
|
||||
} else if (is_linux) {
|
||||
if (current_cpu == "x64") {
|
||||
rustc_target = "x86_64-unknown-linux-gnu"
|
||||
if (use_sysroot) {
|
||||
rust_flags += " -C link-arg=--sysroot=$target_sysroot "
|
||||
rust_flags += " -C link-arg=-Wl,-rpath=\$ORIGIN "
|
||||
}
|
||||
}
|
||||
} else if (is_android) {
|
||||
if (current_cpu == "arm") {
|
||||
|
||||
+14
-31
@@ -19,10 +19,18 @@ def build(args):
|
||||
build_path = args.build_path
|
||||
target = args.target
|
||||
is_debug = args.is_debug
|
||||
clang_prefix = os.path.join(args.clang_prefix, "bin")
|
||||
clang_c_compiler = os.path.join(clang_prefix, "clang")
|
||||
sysroot = args.sysroot
|
||||
rustflags = []
|
||||
|
||||
if args.android_sysroot is not None:
|
||||
sysroot = os.path.join(args.android_toolchain_root, 'sysroot')
|
||||
|
||||
if args.android_toolchain_root is not None:
|
||||
clang_prefix = os.path.join(args.android_toolchain_root, "bin")
|
||||
clang_c_compiler = os.path.join(clang_prefix, "clang")
|
||||
|
||||
print(target)
|
||||
print(sysroot)
|
||||
print(clang_prefix)
|
||||
print(clang_c_compiler)
|
||||
|
||||
# Set environment variables for rustup
|
||||
env = os.environ.copy()
|
||||
@@ -48,34 +56,11 @@ def build(args):
|
||||
if is_debug == "false":
|
||||
env['NDEBUG'] = "1"
|
||||
|
||||
if args.target.endswith("linux-gnu"):
|
||||
rustflags += ["-Clink-arg=-Wl,--build-id"]
|
||||
if not args.target.endswith("darwin"):
|
||||
rustflags += ["-Clink-arg=-Wl,--threads"]
|
||||
|
||||
env["CARGO_TARGET_LINKER"] = clang_c_compiler
|
||||
env["CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER"] = clang_c_compiler
|
||||
env["CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER"] = clang_c_compiler
|
||||
env["CARGO_TARGET_%s_LINKER" % target.replace("-", "_").upper()] = clang_c_compiler
|
||||
rustflags += ["-Clink-arg=--target=" + target]
|
||||
if args.rust_flags is not None:
|
||||
env['RUSTFLAGS'] = args.rust_flags
|
||||
|
||||
env["CARGO_TARGET_%s_RUSTFLAGS" % target.replace("-", "_").upper()] = (
|
||||
' '.join(rustflags)
|
||||
)
|
||||
|
||||
env["CC"] = clang_c_compiler
|
||||
cflags = []
|
||||
if sysroot:
|
||||
cflags += ["--sysroot=" + sysroot]
|
||||
env["CFLAGS"] = " ".join(cflags)
|
||||
|
||||
env["CARGO_BUILD_DEP_INFO_BASEDIR"] = build_path
|
||||
env["RUST_BACKTRACE"] = "1"
|
||||
env["CC"] = os.path.join(clang_prefix, "clang")
|
||||
env["CXX"] = os.path.join(clang_prefix, "clang++")
|
||||
# TODO(bridiver) - these don't exist on mac and cause an error when they are added
|
||||
# env["AR"] = os.path.join(clang_prefix, "llvm-ar")
|
||||
# env["RANLIB"] = os.path.join(clang_prefix, "llvm-ranlib")
|
||||
|
||||
# Clean first because we want GN to decide when to rebuild and cargo doesn't
|
||||
# rebuild when env changes
|
||||
@@ -121,8 +106,6 @@ def parse_args():
|
||||
parser.add_argument('--is_debug', required=True)
|
||||
parser.add_argument('--mac_deployment_target')
|
||||
parser.add_argument('--rust_flags')
|
||||
parser.add_argument('--clang_prefix')
|
||||
parser.add_argument('--sysroot')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user