# Copyright (c) 2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("//build/ohos.gni") import("ark_common_config.gni") config("ark_common_config") { include_dirs = [ "$ark_root", get_label_info(":create_pipeline(${default_toolchain})", "target_gen_dir"), ] defines = [] if (is_ohos && is_standard_system) { defines += [ "PANDA_TARGET_OHOS" ] # include_dirs += [ "$hilog_root/include" ] } if (is_linux) { defines += [ "PANDA_TARGET_UNIX", "PANDA_TARGET_LINUX", "PANDA_WITH_BYTECODE_OPTIMIZER", "PANDA_WITH_COMPILER", ] if (!is_asan) { defines += [ "PANDA_USE_FUTEX" ] } } else if (is_mingw) { defines += [ "PANDA_TARGET_WINDOWS", "PANDA_WITH_BYTECODE_OPTIMIZER", "PANDA_WITH_COMPILER", "__LIBMSVCRT__", ] } else if (is_mac) { defines += [ "PANDA_TARGET_UNIX", "PANDA_TARGET_MACOS", "PANDA_WITH_BYTECODE_OPTIMIZER", "PANDA_WITH_COMPILER", # "PANDA_USE_FUTEX", ] } else if (is_mob) { defines += [ "PANDA_TARGET_UNIX", "PANDA_USE_FUTEX", "PANDA_TARGET_MOBILE", "PANDA_TARGET_MOBILE_WITH_NATIVE_LIBS", ] } else if (is_ohos) { defines += [ # TODO: use PANDA_TARGET_OHOS instead of PANDA_TARGET_UNIX "PANDA_TARGET_UNIX", "PANDA_WITH_COMPILER", ] if (!is_asan) { defines += [ "PANDA_USE_FUTEX" ] } } else { defines += [ "PANDA_TARGET_UNIX", "PANDA_USE_FUTEX", ] } if (!is_debug) { defines += [ "NDEBUG" ] } cflags_cc = [ "-std=c++17", "-pedantic", "-Wall", "-Wextra", "-Werror", "-fno-rtti", "-fno-exceptions", "-Wno-invalid-offsetof", "-Wno-gnu-statement-expression", "-Wno-unused-parameter", "-Wno-unused-result", ] cflags_c = [] if (!is_mac && use_pbqp) { cflags_cc += [ # PBQP regalloc "-mllvm", "-regalloc=pbqp", ] } if (is_fastverify) { cflags_cc += [ "-O3", "-ggdb3", "-fno-omit-frame-pointer", "-D_GLIBCXX_ASSERTIONS", ] cflags_c += [ "-O3", "-ggdb3", "-fno-omit-frame-pointer", "-D_GLIBCXX_ASSERTIONS", ] } else if (is_debug) { cflags_cc += [ "-Og", "-ggdb3", "-gdwarf-4", ] } if (is_asan) { cflags_cc += [ "-g" ] if (defined(use_hwasan) && use_hwasan) { defines += [ "__SANITIZE_HWADDRESS__" ] } else { defines += [ "__SANITIZE_ADDRESS__" ] } print("ASAN is enabled") } defines += [ "PANDA_WITH_ETS" ] configs = [] if (current_cpu == "arm") { cflags_cc += [ "-march=armv7-a", "-mfloat-abi=${arm_float_abi}", "-marm", "-mfpu=vfp", ] if (arm_float_abi == "soft") { defines += [ "PANDA_TARGET_ARM32_ABI_SOFT=1" ] } else if (arm_float_abi == "softfp") { defines += [ "PANDA_TARGET_ARM32_ABI_SOFTFP=1" ] } else if (arm_float_abi == "hard") { defines += [ "PANDA_TARGET_ARM32_ABI_HARD=1" ] } defines += [ "PANDA_TARGET_32", "PANDA_TARGET_ARM32", ] } else if (current_cpu == "arm64") { defines += [ "PANDA_TARGET_ARM64", "PANDA_TARGET_64", "PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES", "PANDA_USE_32_BIT_POINTER", ] } else if (current_cpu == "x86") { defines += [ "PANDA_TARGET_X86" ] } else if (current_cpu == "amd64" || current_cpu == "x64" || current_cpu == "x86_64") { defines += [ "PANDA_TARGET_64", "PANDA_TARGET_AMD64", "PANDA_USE_32_BIT_POINTER", ] } }