Skip to content

Commit

Permalink
Use buildflag instead of defines gn var
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhong committed Mar 2, 2023
1 parent 33c3af7 commit 4e93e4f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,16 @@ source_set("common") {
"brave_vpn_helper_state.h",
"scoped_sc_handle.h",
]
public_configs = [ ":brave_vpn_helper_config" ]

public_deps = [ "//brave/components/brave_vpn/common/buildflags" ]

deps = [
"//base",
"//brave/components/brave_vpn/common",
"//chrome/install_static:install_static_util",
]
}

config("brave_vpn_helper_config") {
defines = []
if (brave_channel == "nightly") {
defines += [ "CHANNEL_NIGHTLY" ]
} else if (brave_channel == "beta") {
defines += [ "CHANNEL_BETA" ]
} else if (brave_channel == "dev") {
defines += [ "CHANNEL_DEV" ]
} else if (brave_channel == "development") {
defines += [ "CHANNEL_DEVELOPMENT" ]
}
}

source_set("lib") {
visibility = [
":brave_vpn_helper",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include <guiddef.h>

#include "brave/components/brave_vpn/common/buildflags/buildflags.h"

namespace brave_vpn {

constexpr char kBraveVpnHelperInstall[] = "install";
Expand All @@ -18,7 +20,7 @@ constexpr wchar_t kBraveVpnHelperFiltersInstalledValue[] = L"filters";
constexpr int kCheckConnectionIntervalInSeconds = 3;

/* UUID of WFP sublayer used by all instances */
#if defined(CHANNEL_NIGHTLY)
#if BUILDFLAG(CHANNEL_NIGHTLY)
constexpr wchar_t kBraveVPNServiceFilter[] =
L"Brave VPN Nightly Service DNS Filter";
constexpr wchar_t kBraveVpnHelperRegistryStoragePath[] =
Expand All @@ -30,7 +32,7 @@ constexpr GUID kVpnDnsSublayerGUID = {
0xeb83,
0x4d2c,
{0x9d, 0x77, 0xf6, 0xe9, 0xb5, 0x47, 0xf3, 0x9c}};
#elif defined(CHANNEL_BETA)
#elif BUILDFLAG(CHANNEL_BETA)
constexpr wchar_t kBraveVPNServiceFilter[] =
L"Brave VPN Beta Service DNS Filter";
constexpr wchar_t kBraveVpnHelperRegistryStoragePath[] =
Expand All @@ -42,7 +44,7 @@ constexpr GUID kVpnDnsSublayerGUID = {
0xe313,
0x4f5e,
{0x80, 0x52, 0xfe, 0x8b, 0x15, 0x0f, 0x7d, 0xe0}};
#elif defined(CHANNEL_DEV)
#elif BUILDFLAG(CHANNEL_DEV)
constexpr wchar_t kBraveVPNServiceFilter[] =
L"Brave VPN Dev Service DNS Filter";
constexpr wchar_t kBraveVpnHelperRegistryStoragePath[] =
Expand All @@ -53,7 +55,7 @@ constexpr GUID kVpnDnsSublayerGUID = {
0x729d,
0x4a89,
{0x87, 0x9b, 0x1c, 0xf0, 0xcd, 0x24, 0x60, 0xc0}};
#elif defined(CHANNEL_DEVELOPMENT)
#elif BUILDFLAG(CHANNEL_DEVELOPMENT)
constexpr wchar_t kBraveVPNServiceFilter[] =
L"Brave VPN Development Service DNS Filter";
constexpr wchar_t kBraveVpnHelperRegistryStoragePath[] =
Expand Down
40 changes: 40 additions & 0 deletions components/brave_vpn/common/buildflags/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,50 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at https://mozilla.org/MPL/2.0/.

import("//brave/build/config.gni")
import("//build/buildflag_header.gni")
import("buildflags.gni")

buildflag_header("buildflags") {
header = "buildflags.h"
flags = [ "ENABLE_BRAVE_VPN=$enable_brave_vpn" ]

if (is_win) {
if (brave_channel == "development") {
flags += [
"CHANNEL_NIGHTLY=0",
"CHANNEL_BETA=0",
"CHANNEL_DEV=0",
"CHANNEL_DEVELOPMENT=1",
]
} else if (brave_channel == "nightly") {
flags += [
"CHANNEL_NIGHTLY=1",
"CHANNEL_BETA=0",
"CHANNEL_DEV=0",
"CHANNEL_DEVELOPMENT=0",
]
} else if (brave_channel == "dev") {
flags += [
"CHANNEL_NIGHTLY=0",
"CHANNEL_BETA=0",
"CHANNEL_DEV=1",
"CHANNEL_DEVELOPMENT=0",
]
} else if (brave_channel == "beta") {
flags += [
"CHANNEL_NIGHTLY=0",
"CHANNEL_BETA=1",
"CHANNEL_DEV=0",
"CHANNEL_DEVELOPMENT=0",
]
} else { # stable
flags += [
"CHANNEL_NIGHTLY=0",
"CHANNEL_BETA=0",
"CHANNEL_DEV=0",
"CHANNEL_DEVELOPMENT=0",
]
}
}
}

0 comments on commit 4e93e4f

Please sign in to comment.