mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
Move use_abi_version from vm directory to bin
I need to access the flag in bin/main.cc, so it can't be in the vm directory Bug: https://github.com/dart-lang/sdk/issues/36047 Change-Id: Ib19a1b4d89295449b25f7753b2a39f6232c004e3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97122 Commit-Queue: Liam Appelbe <liama@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
parent
44753660ec
commit
724d956fd4
|
@ -654,6 +654,27 @@ source_set("dart_kernel_platform_cc") {
|
|||
get_target_outputs(":platform_strong_dill_linkable")
|
||||
}
|
||||
|
||||
action("generate_abi_version_cc_file") {
|
||||
inputs = [
|
||||
"../../tools/utils.py",
|
||||
"../../tools/VERSION",
|
||||
"abi_version_in.cc",
|
||||
]
|
||||
output = "$target_gen_dir/abi_version.cc"
|
||||
outputs = [
|
||||
output,
|
||||
]
|
||||
|
||||
script = "../../tools/make_version.py"
|
||||
args = [
|
||||
"--quiet",
|
||||
"--output",
|
||||
rebase_path(output, root_build_dir),
|
||||
"--input",
|
||||
rebase_path("abi_version_in.cc", root_build_dir),
|
||||
]
|
||||
}
|
||||
|
||||
template("dart_executable") {
|
||||
extra_configs = []
|
||||
if (defined(invoker.extra_configs)) {
|
||||
|
@ -702,6 +723,7 @@ template("dart_executable") {
|
|||
"//third_party/boringssl",
|
||||
"//third_party/zlib",
|
||||
":crashpad",
|
||||
":generate_abi_version_cc_file",
|
||||
] + extra_deps
|
||||
|
||||
defines = extra_defines
|
||||
|
@ -731,6 +753,7 @@ template("dart_executable") {
|
|||
"snapshot_utils.h",
|
||||
"vmservice_impl.cc",
|
||||
"vmservice_impl.h",
|
||||
"$target_gen_dir/abi_version.cc",
|
||||
] + extra_sources
|
||||
|
||||
if (is_win) {
|
||||
|
|
18
runtime/bin/abi_version.h
Normal file
18
runtime/bin/abi_version.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Copyright (c) 2019, 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.
|
||||
|
||||
#ifndef RUNTIME_BIN_ABI_VERSION_H_
|
||||
#define RUNTIME_BIN_ABI_VERSION_H_
|
||||
|
||||
namespace dart {
|
||||
|
||||
class AbiVersion {
|
||||
public:
|
||||
static int GetCurrent();
|
||||
static int GetOldestSupported();
|
||||
};
|
||||
|
||||
} // namespace dart
|
||||
|
||||
#endif // RUNTIME_BIN_ABI_VERSION_H_
|
17
runtime/bin/abi_version_in.cc
Normal file
17
runtime/bin/abi_version_in.cc
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Copyright (c) 2019, 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.
|
||||
|
||||
#include "bin/abi_version.h"
|
||||
|
||||
namespace dart {
|
||||
|
||||
int AbiVersion::GetCurrent() {
|
||||
return {{ABI_VERSION}};
|
||||
}
|
||||
|
||||
int AbiVersion::GetOldestSupported() {
|
||||
return {{OLDEST_SUPPORTED_ABI_VERSION}};
|
||||
}
|
||||
|
||||
} // namespace dart
|
|
@ -7,6 +7,7 @@
|
|||
# io_impl_sources.gypi.
|
||||
|
||||
builtin_impl_sources = [
|
||||
"abi_version.h",
|
||||
"crypto.cc",
|
||||
"crypto.h",
|
||||
"crypto_android.cc",
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "bin/abi_version.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/options.h"
|
||||
#include "bin/platform.h"
|
||||
|
@ -324,6 +325,32 @@ bool Options::ProcessObserveOption(const char* arg,
|
|||
return true;
|
||||
}
|
||||
|
||||
int Options::target_abi_version_ = AbiVersion::GetCurrent();
|
||||
bool Options::ProcessAbiVersionOption(const char* arg,
|
||||
CommandLineOptions* vm_options) {
|
||||
const char* value = OptionProcessor::ProcessOption(arg, "--use_abi_version=");
|
||||
if (value == NULL) {
|
||||
return false;
|
||||
}
|
||||
int ver = 0;
|
||||
for (int i = 0; value[i]; ++i) {
|
||||
if (value[i] >= '0' && value[i] <= '9') {
|
||||
ver = (ver * 10) + value[i] - '0';
|
||||
} else {
|
||||
Log::PrintErr("--use_abi_version must be an int\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (ver < AbiVersion::GetOldestSupported() ||
|
||||
ver > AbiVersion::GetCurrent()) {
|
||||
Log::PrintErr("--use_abi_version must be between %d and %d inclusive\n",
|
||||
AbiVersion::GetOldestSupported(), AbiVersion::GetCurrent());
|
||||
return false;
|
||||
}
|
||||
target_abi_version_ = ver;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool checked_set = false;
|
||||
|
||||
int Options::ParseArguments(int argc,
|
||||
|
|
|
@ -62,7 +62,8 @@ namespace bin {
|
|||
#define CB_OPTIONS_LIST(V) \
|
||||
V(ProcessEnvironmentOption) \
|
||||
V(ProcessEnableVmServiceOption) \
|
||||
V(ProcessObserveOption)
|
||||
V(ProcessObserveOption) \
|
||||
V(ProcessAbiVersionOption)
|
||||
|
||||
// This enum must match the strings in kSnapshotKindNames in main_options.cc.
|
||||
enum SnapshotKind {
|
||||
|
@ -115,6 +116,8 @@ class Options {
|
|||
static const char* vm_service_server_ip() { return vm_service_server_ip_; }
|
||||
static int vm_service_server_port() { return vm_service_server_port_; }
|
||||
|
||||
static int target_abi_version() { return target_abi_version_; }
|
||||
|
||||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||
static DFE* dfe() { return dfe_; }
|
||||
static void set_dfe(DFE* dfe) { dfe_ = dfe; }
|
||||
|
@ -159,6 +162,8 @@ class Options {
|
|||
int default_port,
|
||||
const char* default_ip);
|
||||
|
||||
static int target_abi_version_;
|
||||
|
||||
#define OPTION_FRIEND(flag, variable) friend class OptionProcessor_##flag;
|
||||
STRING_OPTIONS_LIST(OPTION_FRIEND)
|
||||
BOOL_OPTIONS_LIST(OPTION_FRIEND)
|
||||
|
|
|
@ -14,7 +14,6 @@ class Version : public AllStatic {
|
|||
static const char* String();
|
||||
static const char* SnapshotString();
|
||||
static const char* CommitString();
|
||||
static int TargetAbiVersion();
|
||||
static int CurrentAbiVersion();
|
||||
static int OldestSupportedAbiVersion();
|
||||
|
||||
|
|
|
@ -10,12 +10,6 @@
|
|||
|
||||
namespace dart {
|
||||
|
||||
DEFINE_FLAG(int,
|
||||
use_abi_version,
|
||||
Version::CurrentAbiVersion(),
|
||||
"ABI version to use. Valid values are "
|
||||
"{{OLDEST_SUPPORTED_ABI_VERSION}} to {{ABI_VERSION}}.");
|
||||
|
||||
// TODO(iposva): Avoid racy initialization.
|
||||
static const char* formatted_version = NULL;
|
||||
|
||||
|
@ -36,14 +30,6 @@ const char* Version::CommitString() {
|
|||
return commit_;
|
||||
}
|
||||
|
||||
int Version::TargetAbiVersion() {
|
||||
int ver = FLAG_use_abi_version;
|
||||
if (ver < OldestSupportedAbiVersion() || ver > CurrentAbiVersion()) {
|
||||
ver = CurrentAbiVersion();
|
||||
}
|
||||
return ver;
|
||||
}
|
||||
|
||||
int Version::CurrentAbiVersion() {
|
||||
return {{ABI_VERSION}};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue