diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2022-04-11 16:14:25 +0200 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2022-04-12 08:11:04 +0200 |
commit | 42532bb072cb10cf93c3c18217589ed724ac3832 (patch) | |
tree | 9b14b72861954c4035ef3a0d447252b1d82e3616 | |
parent | f8c9a25b35fb1cc0823b495c9d94758d6b1cb1c0 (diff) | |
download | ptxdist-42532bb072cb10cf93c3c18217589ed724ac3832.tar.gz ptxdist-42532bb072cb10cf93c3c18217589ed724ac3832.tar.xz |
ptxd_make_world_prepare: make compile_commands.json useful for cmake and meson
Both build-systems now generate compile_commands.json in the package build
dir. Using these files directly does not work very well. The include paths
added by the toolchain wrappers are missing.
So patch the files to add some more flags and place the result in the
package source dir.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r-- | scripts/lib/ptxd_make_world_prepare.sh | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/scripts/lib/ptxd_make_world_prepare.sh b/scripts/lib/ptxd_make_world_prepare.sh index aa5f91936..538e2bd1b 100644 --- a/scripts/lib/ptxd_make_world_prepare.sh +++ b/scripts/lib/ptxd_make_world_prepare.sh @@ -69,6 +69,26 @@ EOF } export -f ptxd_make_world_prepare_sanity_check +ptxd_make_world_prepare_compile_commands() { + local src_cmds dst_cmds + if [ ! -e compile_commands.json ]; then + return + fi + + if [ "${pkg_dir}" = "${pkg_build_dir}" ]; then + mv compile_commands.json compile_commands.json.orig + src_cmds=compile_commands.json.orig + else + src_cmds=compile_commands.json + fi + dst_cmds="${pkg_dir}/compile_commands.json" + + sed \ + -e "s#\(\"command\": \"[^ ]*\(gcc\|clang\) \)#\1 ${PTXDIST_CROSS_CPPFLAGS} ${pkg_cflags} #" \ + -e "s#\(\"command\": \"[^ ]*++ \)#\1 ${PTXDIST_CROSS_CPPFLAGS} ${pkg_cxxflags} #" \ + "${src_cmds}" > "${dst_cmds}" +} +export -f ptxd_make_world_prepare_compile_commands # # prepare for cmake based pkgs @@ -81,7 +101,8 @@ ptxd_make_world_prepare_cmake() { "${pkg_conf_env}" \ cmake \ "${pkg_conf_opt}" \ - "${pkg_conf_dir}" + "${pkg_conf_dir}" && + ptxd_make_world_prepare_compile_commands } export -f ptxd_make_world_prepare_cmake @@ -151,7 +172,8 @@ ptxd_make_world_prepare_meson() { "${pkg_conf_env}" \ meson \ "${pkg_conf_opt}" \ - "${pkg_conf_dir}" + "${pkg_conf_dir}" && + ptxd_make_world_prepare_compile_commands } export -f ptxd_make_world_prepare_meson |