A script to generate build artifacts for Chrome OS packages.
WARNING: this script is only manually tested for very limited purposes and by very limited engineer. The engineer tried to list possible pitfalls here but certainly missed something. Use at your own risk.
The ultimate goal for the script is to generate input for package_index
which makes references available for Chrome on Codesearch page. The script should help to reuse package_index
for ChromeOS purposes.
Currently, it is able to generate, fix and merge:
The main entrypoint for this tool is at chromite/contrib/package_index_cros/main
. Run that file with --help
for details.
NOTE: same chroot notation used as in ChromiumOS.
Side effect of the compile_commands.json
generator is that it can be used locally with clangd.
Install package_index_cros
with steps above.
Install clangd.
Build packages and preserve build targets:
(inside) $ cros-workon-${BOARD} start package1 package2 package3 $ FEATURES="noclean test" emerge-${BOARD} package1 package2 package3
Generate compile_commands.json
:
(outside) $ /path/to/package_index_cros/main \ --with-tests \ --compile-commands \ /path/to/clangd/compile/commands/dir/compile_commands.json \ package1 package2 package3
Where:
--with-tests
indicates that packages were built with tests.--compile-commands /some/path/compile_commands.json
will store tells the script to generate compile commands and store it in given file.--build-dir ${some_dir}
will create a dir and merge all packages' build dirs and generated files there. Can be useful when working with proto files but fully optional.NOTE: The existing ${some_dir}
is removed each script run. Be careful with that axe.
Bosh. Done. Now you can use clangd and click references in your favorite IDE.
NOTE: The script does not clean up after itself. You might want to use cros_sdk clean
.
To have as many packages as possible in compile commands, build all the packages and run the script on top level packages:
(inside) $ FEATURES="noclean" build_packages \ --board ${BOARD} \ --no-usepkg --no-usepkgonly \ --skip-toolchain-update --skip-chroot-upgrade \ --withtest --withdev --withfactory $ FEATURES="noclean" cros_run_unit_tests --board ${BOARD} (outside) $ /path/to/package_index_cros/main \ --with-tests \ --compile-commands \ /path/to/clangd/compile/commands/dir/compile_commands.json \ virtual/target-chromium-os virtual/target-chromium-os-test \ virtual/target-chromium-os-dev virtual/target-chromium-os-factory \ virtual/target-chromium-os-factory-shim