Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
100aab2793
!15 【Issue修复】安装Bear rpmbuild后的src.rpm包编译失败
From: @xhuacmer 
Reviewed-by: @li-yancheng 
Signed-off-by: @li-yancheng
2023-05-06 03:23:34 +00:00
xhuacmer
3034b71e96 fix missing other tar.gz packages in src.rpm.
delete README.en.md,README.md from SOURCE label.
update release number according to PR comments.

Signed-off-by: xhuacmer <yangt111@chinatelecom.cn>
2023-05-04 14:20:57 +08:00
openeuler-ci-bot
b6719c5b57
!10 Bugfix: skip rebuild without new options and preprocess
From: @huitailangzju 
Reviewed-by: @li-yancheng 
Signed-off-by: @li-yancheng
2022-12-20 06:56:42 +00:00
huitailangzju
35aa381710 Bugfix: skip rebuild without new options and preprocess 2022-12-20 14:42:41 +08:00
openeuler-ci-bot
30c584e070
!8 modify spec
From: @huitailangzju 
Reviewed-by: @li-yancheng 
Signed-off-by: @li-yancheng
2022-12-01 04:12:06 +00:00
huitailangzju
91d9b5c2e6 modify spec 2022-12-01 11:53:07 +08:00
openeuler-ci-bot
2d7b3bb27d
!3 Support build with new options and generate link commands
From: @huitailangzju 
Reviewed-by: @li-yancheng 
Signed-off-by: @li-yancheng
2022-12-01 03:23:29 +00:00
huitailangzju
90e3afbd7b Add option to compiler and linker commands;
rebuild when build failed with new options;
generate compile commands include linker commands
2022-11-30 18:57:17 +08:00
openeuler-ci-bot
3a6995978f
!2 Init Bear repository
From: @huitailangzju 
Reviewed-by: @li-yancheng 
Signed-off-by: @li-yancheng
2022-11-30 06:32:20 +00:00
huitailangzju
8a1687245f Init Bear repository. 2022-11-30 11:58:18 +08:00
9 changed files with 1414 additions and 0 deletions

View File

@ -0,0 +1,76 @@
diff --git a/third_party/fmt/CMakeLists.txt b/third_party/fmt/CMakeLists.txt
index cc6bae4..c26a7ec 100644
--- a/third_party/fmt/CMakeLists.txt
+++ b/third_party/fmt/CMakeLists.txt
@@ -10,13 +10,9 @@ else ()
include(ExternalProject)
ExternalProject_Add(fmt_dependency
URL
- https://github.com/fmtlib/fmt/archive/9.0.0.tar.gz
+ ${DEPEND_PATH}/fmt-9.0.0.tar.gz
URL_HASH
MD5=d56c8b0612b049bb1854f07c8b133f3c
- DOWNLOAD_NO_PROGRESS
- 1
- UPDATE_COMMAND
- ""
LOG_CONFIGURE
1
LOG_BUILD
diff --git a/third_party/googletest/CMakeLists.txt b/third_party/googletest/CMakeLists.txt
index 42dbf27..322b37d 100644
--- a/third_party/googletest/CMakeLists.txt
+++ b/third_party/googletest/CMakeLists.txt
@@ -12,13 +12,9 @@ else ()
include(ExternalProject)
ExternalProject_Add(googletest_dependency
URL
- https://github.com/google/googletest/archive/release-1.12.1.tar.gz
+ ${DEPEND_PATH}/googletest-release-1.12.1.tar.gz
URL_HASH
MD5=e82199374acdfda3f425331028eb4e2a
- DOWNLOAD_NO_PROGRESS
- 1
- UPDATE_COMMAND
- ""
LOG_CONFIGURE
1
LOG_BUILD
diff --git a/third_party/nlohmann_json/CMakeLists.txt b/third_party/nlohmann_json/CMakeLists.txt
index c4ec891..7e57f1d 100644
--- a/third_party/nlohmann_json/CMakeLists.txt
+++ b/third_party/nlohmann_json/CMakeLists.txt
@@ -9,13 +9,9 @@ else ()
include(ExternalProject)
ExternalProject_Add(nlohmann_json_dependency
URL
- https://github.com/nlohmann/json/archive/v3.10.5.tar.gz
+ ${DEPEND_PATH}/json-3.10.5.tar.gz
URL_HASH
MD5=5b946f7d892fa55eabec45e76a20286b
- DOWNLOAD_NO_PROGRESS
- 1
- UPDATE_COMMAND
- ""
LOG_CONFIGURE
1
LOG_BUILD
diff --git a/third_party/spdlog/CMakeLists.txt b/third_party/spdlog/CMakeLists.txt
index 2d8a5da..cefba1d 100644
--- a/third_party/spdlog/CMakeLists.txt
+++ b/third_party/spdlog/CMakeLists.txt
@@ -10,13 +10,9 @@ else ()
include(ExternalProject)
ExternalProject_Add(spdlog_dependency
URL
- https://github.com/gabime/spdlog/archive/v1.10.0.tar.gz
+ ${DEPEND_PATH}/spdlog-1.10.0.tar.gz
URL_HASH
MD5=effea813cd81cfb5588806c5754e14f1
- DOWNLOAD_NO_PROGRESS
- 1
- UPDATE_COMMAND
- ""
LOG_CONFIGURE
1
LOG_BUILD

File diff suppressed because it is too large Load Diff

View File

@ -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

BIN
Bear-3.0.20.tar.gz Normal file

Binary file not shown.

121
Bear.spec Normal file
View File

@ -0,0 +1,121 @@
#
# spec file for package Bear
#
# Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
# Everyone is permitted to copy and distribute verbatim copies
# of this license document, but changing it is not allowed.
#
# This file is under the GNU GENERAL PUBLIC LICENSE Version 3.
#
%bcond_with tests
Name: Bear
Version: 3.0.20
Release: 4
Summary: Tool to generate compilation database for clang tooling
License: GPL-3.0-or-later
URL: https://github.com/rizsotto/Bear
Source0: %{name}-%{version}.tar.gz
Source1: googletest-release-1.12.1.tar.gz
Source2: fmt-9.0.0.tar.gz
Source3: json-3.10.5.tar.gz
Source4: spdlog-1.10.0.tar.gz
BuildRequires: bash-completion
BuildRequires: gcc, gcc-c++, make
BuildRequires: protobuf-devel, grpc-devel, grpc-plugins
BuildRequires: c-ares-devel
BuildRequires: glibc-devel, glibc-debuginfo
BuildRequires: cmake
BuildRequires: pkgconfig(absl_synchronization)
BuildRequires: pkgconfig(grpc)
BuildRequires: pkgconfig(grpc++) >= 1.26
BuildRequires: pkgconfig(protobuf) >= 3.11
%if %{with tests}
BuildRequires: python
BuildRequires: python3-lit
BuildRequires: python3-setuptools
# one of the tests requires /usr/bin/more
BuildRequires: util-linux
# additional binaries for specific tests
BuildRequires: gcc-fortran
BuildRequires: fakeroot
BuildRequires: valgrind
# the fakeroot test requires xargs
BuildRequires: findutils
%endif
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.
One way to get compilation database is to use cmake as build tool. When the
project compiles with no cmake, but another build system, there is no free json
file. Bear is a tool to generate such file during the build process.
%prep
%autosetup -p1 -n %{name}-%{version}
%build
BEAR_MFLAGS_JOBS="%{?_smp_mflags}"
mkdir build
cd build
%cmake .. \
-DDEPEND_PATH=%{_sourcedir} \
-DCMAKE_INSTALL_PREFIX=%{_prefix} \
%if %{with tests}
-DENABLE_UNIT_TESTS=ON \
-DENABLE_FUNC_TESTS=ON
%else
-DENABLE_UNIT_TESTS=OFF \
-DENABLE_FUNC_TESTS=OFF
%endif
make $BEAR_MFLAGS_JOBS
%install
pushd build
make DESTDIR=%{buildroot} install
# Let RPM install it correctly
rm -rf %{buildroot}%{_datadir}/doc
popd
%files
%license COPYING
%doc README.md
%{_bindir}/bear
%{_bindir}/citnames
%{_bindir}/intercept
%{_mandir}/man1/bear.1*
%{_mandir}/man1/citnames.1*
%{_mandir}/man1/intercept.1*
%{_libdir}/bear/
%changelog
* Fri Jan 6 2023 yangtao <yangt111@chinatelecom.cn> - 3.0.20-4
- Type:SPEC
- ID:NA
- SUG:NA
- DESC: fix missing other tar.gz packages in src.rpm.
* 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
- SUG:NA
- DESC:Rebuild when add option failed
* Wed Nov 16 2022 zhaowenyu <804544223@qq.com> - 3.0.20-1
- Type:Init
- ID:NA
- SUG:NA
- DESC:Init Bear 3.0.20 repository

BIN
fmt-9.0.0.tar.gz Normal file

Binary file not shown.

Binary file not shown.

BIN
json-3.10.5.tar.gz Normal file

Binary file not shown.

BIN
spdlog-1.10.0.tar.gz Normal file

Binary file not shown.