Skip to content

Commit

Permalink
Nits from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
ksperling-apple committed Apr 26, 2023
1 parent 0968c7f commit 8739687
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/minimal-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ jobs:
- name: Configure and build All Clusters App
timeout-minutes: 10
run: |
CC=gcc CXX=g++ scripts/configure --project=examples/all-clusters-app/linux && ./ninja
CC=gcc CXX=g++ scripts/configure --project=examples/all-clusters-app/linux && ./ninja-build
19 changes: 10 additions & 9 deletions scripts/configure
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Usage: configure [OPTIONS] [--project=... [PROJECT OPTIONS]]
#
# Configures a stand-alone build for a CHIP application in the current
# directory and creates a `ninja` wrapper script to build it. Should
# directory and creates a `ninja-build` wrapper script to build it. Should
# generally be run from an empty build directory (i.e. out-of-tree).
#
# This is intended to be used in the context of an external build system and
Expand Down Expand Up @@ -106,7 +106,7 @@ function main() { # ...
create_empty_pw_env
gn_generate "$@"
create_ninja_wrapper
info "You can now run ./ninja"
info "You can now run ./ninja-build"
}

function create_empty_pw_env() {
Expand Down Expand Up @@ -135,7 +135,7 @@ function gn_generate() { # [project options]
gn -q gen "$BUILD_ROOT"

# Use the argument list to drive the mapping of our command line options to GN args
python_util process_project_args <(gn args "$BUILD_ROOT" --list --json) "$@" >>"${BUILD_ROOT}/args.gn"
call_impl process_project_args <(gn args "$BUILD_ROOT" --list --json) "$@" >>"${BUILD_ROOT}/args.gn"
gn args "$BUILD_ROOT" --list >"${BUILD_ROOT}/args.configured"

# Now gn gen with the arguments we have configured.
Expand All @@ -146,15 +146,16 @@ function gn_generate() { # [project options]

function create_ninja_wrapper() {
# Note: "." != $BUILD_DIR for in-tree builds
ensure_no_clobber "ninja"
cat >"ninja" <<END
local wrapper="ninja-build"
ensure_no_clobber "$wrapper"
cat >"$wrapper" <<END
#!/bin/bash -e
# ${CONFIGURE_MARKER}
cd "\$(dirname "\$0")"
source "${BUILD_ENV_DIR}/bin/activate"
exec "${NINJA}" -C "${BUILD_DIR}" "\$@"
END
chmod a+x "ninja"
chmod a+x "$wrapper"
}

function activate_build_env() {
Expand Down Expand Up @@ -205,13 +206,13 @@ function download_zap() {
local url="https://github.com/project-chip/zap/releases/download/${version}/zap-${platform}.zip"

progress "Installing zap-cli from $url"
python_util download_and_extract_zip "$url" "${BUILD_ENV_DIR}/bin" zap-cli
call_impl download_and_extract_zip "$url" "${BUILD_ENV_DIR}/bin" zap-cli
chmod a+x "${BUILD_ENV_DIR}/bin/zap-cli" # ZipFile.extract() does not handle permissions
info "ok"
}

function python_util() { # function ...
"$PYTHON" "${CHIP_ROOT}/scripts/configure.utils.py" "$@"
function call_impl() { # func ...
"$PYTHON" "${CHIP_ROOT}/scripts/configure.impl.py" "$@"
}

function check_python() {
Expand Down
11 changes: 6 additions & 5 deletions scripts/configure.utils.py → scripts/configure.impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ def process_parameter(self, name, value):
else:
self.process_generic_parameter(name, value)

def process_parameters(self, argv):
def process_parameters(self, args):
"""Process GNU-style configure command line parameters"""
for arg in argv:
for arg in args:
if not (m := re.fullmatch(r'--([a-z][a-z0-9-]*)(?:=(.*))?', arg)):
fail("Invalid argument: '%s'" % arg)
self.process_parameter(m.group(1), m.group(2))
Expand All @@ -152,6 +152,7 @@ def fail(message):
sys.exit(1)


if __name__ == '__main__' and len(sys.argv) >= 2:
[_, func, *args] = sys.argv
globals()[func](*args)
# `configure` invokes the top-level functions in this file by
# passing the function name and arguments on the command line.
[_, func, *args] = sys.argv
globals()[func](*args)

0 comments on commit 8739687

Please sign in to comment.