2014-11-11 22:03:55 +00:00
|
|
|
# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
|
|
|
|
# for details. All rights reserved. Use of this source code is governed by a
|
|
|
|
# BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
2018-05-03 21:07:13 +00:00
|
|
|
import("../build/dart/dart_host_sdk_toolchain.gni")
|
2018-05-14 15:26:37 +00:00
|
|
|
import("configs.gni")
|
2017-01-30 17:55:20 +00:00
|
|
|
import("runtime_args.gni")
|
|
|
|
|
2019-05-07 00:43:33 +00:00
|
|
|
if (is_fuchsia) {
|
|
|
|
import("//build/fuchsia/sdk.gni")
|
|
|
|
}
|
|
|
|
|
2015-09-25 19:41:03 +00:00
|
|
|
config("dart_public_config") {
|
2018-11-26 16:30:33 +00:00
|
|
|
include_dirs = [
|
|
|
|
".",
|
|
|
|
"include",
|
|
|
|
]
|
2015-09-25 19:41:03 +00:00
|
|
|
}
|
|
|
|
|
2016-09-23 14:47:36 +00:00
|
|
|
# Adds PRODUCT define if Flutter has specified "release" for dart_runtime_mode
|
|
|
|
config("dart_maybe_product_config") {
|
2014-11-11 22:59:00 +00:00
|
|
|
defines = []
|
2015-10-22 19:26:41 +00:00
|
|
|
|
2016-10-26 15:50:54 +00:00
|
|
|
if (dart_runtime_mode != "develop" && dart_runtime_mode != "profile" &&
|
|
|
|
dart_runtime_mode != "release") {
|
2016-04-22 14:00:03 +00:00
|
|
|
print("Invalid |dart_runtime_mode|")
|
|
|
|
assert(false)
|
2014-11-11 22:59:00 +00:00
|
|
|
}
|
|
|
|
|
2016-04-22 14:00:03 +00:00
|
|
|
if (dart_runtime_mode == "release") {
|
2016-04-13 19:55:16 +00:00
|
|
|
if (dart_debug) {
|
2016-04-22 14:00:03 +00:00
|
|
|
print("Debug and release mode are mutually exclusive.")
|
2016-04-13 19:55:16 +00:00
|
|
|
}
|
|
|
|
assert(!dart_debug)
|
2016-10-26 15:50:54 +00:00
|
|
|
defines += [ "PRODUCT" ]
|
2016-04-13 19:55:16 +00:00
|
|
|
}
|
2016-04-22 14:00:03 +00:00
|
|
|
}
|
2016-04-13 19:55:16 +00:00
|
|
|
|
2017-07-16 04:43:47 +00:00
|
|
|
# This is a config to use to build PRODUCT mode artifacts in a RELEASE build.
|
|
|
|
# If a DEBUG build has been specified it will be ignored.
|
|
|
|
config("dart_product_config") {
|
|
|
|
defines = []
|
|
|
|
if (!dart_debug) {
|
|
|
|
defines += [ "PRODUCT" ]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-23 14:47:36 +00:00
|
|
|
config("dart_precompiled_runtime_config") {
|
|
|
|
defines = []
|
2018-05-23 20:35:53 +00:00
|
|
|
defines += [
|
|
|
|
"DART_PRECOMPILED_RUNTIME",
|
|
|
|
"EXCLUDE_CFE_AND_KERNEL_PLATFORM",
|
|
|
|
]
|
2016-09-23 14:47:36 +00:00
|
|
|
}
|
|
|
|
|
2016-04-22 14:00:03 +00:00
|
|
|
# Controls DART_PRECOMPILER #define.
|
|
|
|
config("dart_precompiler_config") {
|
|
|
|
defines = []
|
2016-10-26 15:50:54 +00:00
|
|
|
defines += [ "DART_PRECOMPILER" ]
|
2016-04-22 14:00:03 +00:00
|
|
|
}
|
|
|
|
|
2018-05-14 15:26:37 +00:00
|
|
|
config("dart_nosnapshot_config") {
|
2016-09-23 14:47:36 +00:00
|
|
|
defines = []
|
2016-10-26 15:50:54 +00:00
|
|
|
defines += [ "DART_NO_SNAPSHOT" ]
|
2016-09-23 14:47:36 +00:00
|
|
|
}
|
|
|
|
|
2017-10-31 17:33:13 +00:00
|
|
|
config("dart_os_config") {
|
2016-02-25 21:44:28 +00:00
|
|
|
defines = []
|
|
|
|
|
2017-11-02 19:02:18 +00:00
|
|
|
# If dart_host_toolchain is the current toolchain, and it is different from
|
|
|
|
# host_toolchain, then we are building the SDK for the host, and should not
|
|
|
|
# hardcode these defines.
|
|
|
|
if (current_toolchain != dart_host_toolchain ||
|
|
|
|
host_toolchain == dart_host_toolchain) {
|
|
|
|
if (target_os == "android") {
|
|
|
|
defines += [ "TARGET_OS_ANDROID" ]
|
|
|
|
} else if (target_os == "fuchsia") {
|
|
|
|
defines += [ "TARGET_OS_FUCHSIA" ]
|
|
|
|
} else if (target_os == "ios") {
|
|
|
|
defines += [ "TARGET_OS_MACOS" ]
|
|
|
|
defines += [ "TARGET_OS_MACOS_IOS" ]
|
|
|
|
} else if (target_os == "linux") {
|
|
|
|
defines += [ "TARGET_OS_LINUX" ]
|
|
|
|
} else if (target_os == "mac") {
|
|
|
|
defines += [ "TARGET_OS_MACOS" ]
|
|
|
|
} else if (target_os == "win") {
|
|
|
|
defines += [ "TARGET_OS_WINDOWS" ]
|
|
|
|
} else {
|
|
|
|
print("Unknown target_os: $target_os")
|
|
|
|
assert(false)
|
|
|
|
}
|
2017-06-21 22:19:17 +00:00
|
|
|
}
|
2017-10-31 17:33:13 +00:00
|
|
|
}
|
|
|
|
|
2018-03-28 19:39:49 +00:00
|
|
|
# We need to build gen_snapshot targeting Fuchsia during a build of the SDK
|
|
|
|
# targeting Mac and Linux. This configuration is used to unconditionally target
|
|
|
|
# Fuchsia. It should not be combined with dart_os_config.
|
|
|
|
config("dart_os_fuchsia_config") {
|
|
|
|
defines = [ "TARGET_OS_FUCHSIA" ]
|
|
|
|
}
|
|
|
|
|
2017-10-31 17:33:13 +00:00
|
|
|
config("dart_arch_config") {
|
|
|
|
defines = []
|
2017-06-21 22:19:17 +00:00
|
|
|
|
2017-11-02 19:02:18 +00:00
|
|
|
# If dart_host_toolchain is the current toolchain, and it is different from
|
|
|
|
# host_toolchain, then we are building the SDK for the host, and should not
|
|
|
|
# hardcode these defines.
|
|
|
|
if (current_toolchain != dart_host_toolchain ||
|
|
|
|
host_toolchain == dart_host_toolchain) {
|
|
|
|
if (dart_target_arch == "arm") {
|
|
|
|
defines += [ "TARGET_ARCH_ARM" ]
|
|
|
|
} else if (dart_target_arch == "armv6") {
|
|
|
|
defines += [ "TARGET_ARCH_ARM" ]
|
|
|
|
defines += [ "TARGET_ARCH_ARM_6" ]
|
|
|
|
} else if (dart_target_arch == "armv5te") {
|
|
|
|
defines += [ "TARGET_ARCH_ARM" ]
|
|
|
|
defines += [ "TARGET_ARCH_ARM_5TE" ]
|
|
|
|
} else if (dart_target_arch == "arm64") {
|
|
|
|
defines += [ "TARGET_ARCH_ARM64" ]
|
|
|
|
} else if (dart_target_arch == "x64") {
|
|
|
|
defines += [ "TARGET_ARCH_X64" ]
|
|
|
|
} else if (dart_target_arch == "ia32" || dart_target_arch == "x86") {
|
|
|
|
defines += [ "TARGET_ARCH_IA32" ]
|
|
|
|
} else if (dart_target_arch == "dbc") {
|
|
|
|
defines += [ "TARGET_ARCH_DBC" ]
|
|
|
|
defines += [ "USING_SIMULATOR" ]
|
|
|
|
} else {
|
|
|
|
print("Invalid dart_target_arch: $dart_target_arch")
|
|
|
|
assert(false)
|
|
|
|
}
|
2016-02-25 21:44:28 +00:00
|
|
|
}
|
2017-10-31 17:33:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
config("dart_config") {
|
|
|
|
defines = []
|
2016-02-25 21:44:28 +00:00
|
|
|
|
|
|
|
if (dart_debug) {
|
2016-10-26 15:50:54 +00:00
|
|
|
defines += [ "DEBUG" ]
|
2016-02-25 21:44:28 +00:00
|
|
|
} else {
|
2016-10-26 15:50:54 +00:00
|
|
|
defines += [ "NDEBUG" ]
|
2016-02-25 21:44:28 +00:00
|
|
|
}
|
|
|
|
|
2018-11-15 23:19:38 +00:00
|
|
|
include_dirs = [ "include" ]
|
2017-01-30 17:55:20 +00:00
|
|
|
if (dart_use_tcmalloc) {
|
|
|
|
defines += [ "DART_USE_TCMALLOC" ]
|
|
|
|
include_dirs += [ "../third_party/tcmalloc/gperftools/src" ]
|
|
|
|
}
|
|
|
|
|
2017-05-21 06:30:06 +00:00
|
|
|
if (is_fuchsia) {
|
2019-05-07 00:43:33 +00:00
|
|
|
if (using_fuchsia_sdk) {
|
|
|
|
# TODO(chinmaygarde): Currenty these targets need to be build in the
|
|
|
|
# Fuchsia tree as well as outside it using the SDK. However, not all
|
|
|
|
# Fuchsia features are available in the SDK. As these features are added,
|
|
|
|
# the guards can be removed. Eventually, only SDK builds will be present.
|
|
|
|
# Then, this flag can be removed completely.
|
|
|
|
defines += [ "FUCHSIA_SDK" ]
|
|
|
|
} else {
|
|
|
|
include_dirs += [ "//zircon/system/ulib/zx/include" ]
|
|
|
|
}
|
2017-04-19 22:50:59 +00:00
|
|
|
}
|
|
|
|
|
2016-10-04 16:19:07 +00:00
|
|
|
if (!is_win) {
|
|
|
|
cflags = [
|
|
|
|
"-Werror",
|
|
|
|
"-Wall",
|
2016-10-26 15:50:54 +00:00
|
|
|
"-Wextra", # Also known as -W.
|
2016-10-04 16:19:07 +00:00
|
|
|
"-Wno-unused-parameter",
|
2019-03-23 00:52:41 +00:00
|
|
|
"-Wno-unused-private-field",
|
2016-10-04 16:19:07 +00:00
|
|
|
"-Wnon-virtual-dtor",
|
|
|
|
"-Wvla",
|
|
|
|
"-Wno-conversion-null",
|
|
|
|
"-Woverloaded-virtual",
|
2018-09-17 22:27:43 +00:00
|
|
|
"-Wno-comments", # Conflicts with clang-format.
|
2016-10-04 16:19:07 +00:00
|
|
|
"-g3",
|
|
|
|
"-ggdb3",
|
|
|
|
"-fno-rtti",
|
|
|
|
"-fno-exceptions",
|
2019-02-15 01:12:01 +00:00
|
|
|
"-Wimplicit-fallthrough",
|
2016-02-25 21:44:28 +00:00
|
|
|
]
|
|
|
|
|
2018-10-16 22:11:05 +00:00
|
|
|
ldflags = []
|
|
|
|
if (is_clang && dart_vm_code_coverage) {
|
|
|
|
cflags += [
|
|
|
|
"-O0",
|
|
|
|
"-fprofile-arcs",
|
|
|
|
"-ftest-coverage",
|
|
|
|
]
|
|
|
|
ldflags += [ "--coverage" ]
|
|
|
|
} else if (dart_debug) {
|
2017-01-24 16:36:37 +00:00
|
|
|
cflags += [ "-O${dart_debug_optimization_level}" ]
|
2016-10-04 16:19:07 +00:00
|
|
|
} else {
|
2016-10-26 15:50:54 +00:00
|
|
|
cflags += [ "-O3" ]
|
2016-10-04 16:19:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (defined(is_asan) && is_asan) {
|
2017-01-03 22:37:27 +00:00
|
|
|
ldflags += [ "-fsanitize=address" ]
|
|
|
|
}
|
|
|
|
if (defined(is_msan) && is_msan) {
|
|
|
|
ldflags += [ "-fsanitize=memory" ]
|
|
|
|
}
|
|
|
|
if (defined(is_tsan) && is_tsan) {
|
|
|
|
ldflags += [ "-fsanitize=thread" ]
|
2016-10-04 16:19:07 +00:00
|
|
|
}
|
2019-01-09 02:56:22 +00:00
|
|
|
|
|
|
|
if (is_fuchsia) {
|
|
|
|
# safe-stack does not work with the interpreter.
|
|
|
|
cflags += [ "-fno-sanitize=safe-stack" ]
|
|
|
|
}
|
2016-02-25 21:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-25 23:58:57 +00:00
|
|
|
config("dart_shared_lib") {
|
|
|
|
if (dart_lib_export_symbols) {
|
|
|
|
defines = [ "DART_SHARED_LIB" ]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-25 21:29:42 +00:00
|
|
|
config("dart_libfuzzer_config") {
|
|
|
|
defines = [ "FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION" ]
|
|
|
|
cflags = [ "-fsanitize=address,fuzzer-no-link" ]
|
|
|
|
ldflags = [ "-fsanitize=address,fuzzer" ]
|
|
|
|
}
|
|
|
|
|
2017-04-10 20:44:21 +00:00
|
|
|
source_set("dart_api") {
|
|
|
|
public_configs = [ ":dart_public_config" ]
|
|
|
|
sources = [
|
|
|
|
"include/dart_api.h",
|
|
|
|
"include/dart_native_api.h",
|
|
|
|
"include/dart_tools_api.h",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-05-14 15:26:37 +00:00
|
|
|
library_for_all_configs("libdart") {
|
|
|
|
target_type = dart_component_kind
|
2017-07-16 04:43:47 +00:00
|
|
|
extra_deps = [
|
2018-05-14 15:26:37 +00:00
|
|
|
"third_party/double-conversion/src:libdouble_conversion",
|
|
|
|
":generate_version_cc_file",
|
2017-07-16 04:43:47 +00:00
|
|
|
]
|
2019-03-01 18:05:40 +00:00
|
|
|
if (is_fuchsia) {
|
2019-05-07 00:43:33 +00:00
|
|
|
if (using_fuchsia_sdk) {
|
|
|
|
extra_deps += [ "$fuchsia_sdk_root/pkg:fdio" ]
|
|
|
|
} else {
|
|
|
|
extra_deps += [
|
|
|
|
"//zircon/public/lib/fbl",
|
|
|
|
"//zircon/public/lib/trace-engine",
|
|
|
|
]
|
|
|
|
}
|
2019-03-01 18:05:40 +00:00
|
|
|
}
|
2018-05-14 15:26:37 +00:00
|
|
|
configurable_deps = [
|
2017-08-15 04:54:34 +00:00
|
|
|
"platform:libdart_platform",
|
2018-05-14 15:26:37 +00:00
|
|
|
"vm:libdart_lib",
|
|
|
|
"vm:libdart_vm",
|
2017-03-29 17:12:00 +00:00
|
|
|
]
|
2018-09-25 23:58:57 +00:00
|
|
|
extra_configs = [ ":dart_shared_lib" ]
|
2018-05-14 15:26:37 +00:00
|
|
|
include_dirs = [ "." ]
|
|
|
|
public_configs = [ ":dart_public_config" ]
|
|
|
|
sources = [
|
|
|
|
"$target_gen_dir/version.cc",
|
|
|
|
"include/dart_api.h",
|
|
|
|
"include/dart_native_api.h",
|
|
|
|
"include/dart_tools_api.h",
|
|
|
|
"vm/dart_api_impl.cc",
|
|
|
|
"vm/native_api_impl.cc",
|
|
|
|
"vm/version.h",
|
2017-07-16 04:43:47 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2014-11-11 22:03:55 +00:00
|
|
|
action("generate_version_cc_file") {
|
|
|
|
inputs = [
|
|
|
|
"../tools/utils.py",
|
|
|
|
"../tools/VERSION",
|
|
|
|
"vm/version_in.cc",
|
|
|
|
]
|
2018-06-11 18:22:09 +00:00
|
|
|
if (dart_version_git_info) {
|
|
|
|
inputs += [ "../.git/logs/HEAD" ]
|
|
|
|
}
|
2014-11-11 22:03:55 +00:00
|
|
|
output = "$target_gen_dir/version.cc"
|
2016-10-26 15:50:54 +00:00
|
|
|
outputs = [
|
|
|
|
output,
|
|
|
|
]
|
2014-11-11 22:03:55 +00:00
|
|
|
|
|
|
|
script = "../tools/make_version.py"
|
|
|
|
args = [
|
2015-01-21 15:18:23 +00:00
|
|
|
"--quiet",
|
2016-10-26 15:50:54 +00:00
|
|
|
"--output",
|
|
|
|
rebase_path(output, root_build_dir),
|
|
|
|
"--input",
|
|
|
|
rebase_path("vm/version_in.cc", root_build_dir),
|
2014-11-11 22:03:55 +00:00
|
|
|
]
|
2018-01-08 16:15:22 +00:00
|
|
|
if (!dart_version_git_info) {
|
2018-02-16 20:44:48 +00:00
|
|
|
args += [ "--no_git_hash" ]
|
|
|
|
}
|
|
|
|
if (dart_custom_version_for_pub != "") {
|
|
|
|
args += [
|
|
|
|
"--custom_for_pub",
|
|
|
|
dart_custom_version_for_pub,
|
|
|
|
]
|
2018-01-08 16:15:22 +00:00
|
|
|
}
|
2014-11-11 22:03:55 +00:00
|
|
|
}
|