mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
GN Build fixes for Flutter + gen_snapshot fix
1. Add "dart_runtime_mode" GN argument. This is an enum with three valid values: "release", "profile", and "develop". *) "release" builds product precompiled-runtime. *) "profile" builds non-product precompiled-runtime. *) "develop" builds non-product non-precompiled-runtime. 2. Remove the redundant "dart_product" GN argument. 3. Kill all *precompiled_runtime static library variants and the related config. 4. Always include the precompiler in gen_snapshot. 5. Support multiple --embedder_entry_points_manifest arguments to gen_snapshot. 6. Update our test harness to use gen_snapshot and pass the same kinds of command line arguments the Flutter folks are using. 7. ASSERT that both DART_PRECOMPILED_RUNTIME and DART_PRECOMPILER are not set at the same time. R=fschneider@google.com, rmacnak@google.com Review URL: https://codereview.chromium.org/1903583002 .
This commit is contained in:
parent
1889b1a581
commit
0cfd4f5cd5
8 changed files with 386 additions and 200 deletions
184
runtime/BUILD.gn
184
runtime/BUILD.gn
|
@ -12,9 +12,15 @@ declare_args() {
|
|||
# while themselves doing a Debug build.
|
||||
dart_debug = false
|
||||
|
||||
# Product mode drops many features (e.g. debugger, profiler, etc) in order to
|
||||
# shrink download size and decrease memory and cpu usage.
|
||||
dart_product = false
|
||||
# Set the runtime mode. This affects how the runtime is built and what
|
||||
# features it has. Valid values are:
|
||||
# 'develop' (the default) - VM is built to run as a JIT with all development
|
||||
# features enabled.
|
||||
# 'profile' - The VM is built to run with AOT compiled code with only the
|
||||
# CPU profiling features enabled.
|
||||
# 'release' - The VM is built to run with AOT compiled code with no developer
|
||||
# features enabled.
|
||||
dart_runtime_mode = "develop"
|
||||
|
||||
# Explicitly set the target architecture in case of precompilation. Leaving
|
||||
# this unspecified results in automatic target architecture detection.
|
||||
|
@ -28,6 +34,58 @@ config("dart_public_config") {
|
|||
]
|
||||
}
|
||||
|
||||
# Controls PRODUCT #define.
|
||||
config("dart_product_config") {
|
||||
defines = []
|
||||
|
||||
if ((dart_runtime_mode != "develop") &&
|
||||
(dart_runtime_mode != "profile") &&
|
||||
(dart_runtime_mode != "release")) {
|
||||
print("Invalid |dart_runtime_mode|")
|
||||
assert(false)
|
||||
}
|
||||
|
||||
if (dart_runtime_mode == "release") {
|
||||
if (dart_debug) {
|
||||
print("Debug and release mode are mutually exclusive.")
|
||||
}
|
||||
assert(!dart_debug)
|
||||
defines += ["PRODUCT"]
|
||||
}
|
||||
}
|
||||
|
||||
# Controls DART_PRECOMPILED_RUNTIME #define.
|
||||
config("dart_precompiled_runtime_config") {
|
||||
defines = []
|
||||
|
||||
if ((dart_runtime_mode != "develop") &&
|
||||
(dart_runtime_mode != "profile") &&
|
||||
(dart_runtime_mode != "release")) {
|
||||
print("Invalid |dart_runtime_mode|")
|
||||
assert(false)
|
||||
}
|
||||
|
||||
if (dart_runtime_mode == "release") {
|
||||
if (dart_debug) {
|
||||
print("Debug and release mode are mutually exclusive.")
|
||||
}
|
||||
assert(!dart_debug)
|
||||
defines += ["DART_PRECOMPILED_RUNTIME"]
|
||||
} else if (dart_runtime_mode == "profile") {
|
||||
if (dart_debug) {
|
||||
print("Debug and profile mode are mutually exclusive.")
|
||||
}
|
||||
assert(!dart_debug)
|
||||
defines += ["DART_PRECOMPILED_RUNTIME"]
|
||||
}
|
||||
}
|
||||
|
||||
# Controls DART_PRECOMPILER #define.
|
||||
config("dart_precompiler_config") {
|
||||
defines = []
|
||||
defines += ["DART_PRECOMPILER"]
|
||||
}
|
||||
|
||||
config("dart_config") {
|
||||
defines = []
|
||||
|
||||
|
@ -56,17 +114,6 @@ config("dart_config") {
|
|||
defines += ["NDEBUG"]
|
||||
}
|
||||
|
||||
if (dart_product) {
|
||||
if (dart_debug) {
|
||||
print("Debug and product mode are mutually exclusive.")
|
||||
}
|
||||
assert(!dart_debug)
|
||||
defines += ["PRODUCT"]
|
||||
}
|
||||
|
||||
# Ideally this would only be enabled for gen_snapshot
|
||||
defines += ["DART_PRECOMPILER"]
|
||||
|
||||
cflags = [
|
||||
"-Werror",
|
||||
"-Wall",
|
||||
|
@ -100,78 +147,10 @@ config("dart_config") {
|
|||
}
|
||||
}
|
||||
|
||||
config("dart_config_no_precompiler") {
|
||||
defines = []
|
||||
|
||||
if (dart_target_arch != "") {
|
||||
if (dart_target_arch == "arm") {
|
||||
defines += [ "TARGET_ARCH_ARM" ]
|
||||
} else if (dart_target_arch == "arm64") {
|
||||
defines += [ "TARGET_ARCH_ARM64" ]
|
||||
} else if (dart_target_arch == "mips") {
|
||||
defines += [ "TARGET_ARCH_MIPS" ]
|
||||
} else if (dart_target_arch == "x64") {
|
||||
defines += [ "TARGET_ARCH_X64" ]
|
||||
} else if (dart_target_arch == "ia32") {
|
||||
defines += [ "TARGET_ARCH_IA32" ]
|
||||
} else if (dart_target_arch == "dbc") {
|
||||
defines += [ "TARGET_ARCH_DBC" ]
|
||||
} else {
|
||||
print("Invalid |dart_target_arch|")
|
||||
assert(false)
|
||||
}
|
||||
}
|
||||
|
||||
if (dart_debug) {
|
||||
defines += ["DEBUG"]
|
||||
} else {
|
||||
defines += ["NDEBUG"]
|
||||
}
|
||||
|
||||
if (dart_product) {
|
||||
if (dart_debug) {
|
||||
print("Debug and product mode are mutually exclusive.")
|
||||
}
|
||||
assert(!dart_debug)
|
||||
defines += ["PRODUCT"]
|
||||
}
|
||||
|
||||
cflags = [
|
||||
"-Werror",
|
||||
"-Wall",
|
||||
"-Wextra", # Also known as -W.
|
||||
"-Wno-unused-parameter",
|
||||
"-Wnon-virtual-dtor",
|
||||
"-Wvla",
|
||||
"-Wno-conversion-null",
|
||||
"-Woverloaded-virtual",
|
||||
"-g3",
|
||||
"-ggdb3",
|
||||
"-fno-rtti",
|
||||
"-fno-exceptions",
|
||||
]
|
||||
|
||||
if (dart_debug) {
|
||||
cflags += [
|
||||
"-O1",
|
||||
]
|
||||
} else {
|
||||
cflags += [
|
||||
"-O3",
|
||||
]
|
||||
}
|
||||
|
||||
if (is_asan) {
|
||||
ldflags = [
|
||||
"-Wl,-u_sanitizer_options_link_helper",
|
||||
"-fsanitize=address",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static_library("libdart") {
|
||||
configs += [":dart_config"]
|
||||
configs += [":dart_config",
|
||||
":dart_product_config",
|
||||
":dart_precompiled_runtime_config"]
|
||||
deps = [
|
||||
"vm:libdart_lib",
|
||||
"vm:libdart_vm",
|
||||
|
@ -196,37 +175,6 @@ static_library("libdart") {
|
|||
]
|
||||
}
|
||||
|
||||
|
||||
static_library("libdart_precompiled_runtime") {
|
||||
configs += [":dart_config_no_precompiler"]
|
||||
deps = [
|
||||
"vm:libdart_lib_precompiled_runtime",
|
||||
"vm:libdart_vm_precompiled_runtime",
|
||||
"third_party/double-conversion/src:libdouble_conversion",
|
||||
":generate_version_cc_file",
|
||||
]
|
||||
include_dirs = [
|
||||
".",
|
||||
]
|
||||
public_configs = [":dart_public_config"]
|
||||
sources = [
|
||||
"include/dart_api.h",
|
||||
"include/dart_mirrors_api.h",
|
||||
"include/dart_native_api.h",
|
||||
"include/dart_tools_api.h",
|
||||
"vm/dart_api_impl.cc",
|
||||
"vm/debugger_api_impl.cc",
|
||||
"vm/mirrors_api_impl.cc",
|
||||
"vm/native_api_impl.cc",
|
||||
"vm/version.h",
|
||||
"$target_gen_dir/version.cc",
|
||||
]
|
||||
defines = [
|
||||
"DART_PRECOMPILED_RUNTIME",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
action("generate_version_cc_file") {
|
||||
deps = [
|
||||
":libdart_dependency_helper",
|
||||
|
@ -251,7 +199,9 @@ action("generate_version_cc_file") {
|
|||
|
||||
|
||||
executable("libdart_dependency_helper") {
|
||||
configs += [":dart_config"]
|
||||
configs += [":dart_config",
|
||||
":dart_product_config",
|
||||
":dart_precompiled_runtime_config"]
|
||||
deps = [
|
||||
"vm:libdart_lib_nosnapshot",
|
||||
"vm:libdart_lib",
|
||||
|
|
|
@ -119,7 +119,7 @@ builtin_impl_sources_gypi =
|
|||
["builtin_impl_sources.gypi"])
|
||||
|
||||
static_library("libdart_builtin") {
|
||||
configs += ["..:dart_config"]
|
||||
configs += ["..:dart_config", "..:dart_product_config"]
|
||||
public_configs = [":libdart_builtin_config"]
|
||||
deps = [
|
||||
":generate_builtin_cc_file",
|
||||
|
@ -140,7 +140,9 @@ static_library("libdart_builtin") {
|
|||
|
||||
|
||||
static_library("libdart_nosnapshot") {
|
||||
configs += ["..:dart_config"]
|
||||
configs += ["..:dart_config",
|
||||
"..:dart_product_config",
|
||||
"..:dart_precompiled_runtime_config"]
|
||||
deps = [
|
||||
"../vm:libdart_lib_nosnapshot",
|
||||
"../vm:libdart_vm_nosnapshot",
|
||||
|
@ -171,8 +173,44 @@ static_library("libdart_nosnapshot") {
|
|||
}
|
||||
|
||||
|
||||
static_library("libdart_nosnapshot_with_precompiler") {
|
||||
configs += ["..:dart_config",
|
||||
"..:dart_product_config",
|
||||
"..:dart_precompiler_config"]
|
||||
deps = [
|
||||
"../vm:libdart_lib_nosnapshot_with_precompiler",
|
||||
"../vm:libdart_vm_nosnapshot_with_precompiler",
|
||||
"../vm:libdart_platform",
|
||||
"../third_party/double-conversion/src:libdouble_conversion",
|
||||
"..:generate_version_cc_file",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"../include/dart_api.h",
|
||||
"../include/dart_mirrors_api.h",
|
||||
"../include/dart_native_api.h",
|
||||
"../include/dart_tools_api.h",
|
||||
"../vm/dart_api_impl.cc",
|
||||
"../vm/debugger_api_impl.cc",
|
||||
"../vm/mirrors_api_impl.cc",
|
||||
"../vm/native_api_impl.cc",
|
||||
"$target_gen_dir/../version.cc",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
"..",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"DART_SHARED_LIB",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
executable("gen_snapshot") {
|
||||
configs += ["..:dart_config"]
|
||||
configs += ["..:dart_config",
|
||||
"..:dart_product_config",
|
||||
"..:dart_precompiler_config"]
|
||||
deps = [
|
||||
":gen_resources_cc",
|
||||
":gen_snapshot_dart_io",
|
||||
|
@ -180,7 +218,7 @@ executable("gen_snapshot") {
|
|||
":generate_io_cc_file",
|
||||
":generate_io_patch_cc_file",
|
||||
":libdart_builtin",
|
||||
":libdart_nosnapshot",
|
||||
":libdart_nosnapshot_with_precompiler",
|
||||
]
|
||||
|
||||
sources = [
|
||||
|
@ -207,7 +245,9 @@ executable("gen_snapshot") {
|
|||
|
||||
|
||||
source_set("libdart_embedder_noio") {
|
||||
configs += ["..:dart_config",]
|
||||
configs += ["..:dart_config",
|
||||
"..:dart_product_config",
|
||||
"..:dart_precompiled_runtime_config"]
|
||||
deps = [
|
||||
"..:libdart",
|
||||
"../vm:libdart_platform",
|
||||
|
@ -224,7 +264,9 @@ io_impl_sources_gypi =
|
|||
# A source set for the implementation of 'dart:io' library
|
||||
# (without secure sockets) suitable for linking with gen_snapshot.
|
||||
source_set("gen_snapshot_dart_io") {
|
||||
configs += ["..:dart_config",]
|
||||
configs += ["..:dart_config",
|
||||
"..:dart_product_config",
|
||||
"..:dart_precompiler_config"]
|
||||
|
||||
deps = [
|
||||
"//third_party/zlib",
|
||||
|
@ -263,7 +305,9 @@ source_set("gen_snapshot_dart_io") {
|
|||
# A source set for the implementation of 'dart:io' library
|
||||
# (without secure sockets).
|
||||
source_set("embedded_dart_io") {
|
||||
configs += ["..:dart_config",]
|
||||
configs += ["..:dart_config",
|
||||
"..:dart_product_config",
|
||||
"..:dart_precompiled_runtime_config"]
|
||||
|
||||
custom_sources_filter = [
|
||||
"*_test.cc",
|
||||
|
|
1
runtime/bin/dart_entries.txt
Normal file
1
runtime/bin/dart_entries.txt
Normal file
|
@ -0,0 +1 @@
|
|||
dart:vmservice_io,::,main
|
27
runtime/bin/dart_product_entries.txt
Normal file
27
runtime/bin/dart_product_entries.txt
Normal file
|
@ -0,0 +1,27 @@
|
|||
dart:_builtin,::,_getMainClosure
|
||||
dart:_builtin,::,_getPrintClosure
|
||||
dart:_builtin,::,_getUriBaseClosure
|
||||
dart:_builtin,::,_resolveUri
|
||||
dart:_builtin,::,_setWorkingDirectory
|
||||
dart:_builtin,::,_setPackageRoot
|
||||
dart:_builtin,::,_loadPackagesMap
|
||||
dart:_builtin,::,_loadDataAsync
|
||||
dart:io,::,_makeUint8ListView
|
||||
dart:io,::,_makeDatagram
|
||||
dart:io,::,_setupHooks
|
||||
dart:io,::,_getWatchSignalInternal
|
||||
dart:io,CertificateException,CertificateException.
|
||||
dart:io,Directory,Directory.
|
||||
dart:io,File,File.
|
||||
dart:io,FileSystemException,FileSystemException.
|
||||
dart:io,HandshakeException,HandshakeException.
|
||||
dart:io,Link,Link.
|
||||
dart:io,OSError,OSError.
|
||||
dart:io,TlsException,TlsException.
|
||||
dart:io,X509Certificate,X509Certificate._
|
||||
dart:io,_ExternalBuffer,set:data
|
||||
dart:io,_Platform,set:_nativeScript
|
||||
dart:io,_ProcessStartStatus,set:_errorCode
|
||||
dart:io,_ProcessStartStatus,set:_errorMessage
|
||||
dart:io,_SecureFilterImpl,get:ENCRYPTED_SIZE
|
||||
dart:io,_SecureFilterImpl,get:SIZE
|
|
@ -22,18 +22,38 @@
|
|||
|
||||
#include "include/dart_api.h"
|
||||
|
||||
#include "platform/hashmap.h"
|
||||
#include "platform/globals.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
||||
// Exit code indicating an API error.
|
||||
static const int kApiErrorExitCode = 253;
|
||||
// Exit code indicating a compilation error.
|
||||
static const int kCompilationErrorExitCode = 254;
|
||||
// Exit code indicating an unhandled error that is not a compilation error.
|
||||
static const int kErrorExitCode = 255;
|
||||
// Exit code indicating a vm restart request. Never returned to the user.
|
||||
static const int kRestartRequestExitCode = 1000;
|
||||
|
||||
#define CHECK_RESULT(result) \
|
||||
if (Dart_IsError(result)) { \
|
||||
intptr_t exit_code = 0; \
|
||||
Log::PrintErr("Error: %s", Dart_GetError(result)); \
|
||||
if (Dart_IsCompilationError(result)) { \
|
||||
exit_code = kCompilationErrorExitCode; \
|
||||
} else if (Dart_IsApiError(result)) { \
|
||||
exit_code = kApiErrorExitCode; \
|
||||
} else if (Dart_IsVMRestartRequest(result)) { \
|
||||
exit_code = kRestartRequestExitCode; \
|
||||
} else { \
|
||||
exit_code = kErrorExitCode; \
|
||||
} \
|
||||
Dart_ExitScope(); \
|
||||
Dart_ShutdownIsolate(); \
|
||||
exit(255); \
|
||||
} \
|
||||
exit(exit_code); \
|
||||
}
|
||||
|
||||
|
||||
// Global state that indicates whether a snapshot is to be created and
|
||||
|
@ -41,7 +61,6 @@ namespace bin {
|
|||
static const char* vm_isolate_snapshot_filename = NULL;
|
||||
static const char* isolate_snapshot_filename = NULL;
|
||||
static const char* instructions_snapshot_filename = NULL;
|
||||
static const char* embedder_entry_points_manifest = NULL;
|
||||
static const char* package_root = NULL;
|
||||
|
||||
|
||||
|
@ -54,6 +73,10 @@ static char* app_script_name = NULL;
|
|||
// Global state that captures the URL mappings specified on the command line.
|
||||
static CommandLineOptions* url_mapping = NULL;
|
||||
|
||||
// Global state that captures the entry point manifest files specified on the
|
||||
// command line.
|
||||
static CommandLineOptions* entry_points_files = NULL;
|
||||
|
||||
static bool IsValidFlag(const char* name,
|
||||
const char* prefix,
|
||||
intptr_t prefix_length) {
|
||||
|
@ -63,6 +86,93 @@ static bool IsValidFlag(const char* name,
|
|||
}
|
||||
|
||||
|
||||
// The environment provided through the command line using -D options.
|
||||
static dart::HashMap* environment = NULL;
|
||||
|
||||
static void* GetHashmapKeyFromString(char* key) {
|
||||
return reinterpret_cast<void*>(key);
|
||||
}
|
||||
|
||||
static bool ProcessEnvironmentOption(const char* arg) {
|
||||
ASSERT(arg != NULL);
|
||||
if (*arg == '\0') {
|
||||
return false;
|
||||
}
|
||||
if (*arg != '-') {
|
||||
return false;
|
||||
}
|
||||
if (*(arg + 1) != 'D') {
|
||||
return false;
|
||||
}
|
||||
arg = arg + 2;
|
||||
if (*arg == '\0') {
|
||||
return true;
|
||||
}
|
||||
if (environment == NULL) {
|
||||
environment = new HashMap(&HashMap::SameStringValue, 4);
|
||||
}
|
||||
// Split the name=value part of the -Dname=value argument.
|
||||
char* name;
|
||||
char* value = NULL;
|
||||
const char* equals_pos = strchr(arg, '=');
|
||||
if (equals_pos == NULL) {
|
||||
// No equal sign (name without value) currently not supported.
|
||||
Log::PrintErr("No value given to -D option\n");
|
||||
return false;
|
||||
} else {
|
||||
int name_len = equals_pos - arg;
|
||||
if (name_len == 0) {
|
||||
Log::PrintErr("No name given to -D option\n");
|
||||
return false;
|
||||
}
|
||||
// Split name=value into name and value.
|
||||
name = reinterpret_cast<char*>(malloc(name_len + 1));
|
||||
strncpy(name, arg, name_len);
|
||||
name[name_len] = '\0';
|
||||
value = strdup(equals_pos + 1);
|
||||
}
|
||||
HashMap::Entry* entry = environment->Lookup(
|
||||
GetHashmapKeyFromString(name), HashMap::StringHash(name), true);
|
||||
ASSERT(entry != NULL); // Lookup adds an entry if key not found.
|
||||
entry->value = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static Dart_Handle EnvironmentCallback(Dart_Handle name) {
|
||||
uint8_t* utf8_array;
|
||||
intptr_t utf8_len;
|
||||
Dart_Handle result = Dart_Null();
|
||||
Dart_Handle handle = Dart_StringToUTF8(name, &utf8_array, &utf8_len);
|
||||
if (Dart_IsError(handle)) {
|
||||
handle = Dart_ThrowException(
|
||||
DartUtils::NewDartArgumentError(Dart_GetError(handle)));
|
||||
} else {
|
||||
char* name_chars = reinterpret_cast<char*>(malloc(utf8_len + 1));
|
||||
memmove(name_chars, utf8_array, utf8_len);
|
||||
name_chars[utf8_len] = '\0';
|
||||
const char* value = NULL;
|
||||
printf("Looking for %s\n", name_chars);
|
||||
if (environment != NULL) {
|
||||
HashMap::Entry* entry = environment->Lookup(
|
||||
GetHashmapKeyFromString(name_chars),
|
||||
HashMap::StringHash(name_chars),
|
||||
false);
|
||||
if (entry != NULL) {
|
||||
value = reinterpret_cast<char*>(entry->value);
|
||||
}
|
||||
}
|
||||
if (value != NULL) {
|
||||
result = Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(value),
|
||||
strlen(value));
|
||||
}
|
||||
free(name_chars);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const char* ProcessOption(const char* option, const char* name) {
|
||||
const intptr_t length = strlen(name);
|
||||
if (strncmp(option, name, length) == 0) {
|
||||
|
@ -105,7 +215,7 @@ static bool ProcessInstructionsSnapshotOption(const char* option) {
|
|||
static bool ProcessEmbedderEntryPointsManifestOption(const char* option) {
|
||||
const char* name = ProcessOption(option, "--embedder_entry_points_manifest=");
|
||||
if (name != NULL) {
|
||||
embedder_entry_points_manifest = name;
|
||||
entry_points_files->AddArgument(name);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -114,6 +224,9 @@ static bool ProcessEmbedderEntryPointsManifestOption(const char* option) {
|
|||
|
||||
static bool ProcessPackageRootOption(const char* option) {
|
||||
const char* name = ProcessOption(option, "--package_root=");
|
||||
if (name == NULL) {
|
||||
name = ProcessOption(option, "--package-root=");
|
||||
}
|
||||
if (name != NULL) {
|
||||
package_root = name;
|
||||
return true;
|
||||
|
@ -141,7 +254,7 @@ static int ParseArguments(int argc,
|
|||
char** argv,
|
||||
CommandLineOptions* vm_options,
|
||||
char** script_name) {
|
||||
const char* kPrefix = "--";
|
||||
const char* kPrefix = "-";
|
||||
const intptr_t kPrefixLen = strlen(kPrefix);
|
||||
|
||||
// Skip the binary name.
|
||||
|
@ -154,7 +267,8 @@ static int ParseArguments(int argc,
|
|||
ProcessInstructionsSnapshotOption(argv[i]) ||
|
||||
ProcessEmbedderEntryPointsManifestOption(argv[i]) ||
|
||||
ProcessURLmappingOption(argv[i]) ||
|
||||
ProcessPackageRootOption(argv[i])) {
|
||||
ProcessPackageRootOption(argv[i]) ||
|
||||
ProcessEnvironmentOption(argv[i])) {
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -181,14 +295,14 @@ static int ParseArguments(int argc,
|
|||
}
|
||||
|
||||
if ((instructions_snapshot_filename != NULL) &&
|
||||
(embedder_entry_points_manifest == NULL)) {
|
||||
(entry_points_files->count() == 0)) {
|
||||
Log::PrintErr(
|
||||
"Specifying an instructions snapshot filename indicates precompilation"
|
||||
". But no embedder entry points manifest was specified.\n\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((embedder_entry_points_manifest != NULL) &&
|
||||
if ((entry_points_files->count() > 0) &&
|
||||
(instructions_snapshot_filename == NULL)) {
|
||||
Log::PrintErr(
|
||||
"Specifying the embedder entry points manifest indicates "
|
||||
|
@ -201,8 +315,8 @@ static int ParseArguments(int argc,
|
|||
|
||||
|
||||
static bool IsSnapshottingForPrecompilation(void) {
|
||||
return embedder_entry_points_manifest != NULL &&
|
||||
instructions_snapshot_filename != NULL;
|
||||
return (entry_points_files->count() > 0) &&
|
||||
(instructions_snapshot_filename != NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -510,9 +624,7 @@ static void VerifyLoaded(Dart_Handle library) {
|
|||
if (Dart_IsError(library)) {
|
||||
const char* err_msg = Dart_GetError(library);
|
||||
Log::PrintErr("Errors encountered while loading: %s\n", err_msg);
|
||||
Dart_ExitScope();
|
||||
Dart_ShutdownIsolate();
|
||||
exit(255);
|
||||
CHECK_RESULT(library);
|
||||
}
|
||||
ASSERT(Dart_IsLibrary(library));
|
||||
}
|
||||
|
@ -781,31 +893,34 @@ int64_t ParseEntryPointsManifestLines(FILE* file,
|
|||
}
|
||||
|
||||
|
||||
static Dart_QualifiedFunctionName* ParseEntryPointsManifestFile(
|
||||
const char* path) {
|
||||
if (path == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
static Dart_QualifiedFunctionName* ParseEntryPointsManifestFiles() {
|
||||
// Total number of entries across all manifest files.
|
||||
int64_t entry_count = 0;
|
||||
|
||||
FILE* file = fopen(path, "r");
|
||||
|
||||
if (file == NULL) {
|
||||
Log::PrintErr("Could not open entry points manifest file\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Parse the file once but don't store the results. This is done to first
|
||||
// Parse the files once but don't store the results. This is done to first
|
||||
// determine the number of entries in the manifest
|
||||
int64_t entry_count = ParseEntryPointsManifestLines(file, NULL);
|
||||
for (intptr_t i = 0; i < entry_points_files->count(); i++) {
|
||||
const char* path = entry_points_files->GetArgument(i);
|
||||
|
||||
if (entry_count <= 0) {
|
||||
Log::PrintErr(
|
||||
"Manifest file specified is invalid or contained no entries\n");
|
||||
FILE* file = fopen(path, "r");
|
||||
|
||||
if (file == NULL) {
|
||||
Log::PrintErr("Could not open entry points manifest file `%s`\n", path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int64_t entries = ParseEntryPointsManifestLines(file, NULL);
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rewind(file);
|
||||
if (entries <= 0) {
|
||||
Log::PrintErr(
|
||||
"Manifest file `%s` specified is invalid or contained no entries\n",
|
||||
path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
entry_count += entries;
|
||||
}
|
||||
|
||||
// Allocate enough storage for the entries in the file plus a termination
|
||||
// sentinel and parse it again to populate the allocation
|
||||
|
@ -813,10 +928,16 @@ static Dart_QualifiedFunctionName* ParseEntryPointsManifestFile(
|
|||
reinterpret_cast<Dart_QualifiedFunctionName*>(
|
||||
calloc(entry_count + 1, sizeof(Dart_QualifiedFunctionName)));
|
||||
|
||||
int64_t parsed_entry_count = ParseEntryPointsManifestLines(file, entries);
|
||||
ASSERT(parsed_entry_count == entry_count);
|
||||
int64_t parsed_entry_count = 0;
|
||||
for (intptr_t i = 0; i < entry_points_files->count(); i++) {
|
||||
const char* path = entry_points_files->GetArgument(i);
|
||||
FILE* file = fopen(path, "r");
|
||||
parsed_entry_count +=
|
||||
ParseEntryPointsManifestLines(file, &entries[parsed_entry_count]);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
ASSERT(parsed_entry_count == entry_count);
|
||||
|
||||
// The entries allocation must be explicitly cleaned up via
|
||||
// |CleanupEntryPointsCollection|
|
||||
|
@ -825,8 +946,7 @@ static Dart_QualifiedFunctionName* ParseEntryPointsManifestFile(
|
|||
|
||||
|
||||
static Dart_QualifiedFunctionName* ParseEntryPointsManifestIfPresent() {
|
||||
Dart_QualifiedFunctionName* entries =
|
||||
ParseEntryPointsManifestFile(embedder_entry_points_manifest);
|
||||
Dart_QualifiedFunctionName* entries = ParseEntryPointsManifestFiles();
|
||||
if ((entries == NULL) && IsSnapshottingForPrecompilation()) {
|
||||
Log::PrintErr(
|
||||
"Could not find native embedder entry points during precompilation\n");
|
||||
|
@ -998,6 +1118,10 @@ int main(int argc, char** argv) {
|
|||
CommandLineOptions url_mapping_array(argc);
|
||||
url_mapping = &url_mapping_array;
|
||||
|
||||
// Initialize the entrypoints array.
|
||||
CommandLineOptions entry_points_files_array(argc);
|
||||
entry_points_files = &entry_points_files_array;
|
||||
|
||||
// Parse command line arguments.
|
||||
if (ParseArguments(argc,
|
||||
argv,
|
||||
|
@ -1067,6 +1191,9 @@ int main(int argc, char** argv) {
|
|||
Dart_Handle library;
|
||||
Dart_EnterScope();
|
||||
|
||||
result = Dart_SetEnvironmentCallback(EnvironmentCallback);
|
||||
CHECK_RESULT(result);
|
||||
|
||||
ASSERT(vm_isolate_snapshot_filename != NULL);
|
||||
ASSERT(isolate_snapshot_filename != NULL);
|
||||
// Load up the script before a snapshot is created.
|
||||
|
@ -1108,6 +1235,8 @@ int main(int argc, char** argv) {
|
|||
exit(255);
|
||||
}
|
||||
Dart_EnterScope();
|
||||
result = Dart_SetEnvironmentCallback(EnvironmentCallback);
|
||||
CHECK_RESULT(result);
|
||||
|
||||
// Set up the library tag handler in such a manner that it will use the
|
||||
// URL mapping specified on the command line to load the libraries.
|
||||
|
@ -1129,8 +1258,7 @@ int main(int argc, char** argv) {
|
|||
result = Dart_FinalizeLoading(false);
|
||||
CHECK_RESULT(result);
|
||||
|
||||
if (entry_points == NULL) {
|
||||
ASSERT(!IsSnapshottingForPrecompilation());
|
||||
if (!IsSnapshottingForPrecompilation()) {
|
||||
CreateAndWriteSnapshot();
|
||||
} else {
|
||||
CreateAndWritePrecompiledSnapshot(entry_points);
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
// 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.
|
||||
|
||||
#ifndef PLATFORM_GLOBALS_H_
|
||||
#define PLATFORM_GLOBALS_H_
|
||||
#ifndef RUNTIME_PLATFORM_GLOBALS_H_
|
||||
#define RUNTIME_PLATFORM_GLOBALS_H_
|
||||
|
||||
// __STDC_FORMAT_MACROS has to be defined before including <inttypes.h> to
|
||||
// enable platform independent printf format specifiers.
|
||||
|
@ -136,6 +136,10 @@
|
|||
#endif // defined(PRODUCT)
|
||||
|
||||
|
||||
#if defined(DART_PRECOMPILED_RUNTIME) && defined(DART_PRECOMPILER)
|
||||
#error DART_PRECOMPILED_RUNTIME and DART_PRECOMPILER are mutually exclusive
|
||||
#endif // defined(DART_PRECOMPILED_RUNTIME) && defined(DART_PRECOMPILER)
|
||||
|
||||
namespace dart {
|
||||
|
||||
struct simd128_value_t {
|
||||
|
@ -674,4 +678,4 @@ static inline T ReadUnaligned(const T* ptr) {
|
|||
|
||||
} // namespace dart
|
||||
|
||||
#endif // PLATFORM_GLOBALS_H_
|
||||
#endif // RUNTIME_PLATFORM_GLOBALS_H_
|
||||
|
|
|
@ -18,7 +18,7 @@ config("libdart_vm_config") {
|
|||
|
||||
|
||||
static_library("libdart_platform") {
|
||||
configs += ["..:dart_config"]
|
||||
configs += ["..:dart_config", "..:dart_product_config"]
|
||||
public_configs = [":libdart_vm_config"]
|
||||
|
||||
platform_headers_gypi =
|
||||
|
@ -43,9 +43,10 @@ static_library("libdart_platform") {
|
|||
]
|
||||
}
|
||||
|
||||
|
||||
static_library("libdart_vm") {
|
||||
configs += ["..:dart_config"]
|
||||
configs += ["..:dart_config",
|
||||
"..:dart_product_config",
|
||||
"..:dart_precompiled_runtime_config"]
|
||||
public_configs = [":libdart_vm_config"]
|
||||
|
||||
vm_sources_list = exec_script("../../tools/gypi_to_gn.py",
|
||||
|
@ -61,25 +62,29 @@ static_library("libdart_vm") {
|
|||
}
|
||||
|
||||
|
||||
static_library("libdart_vm_precompiled_runtime") {
|
||||
configs += ["..:dart_config_no_precompiler"]
|
||||
public_configs = [":libdart_vm_config"]
|
||||
defines = ["DART_PRECOMPILED_RUNTIME"]
|
||||
vm_sources_list = exec_script("../../tools/gypi_to_gn.py",
|
||||
[rebase_path("vm_sources.gypi")],
|
||||
"scope",
|
||||
["vm_sources.gypi"])
|
||||
|
||||
set_sources_assignment_filter(["*_test.cc", "*_test.h"])
|
||||
sources = vm_sources_list.sources
|
||||
include_dirs = [
|
||||
"..",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
static_library("libdart_vm_nosnapshot") {
|
||||
configs += ["..:dart_config"]
|
||||
configs += ["..:dart_config",
|
||||
"..:dart_product_config",
|
||||
"..:dart_precompiled_runtime_config"]
|
||||
public_configs = [":libdart_vm_config"]
|
||||
defines = [ "DART_NO_SNAPSHOT" ]
|
||||
vm_sources_list = exec_script("../../tools/gypi_to_gn.py",
|
||||
[rebase_path("vm_sources.gypi")],
|
||||
"scope",
|
||||
["vm_sources.gypi"])
|
||||
|
||||
set_sources_assignment_filter(["*_test.cc", "*_test.h"])
|
||||
sources = vm_sources_list.sources
|
||||
include_dirs = [
|
||||
"..",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
static_library("libdart_vm_nosnapshot_with_precompiler") {
|
||||
configs += ["..:dart_config",
|
||||
"..:dart_product_config",
|
||||
"..:dart_precompiler_config"]
|
||||
public_configs = [":libdart_vm_config"]
|
||||
defines = [ "DART_NO_SNAPSHOT" ]
|
||||
vm_sources_list = exec_script("../../tools/gypi_to_gn.py",
|
||||
|
@ -185,24 +190,30 @@ template("generate_core_libraries") {
|
|||
}
|
||||
|
||||
static_library("libdart_lib_nosnapshot") {
|
||||
configs += ["..:dart_config"]
|
||||
configs += ["..:dart_config",
|
||||
"..:dart_product_config",
|
||||
"..:dart_precompiled_runtime_config"]
|
||||
deps = libdeps
|
||||
sources = libsources + ["bootstrap.cc"] + liboutputs
|
||||
include_dirs = [
|
||||
"..",
|
||||
]
|
||||
}
|
||||
static_library("libdart_lib") {
|
||||
configs += ["..:dart_config"]
|
||||
sources = libsources + [ "bootstrap_nocore.cc", ]
|
||||
static_library("libdart_lib_nosnapshot_with_precompiler") {
|
||||
configs += ["..:dart_config",
|
||||
"..:dart_product_config",
|
||||
"..:dart_precompiler_config" ]
|
||||
deps = libdeps
|
||||
sources = libsources + [ "bootstrap.cc"] + liboutputs
|
||||
include_dirs = [
|
||||
"..",
|
||||
]
|
||||
}
|
||||
static_library("libdart_lib_precompiled_runtime") {
|
||||
configs += ["..:dart_config_no_precompiler"]
|
||||
defines = ["DART_PRECOMPILED_RUNTIME"]
|
||||
sources = libsources + [ "bootstrap_nocore.cc", ]
|
||||
static_library("libdart_lib") {
|
||||
configs += ["..:dart_config",
|
||||
"..:dart_product_config",
|
||||
"..:dart_precompiled_runtime_config"]
|
||||
sources = libsources + [ "bootstrap_nocore.cc"]
|
||||
include_dirs = [
|
||||
"..",
|
||||
]
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
library compiler_configuration;
|
||||
|
||||
import 'dart:io' show Platform;
|
||||
import 'dart:io' show Directory, Platform;
|
||||
|
||||
import 'runtime_configuration.dart' show RuntimeConfiguration;
|
||||
|
||||
|
@ -47,6 +47,7 @@ abstract class CompilerConfiguration {
|
|||
// which can eventually completely replace the Map-based configuration
|
||||
// object.
|
||||
bool isDebug = configuration['mode'] == 'debug';
|
||||
bool isProduct = configuration['mode'] == 'product';
|
||||
bool isChecked = configuration['checked'];
|
||||
bool isHostChecked = configuration['host_checked'];
|
||||
bool useSdk = configuration['use_sdk'];
|
||||
|
@ -77,6 +78,7 @@ abstract class CompilerConfiguration {
|
|||
return new PrecompilerCompilerConfiguration(
|
||||
isDebug: isDebug,
|
||||
isChecked: isChecked,
|
||||
isProduct: isProduct,
|
||||
arch: configuration['arch']);
|
||||
case 'none':
|
||||
return new NoneCompilerConfiguration(
|
||||
|
@ -299,9 +301,12 @@ class Dart2jsCompilerConfiguration extends Dart2xCompilerConfiguration {
|
|||
|
||||
class PrecompilerCompilerConfiguration extends CompilerConfiguration {
|
||||
final String arch;
|
||||
final bool isProduct;
|
||||
|
||||
PrecompilerCompilerConfiguration({bool isDebug, bool isChecked, String arch})
|
||||
PrecompilerCompilerConfiguration(
|
||||
{bool isDebug, bool isChecked, bool isProduct, String arch})
|
||||
: super._subclass(isDebug: isDebug, isChecked: isChecked),
|
||||
isProduct = isProduct,
|
||||
arch = arch;
|
||||
|
||||
int computeTimeoutMultiplier() {
|
||||
|
@ -333,9 +338,25 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration {
|
|||
CommandBuilder commandBuilder,
|
||||
List arguments,
|
||||
Map<String, String> environmentOverrides) {
|
||||
var exec = "$buildDir/dart_bootstrap";
|
||||
var sourceDir = Directory.current.path;
|
||||
var exec = "$buildDir/gen_snapshot";
|
||||
var args = new List();
|
||||
args.add("--gen-precompiled-snapshot=$tempDir");
|
||||
|
||||
var precompiledVMIsolate = "$tempDir/precompiled.vmisolate";
|
||||
var precompiledIsolate = "$tempDir/precompiled.isolate";
|
||||
var precompiledInstructions = "$tempDir/precompiled.S";
|
||||
var dartProductEntries = "$sourceDir/runtime/bin/dart_product_entries.txt";
|
||||
var dartEntries = "$sourceDir/runtime/bin/dart_entries.txt";
|
||||
var vmServiceIoMain = "$sourceDir/runtime/bin/vmservice/vmservice_io.dart";
|
||||
|
||||
args.add("--embedder_entry_points_manifest=$dartProductEntries");
|
||||
if (!isProduct) {
|
||||
args.add("--embedder_entry_points_manifest=$dartEntries");
|
||||
}
|
||||
args.add("--vm_isolate_snapshot=$precompiledVMIsolate");
|
||||
args.add("--isolate_snapshot=$precompiledIsolate");
|
||||
args.add("--instructions_snapshot=$precompiledInstructions");
|
||||
args.add("--url_mapping=dart:vmservice_io,$vmServiceIoMain");
|
||||
args.addAll(arguments);
|
||||
|
||||
return commandBuilder.getCompilationCommand('precompiler', tempDir, !useSdk,
|
||||
|
|
Loading…
Reference in a new issue