From ec07f781e2c391c93f7878208397b63abe462c7f Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Sat, 22 Feb 2025 19:34:32 -0300 Subject: [PATCH 01/11] init brew script --- .github/workflows/macos.yml | 24 ++++++++++++++++++++++++ install-forefire-osx.sh | 25 +++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .github/workflows/macos.yml create mode 100644 install-forefire-osx.sh diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 00000000..424eb395 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,24 @@ +name: Build ForeFire on macOS + +on: + push: + branches: + - brew-macos + + workflow_dispatch: + +jobs: + build-native-macos: + runs-on: macos-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Make install script executable + run: chmod +x ./install-forefire-osx.sh + + - name: Build ForeFire using macOS install script + run: ./install-forefire-osx.sh + + - name: Check ForeFire version + run: ./bin/forefire -v diff --git a/install-forefire-osx.sh b/install-forefire-osx.sh new file mode 100644 index 00000000..2052ceea --- /dev/null +++ b/install-forefire-osx.sh @@ -0,0 +1,25 @@ +#!/bin/bash +echo "====== MAC OS REQUIREMENTS ========" + +# Update Homebrew +brew update + +# Optionally ensure that Xcode Command Line Tools are installed: +if ! xcode-select -p > /dev/null 2>&1; then + echo "Xcode Command Line Tools not found. Installing..." + xcode-select --install +fi + +# Install required packages via Homebrew. +brew install cmake +brew install netcdf-cxx-legacy # Equivalent to libnetcdf-c++4-dev on Linux + +echo "===========================" +echo "========= FOREFIRE ========" +echo "===========================" + +# Create build directory, configure, and compile ForeFire. +mkdir -p build +cd build +cmake ../ +make From be71f7113da59a852682341f8b079ba3ed78aca2 Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Sat, 22 Feb 2025 19:39:34 -0300 Subject: [PATCH 02/11] of course netcdf is complicated --- install-forefire-osx.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/install-forefire-osx.sh b/install-forefire-osx.sh index 2052ceea..346d79f1 100644 --- a/install-forefire-osx.sh +++ b/install-forefire-osx.sh @@ -4,15 +4,19 @@ echo "====== MAC OS REQUIREMENTS ========" # Update Homebrew brew update -# Optionally ensure that Xcode Command Line Tools are installed: +# Ensure Xcode Command Line Tools are installed. if ! xcode-select -p > /dev/null 2>&1; then echo "Xcode Command Line Tools not found. Installing..." xcode-select --install fi -# Install required packages via Homebrew. +# Install dependencies via Homebrew. brew install cmake -brew install netcdf-cxx-legacy # Equivalent to libnetcdf-c++4-dev on Linux +brew install netcdf-cxx + +# Set NETCDF_HOME to the Homebrew prefix for netcdf-cxx. +export NETCDF_HOME=$(brew --prefix netcdf-cxx) +echo "NETCDF_HOME set to $NETCDF_HOME" echo "===========================" echo "========= FOREFIRE ========" @@ -21,5 +25,5 @@ echo "===========================" # Create build directory, configure, and compile ForeFire. mkdir -p build cd build -cmake ../ +cmake -D NETCDF_HOME=$NETCDF_HOME ../ make From e70dfc62da9e460e12533e45ef9fcd7c9030e96a Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Sat, 22 Feb 2025 19:46:35 -0300 Subject: [PATCH 03/11] Update install script to include NetCDF installation and set environment variables --- install-forefire-osx.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/install-forefire-osx.sh b/install-forefire-osx.sh index 346d79f1..2b015e65 100644 --- a/install-forefire-osx.sh +++ b/install-forefire-osx.sh @@ -1,7 +1,7 @@ #!/bin/bash echo "====== MAC OS REQUIREMENTS ========" -# Update Homebrew +# Update Homebrew. brew update # Ensure Xcode Command Line Tools are installed. @@ -12,10 +12,11 @@ fi # Install dependencies via Homebrew. brew install cmake +brew install netcdf brew install netcdf-cxx -# Set NETCDF_HOME to the Homebrew prefix for netcdf-cxx. -export NETCDF_HOME=$(brew --prefix netcdf-cxx) +# Set NETCDF_HOME to the prefix for the NetCDF C library. +export NETCDF_HOME=$(brew --prefix netcdf) echo "NETCDF_HOME set to $NETCDF_HOME" echo "===========================" @@ -25,5 +26,10 @@ echo "===========================" # Create build directory, configure, and compile ForeFire. mkdir -p build cd build -cmake -D NETCDF_HOME=$NETCDF_HOME ../ + +# Pass NETCDF_HOME and also set CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH. +cmake -D NETCDF_HOME=$NETCDF_HOME \ + -DCMAKE_INCLUDE_PATH=$NETCDF_HOME/include \ + -DCMAKE_LIBRARY_PATH=$NETCDF_HOME/lib \ + ../ make From d772d3ae2c04d8f0f158089d885333bcaafefea6 Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Sat, 22 Feb 2025 19:53:57 -0300 Subject: [PATCH 04/11] still trying --- install-forefire-osx.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/install-forefire-osx.sh b/install-forefire-osx.sh index 2b015e65..031398e4 100644 --- a/install-forefire-osx.sh +++ b/install-forefire-osx.sh @@ -27,9 +27,8 @@ echo "===========================" mkdir -p build cd build -# Pass NETCDF_HOME and also set CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH. +# Pass the include flag explicitly. cmake -D NETCDF_HOME=$NETCDF_HOME \ - -DCMAKE_INCLUDE_PATH=$NETCDF_HOME/include \ - -DCMAKE_LIBRARY_PATH=$NETCDF_HOME/lib \ + -DCMAKE_CXX_FLAGS="-I$NETCDF_HOME/include" \ ../ make From 7a0adccd0520a342df28a6eb75dea11025be2a47 Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Sat, 22 Feb 2025 19:59:30 -0300 Subject: [PATCH 05/11] last try today --- install-forefire-osx.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/install-forefire-osx.sh b/install-forefire-osx.sh index 031398e4..41551c69 100644 --- a/install-forefire-osx.sh +++ b/install-forefire-osx.sh @@ -19,6 +19,14 @@ brew install netcdf-cxx export NETCDF_HOME=$(brew --prefix netcdf) echo "NETCDF_HOME set to $NETCDF_HOME" +# Create a symbolic link in the include directory so that "netcdf" points to "netcdf.h" +cd "$NETCDF_HOME/include" +if [ ! -e netcdf ]; then + echo "Creating symlink for netcdf -> netcdf.h" + ln -s netcdf.h netcdf +fi +cd - > /dev/null + echo "===========================" echo "========= FOREFIRE ========" echo "===========================" From ab770aef97b1a48d14c4ddd37f03fb45c410ee1f Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Sat, 22 Feb 2025 20:05:30 -0300 Subject: [PATCH 06/11] now last try --- install-forefire-osx.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/install-forefire-osx.sh b/install-forefire-osx.sh index 41551c69..a30a0b60 100644 --- a/install-forefire-osx.sh +++ b/install-forefire-osx.sh @@ -19,7 +19,11 @@ brew install netcdf-cxx export NETCDF_HOME=$(brew --prefix netcdf) echo "NETCDF_HOME set to $NETCDF_HOME" -# Create a symbolic link in the include directory so that "netcdf" points to "netcdf.h" +# Also get the prefix for netcdf-cxx. +export NETCDF_CXX_HOME=$(brew --prefix netcdf-cxx) +echo "NETCDF_CXX_HOME set to $NETCDF_CXX_HOME" + +# Create a symlink in NETCDF_HOME/include so that "netcdf" points to "netcdf.h" cd "$NETCDF_HOME/include" if [ ! -e netcdf ]; then echo "Creating symlink for netcdf -> netcdf.h" @@ -35,8 +39,8 @@ echo "===========================" mkdir -p build cd build -# Pass the include flag explicitly. +# Pass include flags for both netcdf and netcdf-cxx. cmake -D NETCDF_HOME=$NETCDF_HOME \ - -DCMAKE_CXX_FLAGS="-I$NETCDF_HOME/include" \ + -DCMAKE_CXX_FLAGS="-I$NETCDF_HOME/include -I$NETCDF_CXX_HOME/include" \ ../ make From e138e390c05775d937cddc473a5723daff7de8f6 Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Mon, 24 Feb 2025 09:43:46 -0300 Subject: [PATCH 07/11] lets try again --- install-forefire-osx.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/install-forefire-osx.sh b/install-forefire-osx.sh index a30a0b60..f686075f 100644 --- a/install-forefire-osx.sh +++ b/install-forefire-osx.sh @@ -19,7 +19,7 @@ brew install netcdf-cxx export NETCDF_HOME=$(brew --prefix netcdf) echo "NETCDF_HOME set to $NETCDF_HOME" -# Also get the prefix for netcdf-cxx. +# Set NETCDF_CXX_HOME to the prefix for the NetCDF C++ library. export NETCDF_CXX_HOME=$(brew --prefix netcdf-cxx) echo "NETCDF_CXX_HOME set to $NETCDF_CXX_HOME" @@ -39,8 +39,9 @@ echo "===========================" mkdir -p build cd build -# Pass include flags for both netcdf and netcdf-cxx. +# **Critical change:** Pass the include flag for netcdf-cxx first, +# so that the netCDF namespace and types are picked up from there. cmake -D NETCDF_HOME=$NETCDF_HOME \ - -DCMAKE_CXX_FLAGS="-I$NETCDF_HOME/include -I$NETCDF_CXX_HOME/include" \ + -DCMAKE_CXX_FLAGS="-I$NETCDF_CXX_HOME/include -I$NETCDF_HOME/include" \ ../ make From 3c720555fd1d36b68d431620ec85ba78019e445f Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Mon, 24 Feb 2025 10:16:44 -0300 Subject: [PATCH 08/11] allez GPT --- install-forefire-osx.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/install-forefire-osx.sh b/install-forefire-osx.sh index f686075f..d5a309c5 100644 --- a/install-forefire-osx.sh +++ b/install-forefire-osx.sh @@ -31,6 +31,21 @@ if [ ! -e netcdf ]; then fi cd - > /dev/null +# Create a symlink in NETCDF_CXX_HOME/lib so that -lnetcdf_c++4 can be resolved. +cd "$NETCDF_CXX_HOME/lib" +# Check if the expected library exists under the Homebrew name. +if [ -e libnetcdf-cxx.dylib ]; then + if [ ! -e libnetcdf_c++4.dylib ]; then + echo "Creating symlink: libnetcdf_c++4.dylib -> libnetcdf-cxx.dylib" + ln -s libnetcdf-cxx.dylib libnetcdf_c++4.dylib + else + echo "Symlink for netcdf_c++4 already exists." + fi +else + echo "Error: Expected libnetcdf-cxx.dylib not found in $NETCDF_CXX_HOME/lib" +fi +cd - > /dev/null + echo "===========================" echo "========= FOREFIRE ========" echo "===========================" @@ -39,8 +54,7 @@ echo "===========================" mkdir -p build cd build -# **Critical change:** Pass the include flag for netcdf-cxx first, -# so that the netCDF namespace and types are picked up from there. +# Pass include flags for both netcdf-cxx and netcdf. cmake -D NETCDF_HOME=$NETCDF_HOME \ -DCMAKE_CXX_FLAGS="-I$NETCDF_CXX_HOME/include -I$NETCDF_HOME/include" \ ../ From 5635df11512b1a67c775d82ad5a10a1947ca3bdd Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Mon, 24 Feb 2025 10:23:51 -0300 Subject: [PATCH 09/11] and now? --- install-forefire-osx.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/install-forefire-osx.sh b/install-forefire-osx.sh index d5a309c5..038a6429 100644 --- a/install-forefire-osx.sh +++ b/install-forefire-osx.sh @@ -31,18 +31,18 @@ if [ ! -e netcdf ]; then fi cd - > /dev/null -# Create a symlink in NETCDF_CXX_HOME/lib so that -lnetcdf_c++4 can be resolved. +# Now, create a symlink in the netcdf-cxx lib directory. cd "$NETCDF_CXX_HOME/lib" -# Check if the expected library exists under the Homebrew name. -if [ -e libnetcdf-cxx.dylib ]; then +# Expect the Homebrew formula to install the library as "libnetcdf-cxx4.dylib" +if [ -e libnetcdf-cxx4.dylib ]; then if [ ! -e libnetcdf_c++4.dylib ]; then - echo "Creating symlink: libnetcdf_c++4.dylib -> libnetcdf-cxx.dylib" - ln -s libnetcdf-cxx.dylib libnetcdf_c++4.dylib + echo "Creating symlink: libnetcdf_c++4.dylib -> libnetcdf-cxx4.dylib" + ln -s libnetcdf-cxx4.dylib libnetcdf_c++4.dylib else echo "Symlink for netcdf_c++4 already exists." fi else - echo "Error: Expected libnetcdf-cxx.dylib not found in $NETCDF_CXX_HOME/lib" + echo "Error: Expected libnetcdf-cxx4.dylib not found in $NETCDF_CXX_HOME/lib" fi cd - > /dev/null From 3f8566818f51df3a2e6c22a88d7d00db9047db9b Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Mon, 24 Feb 2025 10:33:15 -0300 Subject: [PATCH 10/11] adding debug --- install-forefire-osx.sh | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/install-forefire-osx.sh b/install-forefire-osx.sh index 038a6429..50f3d9eb 100644 --- a/install-forefire-osx.sh +++ b/install-forefire-osx.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e echo "====== MAC OS REQUIREMENTS ========" # Update Homebrew. @@ -23,27 +24,44 @@ echo "NETCDF_HOME set to $NETCDF_HOME" export NETCDF_CXX_HOME=$(brew --prefix netcdf-cxx) echo "NETCDF_CXX_HOME set to $NETCDF_CXX_HOME" +# Debug: List the contents of the netcdf include directory. +echo "Contents of $NETCDF_HOME/include:" +ls -l "$NETCDF_HOME/include" + # Create a symlink in NETCDF_HOME/include so that "netcdf" points to "netcdf.h" cd "$NETCDF_HOME/include" if [ ! -e netcdf ]; then echo "Creating symlink for netcdf -> netcdf.h" ln -s netcdf.h netcdf +else + echo "Symlink for netcdf already exists." fi cd - > /dev/null -# Now, create a symlink in the netcdf-cxx lib directory. +# Now, create a symlink in the netcdf-cxx lib directory for the linker. cd "$NETCDF_CXX_HOME/lib" -# Expect the Homebrew formula to install the library as "libnetcdf-cxx4.dylib" +echo "Contents of $NETCDF_CXX_HOME/lib:" +ls -l + +target="" if [ -e libnetcdf-cxx4.dylib ]; then - if [ ! -e libnetcdf_c++4.dylib ]; then - echo "Creating symlink: libnetcdf_c++4.dylib -> libnetcdf-cxx4.dylib" - ln -s libnetcdf-cxx4.dylib libnetcdf_c++4.dylib - else - echo "Symlink for netcdf_c++4 already exists." - fi + target="libnetcdf-cxx4.dylib" +elif [ -e libnetcdf-cxx.dylib ]; then + target="libnetcdf-cxx.dylib" +else + echo "Error: Neither libnetcdf-cxx4.dylib nor libnetcdf-cxx.dylib found in $NETCDF_CXX_HOME/lib" + exit 1 +fi + +echo "Using target library: $target" +if [ ! -e libnetcdf_c++4.dylib ]; then + echo "Creating symlink: libnetcdf_c++4.dylib -> $target" + ln -s "$target" libnetcdf_c++4.dylib else - echo "Error: Expected libnetcdf-cxx4.dylib not found in $NETCDF_CXX_HOME/lib" + echo "Symlink libnetcdf_c++4.dylib already exists." fi +echo "Contents after symlink creation:" +ls -l cd - > /dev/null echo "===========================" From bd738fceb5dc7be74dd70bf11e84681964a7a7ea Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Mon, 24 Feb 2025 10:42:02 -0300 Subject: [PATCH 11/11] getting there --- install-forefire-osx.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/install-forefire-osx.sh b/install-forefire-osx.sh index 50f3d9eb..651dbc55 100644 --- a/install-forefire-osx.sh +++ b/install-forefire-osx.sh @@ -24,7 +24,7 @@ echo "NETCDF_HOME set to $NETCDF_HOME" export NETCDF_CXX_HOME=$(brew --prefix netcdf-cxx) echo "NETCDF_CXX_HOME set to $NETCDF_CXX_HOME" -# Debug: List the contents of the netcdf include directory. +# Debug: list headers in NETCDF_HOME/include echo "Contents of $NETCDF_HOME/include:" ls -l "$NETCDF_HOME/include" @@ -38,11 +38,12 @@ else fi cd - > /dev/null -# Now, create a symlink in the netcdf-cxx lib directory for the linker. +# Debug: list the contents of NETCDF_CXX_HOME/lib cd "$NETCDF_CXX_HOME/lib" echo "Contents of $NETCDF_CXX_HOME/lib:" ls -l +# Determine target library name. target="" if [ -e libnetcdf-cxx4.dylib ]; then target="libnetcdf-cxx4.dylib" @@ -64,6 +65,10 @@ echo "Contents after symlink creation:" ls -l cd - > /dev/null +# Set LIBRARY_PATH for the linker. +export LIBRARY_PATH=$NETCDF_CXX_HOME/lib:$LIBRARY_PATH +echo "LIBRARY_PATH set to: $LIBRARY_PATH" + echo "===========================" echo "========= FOREFIRE ========" echo "===========================" @@ -72,8 +77,10 @@ echo "===========================" mkdir -p build cd build -# Pass include flags for both netcdf-cxx and netcdf. +# Pass include flags for both netcdf-cxx and netcdf, +# and add the netcdf-cxx lib directory to the shared linker flags. cmake -D NETCDF_HOME=$NETCDF_HOME \ -DCMAKE_CXX_FLAGS="-I$NETCDF_CXX_HOME/include -I$NETCDF_HOME/include" \ + -DCMAKE_SHARED_LINKER_FLAGS="-L$NETCDF_CXX_HOME/lib" \ ../ make