Skip to content

Commit 50a2af2

Browse files
authored
Merge branch 'development' into f-FixesMissingLinkDeps
2 parents c036ce6 + 1789560 commit 50a2af2

9 files changed

Lines changed: 201 additions & 12 deletions

File tree

.github/workflows/ci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Phasar CI
2+
3+
on:
4+
push:
5+
branches: [ master, development ]
6+
pull_request:
7+
branches: [ master, development ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-20.04
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
compiler: [ [clang++-12, clang-12] ]
16+
build: [ Debug, Release ]
17+
18+
continue-on-error: false
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v2
22+
with:
23+
fetch-depth: 0
24+
submodules: recursive
25+
26+
- name: Install Basic Dependencies
27+
shell: bash
28+
run: |
29+
sudo apt-get update
30+
sudo apt-get -y install --no-install-recommends \
31+
cmake \
32+
ninja-build \
33+
libstdc++6 \
34+
libboost-all-dev
35+
36+
- name: Install Phasar Dependencies
37+
shell: bash
38+
run: |
39+
./utils/InstallAptDependencies.sh
40+
41+
- name: Install Strategy Dependencies
42+
shell: bash
43+
run: |
44+
sudo apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key
45+
sudo add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main'
46+
sudo apt-get update
47+
sudo apt-get -y install --no-install-recommends \
48+
${{ matrix.compiler[1] }} \
49+
llvm-12-dev \
50+
libllvm12 \
51+
libclang-common-12-dev \
52+
libclang-12-dev \
53+
libclang-cpp12-dev \
54+
clang-tidy-12
55+
56+
- name: Building Phasar in ${{ matrix.build }} with ${{ matrix.compiler[0] }}
57+
env:
58+
BUILD_TYPE: ${{ matrix.build }}
59+
CXX: ${{ matrix.compiler[0] }}
60+
CC: ${{ matrix.compiler[1] }}
61+
shell: bash
62+
run: |
63+
mkdir build
64+
cd build
65+
cmake .. \
66+
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
67+
-DCMAKE_CXX_COMPILER=$CXX \
68+
-G Ninja
69+
cmake --build .
70+
71+
- name: Run Unittests
72+
shell: bash
73+
run: |
74+
cd build
75+
cmake --build . --target check-phasar-unittests

.github/workflows/pre-commit.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
pre-commit:
8+
runs-on: ubuntu-20.04
9+
steps:
10+
- uses: actions/checkout@v2
11+
with:
12+
fetch-depth: 0
13+
14+
- uses: actions/setup-python@v2
15+
16+
- uses: pre-commit/action@v2.0.0
17+
with:
18+
extra_args: --from-ref origin/development --to-ref HEAD
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Phasar clang-format review runner
2+
3+
on:
4+
pull_request:
5+
branches: [ master, development ]
6+
7+
jobs:
8+
format:
9+
runs-on: ubuntu-20.04
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
tool: [ clang-format ]
14+
include:
15+
- tool: clang-format
16+
install: |
17+
sudo apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key
18+
sudo add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main'
19+
sudo apt-get update
20+
sudo apt-get -y install --no-install-recommends clang-format-12
21+
regex: \.(h|c|hpp|cpp)$
22+
command: clang-format-12 --style=file -i
23+
24+
continue-on-error: false
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v2
28+
with:
29+
submodules: recursive
30+
31+
- name: Install Dependencies
32+
shell: bash
33+
run: ${{ matrix.install }}
34+
35+
- name: Fetch Base Branch
36+
shell: bash
37+
run: |
38+
git fetch --depth=1 origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
39+
40+
- name: Run Tool
41+
shell: bash
42+
run: |
43+
FILES=$(git diff --name-only --diff-filter=AM origin/${{ github.base_ref }} HEAD | egrep "${{ matrix.regex }}" || true)
44+
[ -z "$FILES" ] || (${{ matrix.command }} $FILES && git diff --diff-filter=M $FILES)
45+
46+
- name: Add Suggestions
47+
uses: reviewdog/action-suggester@v1
48+
with:
49+
tool_name: ${{ matrix.tool }}
50+
filter_mode: diff_context
51+
level: warning

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v2.4.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
- id: requirements-txt-fixer
12+
- repo: https://github.com/pre-commit/mirrors-clang-format
13+
rev: 'v12.0.1'
14+
hooks:
15+
- id: clang-format

CMakeLists.txt

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ set(CMAKE_CXX_STANDARD 17)
1515
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1616
set(CMAKE_CXX_EXTENSIONS OFF)
1717

18+
include(GNUInstallDirs)
19+
1820
set_property(GLOBAL PROPERTY TARGET_MESSAGES OFF)
1921

2022
if (NOT CMAKE_BUILD_TYPE)
@@ -99,7 +101,10 @@ include_directories(
99101
${PHASAR_SRC_DIR}/include
100102
)
101103

102-
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
104+
105+
set(PHASAR_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}/phasar)
106+
107+
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${PHASAR_INSTALL_LIBDIR})
103108
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
104109

105110
if (LLVM_ENABLE_LIBCXX)
@@ -117,14 +122,36 @@ find_package(Boost 1.65.1 COMPONENTS filesystem graph system program_options log
117122
#find_package(Boost 1.72.0 COMPONENTS filesystem graph system program_options log ${BOOST_THREAD} REQUIRED)
118123
include_directories(${Boost_INCLUDE_DIRS})
119124

120-
# JSON library
121-
option(JSON_BuildTests OFF)
122-
add_subdirectory(external/json EXCLUDE_FROM_ALL)
125+
# We need to work around the behavior of nlohmann_json_schema_validator and nlohmann_json here
126+
# The validator needs the json part, but if you include it, the library of nlohmann_json_schema_validator
127+
# is not installed, leading to linker error. But just including nlohmann_json is not sufficient, as
128+
# in the installed state the nlohmann_json_schema_validator needs the nlohmann_json package which needs
129+
# to be installed.
130+
# The following workaround may collapse or become unnecessary once the issue is
131+
# changed or fixed in nlohmann_json_schema_validator.
132+
133+
#Override option of nlohmann_json_schema_validator to not build its tests
134+
set(BUILD_TESTS OFF CACHE BOOL "Build json-schema-validator-tests")
135+
136+
# Make nlohmann_json_schema_validator happy by telling it how to find the single include of nlohmann_json
123137
include_directories(external/json/single_include/)
138+
124139
if (PHASAR_IN_TREE)
125140
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS nlohmann_json_schema_validator)
126141
endif()
127142

143+
set(nlohmann_json_DIR ${PHASAR_SRC_DIR}/external/json/single_include/)
144+
145+
# Json Schema Validator
146+
set(JSON_VALIDATOR_INSTALL ON)
147+
add_subdirectory(external/json-schema-validator)
148+
include_directories(external/json-schema-validator/src/)
149+
150+
# now we finally add the subdirectory
151+
set(JSON_BuildTests OFF)
152+
set(JSON_Install ON)
153+
add_subdirectory(external/json)
154+
128155
# Googletest
129156
if (NOT PHASAR_IN_TREE)
130157
add_subdirectory(external/googletest EXCLUDE_FROM_ALL)
@@ -162,7 +189,7 @@ endif()
162189
# Clang
163190
# The clang-cpp shared library is now the preferred way to link dynamically against libclang if we build out of tree.
164191
if(NOT PHASAR_IN_TREE)
165-
find_library(CLANG_LIBRARY NAMES clang-cpp REQUIRED HINTS ${LLVM_LIBRARY_DIRS})
192+
find_library(CLANG_LIBRARY NAMES clang-cpp libclang-cpp REQUIRED HINTS ${LLVM_LIBRARY_DIRS})
166193
if(${CLANG_LIBRARY} STREQUAL "CLANG_LIBRARY-NOTFOUND")
167194
set(NEED_LIBCLANG_COMPONENT_LIBS on)
168195
endif()

cmake/phasar_macros.cmake

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ function(add_phasar_unittest test_name)
2626
phasar_experimental
2727
# phasar_clang
2828
phasar_passes
29-
# FIXME: cmake variable ${PHASAR_PLUGINS_LIB} is empty although it should contain phasar_plugins
29+
# FIXME: cmake variable ${PHASAR_PLUGINS_LIB} is empty although it should contain phasar_plugins
3030
phasar_plugins
3131
# ${PHASAR_PLUGINS_LIB}
3232
phasar_pointer
3333
phasar_typehierarchy
34+
phasar_taintconfig
35+
nlohmann_json_schema_validator
3436
${SQLITE3_LIBRARY}
3537
${Boost_LIBRARIES}
3638
${CMAKE_DL_LIBS}
@@ -198,14 +200,14 @@ macro(add_phasar_library name)
198200
else()
199201
install(TARGETS ${name}
200202
EXPORT phasarTargets
201-
LIBRARY DESTINATION lib
202-
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
203+
LIBRARY DESTINATION ${PHASAR_INSTALL_LIBDIR}
204+
ARCHIVE DESTINATION ${PHASAR_INSTALL_LIBDIR})
203205
install(TARGETS ${name}
204206
EXPORT ${name}-targets
205207
COMPONENT ${component_name}
206208
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/phasar
207-
LIBRARY DESTINATION lib
208-
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
209+
LIBRARY DESTINATION ${PHASAR_INSTALL_LIBDIR}
210+
ARCHIVE DESTINATION ${PHASAR_INSTALL_LIBDIR})
209211
install(EXPORT ${name}-targets
210212
FILE ${name}-targets.cmake
211213
NAMESPACE phasar::

lib/PhasarLLVM/DataFlowSolver/IfdsIde/phasar_ifdside-config.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ list(APPEND
1616
controlflow
1717
phasarllvm_utils
1818
db
19+
taintconfig
1920
)
2021

2122
foreach(dep ${IFDSIDE_DEPS})

lib/PhasarLLVM/TaintConfig/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ endif()
2525

2626
target_link_libraries(phasar_taintconfig
2727
LINK_PUBLIC
28-
nlohmann_json::nlohmann_json
2928
nlohmann_json_schema_validator
3029
)
3130

lib/PhasarLLVM/TaintConfig/phasar_taintconfig-config.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ foreach(dep ${PHASAR_TAINTCONFIG_DEPS})
1717
endif()
1818
endforeach()
1919

20+
find_package(nlohmann_json_schema_validator REQUIRED)
21+
2022
list(APPEND
2123
PHASAR_NEEDED_LIBS
2224
phasar::phasar_taintconfig
23-
nlohmann_json::nlohmann_json
2425
nlohmann_json_schema_validator
2526
)

0 commit comments

Comments
 (0)