forked from pistacheio/pistache
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pistacheio#1263 from dgreatwood/macOSRealGccRunners
Feat: Enable GCC Builds on macOS and in macos.yaml Workflow
- Loading branch information
Showing
34 changed files
with
377 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# SPDX-FileCopyrightText: 2024 Duncan Greatwood | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
# This script configures gcc on macOS. You should call it in each | ||
# terminal from which you'll build Pistache with gcc. | ||
# - Installs gcc if not yet installed | ||
# - Configures the CXX and CC environment variables | ||
# - Replaces brew googletest if needed and on user confirmation | ||
# | ||
# Use "source ..." to invoke the script, like: | ||
# source bldscripts/gccmacsetup.sh | ||
# | ||
# Add the "-y' option to proceed to replace brew googletest if needed | ||
# without prompting for confirmation, like this: | ||
# source bldscripts/gccmacsetup.sh -y | ||
|
||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then | ||
echo "Error: script was invoked directly, please invoke with source." | ||
echo "Like this:" | ||
echo " source $(printf %q "$BASH_SOURCE")$((($#)) && printf ' %q' "$@")" | ||
exit 1 | ||
fi | ||
|
||
if [ "$(uname)" != "Darwin" ]; then | ||
echo "Error: This script is for use solely on macOS" | ||
return 1 | ||
fi | ||
|
||
if ! type "brew" > /dev/null; then | ||
echo "Error: brew command not found. Please install Homebrew." | ||
return 1 | ||
fi | ||
|
||
gcc_installed_here="N" | ||
if ! brew list gcc &>/dev/null; then | ||
echo "Installing gcc with brew" | ||
brew install gcc | ||
gcc_installed_here="Y" | ||
fi | ||
|
||
if ! [ "x$CXX" = "x" ] && [ ${#CXX} -ge 6 ]; then | ||
if [ ${CXX:0:4} = g++- ] || [ ${CXX:0:4} = gcc- ]; then | ||
if [ "x$gcc_installed_here" = "xY" ]; then | ||
echo "Success: gcc installed and configured" | ||
else | ||
echo "Success: gcc already configured, exiting" | ||
fi | ||
return 0 | ||
fi | ||
fi | ||
|
||
gcc_lns=`brew list gcc | grep "bin/g++-[0-9][0-9]" | sort -r` | ||
gcc_fstln=`echo "$gcc_lns" | head -1` | ||
export CXX=`basename $gcc_fstln` | ||
if [ "x$CXX" = "x" ] || [ ${#CXX} -lt 6 ] || ! [ ${CXX:0:4} = g++- ]; then | ||
echo "Error: CXX (which has value: $CXX) not configured" | ||
return 1 | ||
fi | ||
|
||
gcc_lns=`brew list gcc | grep "bin/gcc-[0-9][0-9]" | sort -r` | ||
gcc_fstln=`echo "$gcc_lns" | head -1` | ||
export CC=`basename $gcc_fstln` | ||
if [ "x$CC" = "x" ] || [ ${#CC} -lt 6 ] || ! [ ${CC:0:4} = gcc- ]; then | ||
echo "Error: CC (which has value: $CC) not configured" | ||
return 1 | ||
fi | ||
|
||
echo "Success: CXX is $CXX; CC is $CC" | ||
|
||
if brew list googletest &>/dev/null; then | ||
echo "" | ||
echo "You have brew's googletest installed" | ||
echo "Brew's googletest may not be compatible with building with gcc" | ||
replace_gt="N" | ||
if [ $# -ge 1 ] && [ $1 = "-y" ]; then | ||
replace_gt="Y" | ||
else | ||
read -e -p \ | ||
'Replace googletest with gcc-compatible version (uses sudo)? [y/N]> ' | ||
if [[ "$REPLY" == [Yy]* ]]; then | ||
replace_gt="Y" | ||
fi | ||
fi | ||
if [ "x$replace_gt" = "xY" ]; then | ||
echo "Replacing googletest" | ||
brew remove googletest | ||
|
||
git clone https://github.com/google/googletest | ||
cd googletest | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make | ||
echo "" | ||
echo "Installing gcc-compatible googletest using \"sudo make install\"" | ||
sudo make install | ||
cd "../.." | ||
else | ||
echo "You may see undefined symbols if linking Pistache's tests" | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Bash Script (for sourcing) | ||
|
||
# | ||
# SPDX-FileCopyrightText: 2024 Duncan Greatwood | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
# Do not execute this script directly. In can be sourced into other | ||
# scripts that need it. | ||
|
||
# This script checks for the existence of a directory | ||
# "~/mesbuild/<project-dir>"; if that directory exists, | ||
# $MESON_BUILD_DIR is set to point to a subdirectory within it. In | ||
# this way, if desired we can keep the build dir well away from the | ||
# sources. | ||
|
||
# On macOS, it also checks if we're building with gcc, and, if we are, | ||
# it appends ".gcc" to MESON_BUILD_DIR. | ||
|
||
if [ ! "x$HOME" = "x" ]; then | ||
if [ -d "$HOME/mesbuild" ]; then | ||
gitprojroot=$(git rev-parse --show-toplevel) | ||
if [ ! "x$gitprojroot" = "x" ] && [ -d "$gitprojroot" ]; then | ||
gitprojrootleaf=$(basename $gitprojroot) | ||
bldpathbase="$HOME/mesbuild/$gitprojrootleaf" | ||
if [ -d "$bldpathbase" ]; then | ||
MESON_BUILD_DIR="$bldpathbase/$MESON_BUILD_DIR" | ||
else | ||
echo "Create dir $bldpathbase if you prefer to build there" | ||
fi | ||
fi | ||
fi | ||
fi | ||
|
||
if [ "$(uname)" = "Darwin" ]; then | ||
if ! [ "x$CXX" = "x" ] && [ ${#CXX} -ge 6 ]; then | ||
if [ ${CXX:0:4} = g++- ] || [ ${CXX:0:4} = gcc- ]; then | ||
MESON_BUILD_DIR="$MESON_BUILD_DIR.gcc" | ||
fi | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.