import("//build/config/sysroot.gni")
import("//build/config/clang/clang.gni")
assert(is_ohos)
ohos_clang_base_path = "${ohos_sdk_native_root}/llvm"
ohos_clang_version = "15.0.4"
if (is_ohos) {
if (current_cpu == "arm") {
abi_target = "arm-linux-ohos"
} else if (current_cpu == "x86") {
abi_target = ""
} else if (current_cpu == "arm64") {
abi_target = "aarch64-linux-ohos"
} else if (current_cpu == "x86_64") {
abi_target = "x86_64-linux-ohos"
} else {
assert(false, "Architecture not supported")
}
}
config("compiler") {
cflags = [
"-ffunction-sections",
"-fno-short-enums",
"-fno-addrsig",
"-fno-rtti",
]
cflags += [
"-Wno-unknown-warning-option",
"-Wno-int-conversion",
"-Wno-unused-variable",
"-Wno-misleading-indentation",
"-Wno-missing-field-initializers",
"-Wno-unused-parameter",
"-Wno-c++11-narrowing",
"-Wno-unneeded-internal-declaration",
"-Wno-undefined-var-template",
"-Wno-implicit-int-float-conversion",
]
defines = [
# The NDK has these things, but doesn't define the constants to say that it
# does. Define them here instead.
"HAVE_SYS_UIO_H",
]
defines += [
"OHOS",
"__MUSL__",
"_LIBCPP_HAS_MUSL_LIBC",
"__BUILD_LINUX_WITH_CLANG",
"__GNU_SOURCE",
"_GNU_SOURCE",
]
ldflags = [
"-Wl,--no-undefined",
"-Wl,--exclude-libs=libunwind_llvm.a",
"-Wl,--exclude-libs=libc++_static.a",
# Don't allow visible symbols from libraries that contain
# assembly code with symbols that aren't hidden properly.
# http://crbug.com/448386
"-Wl,--exclude-libs=libvpx_assembly_arm.a",
"-s",
"-L$sysroot/usr/lib/${abi_target}",
]
cflags += [ "--target=$abi_target" ]
include_dirs = [
"${sysroot}/usr/include/${abi_target}",
"${ohos_clang_base_path}/lib/clang/${ohos_clang_version}/include",
]
ldflags += [ "--target=$abi_target" ]
# Assign any flags set for the C compiler to asmflags so that they are sent
# to the assembler.
asmflags = cflags
}