Skip to content

Commit e80dfb2

Browse files
anna-nexthopmeta-codesync[bot]
authored andcommitted
Document build type options
Summary: **Pre-submission checklist** - [x] I've ran the linters locally and fixed lint errors related to the files I modified in this PR. You can install the linters by running `pip install -r requirements-dev.txt && pre-commit install` - [x] `pre-commit run` Document the `--build-type` option for the run-getdeps.py build script and refactor the argument definition to eliminate code duplication. - **docs/docs/build/Building_FBOSS_on_containers.md**: Added comprehensive documentation about build types (Debug, Release, RelWithDebInfo, MinSizeRel) with a table explaining each option - **docs/docs/platform/Building_Platform_Services.md**: Updated build commands to use `--build-type` flag - **docs/static/code_snips/*.sh**: Updated all build script examples to use `--build-type` instead of passing `CMAKE_BUILD_TYPE` in `--extra-cmake-defines` - Updated the `--build-type` help text in run-getdeps.py to include: - Concise descriptions of each build type - Indication that RelWithDebInfo is the default - Removed the outdated "widely supported" comment - Created a shared `BUILD_TYPE_ARG` kwargs dictionary to define the `--build-type` argument once - Replaced three duplicate argument definitions in BuildCmd, TestCmd, and GenerateGithubActionsCmd classes - Reduced code duplication and improved maintainability - Users now understand what each build type does - Cleaner syntax: `--build-type MinSizeRel` vs JSON in `--extra-cmake-defines` - Single source of truth for the argument definition - Easier to maintain and update in the future Verified that help output works correctly for all three commands: - `build --help` - `test --help` - `generate-github-actions --help` X-link: facebook/fboss#842 Reviewed By: joseph5wu Differential Revision: D93010077 Pulled By: KevinYakar fbshipit-source-id: d1a0b780c28e8f8fa5ca716326fbcadb244ade87
1 parent e403663 commit e80dfb2

File tree

2 files changed

+12
-25
lines changed

2 files changed

+12
-25
lines changed

build/fbcode_builder/getdeps.py

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ class UsageError(Exception):
4747
pass
4848

4949

50+
# Shared argument definition for --build-type used by multiple commands
51+
BUILD_TYPE_ARG = {
52+
"help": "Set the build type explicitly: Debug (unoptimized, debug symbols), RelWithDebInfo (optimized with debug symbols, default), MinSizeRel (size-optimized, no debug), or Release (optimized, no debug).",
53+
"choices": ["Debug", "Release", "RelWithDebInfo", "MinSizeRel"],
54+
"action": "store",
55+
"default": "RelWithDebInfo",
56+
}
57+
58+
5059
@cmd("validate-manifest", "parse a manifest and validate that it is correct")
5160
class ValidateManifest(SubCmd):
5261
def run(self, args):
@@ -881,13 +890,7 @@ def setup_project_cmd_parser(self, parser):
881890
action="store_true",
882891
default=False,
883892
)
884-
parser.add_argument(
885-
"--build-type",
886-
help="Set the build type explicitly. Cmake and cargo builders act on them. Only Debug and RelWithDebInfo widely supported.",
887-
choices=["Debug", "Release", "RelWithDebInfo", "MinSizeRel"],
888-
action="store",
889-
default=None,
890-
)
893+
parser.add_argument("--build-type", **BUILD_TYPE_ARG)
891894

892895

893896
@cmd("fixup-dyn-deps", "Adjusts dynamic dependencies for packaging purposes")
@@ -969,13 +972,7 @@ def setup_project_cmd_parser(self, parser):
969972
default=None,
970973
help="Timeout in seconds for each individual test",
971974
)
972-
parser.add_argument(
973-
"--build-type",
974-
help="Set the build type explicitly. Cmake and cargo builders act on them. Only Debug and RelWithDebInfo widely supported.",
975-
choices=["Debug", "Release", "RelWithDebInfo", "MinSizeRel"],
976-
action="store",
977-
default=None,
978-
)
975+
parser.add_argument("--build-type", **BUILD_TYPE_ARG)
979976

980977

981978
@cmd(
@@ -1450,13 +1447,7 @@ def setup_project_cmd_parser(self, parser):
14501447
action="store_true",
14511448
default=False,
14521449
)
1453-
parser.add_argument(
1454-
"--build-type",
1455-
help="Set the build type explicitly. Cmake and cargo builders act on them. Only Debug and RelWithDebInfo widely supported.",
1456-
choices=["Debug", "Release", "RelWithDebInfo", "MinSizeRel"],
1457-
action="store",
1458-
default=None,
1459-
)
1450+
parser.add_argument("--build-type", **BUILD_TYPE_ARG)
14601451
parser.add_argument(
14611452
"--no-build-cache",
14621453
action="store_false",

build/fbcode_builder/getdeps/buildopts.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,6 @@ def __init__(
113113
self.lfs_path = lfs_path
114114
self.shared_libs = shared_libs
115115
self.free_up_disk = free_up_disk
116-
117-
if build_type is None:
118-
build_type = "RelWithDebInfo"
119-
120116
self.build_type = build_type
121117

122118
lib_path = None

0 commit comments

Comments
 (0)