Bugfix: skip rebuild without new options and preprocess
This commit is contained in:
parent
91d9b5c2e6
commit
35aa381710
@ -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<wr::Execution> 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<sys::Process>(lmd_builder)
|
||||
.and_then<sys::ExitStatus>(lmd_child_wait)
|
||||
.map<int>(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<sys::Process>(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<std::string> 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
|
||||
10
Bear.spec
10
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user