From 517573479f8f1d95ee4409e7e994ddc9b3e8c3ff Mon Sep 17 00:00:00 2001 From: Joshua Villasenor Date: Tue, 16 Nov 2021 10:23:21 -0800 Subject: [PATCH] Simulated app to gen to zzz_generated folder and add build workflow --- .github/workflows/build.yaml | 20 ++++++++++++++++++-- examples/placeholder/linux/BUILD.gn | 2 +- examples/placeholder/templates/helper.js | 2 +- scripts/build/gn_gen.sh | 5 ++++- scripts/examples/gn_build_test_example.sh | 6 +++--- scripts/tools/zap_regen_all.py | 18 ++++++++++++++++-- 6 files changed, 43 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index be95ea628f683b..275537e01430d8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -91,7 +91,7 @@ jobs: timeout-minutes: 20 run: scripts/build/gn_build.sh build_linux: - name: Build on Linux (gcc_release, clang, mbedtls) + name: Build on Linux (gcc_release, clang, mbedtls, simulated) timeout-minutes: 60 runs-on: ubuntu-latest @@ -135,6 +135,14 @@ jobs: path: | .environment/gn_out/.ninja_log .environment/pigweed-venv/*.log + - name: Setup and Build Simulated Device + timeout-minutes: 5 + run: | + BUILD_TYPE=simulated + GN_ARGS='chip_tests_zap_config="app1" chip_project_config_include_dirs=["../../examples/placeholder/linux/apps/app1/include", "../../config/standalone"] chip_config_network_layer_ble=false' + CHIP_ROOT_PATH=examples/placeholder/linux + CHIP_ROOT_PATH="$CHIP_ROOT_PATH" BUILD_TYPE="$BUILD_TYPE" scripts/build/gn_gen.sh --args="$GN_ARGS" + CHIP_ROOT_PATH="$CHIP_ROOT_PATH" BUILD_TYPE="$BUILD_TYPE" scripts/build/gn_build.sh - name: Setup Build, Run Build and Run Tests timeout-minutes: 50 run: | @@ -254,7 +262,7 @@ jobs: # if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }} # uses: github/codeql-action/analyze@v1 build_darwin: - name: Build on Darwin (clang, python_lib) + name: Build on Darwin (clang, python_lib, simulated) timeout-minutes: 90 env: @@ -292,6 +300,14 @@ jobs: path: | .environment/gn_out/.ninja_log .environment/pigweed-venv/*.log + - name: Setup and Build Simulated Device + timeout-minutes: 5 + run: | + BUILD_TYPE=simulated + GN_ARGS='chip_tests_zap_config="app1" chip_project_config_include_dirs=["../../examples/placeholder/linux/apps/app1/include", "../../config/standalone"] chip_config_network_layer_ble=false' + CHIP_ROOT_PATH=examples/placeholder/linux + CHIP_ROOT_PATH="$CHIP_ROOT_PATH" BUILD_TYPE="$BUILD_TYPE" scripts/build/gn_gen.sh --args="$GN_ARGS" + CHIP_ROOT_PATH="$CHIP_ROOT_PATH" BUILD_TYPE="$BUILD_TYPE" scripts/build/gn_build.sh - name: Setup Build, Run Build and Run Tests timeout-minutes: 75 # Just go ahead and do the "all" build; on Darwin that's fairly diff --git a/examples/placeholder/linux/BUILD.gn b/examples/placeholder/linux/BUILD.gn index 0e0b8601990e5f..3ca3b3adef5096 100644 --- a/examples/placeholder/linux/BUILD.gn +++ b/examples/placeholder/linux/BUILD.gn @@ -24,7 +24,7 @@ declare_args() { chip_data_model("configuration") { zap_file = "apps/${chip_tests_zap_config}/config.zap" - zap_pregenerated_dir = "${chip_root}/out/debug/placeholder/${chip_tests_zap_config}/zap-generated" + zap_pregenerated_dir = "${chip_root}/zzz_generated/placeholder/${chip_tests_zap_config}/zap-generated" is_server = true } diff --git a/examples/placeholder/templates/helper.js b/examples/placeholder/templates/helper.js index 18965aa9158922..01fc3dad95fec5 100644 --- a/examples/placeholder/templates/helper.js +++ b/examples/placeholder/templates/helper.js @@ -18,7 +18,7 @@ function getTests() { try { - const appTest = require('../linux/apps/' + process.env.TARGET_APP + '/tests.js'); + const appTest = require('../linux/apps/app1/tests.js'); return appTest.getTests(); } catch (e) { console.info("No tests configuration has been found."); diff --git a/scripts/build/gn_gen.sh b/scripts/build/gn_gen.sh index a53839f60df169..8962f22825ff2b 100755 --- a/scripts/build/gn_gen.sh +++ b/scripts/build/gn_gen.sh @@ -21,6 +21,9 @@ set -e # GN gen script for GN build GitHub workflow. CHIP_ROOT="$(dirname "$0")/../.." +if [[ -z "${CHIP_ROOT_PATH}" ]]; then + CHIP_ROOT_PATH="" +fi source "$CHIP_ROOT/scripts/activate.sh" @@ -28,4 +31,4 @@ set -x env -gn --root="$CHIP_ROOT" gen --check --fail-on-unused-args "$CHIP_ROOT/out/$BUILD_TYPE" "$@" +gn --root="$CHIP_ROOT/$CHIP_ROOT_PATH" gen --check --fail-on-unused-args "$CHIP_ROOT/out/$BUILD_TYPE" "$@" diff --git a/scripts/examples/gn_build_test_example.sh b/scripts/examples/gn_build_test_example.sh index 1e79a10851a2ef..e810cd437d7f91 100755 --- a/scripts/examples/gn_build_test_example.sh +++ b/scripts/examples/gn_build_test_example.sh @@ -23,7 +23,7 @@ set -e CHIP_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"/../.. INPUT_DIR="$CHIP_ROOT/examples/placeholder/linux" -OUTPUT_DIR="$CHIP_ROOT/out/debug/placeholder" +OUTPUT_DIR="$CHIP_ROOT/zzz_generated/placeholder" source "$CHIP_ROOT/scripts/activate.sh" @@ -54,11 +54,11 @@ function runGN() { GN_ARGS+="chip_project_config_include_dirs=[\"$INPUT_DIR/apps/$APP_DIR/include\", \"$CHIP_ROOT/config/standalone\"]" GN_ARGS+="chip_config_network_layer_ble=false" - gn gen --check --fail-on-unused-args --root=examples/placeholder/linux "$OUTPUT_DIR" --args="$GN_ARGS" + gn gen --check --fail-on-unused-args --root=examples/placeholder/linux "$CHIP_ROOT/out/$APP_DIR" --args="$GN_ARGS" } function runNinja() { - ninja -C "$OUTPUT_DIR" + ninja -C "$CHIP_ROOT/out/$APP_DIR" } function runAll() { diff --git a/scripts/tools/zap_regen_all.py b/scripts/tools/zap_regen_all.py index 87b9900e89930f..99b0fafb4f6257 100755 --- a/scripts/tools/zap_regen_all.py +++ b/scripts/tools/zap_regen_all.py @@ -40,9 +40,23 @@ def getGlobalTemplatesTargets(): example_name = example_name[example_name.index('examples/') + 9:] example_name = example_name[:example_name.index('/')] - # Ignore placeholder examples since the zap files there are not intended to - # be part of the tree. + # Place holder has apps within each build if example_name == "placeholder": + example_name = filepath.as_posix() + example_name = example_name[example_name.index('apps/') + 5:] + example_name = example_name[:example_name.index('/')] + logging.info("Found example %s (via %s)" % + (example_name, str(filepath))) + + # The name zap-generated is to make includes clear by using + # a name like + output_dir = os.path.join( + 'zzz_generated', 'placeholder', example_name, 'zap-generated') + if not os.path.exists(output_dir): + os.makedirs(output_dir) + template = 'examples/placeholder/templates/templates.json' + targets.append([str(filepath), '-o', output_dir]) + targets.append([str(filepath), '-o', output_dir, '-t', template]) continue logging.info("Found example %s (via %s)" %