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>
diff --git a/runtime/bin/BUILD.gn b/runtime/bin/BUILD.gn
index 51c708c..5724879 100644
--- a/runtime/bin/BUILD.gn
+++ b/runtime/bin/BUILD.gn
@@ -654,6 +654,27 @@
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 @@
"//third_party/boringssl",
"//third_party/zlib",
":crashpad",
+ ":generate_abi_version_cc_file",
] + extra_deps
defines = extra_defines
@@ -731,6 +753,7 @@
"snapshot_utils.h",
"vmservice_impl.cc",
"vmservice_impl.h",
+ "$target_gen_dir/abi_version.cc",
] + extra_sources
if (is_win) {
diff --git a/runtime/bin/abi_version.h b/runtime/bin/abi_version.h
new file mode 100644
index 0000000..acd0cdf
--- /dev/null
+++ b/runtime/bin/abi_version.h
@@ -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_
diff --git a/runtime/bin/abi_version_in.cc b/runtime/bin/abi_version_in.cc
new file mode 100644
index 0000000..ad737b2
--- /dev/null
+++ b/runtime/bin/abi_version_in.cc
@@ -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
diff --git a/runtime/bin/builtin_impl_sources.gni b/runtime/bin/builtin_impl_sources.gni
index d4c7489..f329f03 100644
--- a/runtime/bin/builtin_impl_sources.gni
+++ b/runtime/bin/builtin_impl_sources.gni
@@ -7,6 +7,7 @@
# io_impl_sources.gypi.
builtin_impl_sources = [
+ "abi_version.h",
"crypto.cc",
"crypto.h",
"crypto_android.cc",
diff --git a/runtime/bin/main_options.cc b/runtime/bin/main_options.cc
index a7181f5..d68bfaa 100644
--- a/runtime/bin/main_options.cc
+++ b/runtime/bin/main_options.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 @@
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,
diff --git a/runtime/bin/main_options.h b/runtime/bin/main_options.h
index a2c2755..e290696 100644
--- a/runtime/bin/main_options.h
+++ b/runtime/bin/main_options.h
@@ -62,7 +62,8 @@
#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 @@
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 @@
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)
diff --git a/runtime/vm/version.h b/runtime/vm/version.h
index 24540c3..fdc6bb0 100644
--- a/runtime/vm/version.h
+++ b/runtime/vm/version.h
@@ -14,7 +14,6 @@
static const char* String();
static const char* SnapshotString();
static const char* CommitString();
- static int TargetAbiVersion();
static int CurrentAbiVersion();
static int OldestSupportedAbiVersion();
diff --git a/runtime/vm/version_in.cc b/runtime/vm/version_in.cc
index d59584b..ae3cff7 100644
--- a/runtime/vm/version_in.cc
+++ b/runtime/vm/version_in.cc
@@ -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 @@
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}};
}