Skip to content

Commit

Permalink
Allow for non vendored abseil and gtest, as required on some platforms,
Browse files Browse the repository at this point in the history
  • Loading branch information
timkpaine committed Sep 26, 2023
1 parent 75c9529 commit 17054a2
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 34 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
81 changes: 74 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,87 @@ jobs:
steps:

- name: Cancel previous
uses: styfle/cancel-workflow-action@0.9.1
uses: styfle/cancel-workflow-action@0.11.0
with:
access_token: ${{ github.token }}

- name: Install build dependencies for simview and surelog
run: |
sudo apt-get update -qq
sudo apt install -y \
libunwind-dev \
build-essential \
cmake \
ninja-build \
g++ \
default-jre \
google-perftools \
python3 python3-dev python3-orderedmultidict python3-psutil \
libgoogle-perftools-dev \
uuid-dev
- name: Checkout simview
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use ccache
uses: hendrikmuhs/[email protected]
with:
key: build-cache

- name: Configure shell
run: |
echo 'PATH=/usr/lib/ccache:'"$PATH" >> $GITHUB_ENV
echo 'PREFIX=${GITHUB_WORKSPACE}/surelog-install' >> $GITHUB_ENV
- name: Show shell configuration
run: |
env
- name: Build Surelog
run: |
git clone --recursive --branch v1.75 https://github.com/chipsalliance/Surelog.git
(cd Surelog ; make install)
- name: Build
run: |
cmake -B build -GNinja -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/surelog-install -DCMAKE_CXX_FLAGS="-Wall -W -Wextra -Werror" .
ninja -C build
- name: Test
run: |
ninja -C build test
linux-build-nonvendored:
name: Build and Test (No Vendored Dependencies)

runs-on: ubuntu-latest
steps:

- name: Install build dependencies for simview and surelog
run: |
sudo apt-get update -qq
sudo apt install -y libunwind-dev
sudo apt install -y \
build-essential cmake ninja-build \
g++ default-jre \
libunwind-dev \
build-essential \
cmake \
ninja-build \
g++ \
default-jre \
google-perftools \
python3 python3-dev python3-orderedmultidict python3-psutil \
libgoogle-perftools-dev \
uuid-dev
- name: Checkout simview
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use ccache
uses: hendrikmuhs/ccache-action@v1
uses: hendrikmuhs/ccache-action@v1.2
with:
key: build-cache

Expand All @@ -49,26 +107,35 @@ jobs:
run: |
env
- name: Install Abseil and GTest
run: |
git clone --depth 1 https://github.com/google/googletest.git
cd googletest && cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 -DCMAKE_POSITION_INDEPENDENT_CODE=ON . && cmake --build build && sudo cmake --install build
git clone --depth 1 --branch 20230802.1 https://github.com/abseil/abseil-cpp.git
pushd abseil-cpp && cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 -DCMAKE_POSITION_INDEPENDENT_CODE=ON . && cmake --build build && sudo cmake --install build
- name: Build Surelog
run: |
git clone --recursive https://github.com/chipsalliance/Surelog.git
(cd Surelog ; make install)
- name: Build
run: |
cmake -B build -GNinja -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/surelog-install -DCMAKE_CXX_FLAGS="-Wall -W -Wextra -Werror" .
cmake -B build -GNinja -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/surelog-install -DCMAKE_CXX_FLAGS="-Wall -W -Wextra -Werror" -DSIMVIEW_USE_HOST_GTEST=ON -DSIMVIEW_USE_HOST_ABSL=ON .
ninja -C build
- name: Test
run: |
ninja -C build test
CodeFormatting:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
20 changes: 16 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ endif()
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")

# Options
option(SIMVIEW_BUILD_TESTS "Build tests" ON)
option(SIMVIEW_USE_HOST_ABSL "Use abseil from host" OFF)
option(SIMVIEW_USE_HOST_GTEST "Use gtest from host" OFF)

# Require out-of-source builds
file(TO_CMAKE_PATH "${PROJECT_BINARY_DIR}/CMakeLists.txt" LOC_PATH)
if(EXISTS "${LOC_PATH}")
Expand All @@ -38,11 +43,18 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-fcolor-diagnostics)
endif()

# Helper macros are defined in a separate file.
include(macros.cmake)
if(SIMVIEW_BUILD_TESTS)
# Testing is good!
enable_testing()

# Testing is good!
enable_testing()
macro(simview_add_test Name)
if(SIMVIEW_BUILD_TESTS)
add_executable(${Name} ${ARGN})
target_link_libraries(${Name} PRIVATE gtest_main)
add_test(NAME ${Name} COMMAND ${Name})
endif()
endmacro()
endif()

# All include is relative to project root, or local dir.
include_directories(${PROJECT_SOURCE_DIR})
Expand Down
51 changes: 34 additions & 17 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,40 @@
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")

if(NOT SIMVIEW_USE_HOST_ABSL OR (SIMVIEW_BUILD_TESTS AND NOT SIMVIEW_USE_HOST_GTEST))
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()
endif()

# Abseil can trigger this warning at current version.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized")
if(NOT SIMVIEW_USE_HOST_ABSL)
# Abseil can trigger this warning at current version.
set(CMAKE_CXX_FLAGS "-Wno-maybe-uninitialized")

# Add all expected submodules.
set(ABSL_PROPAGATE_CXX_STD ON)
add_subdirectory(abseil-cpp EXCLUDE_FROM_ALL)
else()
find_package(absl CONFIG REQUIRED)
set_target_properties(absl::flat_hash_map PROPERTIES IMPORTED_GLOBAL True)
set_target_properties(absl::str_format PROPERTIES IMPORTED_GLOBAL True)
set_target_properties(absl::time PROPERTIES IMPORTED_GLOBAL True)
endif()

if(SIMVIEW_BUILD_TESTS AND NOT SIMVIEW_USE_HOST_GTEST)
add_subdirectory(googletest EXCLUDE_FROM_ALL)
elseif(SIMVIEW_BUILD_TESTS)
find_package(GTest CONFIG)
set_target_properties(GTest::gtest_main PROPERTIES IMPORTED_GLOBAL True)
endif()

# Add all expected submodules.
set(ABSL_PROPAGATE_CXX_STD ON)
add_subdirectory(abseil-cpp EXCLUDE_FROM_ALL)
add_subdirectory(googletest EXCLUDE_FROM_ALL)
add_subdirectory(fst)
6 changes: 0 additions & 6 deletions macros.cmake

This file was deleted.

0 comments on commit 17054a2

Please sign in to comment.