Skip to content

Commit

Permalink
Add a build flag to enable dev channel features.
Browse files Browse the repository at this point in the history
This CL adds a build flag `--define CHANNEL=dev` to enable dev channel features.

When this flag is specified, the `DEV_CHANNEL=1` macro is defined.

PiperOrigin-RevId: 659595286
  • Loading branch information
hiroyuki-komatsu committed Aug 5, 2024
1 parent b0daf3e commit b28f9c9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 14 deletions.
5 changes: 5 additions & 0 deletions src/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ common:prod_android --config=compiler_gcc_like
common:macos --config=compiler_gcc_like
common:oss_macos --config=compiler_gcc_like
common:prod_macos --config=compiler_gcc_like
common:prod_macos_dev --config=prod_macos --config=dev_channel
common:windows --config=compiler_msvc_like
common:oss_windows --config=compiler_msvc_like
common:prod_windows --config=compiler_msvc_like
common:prod_windows_dev --config=prod_windows --config=dev_channel

# Make sure we set -std=c++20 that may affect ABI across all the compilation targets.
# https://github.com/abseil/abseil-cpp/blob/master/FAQ.md#what-is-abi-and-why-dont-you-recommend-using-a-pre-compiled-version-of-abseil
Expand All @@ -27,6 +29,9 @@ build:compiler_msvc_like --copt "/utf-8" --host_copt "/utf-8"
build:compiler_msvc_like --cxxopt "/J" --host_cxxopt "/J"
build:compiler_msvc_like --cxxopt "/utf-8" --host_cxxopt "/utf-8"

# Dev channel
build:dev_channel --define CHANNEL=dev

# Linux
build:linux --define TARGET=oss_linux --copt "-fPIC"
build:linux --build_tag_filters=-nolinux
Expand Down
12 changes: 11 additions & 1 deletion src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ config_setting(
visibility = ["//visibility:private"],
)

config_setting(
name = "dev_channel",
values = {
"define": "CHANNEL=dev",
},
)

alias(
name = "compiler",
actual = BAZEL_TOOLS_PREFIX + "//tools/cpp:compiler",
Expand Down Expand Up @@ -157,7 +164,10 @@ cc_library(
) + mozc_select_enable_supplemental_model([
]) + mozc_select_enable_usage_rewriter(
off = ["NO_USAGE_REWRITER"],
),
) + select({
":dev_channel": ["CHANNEL_DEV=1"],
"//conditions:default": [],
}),
)

bzl_library(
Expand Down
35 changes: 22 additions & 13 deletions src/mac/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ load(

package(default_visibility = ["//:__subpackages__"])

# BUILD_TYPE_SELECT is treated as a function, but not a string. This cannot be a value of join().
BUILD_TYPE_SELECT = select({
"//:dev_channel": "dev",
"//conditions:default": "stable",
})

mozc_macos_application(
name = "mozc_macos",
additional_contents = mozc_select(
Expand Down Expand Up @@ -380,8 +386,8 @@ genrule(
"$(location //build_tools:tweak_macinstaller_script)",
" --output $@",
" --input $<",
" --build_type dev", # or stable.
]),
" --build_type ",
]) + BUILD_TYPE_SELECT, # "dev" or "stable".
tools = ["//build_tools:tweak_macinstaller_script"],
)

Expand All @@ -397,8 +403,8 @@ genrule(
" --output $@",
" --input $<",
" --version_file $(location //base:mozc_version_txt)",
" --build_type dev", # or stable.
]),
" --build_type ",
]) + BUILD_TYPE_SELECT, # "dev" or "stable".
tools = [
"//base:mozc_version_txt",
"//build_tools:tweak_macinstaller_script",
Expand Down Expand Up @@ -505,13 +511,16 @@ genrule(
prod_macos = ["installer/Mozc_template.pkgproj"],
),
outs = ["Mozc_Packages.pkg"],
cmd = ("$(location :build_installer) --input $(location :tweaked_installer_files) --output $@" +
" --pkgproj_command $(location //build_tools:tweak_pkgproj)" +
" --pkgproj_input $(location installer/Mozc_template.pkgproj)" +
" --pkgproj_output installer.pkgproj" +
" --version_file $(location //base:mozc_version_txt)" +
" --auto_updater_dir " + AUTO_UPDATER_DIR +
" --build_type dev"), # or stable
cmd = " ".join([
"$(location :build_installer)",
"--input $(location :tweaked_installer_files) --output $@" +
"--pkgproj_command $(location //build_tools:tweak_pkgproj)",
"--pkgproj_input $(location installer/Mozc_template.pkgproj)",
"--pkgproj_output installer.pkgproj",
"--version_file $(location //base:mozc_version_txt)",
"--auto_updater_dir " + AUTO_UPDATER_DIR,
"--build_type ",
]) + BUILD_TYPE_SELECT, # "dev" or "stable"
tags = ["manual"],
tools = [
":build_installer",
Expand All @@ -529,8 +538,8 @@ genrule(
"$(location //build_tools:tweak_macinstaller_script)",
"--output $@",
"--input $(SRCS)",
"--build_type dev", # or stable
]),
"--build_type ",
]) + BUILD_TYPE_SELECT, # "dev" or "stable"
tags = ["manual"],
tools = [
"//build_tools:tweak_macinstaller_script",
Expand Down
3 changes: 3 additions & 0 deletions src/win32/installer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Build rules for the Windows installer.

# Note, omaha_channel_type can be controlled by //:dev_channel
# See BUILD_TYPE_SELECT in mac/BUILD as an example.

0 comments on commit b28f9c9

Please sign in to comment.