diff --git a/0003-Bugfix-skip-rebuild-without-new-options-and-preprocess.patch b/0003-Bugfix-skip-rebuild-without-new-options-and-preprocess.patch new file mode 100644 index 0000000000000000000000000000000000000000..26c839e6c63eb0bc64ae84a47e8b762cf983e7ab --- /dev/null +++ b/0003-Bugfix-skip-rebuild-without-new-options-and-preprocess.patch @@ -0,0 +1,79 @@ +diff --git a/source/intercept/source/report/wrapper/Application.cc b/source/intercept/source/report/wrapper/Application.cc +index 358d2dc..cec5dba 100644 +--- a/source/intercept/source/report/wrapper/Application.cc ++++ b/source/intercept/source/report/wrapper/Application.cc +@@ -167,6 +167,15 @@ namespace wr { + return option_new; + } + ++ bool WrapperBuilder::enableWrapperBuilder() ++ { ++ bool emtpy_options = compile_flags_.size() == 0 && ld_flags_.size() == 0; ++ // skip preprocess commands ++ auto it = std::find(parameters_replace_.begin(), parameters_replace_.end(), "-E"); ++ bool preprocess = it != parameters_replace_.end(); ++ return !emtpy_options && !preprocess; ++ } ++ + Execution WrapperBuilder::get_new_execution(Execution& execution) + { + return Execution { +@@ -253,17 +262,17 @@ namespace wr { + rust::Result result_execution = supervisor_client.resolve(execution_); + + wr::Execution execution = result_execution.unwrap(); +- +- if (!lamd_is_compiler_call(execution.executable) && !lamd_is_linker_call(execution.executable)) { ++ wr::WrapperBuilder wrBuilder = wr::WrapperBuilder(execution.executable, execution.environment) ++ .add_arguments(execution.arguments.begin(), execution.arguments.end()); ++ if ((!lamd_is_compiler_call(execution.executable) && !lamd_is_linker_call(execution.executable)) ++ || !wrBuilder.enableWrapperBuilder()) { + return result_execution + .and_then(lmd_builder) + .and_then(lmd_child_wait) + .map(lmd_status_ret); + } + +- auto new_execution = wr::WrapperBuilder(execution.executable, execution.environment) +- .add_arguments(execution.arguments.begin(), execution.arguments.end()) +- .get_new_execution(execution); ++ auto new_execution = wrBuilder.get_new_execution(execution); + + auto build_spawn = result_execution.and_then(lmd_wrapper_builder); + +diff --git a/source/intercept/source/report/wrapper/Application.h b/source/intercept/source/report/wrapper/Application.h +index 5113be3..41160c5 100644 +--- a/source/intercept/source/report/wrapper/Application.h ++++ b/source/intercept/source/report/wrapper/Application.h +@@ -79,6 +79,7 @@ namespace wr { + std::list split_optons(std::string& options); + + Execution get_new_execution(Execution& execution); ++ bool enableWrapperBuilder(); + public: + NON_DEFAULT_CONSTRUCTABLE(WrapperBuilder) + +diff --git a/test/cases/compilation/output/skip_preprocess_commands.sh b/test/cases/compilation/output/skip_preprocess_commands.sh +new file mode 100644 +index 0000000..ea229b6 +--- /dev/null ++++ b/test/cases/compilation/output/skip_preprocess_commands.sh +@@ -0,0 +1,18 @@ ++#!/usr/bin/env sh ++ ++# REQUIRES: preload, shell ++# RUN: %{shell} %s %t ++# RUN: cd %T; /usr/bin/env - %{bear} --verbose --output %t.json -- %{shell} %t/build.sh ++# RUN: assert_compilation %t.json count -eq 0 ++ ++ ++TEST=$1 ++ ++mkdir -p $TEST; ++touch $TEST/source.c; ++ ++cat > "$TEST/build.sh" << EOF ++#!/usr/bin/env sh ++ ++$CC -E -o $TEST/source.i $TEST/source.c; ++EOF diff --git a/Bear.spec b/Bear.spec index a6bc81c150ace62b821c146c3b205b79547a6006..161b5ec8b893fad69031647ca4e61cb5bced668c 100644 --- a/Bear.spec +++ b/Bear.spec @@ -11,7 +11,7 @@ %bcond_with tests Name: Bear Version: 3.0.20 -Release: 2 +Release: 3 Summary: Tool to generate compilation database for clang tooling License: GPL-3.0-or-later URL: https://github.com/rizsotto/Bear @@ -42,7 +42,7 @@ BuildRequires: findutils Patch1: 0001-change-external-project-to-local-package.patch Patch2: 0002-Rebuild-when-add-option-failed.patch - +Patch3: 0003-Bugfix-skip-rebuild-without-new-options-and-preprocess.patch %description Bear is a tool to generate compilation database for clang tooling. @@ -92,6 +92,12 @@ popd %{_libdir}/bear/ %changelog +* Mon Dec 19 2022 zhaowenyu <804544223@qq.com> - 3.0.20-3 +- Type:SPEC +- ID:NA +- SUG:NA +- DESC:Skip rebuild without new options and preprocess + * Thu Dec 01 2022 zhaowenyu <804544223@qq.com> - 3.0.20-2 - Type:SPEC - ID:NA