Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions PACKAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
load("@prelude//cfg/modifier:alias.bzl", "OSS_ALIASES")
load("@prelude//cfg/modifier:cfg_constructor.bzl", "cfg_constructor_post_constraint_analysis", "cfg_constructor_pre_constraint_analysis")
load("@prelude//cfg/modifier:common.bzl", "MODIFIER_METADATA_KEY")
load("@prelude//cfg/modifier/set_cfg_modifiers.bzl", "set_cfg_modifiers")

set_cfg_modifiers(["ovr_config//build_mode:dev"])

# https://buck2.build/docs/users/how_tos/modifiers_setup/
#
# This is required for -m MODIFIER to do anything. Otherwise you need
# to use configuration transitions.
native.set_cfg_constructor(
aliases = OSS_ALIASES,
extra_data = struct(),
key = MODIFIER_METADATA_KEY,
stage0 = cfg_constructor_pre_constraint_analysis,
stage1 = cfg_constructor_post_constraint_analysis,
)
12 changes: 12 additions & 0 deletions prelude/build_mode/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,15 @@ config_setting(
name = "arvr_mode",
visibility = ["PUBLIC"],
)

constraint_value(
name = "dev",
constraint_setting = "//build_mode/constraints:core_build_mode",
visibility = ["PUBLIC"],
)

constraint_value(
name = "opt",
constraint_setting = "//build_mode/constraints:core_build_mode",
visibility = ["PUBLIC"],
)
18 changes: 18 additions & 0 deletions prelude/build_mode/constraints/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is dual-licensed under either the MIT license found in the
# LICENSE-MIT file in the root directory of this source tree or the Apache
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
# of this source tree. You may select, at your option, one of the
# above-listed licenses.

load("@prelude//utils:source_listing.bzl", "source_listing")

oncall("build_infra")

source_listing()

constraint_setting(
name = "core_build_mode",
visibility = ["PUBLIC"],
)
30 changes: 30 additions & 0 deletions prelude/build_mode/default_opt_cxx/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is dual-licensed under either the MIT license found in the
# LICENSE-MIT file in the root directory of this source tree or the Apache
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
# of this source tree. You may select, at your option, one of the
# above-listed licenses.

load("@prelude//utils:source_listing.bzl", "source_listing")

oncall("build_infra")

source_listing()

constraint_setting(
name = "default_opt_cxx_setting",
visibility = ["PUBLIC"],
)

constraint_value(
name = "enabled",
constraint_setting = ":default_opt_cxx_setting",
visibility = ["PUBLIC"],
)

constraint_value(
name = "disabled",
constraint_setting = ":default_opt_cxx_setting",
visibility = ["PUBLIC"],
)
5 changes: 4 additions & 1 deletion prelude/cfg/modifier/alias.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ All constraints used in these aliases must also be available in OSS.
# 3. It's unlikely a user has to ever define an alias twice in both the `alias` buckconfig
# and in modifier aliases because a modifier alias is a constraint value/config setting
# and those don't typically get built on CLI.
OSS_ALIASES = struct()
OSS_ALIASES = struct(
dev = ["ovr_config//build_mode:dev", "ovr_config//build_mode/default_opt_cxx:enabled"],
opt = ["ovr_config//build_mode:opt", "ovr_config//build_mode/default_opt_cxx:enabled"],
)
10 changes: 9 additions & 1 deletion shim/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ system_cxx_toolchain(
# with clang-only flags and rejects them.
compiler_type = "gcc",
cxx_compiler = "g++",
cxx_flags = ["-std=c++20"],
cxx_flags = ["-std=c++20"] + select({
"ovr_config//build_mode/default_opt_cxx:enabled": ["-O2"],
"DEFAULT": [],
}),
# The sandcastle OSS-bootstrap environment has `gcc`/`g++` on PATH but
# not `clang`/`clang++` or `lld`, which are the defaults pulled in by
# `prelude//toolchains/cxx/clang:path_clang_tools`. Using `g++` as the
Expand Down Expand Up @@ -77,6 +80,11 @@ system_python_bootstrap_toolchain(
system_rust_toolchain(
name = "rust",
default_edition = "2021",
rustc_flags = select({
"ovr_config//build_mode:opt": ["-O"],
"ovr_config//build_mode:dev": ["-C", "debuginfo=2"],
"DEFAULT": [],
}),
visibility = ["PUBLIC"],
)

Expand Down
Loading