mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 22:22:26 +00:00
build-all: --add-commit-sha cli arg
This commit is contained in:
+22
-2
@@ -137,7 +137,15 @@ from pathlib import Path
|
|||||||
from typing import Literal, NamedTuple, TypeAlias
|
from typing import Literal, NamedTuple, TypeAlias
|
||||||
from urllib.request import urlretrieve
|
from urllib.request import urlretrieve
|
||||||
|
|
||||||
from common import BUILD_CFG_DEFAULT, BUILD_CFGS, BuildCfg, ColorFormatter, HelpStrings, resolve_cli_or_env
|
from common import (
|
||||||
|
ADD_COMMIT_SHA_DEFAULT,
|
||||||
|
BUILD_CFG_DEFAULT,
|
||||||
|
BUILD_CFGS,
|
||||||
|
BuildCfg,
|
||||||
|
ColorFormatter,
|
||||||
|
HelpStrings,
|
||||||
|
resolve_cli_or_env,
|
||||||
|
)
|
||||||
from typing_extensions import assert_never
|
from typing_extensions import assert_never
|
||||||
|
|
||||||
# `common` configures the root logger on import, so reuse it here.
|
# `common` configures the root logger on import, so reuse it here.
|
||||||
@@ -157,7 +165,6 @@ def is_on_off(value: str | None, *, default: bool) -> bool:
|
|||||||
|
|
||||||
PROJECT_NAME = "IfcOpenShell"
|
PROJECT_NAME = "IfcOpenShell"
|
||||||
USE_CURRENT_PYTHON_VERSION = is_on_off(os.getenv("USE_CURRENT_PYTHON_VERSION"), default=False)
|
USE_CURRENT_PYTHON_VERSION = is_on_off(os.getenv("USE_CURRENT_PYTHON_VERSION"), default=False)
|
||||||
ADD_COMMIT_SHA = is_on_off(os.getenv("ADD_COMMIT_SHA"), default=False)
|
|
||||||
IFCOS_BUILD_PYTHON_WRAPPER = is_on_off(os.getenv("IFCOS_BUILD_PYTHON_WRAPPER"), default=True)
|
IFCOS_BUILD_PYTHON_WRAPPER = is_on_off(os.getenv("IFCOS_BUILD_PYTHON_WRAPPER"), default=True)
|
||||||
USE_OCCT = is_on_off(os.getenv("USE_OCCT"), default=True)
|
USE_OCCT = is_on_off(os.getenv("USE_OCCT"), default=True)
|
||||||
PYTHON_USER_SITE = is_on_off(os.getenv("PYTHON_USER_SITE"), default=False)
|
PYTHON_USER_SITE = is_on_off(os.getenv("PYTHON_USER_SITE"), default=False)
|
||||||
@@ -219,6 +226,7 @@ class Args(NamedTuple):
|
|||||||
num_build_procs: int
|
num_build_procs: int
|
||||||
schemas: str | None
|
schemas: str | None
|
||||||
build_cfg: BuildCfg
|
build_cfg: BuildCfg
|
||||||
|
add_commit_sha: bool
|
||||||
|
|
||||||
|
|
||||||
class DynamicArgs(NamedTuple):
|
class DynamicArgs(NamedTuple):
|
||||||
@@ -342,6 +350,13 @@ def parse_args() -> tuple[Args, DynamicArgs]:
|
|||||||
default=argparse.SUPPRESS,
|
default=argparse.SUPPRESS,
|
||||||
help=HelpStrings.BUILD_CFG + " Also can be specified by using BUILD_CFG env variable.",
|
help=HelpStrings.BUILD_CFG + " Also can be specified by using BUILD_CFG env variable.",
|
||||||
)
|
)
|
||||||
|
arg_parser.add_argument(
|
||||||
|
"--add-commit-sha",
|
||||||
|
dest="add_commit_sha",
|
||||||
|
action=argparse.BooleanOptionalAction,
|
||||||
|
default=argparse.SUPPRESS,
|
||||||
|
help=HelpStrings.ADD_COMMIT_SHA,
|
||||||
|
)
|
||||||
namespace, unknown_flags = arg_parser.parse_known_args()
|
namespace, unknown_flags = arg_parser.parse_known_args()
|
||||||
num_build_procs = resolve_cli_or_env(
|
num_build_procs = resolve_cli_or_env(
|
||||||
getattr(namespace, "num_build_procs", None),
|
getattr(namespace, "num_build_procs", None),
|
||||||
@@ -353,6 +368,9 @@ def parse_args() -> tuple[Args, DynamicArgs]:
|
|||||||
build_cfg = resolve_cli_or_env(
|
build_cfg = resolve_cli_or_env(
|
||||||
getattr(namespace, "build_cfg", None), "BUILD_CFG", BUILD_CFG_DEFAULT, arg_type="str"
|
getattr(namespace, "build_cfg", None), "BUILD_CFG", BUILD_CFG_DEFAULT, arg_type="str"
|
||||||
)
|
)
|
||||||
|
add_commit_sha = resolve_cli_or_env(
|
||||||
|
getattr(namespace, "add_commit_sha", None), "ADD_COMMIT_SHA", ADD_COMMIT_SHA_DEFAULT, arg_type="bool"
|
||||||
|
)
|
||||||
args = Args(
|
args = Args(
|
||||||
explicit_targets=namespace.explicit_targets,
|
explicit_targets=namespace.explicit_targets,
|
||||||
build_examples=namespace.build_examples,
|
build_examples=namespace.build_examples,
|
||||||
@@ -367,6 +385,7 @@ def parse_args() -> tuple[Args, DynamicArgs]:
|
|||||||
num_build_procs=num_build_procs,
|
num_build_procs=num_build_procs,
|
||||||
schemas=schemas,
|
schemas=schemas,
|
||||||
build_cfg=build_cfg,
|
build_cfg=build_cfg,
|
||||||
|
add_commit_sha=add_commit_sha,
|
||||||
)
|
)
|
||||||
|
|
||||||
dynamic_args = DynamicArgs.from_unknown_flags(unknown_flags, arg_parser)
|
dynamic_args = DynamicArgs.from_unknown_flags(unknown_flags, arg_parser)
|
||||||
@@ -482,6 +501,7 @@ if not os.path.exists(DEPS_DIR):
|
|||||||
|
|
||||||
INSTALL_DIR = Path(DEPS_DIR) / "install"
|
INSTALL_DIR = Path(DEPS_DIR) / "install"
|
||||||
BUILD_CFG = ARGS.build_cfg
|
BUILD_CFG = ARGS.build_cfg
|
||||||
|
ADD_COMMIT_SHA = ARGS.add_commit_sha
|
||||||
|
|
||||||
|
|
||||||
# Print build configuration information
|
# Print build configuration information
|
||||||
|
|||||||
@@ -135,6 +135,8 @@ BuildType = Literal["Build", "Rebuild", "Clean"]
|
|||||||
BUILD_TYPES = get_args(BuildType)
|
BUILD_TYPES = get_args(BuildType)
|
||||||
BUILD_TYPE_DEFAULT: BuildType = "Build"
|
BUILD_TYPE_DEFAULT: BuildType = "Build"
|
||||||
|
|
||||||
|
ADD_COMMIT_SHA_DEFAULT = False
|
||||||
|
|
||||||
|
|
||||||
class HelpStrings:
|
class HelpStrings:
|
||||||
NUM_BUILD_PROCS = (
|
NUM_BUILD_PROCS = (
|
||||||
@@ -150,6 +152,12 @@ class HelpStrings:
|
|||||||
BUILD_CFG = f"Build configuration type. (default: {BUILD_CFG_DEFAULT})"
|
BUILD_CFG = f"Build configuration type. (default: {BUILD_CFG_DEFAULT})"
|
||||||
BUILD_CFG_FLAG = "Alternative way to specify the build configuration type, instead of the positional argument."
|
BUILD_CFG_FLAG = "Alternative way to specify the build configuration type, instead of the positional argument."
|
||||||
|
|
||||||
|
ADD_COMMIT_SHA = (
|
||||||
|
"Add the commit SHA to the built version string. "
|
||||||
|
"Also can be specified by using ADD_COMMIT_SHA env variable. "
|
||||||
|
f"(default: {ADD_COMMIT_SHA_DEFAULT})"
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generator(omitted_behavior: str) -> str:
|
def generator(omitted_behavior: str) -> str:
|
||||||
return (
|
return (
|
||||||
|
|||||||
+2
-6
@@ -30,6 +30,7 @@ from pathlib import Path
|
|||||||
from typing import Literal, NamedTuple, NoReturn
|
from typing import Literal, NamedTuple, NoReturn
|
||||||
|
|
||||||
from common import (
|
from common import (
|
||||||
|
ADD_COMMIT_SHA_DEFAULT,
|
||||||
OFF_ON,
|
OFF_ON,
|
||||||
PROJECT_NAME,
|
PROJECT_NAME,
|
||||||
REPO_ROOT,
|
REPO_ROOT,
|
||||||
@@ -178,17 +179,12 @@ def parse_args() -> Args:
|
|||||||
default=None,
|
default=None,
|
||||||
help=HelpStrings.GENERATOR_FLAG,
|
help=HelpStrings.GENERATOR_FLAG,
|
||||||
)
|
)
|
||||||
ADD_COMMIT_SHA_DEFAULT = False
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--add-commit-sha",
|
"--add-commit-sha",
|
||||||
dest="add_commit_sha",
|
dest="add_commit_sha",
|
||||||
action=argparse.BooleanOptionalAction,
|
action=argparse.BooleanOptionalAction,
|
||||||
default=argparse.SUPPRESS,
|
default=argparse.SUPPRESS,
|
||||||
help=(
|
help=HelpStrings.ADD_COMMIT_SHA,
|
||||||
"Add the commit SHA to the built version string. "
|
|
||||||
"Also can be specified by using ADD_COMMIT_SHA env variable. "
|
|
||||||
f"(default: {ADD_COMMIT_SHA_DEFAULT})"
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
USE_NINJA_DEFAULT = False
|
USE_NINJA_DEFAULT = False
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
|||||||
Reference in New Issue
Block a user