# Copyright (c) 2021-2022 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("//arkcompiler/runtime_core/static_core/ark_config.gni") import("//arkcompiler/runtime_core/static_vm_config.gni") import("//build/ohos.gni") import("$ark_root/plugins/plugins.gni") group("ark_packages") { if (enable_static_vm) { deps = plugin_ark_packages if (host_os != "mac") { deps += [ "$ark_root/compiler:libarktscompiler", "$ark_root/compiler/aot:libarkaotmanager", "$ark_root/libpandabase:libarktsbase", "$ark_root/libpandafile:libarktsfile", "$ark_root/libpandafile/external:libarkfileExt", "$ark_root/libpandafile/external:libarksupport", "$ark_root/libziparchive:libarktsziparchive", "$ark_root/panda:arkts_bin", "$ark_root/runtime:libarkruntime", "$ark_root/verification/verifier:verifier.config", "$ark_root/verification/verifier:verifier_bin", ] if (!is_ohos) { deps += [ "$ark_root/runtime/tooling/inspector:libarkinspector" ] } if (enable_codegen) { deps += [ "$ark_root/compiler/optimizer/code_generator:libarkencoder" ] } # TODO: don't exclude these targets from OHOS build if (ark_standalone_build) { deps += [ "$ark_root/compiler/tools/paoc:ark_aot" ] } } } } group("ark_host_linux_tools_packages") { deps = plugin_ark_host_linux_tools_packages if (host_os != "mac" && current_cpu != "arm") { deps += [ "$ark_root/assembler:arkts_asm(${host_toolchain})", "$ark_root/compiler:libarktscompiler(${host_toolchain})", "$ark_root/compiler/aot:libarkaotmanager(${host_toolchain})", "$ark_root/libpandabase:libarktsbase(${host_toolchain})", "$ark_root/libpandafile:libarktsfile(${host_toolchain})", "$ark_root/libpandafile/external:libarkfileExt(${host_toolchain})", "$ark_root/libpandafile/external:libarksupport(${host_toolchain})", "$ark_root/libziparchive:libarktsziparchive(${host_toolchain})", "$ark_root/panda:arkts_bin(${host_toolchain})", "$ark_root/runtime:libarkruntime(${host_toolchain})", ] if (enable_codegen) { deps += [ "$ark_root/compiler/optimizer/code_generator:libarkencoder(${host_toolchain})" ] } # TODO: don't exclude these targets from OHOS build if (ark_standalone_build) { deps += [ "$ark_root/compiler/tools/aotdump:ark_aotdump(${host_toolchain})", "$ark_root/compiler/tools/paoc:ark_aot(${host_toolchain})", "$ark_root/disassembler:ark_disasm(${host_toolchain})", "$ark_root/static_linker:ark_link(${host_toolchain})", ] } } } group("ark_host_windows_tools_packages") { deps = plugin_ark_host_windows_tools_packages if (host_os != "mac" && current_cpu != "arm" && !ark_standalone_build) { deps += [ "$ark_root/assembler:arkts_asm(//build/toolchain/mingw:mingw_x86_64)", "$ark_root/disassembler:ark_disasm(//build/toolchain/mingw:mingw_x86_64)", "$ark_root/static_linker:ark_link(//build/toolchain/mingw:mingw_x86_64)", ] } } group("ark_host_mac_tools_packages") { deps = plugin_ark_host_mac_tools_packages if (host_os == "mac") { deps += [ "$ark_root/assembler:arkts_asm(//build/toolchain/mac:clang_x64)", "$ark_root/disassembler:ark_disasm(//build/toolchain/mac:clang_x64)", "$ark_root/libpandabase:libarktsbase(//build/toolchain/mac:clang_x64)", "$ark_root/libpandafile:libarktsfile(//build/toolchain/mac:clang_x64)", "$ark_root/libziparchive:libarktsziparchive(//build/toolchain/mac:clang_x64)", "$ark_root/static_linker:ark_link(//build/toolchain/mac:clang_x64)", ] } } group("ark_host_tests") { testonly = true deps = [] if (defined(extras)) { foreach(ext, extras) { deps += [ "${ext}:host_tests" ] } } } # Common config for ark source config("ark_config") { if (!ark_standalone_build) { visibility = [ "$ark_es2panda_root:libes2panda", "$ark_es2panda_root:libes2panda_frontend_static", "$ark_es2panda_root:libes2panda_public", "$ark_es2panda_root:libes2panda_public_frontend_static", "$ark_es2panda_root/aot:es2panda", "$ark_third_party_root/asmjit:*", "$ark_third_party_root/vixl:*", "./*", ] } # In GN build we just create merged files, without any content. Because no languages are involved in GN build. if (current_toolchain == default_toolchain) { generated_file("create_pipeline") { outputs = [ "$target_gen_dir/plugins/create_pipeline.h" ] contents = "" } generated_file("create_pipeline_includes") { outputs = [ "$target_gen_dir/plugins/create_pipeline_includes.h" ] contents = "" } generated_file("optimizations_after_unroll") { outputs = [ "$target_gen_dir/plugins/optimizations_after_unroll.h" ] contents = "" } generated_file("clear_profile") { outputs = [ "$target_gen_dir/plugins/clear_profile.h" ] contents = "" } generated_file("destroy_profile") { outputs = [ "$target_gen_dir/plugins/destroy_profile.h" ] contents = "" } generated_file("dump_profile") { outputs = [ "$target_gen_dir/plugins/dump_profile.h" ] contents = "" } generated_file("find_method_in_profile") { outputs = [ "$target_gen_dir/plugins/find_method_in_profile.h" ] contents = "" } generated_file("profiling_includes_disasm") { outputs = [ "$target_gen_dir/plugins/profiling_includes_disasm.h" ] contents = "" } generated_file("profiling_includes") { outputs = [ "$target_gen_dir/plugins/profiling_includes.h" ] contents = "" } generated_file("read_profile") { outputs = [ "$target_gen_dir/plugins/read_profile.h" ] contents = "" } } include_dirs = [ "$ark_root", get_label_info(":create_pipeline(${default_toolchain})", "target_gen_dir"), ] defines = [ "PANDA_TARGET_MOBILE_WITH_MANAGED_LIBS=1" ] if (enable_codegen) { defines += [ "PANDA_COMPILER_ENABLE" ] } if (is_emulator) { defines += [ "PANDA_TARGET_EMULATOR" ] } if (is_llvmbackend) { defines += [ "PANDA_LLVM_IRTOC", "PANDA_LLVM_INTERPRETER", ] } 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 (enable_irtoc) { defines += [ "PANDA_WITH_IRTOC" ] } if (enable_codegen) { defines += [ "PANDA_WITH_CODEGEN" ] } if (!is_asan) { defines += [ "PANDA_USE_FUTEX" ] } } else if (is_mingw) { defines += [ "PANDA_TARGET_WINDOWS", "PANDA_WITH_BYTECODE_OPTIMIZER", "PANDA_WITH_COMPILER", "_CRTBLD", "__LIBMSVCRT__", ] if (enable_irtoc) { defines += [ "PANDA_WITH_IRTOC" ] } if (enable_codegen) { defines += [ "PANDA_WITH_CODEGEN" ] } } else if (is_mac) { defines += [ "PANDA_TARGET_UNIX", "PANDA_TARGET_MACOS", "PANDA_WITH_BYTECODE_OPTIMIZER", "PANDA_WITH_COMPILER", # "PANDA_USE_FUTEX", ] if (enable_irtoc) { defines += [ "PANDA_WITH_IRTOC" ] } if (enable_codegen) { defines += [ "PANDA_WITH_CODEGEN" ] } } 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" ] } if (enable_irtoc) { defines += [ "PANDA_WITH_IRTOC" ] } if (enable_codegen) { defines += [ "PANDA_WITH_CODEGEN" ] } } 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", ] if (ark_standalone_build) { cflags_cc += [ "-Wno-bitwise-instead-of-logical" ] } if (!is_mac && use_pbqp) { cflags_cc += [ # PBQP regalloc "-mllvm", "-regalloc=pbqp", ] } if (is_debug) { cflags_cc += [ "-Og", "-ggdb3", "-gdwarf-4", ] } if (is_asan) { cflags_cc += [ "-g" ] defines += [ "__SANITIZE_ADDRESS__" ] print("ASAN is enabled") } if (enable_relayout_profile) { defines += [ "PANDA_ENABLE_RELAYOUT_PROFILE" ] } configs = plugin_ark_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", ] } } concat_yamls("concat_plugins_yamls") { output_file = "$ark_plugin_options_yaml" default_file = "$ark_root/templates/plugin_options.yaml" add_yamls = plugin_option_yamls } concat_yamls("concat_entrypoints_yamls") { output_file = "$target_gen_dir/runtime/entrypoints.yaml" default_file = "$ark_root/runtime/entrypoints/entrypoints.yaml" add_yamls = plugin_entrypoints_yamls } concat_yamls("concat_inst_templates_yamls") { output_file = "$target_gen_dir/compiler/generated/inst_templates.yaml" default_file = "$ark_root/compiler/optimizer/ir_builder/inst_templates.yaml" add_yamls = plugin_inst_templates_yamls } merge_yamls("merge_runtime_options_yamls") { output_file = "$target_gen_dir/runtime_options.yaml" add_yamls = [ "$ark_root/runtime/options.yaml" ] + plugin_runtime_options_yamls } merge_yamls("merge_compiler_options_yamls") { output_file = "$target_gen_dir/compiler/generated/compiler_options.yaml" add_yamls = [ "$ark_root/compiler/compiler.yaml" ] + plugin_compiler_options_yamls }