Skip to content

Commit

Permalink
Migrating deprecated GN flag: export-compile-commands (project-chip#3…
Browse files Browse the repository at this point in the history
…5429)

* changing deprecated GN flag

* Restyled by shfmt

* Restyled by autopep8

* removeing quotes from wildcard

* more conversions

* Updating dry-run golden standard files

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
Alami-Amine and restyled-commits authored Nov 12, 2024
1 parent aba2383 commit 47780ad
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,14 @@ jobs:
esac
rm -rf ./out/sanitizers
BUILD_TYPE=sanitizers scripts/build/gn_gen.sh --args="$GN_ARGS" --export-compile-commands
BUILD_TYPE=sanitizers scripts/build/gn_gen.sh --args="$GN_ARGS" --add-export-compile-commands=*
BUILD_TYPE=sanitizers scripts/tests/gn_tests.sh
done
- name: Generate tests with sanitizers (for tidy)
if: github.event.pull_request.number != null
run: |
rm -rf ./out/sanitizers
BUILD_TYPE=sanitizers scripts/build/gn_gen.sh --args="is_clang=true is_asan=true" --export-compile-commands
BUILD_TYPE=sanitizers scripts/build/gn_gen.sh --args="is_clang=true is_asan=true" --add-export-compile-commands=*
- name: Ensure codegen is done for sanitize
run: |
./scripts/run_in_build_env.sh "./scripts/run_codegen_targets.sh out/sanitizers"
Expand Down Expand Up @@ -439,7 +439,7 @@ jobs:
# We want to build various standalone example apps (similar to what examples-linux-standalone.yaml
# does), so use target_os="all" to get those picked up as part of the "unified" build. But then
# to save CI resources we want to exclude the "host clang" build, which uses the pigweed clang.
scripts/build/gn_gen.sh --args='target_os="all" is_asan=true enable_host_clang_build=false' --export-compile-commands
scripts/build/gn_gen.sh --args='target_os="all" is_asan=true enable_host_clang_build=false' --add-export-compile-commands=*
scripts/run_in_build_env.sh "ninja -C ./out/$BUILD_TYPE"
scripts/tests/gn_tests.sh
- name: Ensure codegen is done for default
Expand Down
2 changes: 1 addition & 1 deletion config/qpg/chip-gn/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ gn \
--root-target=//config/qpg/chip-gn \
--dotfile="$GN_ROOT_TARGET/.gn" \
--script-executable=python3 \
--export-compile-commands \
--add-export-compile-commands="*" \
gen \
--check \
--args="$GN_ARGS" \
Expand Down
2 changes: 1 addition & 1 deletion examples/chef/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ def main() -> int:
"""))
if options.do_clean:
shell.run_cmd("rm -rf out")
shell.run_cmd("gn gen --export-compile-commands out")
shell.run_cmd("gn gen --add-export-compile-commands=* out")
shell.run_cmd("ninja -C out")

#
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/tizen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Generating tizen-arm-light
```sh
gn gen --check \
--fail-on-unused-args \
--export-compile-commands \
--add-export-compile-commands=* \
--root=$PW_PROJECT_ROOT/examples/lighting-app/tizen \
"--args=target_os=\"tizen\" target_cpu=\"arm\" tizen_sdk_root=\"$TIZEN_SDK_ROOT\" tizen_sdk_sysroot=\"$TIZEN_SDK_SYSROOT\"" \
$PW_PROJECT_ROOT/out/tizen-arm-light
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/builders/efr32.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def bundle_outputs(self):
def generate(self):
cmd = [
'gn', 'gen', '--check', '--fail-on-unused-args',
'--export-compile-commands',
'--add-export-compile-commands=*',
'--root=%s' % self.root
]
if self.dotfile:
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/builders/gn.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def PostBuildCommand(self):
def generate(self):
cmd = [
'gn', 'gen', '--check', '--fail-on-unused-args',
'--export-compile-commands',
'--add-export-compile-commands=*',
'--root=%s' % self.root
]

Expand Down
2 changes: 1 addition & 1 deletion scripts/build/builders/nxp.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def generate(self):

elif self.build_system == NxpBuildSystem.GN:
# add empty space at the end to avoid concatenation issue when there is no --args
cmd += 'gn gen --check --fail-on-unused-args --export-compile-commands --root=%s ' % self.root
cmd += 'gn gen --check --fail-on-unused-args --add-export-compile-commands=* --root=%s ' % self.root

extra_args = []

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
cd "{root}"

# Generating efr32-brd4187c-light-rpc-no-version
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/silabs '--args=silabs_board="BRD4187C" is_debug=false import("//with_pw_rpc.gni") efr32_sdk_root="TEST_GSDK_ROOT" openthread_root="TEST_GSDK_ROOT/util/third_party/openthread" wiseconnect_sdk_root="TEST_WISECONNECT_SDK_ROOT" wifi_sdk_root="TEST_WIFI_SDK_ROOT"' {out}/efr32-brd4187c-light-rpc-no-version
gn gen --check --fail-on-unused-args '--add-export-compile-commands=*' --root={root}/examples/lighting-app/silabs '--args=silabs_board="BRD4187C" is_debug=false import("//with_pw_rpc.gni") efr32_sdk_root="TEST_GSDK_ROOT" openthread_root="TEST_GSDK_ROOT/util/third_party/openthread" wiseconnect_sdk_root="TEST_WISECONNECT_SDK_ROOT" wifi_sdk_root="TEST_WIFI_SDK_ROOT"' {out}/efr32-brd4187c-light-rpc-no-version

# Building efr32-brd4187c-light-rpc-no-version
ninja -C {out}/efr32-brd4187c-light-rpc-no-version
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cd "{root}"
# Generating linux-arm64-chip-tool-ipv6only-clang
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/chip-tool '"'"'--args=chip_inet_config_enable_ipv4=false is_clang=true target_cpu="arm64" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-chip-tool-ipv6only-clang'
gn gen --check --fail-on-unused-args '"'"'--add-export-compile-commands=*'"'"' --root={root}/examples/chip-tool '"'"'--args=chip_inet_config_enable_ipv4=false is_clang=true target_cpu="arm64" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-chip-tool-ipv6only-clang'

# Setting up Java deps
third_party/java_deps/set_up_java_deps.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cd "{root}"
# Generating linux-arm64-ota-requestor-nodeps-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/ota-requestor-app/linux '"'"'--args=chip_inet_config_enable_ipv4=false chip_config_network_layer_ble=false chip_enable_ble=false chip_enable_wifi=false chip_enable_openthread=false is_clang=true chip_crypto="mbedtls" target_cpu="arm64" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-ota-requestor-nodeps-ipv6only'
gn gen --check --fail-on-unused-args '"'"'--add-export-compile-commands=*'"'"' --root={root}/examples/ota-requestor-app/linux '"'"'--args=chip_inet_config_enable_ipv4=false chip_config_network_layer_ble=false chip_enable_ble=false chip_enable_wifi=false chip_enable_openthread=false is_clang=true chip_crypto="mbedtls" target_cpu="arm64" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-ota-requestor-nodeps-ipv6only'

# Setting up Java deps
third_party/java_deps/set_up_java_deps.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
cd "{root}"

# Generating linux-x64-all-clusters-coverage
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/all-clusters-app/linux --args=use_coverage=true {out}/linux-x64-all-clusters-coverage
gn gen --check --fail-on-unused-args '--add-export-compile-commands=*' --root={root}/examples/all-clusters-app/linux --args=use_coverage=true {out}/linux-x64-all-clusters-coverage

# Setting up Java deps
third_party/java_deps/set_up_java_deps.sh
Expand Down
2 changes: 1 addition & 1 deletion scripts/examples/gn_bouffalolab_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ else
example_dir=$MATTER_ROOT/examples/$example_name/bouffalolab/$bouffalo_chip
output_dir=$MATTER_ROOT/$output_folder

gn gen --check --fail-on-unused-args --export-compile-commands --root="$example_dir" "$output_dir" --args="${optArgs[*]}"
gn gen --check --fail-on-unused-args --add-export-compile-commands=* --root="$example_dir" "$output_dir" --args="${optArgs[*]}"

ninja -C "$output_dir"
fi
2 changes: 1 addition & 1 deletion scripts/examples/gn_silabs_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ else
optArgs+="openthread_root=\"$GSDK_ROOT/util/third_party/openthread\" "
fi

"$GN_PATH" gen --check --script-executable="$PYTHON_PATH" --fail-on-unused-args --export-compile-commands --root="$ROOT" --dotfile="$DOTFILE" --args="silabs_board=\"$SILABS_BOARD\" $optArgs" "$BUILD_DIR"
"$GN_PATH" gen --check --script-executable="$PYTHON_PATH" --fail-on-unused-args --add-export-compile-commands=* --root="$ROOT" --dotfile="$DOTFILE" --args="silabs_board=\"$SILABS_BOARD\" $optArgs" "$BUILD_DIR"

if [ "$USE_SLC" == true ]; then
# Activation needs to be after SLC generation which is done in gn gen.
Expand Down
6 changes: 3 additions & 3 deletions scripts/examples/gn_stm32_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,14 @@ else
BUILD_DIR=$OUTDIR/$STM32_BOARD
echo BUILD_DIR="$BUILD_DIR"
if [ "$USE_WIFI" == true ]; then
gn gen --check --fail-on-unused-args --export-compile-commands --root="$ROOT" --dotfile="$ROOT"/build_for_wifi_gnfile.gn --args="stm32_board=\"$STM32_BOARD\" $optArgs" "$BUILD_DIR"
gn gen --check --fail-on-unused-args --add-export-compile-commands=* --root="$ROOT" --dotfile="$ROOT"/build_for_wifi_gnfile.gn --args="stm32_board=\"$STM32_BOARD\" $optArgs" "$BUILD_DIR"
else
# thread build
#
if [ -z "$optArgs" ]; then
gn gen --check --fail-on-unused-args --export-compile-commands --root="$ROOT" --args="stm32_board=\"$STM32_BOARD\" treat_warnings_as_errors=false" --ide=json "$BUILD_DIR"
gn gen --check --fail-on-unused-args --add-export-compile-commands=* --root="$ROOT" --args="stm32_board=\"$STM32_BOARD\" treat_warnings_as_errors=false" --ide=json "$BUILD_DIR"
else
gn gen --check --fail-on-unused-args --export-compile-commands --root="$ROOT" --args="stm32_board=\"$STM32_BOARD\" $optArgs treat_warnings_as_errors=false" --ide=json "$BUILD_DIR"
gn gen --check --fail-on-unused-args --add-export-compile-commands=* --root="$ROOT" --args="stm32_board=\"$STM32_BOARD\" $optArgs treat_warnings_as_errors=false" --ide=json "$BUILD_DIR"
fi
fi
ninja -v -C "$BUILD_DIR"/
Expand Down
14 changes: 7 additions & 7 deletions scripts/helpers/update_compile_commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ CHIP_ROOT="$(dirname "$0")/../.."

source "$CHIP_ROOT/scripts/activate.sh"

gn --root="$CHIP_ROOT" gen "$CHIP_ROOT/out/debug" --export-compile-commands=host_gcc
gn --root="$CHIP_ROOT" gen "$CHIP_ROOT/out/debug" --add-export-compile-commands="//:host_gcc"
mv "$CHIP_ROOT/out/debug/compile_commands.json" "$CHIP_ROOT/out/debug/compile_commands.gcc.json"

gn --root="$CHIP_ROOT" gen "$CHIP_ROOT/out/debug" --export-compile-commands=host_clang
gn --root="$CHIP_ROOT" gen "$CHIP_ROOT/out/debug" --add-export-compile-commands="//:host_clang"
mv "$CHIP_ROOT/out/debug/compile_commands.json" "$CHIP_ROOT/out/debug/compile_commands.clang.json"

gn --root="$CHIP_ROOT" gen "$CHIP_ROOT/out/debug" --export-compile-commands=host_gcc_mbedtls
gn --root="$CHIP_ROOT" gen "$CHIP_ROOT/out/debug" --add-export-compile-commands="//:host_gcc_mbedtls"
mv "$CHIP_ROOT/out/debug/compile_commands.json" "$CHIP_ROOT/out/debug/compile_commands.mbedtls.json"

gn --root="$CHIP_ROOT" gen "$CHIP_ROOT/out/debug" --export-compile-commands=android_x64
gn --root="$CHIP_ROOT" gen "$CHIP_ROOT/out/debug" --add-export-compile-commands="//:android_x64"
mv "$CHIP_ROOT/out/debug/compile_commands.json" "$CHIP_ROOT/out/debug/compile_commands.android_x64.json"

gn --root="$CHIP_ROOT" gen "$CHIP_ROOT/out/debug" --export-compile-commands=android_arm64
gn --root="$CHIP_ROOT" gen "$CHIP_ROOT/out/debug" --add-export-compile-commands="//:android_arm64"
mv "$CHIP_ROOT/out/debug/compile_commands.json" "$CHIP_ROOT/out/debug/compile_commands.android_arm64.json"

gn --root="$CHIP_ROOT" gen "$CHIP_ROOT/out/debug" --export-compile-commands=efr32_lock_app
gn --root="$CHIP_ROOT" gen "$CHIP_ROOT/out/debug" --add-export-compile-commands="//:efr32_lock_app"
mv "$CHIP_ROOT/out/debug/compile_commands.json" "$CHIP_ROOT/out/debug/compile_commands.efr32.json"

gn --root="$CHIP_ROOT" gen "$CHIP_ROOT/out/debug" --export-compile-commands=tizen_lighting_app
gn --root="$CHIP_ROOT" gen "$CHIP_ROOT/out/debug" --add-export-compile-commands="//:tizen_lighting_app"
mv "$CHIP_ROOT/out/debug/compile_commands.json" "$CHIP_ROOT/out/debug/compile_commands.tizen_arm.json"

0 comments on commit 47780ad

Please sign in to comment.