Skip to content

Commit

Permalink
Simplified build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mikucionisaau committed Sep 22, 2023
1 parent f3088e8 commit 13f08bc
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 27 deletions.
52 changes: 43 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Formatting
run: find src include test -iregex '.*\.\(c\|h\|cpp\|hpp\|cc\|hh\|cxx\|hxx\)$' -exec clang-format-11 -n -Werror {} \;

build-linux64:
linux-x86_64:
needs: [ formatting ]
strategy:
fail-fast: false
Expand All @@ -54,23 +54,25 @@ jobs:
BUILD_DIR: build-linux64-gcc10
CTEST_OUTPUT_ON_FAILURE: 1
CMAKE_BUILD_TYPE: Debug
CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/cmake/toolchain/linux64-gcc10.cmake
CMAKE_PREFIX_PATH: ${{ github.workspace }}/local/linux64-gcc10
CMAKE_GENERATOR: Ninja
steps:
- uses: actions/checkout@v3
- name: Get Ubuntu dependencies
run: |
sudo apt-get -qy update
sudo apt-get -qy install bison curl wget unzip xz-utils cmake ninja-build flex libc6-dev g++-10
sudo apt-get -qqy update
sudo apt-get -qqy install bison curl wget unzip xz-utils cmake ninja-build flex libc6-dev g++-10
- name: Get library dependencies
run: ./getlibs/getlibs.sh linux64-gcc10
- name: Configure CMake build system
run: cmake -B "$BUILD_DIR" -S . -DCMAKE_TOOLCHAIN_FILE=$PWD/cmake/toolchain/linux64-gcc10.cmake -DCMAKE_PREFIX_PATH=$PWD/local/linux64-gcc10 -DSSP=ON -DUBSAN=ON -DASAN=ON -DLSAN=ON
run: cmake -B "$BUILD_DIR" -S . -DSSP=ON -DUBSAN=ON -DASAN=ON -DLSAN=ON
- name: Build
run: cmake --build $BUILD_DIR --config Debug
run: cmake --build "$BUILD_DIR" --config Debug
- name: Test
run: ctest --test-dir "$BUILD_DIR" -C Debug

build-win64:
windows-x86_64:
needs: [ formatting ]
strategy:
fail-fast: false
Expand All @@ -82,6 +84,8 @@ jobs:
CROSSCOMPILING_EMULATOR: wine
WINARCH: win64
CMAKE_BUILD_TYPE: Debug
CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/cmake/toolchain/win64.cmake
CMAKE_PREFIX_PATH: ${{ github.workspace }}/local/win64
CMAKE_GENERATOR: Ninja
steps:
- uses: actions/checkout@v3
Expand All @@ -92,16 +96,30 @@ jobs:
sudo apt-get -qqy install wine-binfmt
sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
- name: Restore Libs Cache
id: cache-libs-restore
uses: actions/cache@v3
with:
path: local/win64
key: getlibs-win64-${{ hashFiles('/getlibs/**') }}
- name: Get library dependencies
if: steps.cache-libs-restore.outputs.cache-hit != 'true'
run: ./getlibs/getlibs.sh win64
- name: Store Libs Cache
if: steps.cache-libs-restore.outputs.cache-hit != 'true'
id: cache-libs-save
uses: actions/cache/save@v3
with:
path: local/win64
key: ${{ steps.cache-libs-restore.outputs.cache-primary-key }}
- name: Configure CMake build system
run: cmake -B "$BUILD_DIR" -S . -DCMAKE_TOOLCHAIN_FILE=$PWD/cmake/toolchain/win64.cmake -DCMAKE_PREFIX_PATH=$PWD/local/win64 -DSSP=ON
run: cmake -B "$BUILD_DIR" -S . -DSSP=ON
- name: Build
run: cmake --build "$BUILD_DIR" --config Debug
- name: Test
run: ctest --test-dir "$BUILD_DIR" -C Debug

build-macos:
darwin-brew-gcc10:
needs: [ formatting ]
strategy:
fail-fast: false
Expand All @@ -111,6 +129,8 @@ jobs:
BUILD_DIR: build-darwin
CTEST_OUTPUT_ON_FAILURE: 1
CMAKE_BUILD_TYPE: Debug
CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/cmake/toolchain/darwin-brew-gcc10.cmake
CMAKE_PREFIX_PATH: ${{ github.workspace }}/local/darwin-brew-gcc10
CMAKE_GENERATOR: Ninja
steps:
- uses: actions/checkout@v3
Expand All @@ -119,10 +139,24 @@ jobs:
xcode-version: '13.2.1'
- name: Get Home Brew dependencies
run: brew install -q cmake ninja gcc@10 flex bison wget curl coreutils automake autoconf libtool gnu-sed gawk
- name: Restore Libs Cache
id: cache-libs-restore
uses: actions/cache@v3
with:
path: local/darwin-brew-gcc10
key: getlibs-darwin-brew-gcc10-${{ hashFiles('/getlibs/**') }}
- name: Get library dependencies
if: steps.cache-libs-restore.outputs.cache-hit != 'true'
run: ./getlibs/getlibs.sh darwin-brew-gcc10
- name: Store Libs Cache
if: steps.cache-libs-restore.outputs.cache-hit != 'true'
id: cache-libs-save
uses: actions/cache/save@v3
with:
path: local/darwin-brew-gcc10
key: ${{ steps.cache-libs-restore.outputs.cache-primary-key }}
- name: Configure CMake build system
run: cmake -B "$BUILD_DIR" -S . -DCMAKE_TOOLCHAIN_FILE=$PWD/cmake/toolchain/darwin-brew-gcc10.cmake -DCMAKE_PREFIX_PATH=$PWD/local/darwin-brew-gcc10 -DSSP=ON -DUBSAN=ON -DASAN=ON -DLSAN=ON
run: cmake -B "$BUILD_DIR" -S . -DSSP=ON -DUBSAN=ON -DASAN=ON -DLSAN=ON
- name: Build
run: cmake --build "$BUILD_DIR" --config Debug
- name: Test
Expand Down
76 changes: 59 additions & 17 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,72 @@ NC="\e[0m" # no color

if [ "$#" -lt 1 ]; then
echo "Expecting a list of target platforms as arguments."
echo -e "For example: ${BW}$0 darwin linux64 win32${NC}"
echo -e "See ${BW}cmake/toolchain/*.cmake${NC} for the list of supported platforms:"
(cd cmake/toolchain ; ls)
echo -e "For example:"
echo -e " ${BW}$0 darwin linux64 win32${NC}"
echo -e "List of supported platforms:"
for platform in $(ls "$PROJECT_DIR/cmake/toolchain") ; do
echo -e " ${BW}${platform%%.cmake}${NC}"
done
fi

export CTEST_OUTPUT_ON_FAILURE=1

test -n "$CMAKE_BUILD_TYPE" || export CMAKE_BUILD_TYPE=Release

PREFIX="$CMAKE_PREFIX_PATH"
TOOLCHAIN_FILE="$CMAKE_TOOLCHAIN_FILE"
INSTALL_PREFIX="$CMAKE_INSTALL_PREFIX"

for target in "$@" ; do
BUILD="build-${target}-release"
if [ -d "${LOCAL}/${target}" ]; then
PREFIX="${LOCAL}/${target}"
INSTALL_PREFIX="${LOCAL}/${target}"
case "$target" in
win64*|x86_64-w64-mingw32*)
export WINARCH=win64
export WINEPATH="$($PROJECT_DIR/winepath-for x86_64-w64-mingw32)"
;;
win32*|i686-w64-mingw32*)
export WINARCH=win32
export WINEPATH="$($PROJECT_DIR/winepath-for i686-w64-mingw32)"
;;
*)
unset WINARCH
unset WINEPATH
esac
if [ -n "$TOOLCHAIN_FILE" ]; then
export CMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE"
elif [ -r "$PROJECT_DIR/cmake/toolchain/$target.cmake" ]; then
export CMAKE_TOOLCHAIN_FILE="$PROJECT_DIR/cmake/toolchain/$target.cmake"
else
unset CMAKE_TOOLCHAIN_FILE
fi
"${PROJECT_DIR}/getlibs/getlibs.sh" "${target}"
if [ -n "$PREFIX" ]; then
export CMAKE_PREFIX_PATH="$PREFIX"
elif [ -d "${LOCAL}/${target}" ]; then
export CMAKE_PREFIX_PATH="${LOCAL}/${target}"
else
unset CMAKE_PREFIX_PATH
fi
if [ -n "$INSTALL_PREFIX" ]; then
export CMAKE_INSTALL_PREFIX="$INSTALL_PREFIX"
elif [ -d "${LOCAL}/${target}" ]; then
export CMAKE_INSTALL_PREFIX="${LOCAL}/${target}"
else
PREFIX=""
INSTALL_PREFIX=""
unset CMAKE_INSTALL_PREFIX
fi
# "${PROJECT_DIR}/getlibs/getlibs.sh" "${target}"
echo -e "${BW}${target}: Configuring UTAP${NC}"
cmake -S . -B "$BUILD" -DCMAKE_TOOLCHAIN_FILE="$PROJECT_DIR/cmake/toolchain/${target}.cmake" \
-DCMAKE_PREFIX_PATH="$PREFIX" -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" \
-DCMAKE_BUILD_TYPE=Release -DFIND_FATAL=ON
BUILD="build-${target}-release"
echo -e "${BW}${target}: Configuring UTAP:${NC}"
echo " CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-(unset)}"
echo " CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE:-(unset)}"
echo " CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH:-(unset)}"
echo " CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX:-(unset)}"
cmake -S . -B "$BUILD" -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" -DFIND_FATAL=ON
echo -e "${BW}${target}: Building UTAP${NC}"
cmake --build "$BUILD"
cmake --build "$BUILD" --config $CMAKE_BUILD_TYPE
echo -e "${BW}${target}: Testing UTAP${NC}"
(cd "$BUILD" ; ctest)
echo -e "${BW}Success!${NC}"
echo " WINEPATH=${WINEPATH:-(unset)}"
echo " WINARCH=${WINARCH:-(unset)}"
ctest --test-dir "$BUILD" -C $CMAKE_BUILD_TYPE
echo "Run the following to install UTAP into $CMAKE_INSTALL_PREFIX:"
echo " cmake --install \"$BUILD\" --config $CMAKE_BUILD_TYPE --prefix \"$CMAKE_INSTALL_PREFIX\""
echo -e "${BW}$target: Success!${NC}"
done
2 changes: 1 addition & 1 deletion getlibs/getlibs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fi

missing_tools=""
for tool in wget tar sha256sum cmake ; do
if [ -z "(command -v $tool)" ] ; then
if [ -z "$(command -v $tool)" ] ; then
echo "Could not find $tool"
missing_tools="${missing_tools:+$missing_tools} $tools"
fi
Expand Down

0 comments on commit 13f08bc

Please sign in to comment.