Skip to content

Commit 47780ad

Browse files
Migrating deprecated GN flag: export-compile-commands (#35429)
* 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 <commits@restyled.io>
1 parent aba2383 commit 47780ad

15 files changed

+25
-25
lines changed

.github/workflows/build.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,14 @@ jobs:
205205
esac
206206
207207
rm -rf ./out/sanitizers
208-
BUILD_TYPE=sanitizers scripts/build/gn_gen.sh --args="$GN_ARGS" --export-compile-commands
208+
BUILD_TYPE=sanitizers scripts/build/gn_gen.sh --args="$GN_ARGS" --add-export-compile-commands=*
209209
BUILD_TYPE=sanitizers scripts/tests/gn_tests.sh
210210
done
211211
- name: Generate tests with sanitizers (for tidy)
212212
if: github.event.pull_request.number != null
213213
run: |
214214
rm -rf ./out/sanitizers
215-
BUILD_TYPE=sanitizers scripts/build/gn_gen.sh --args="is_clang=true is_asan=true" --export-compile-commands
215+
BUILD_TYPE=sanitizers scripts/build/gn_gen.sh --args="is_clang=true is_asan=true" --add-export-compile-commands=*
216216
- name: Ensure codegen is done for sanitize
217217
run: |
218218
./scripts/run_in_build_env.sh "./scripts/run_codegen_targets.sh out/sanitizers"
@@ -439,7 +439,7 @@ jobs:
439439
# We want to build various standalone example apps (similar to what examples-linux-standalone.yaml
440440
# does), so use target_os="all" to get those picked up as part of the "unified" build. But then
441441
# to save CI resources we want to exclude the "host clang" build, which uses the pigweed clang.
442-
scripts/build/gn_gen.sh --args='target_os="all" is_asan=true enable_host_clang_build=false' --export-compile-commands
442+
scripts/build/gn_gen.sh --args='target_os="all" is_asan=true enable_host_clang_build=false' --add-export-compile-commands=*
443443
scripts/run_in_build_env.sh "ninja -C ./out/$BUILD_TYPE"
444444
scripts/tests/gn_tests.sh
445445
- name: Ensure codegen is done for default

config/qpg/chip-gn/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ gn \
3131
--root-target=//config/qpg/chip-gn \
3232
--dotfile="$GN_ROOT_TARGET/.gn" \
3333
--script-executable=python3 \
34-
--export-compile-commands \
34+
--add-export-compile-commands="*" \
3535
gen \
3636
--check \
3737
--args="$GN_ARGS" \

examples/chef/chef.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ def main() -> int:
884884
"""))
885885
if options.do_clean:
886886
shell.run_cmd("rm -rf out")
887-
shell.run_cmd("gn gen --export-compile-commands out")
887+
shell.run_cmd("gn gen --add-export-compile-commands=* out")
888888
shell.run_cmd("ninja -C out")
889889

890890
#

examples/lighting-app/tizen/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Generating tizen-arm-light
1313
```sh
1414
gn gen --check \
1515
--fail-on-unused-args \
16-
--export-compile-commands \
16+
--add-export-compile-commands=* \
1717
--root=$PW_PROJECT_ROOT/examples/lighting-app/tizen \
1818
"--args=target_os=\"tizen\" target_cpu=\"arm\" tizen_sdk_root=\"$TIZEN_SDK_ROOT\" tizen_sdk_sysroot=\"$TIZEN_SDK_SYSROOT\"" \
1919
$PW_PROJECT_ROOT/out/tizen-arm-light

scripts/build/builders/efr32.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def bundle_outputs(self):
337337
def generate(self):
338338
cmd = [
339339
'gn', 'gen', '--check', '--fail-on-unused-args',
340-
'--export-compile-commands',
340+
'--add-export-compile-commands=*',
341341
'--root=%s' % self.root
342342
]
343343
if self.dotfile:

scripts/build/builders/gn.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def PostBuildCommand(self):
5555
def generate(self):
5656
cmd = [
5757
'gn', 'gen', '--check', '--fail-on-unused-args',
58-
'--export-compile-commands',
58+
'--add-export-compile-commands=*',
5959
'--root=%s' % self.root
6060
]
6161

scripts/build/builders/nxp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def generate(self):
421421

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

426426
extra_args = []
427427

scripts/build/testdata/dry_run_efr32-brd4187c-light-rpc-no-version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
cd "{root}"
33

44
# Generating efr32-brd4187c-light-rpc-no-version
5-
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
5+
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
66

77
# Building efr32-brd4187c-light-rpc-no-version
88
ninja -C {out}/efr32-brd4187c-light-rpc-no-version

scripts/build/testdata/dry_run_linux-arm64-chip-tool-ipv6only-clang.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cd "{root}"
44
# Generating linux-arm64-chip-tool-ipv6only-clang
55
bash -c '
66
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
7-
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'
7+
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'
88

99
# Setting up Java deps
1010
third_party/java_deps/set_up_java_deps.sh

scripts/build/testdata/dry_run_linux-arm64-ota-requestor-nodeps-ipv6only.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cd "{root}"
44
# Generating linux-arm64-ota-requestor-nodeps-ipv6only
55
bash -c '
66
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
7-
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'
7+
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'
88

99
# Setting up Java deps
1010
third_party/java_deps/set_up_java_deps.sh

scripts/build/testdata/dry_run_linux-x64-all-clusters-coverage.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
cd "{root}"
33

44
# Generating linux-x64-all-clusters-coverage
5-
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
5+
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
66

77
# Setting up Java deps
88
third_party/java_deps/set_up_java_deps.sh

scripts/examples/gn_bouffalolab_example.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ else
200200
example_dir=$MATTER_ROOT/examples/$example_name/bouffalolab/$bouffalo_chip
201201
output_dir=$MATTER_ROOT/$output_folder
202202

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

205205
ninja -C "$output_dir"
206206
fi

scripts/examples/gn_silabs_example.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ else
340340
optArgs+="openthread_root=\"$GSDK_ROOT/util/third_party/openthread\" "
341341
fi
342342

343-
"$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"
343+
"$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"
344344

345345
if [ "$USE_SLC" == true ]; then
346346
# Activation needs to be after SLC generation which is done in gn gen.

scripts/examples/gn_stm32_example.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,14 @@ else
176176
BUILD_DIR=$OUTDIR/$STM32_BOARD
177177
echo BUILD_DIR="$BUILD_DIR"
178178
if [ "$USE_WIFI" == true ]; then
179-
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"
179+
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"
180180
else
181181
# thread build
182182
#
183183
if [ -z "$optArgs" ]; then
184-
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"
184+
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"
185185
else
186-
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"
186+
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"
187187
fi
188188
fi
189189
ninja -v -C "$BUILD_DIR"/

scripts/helpers/update_compile_commands.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@ CHIP_ROOT="$(dirname "$0")/../.."
2323

2424
source "$CHIP_ROOT/scripts/activate.sh"
2525

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)