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 f664e57 commit a5c60de
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 21 deletions.
72 changes: 70 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
linux-build:
Expand All @@ -17,18 +18,84 @@ jobs:
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@v2
with:
fetch-depth: 0

- name: Use ccache
uses: hendrikmuhs/ccache-action@v1
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 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: 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: Checkout simview
uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -62,6 +129,7 @@ jobs:
run: |
ninja -C build test
CodeFormatting:
runs-on: ubuntu-latest

Expand Down
11 changes: 9 additions & 2 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 @@ -41,8 +46,10 @@ endif()
# Helper macros are defined in a separate file.
include(macros.cmake)

# Testing is good!
enable_testing()
if(SIMVIEW_BUILD_TESTS)
# Testing is good!
enable_testing()
endif()

# All include is relative to project root, or local dir.
include_directories(${PROJECT_SOURCE_DIR})
Expand Down
43 changes: 26 additions & 17 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
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 "-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)
endif()

if(NOT SIMVIEW_USE_HOST_GTEST)
add_subdirectory(googletest EXCLUDE_FROM_ALL)
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)

0 comments on commit a5c60de

Please sign in to comment.