From 92c5ff30a711abcff0ad2076d0949bd8f057adaa Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 7 Feb 2024 07:23:17 +0900 Subject: [PATCH] build: add flag for setting vendor version (#41247) --- buildflags/BUILD.gn | 11 +++++++++++ buildflags/buildflags.gni | 6 ++++++ shell/common/node_bindings.cc | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/buildflags/BUILD.gn b/buildflags/BUILD.gn index 18ac3e42de9b..ef00ad27f608 100644 --- a/buildflags/BUILD.gn +++ b/buildflags/BUILD.gn @@ -14,4 +14,15 @@ buildflag_header("buildflags") { "ENABLE_BUILTIN_SPELLCHECKER=$enable_builtin_spellchecker", "OVERRIDE_LOCATION_PROVIDER=$enable_fake_location_provider", ] + + if (electron_vendor_version != "") { + result = string_split(electron_vendor_version, ":") + flags += [ + "HAS_VENDOR_VERSION=true", + "VENDOR_VERSION_NAME=\"${result[0]}\"", + "VENDOR_VERSION_VALUE=\"${result[1]}\"", + ] + } else { + flags += [ "HAS_VENDOR_VERSION=false" ] + } } diff --git a/buildflags/buildflags.gni b/buildflags/buildflags.gni index 1c5cb8dfd32c..801732cb2595 100644 --- a/buildflags/buildflags.gni +++ b/buildflags/buildflags.gni @@ -21,4 +21,10 @@ declare_args() { # Packagers and vendor builders should set this in gn args to avoid running # the script that reads git tag. override_electron_version = "" + + # Define an extra item that will show in process.versions, the value must + # be in the format of "key:value". + # Packagers and vendor builders can set this in gn args to attach extra info + # about the build in the binary. + electron_vendor_version = "" } diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index 22d08a962974..2ef6c3d7909d 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -942,6 +942,10 @@ void OnNodePreload(node::Environment* env, if (dict.Get("versions", &versions)) { versions.SetReadOnly(ELECTRON_PROJECT_NAME, ELECTRON_VERSION_STRING); versions.SetReadOnly("chrome", CHROME_VERSION_STRING); +#if BUILDFLAG(HAS_VENDOR_VERSION) + versions.SetReadOnly(BUILDFLAG(VENDOR_VERSION_NAME), + BUILDFLAG(VENDOR_VERSION_VALUE)); +#endif } // Execute lib/node/init.ts.