Skip to content

Commit

Permalink
Build with Ruby and Pass cmake options using env file macOS (#428)
Browse files Browse the repository at this point in the history
* Pass cmake options using env file

* Update metacall-configure.sh

* Update metacall-configure.sh

* Update metacall-environment.sh

---------

Co-authored-by: Vicente Eduardo Ferrer Garcia <7854099+viferga@users.noreply.github.com>
  • Loading branch information
ahmedihabb2 and viferga authored Apr 26, 2023
1 parent b9e4460 commit f85d548
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 10 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/macos-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,30 @@ jobs:
npm uninstall npm -g
rm -rf /usr/local/lib/node_modules/npm
- name: Uninstall Ruby
run: |
brew uninstall --force ruby
brew autoremove
RUBY_FRAMEWORK_DIR=$(xcrun --sdk macosx --show-sdk-path)/System/Library/Frameworks/Ruby.framework
sudo rm -rf $RUBY_FRAMEWORK_DIR
- name: Set up the environment
run: sh ./tools/metacall-environment.sh $METACALL_INSTALL_OPTIONS
env:
METACALL_INSTALL_OPTIONS: base python nodejs java # ruby netcore5 typescript file rpc wasm c cobol rust rapidjson funchook swig pack # clangformat v8rep51 coverage
METACALL_INSTALL_OPTIONS: base python nodejs java ruby #netcore5 typescript file rpc wasm c cobol rust rapidjson funchook swig pack # clangformat v8rep51 coverage

- name: Configure
run: |
mkdir -p build
cd build
bash ../tools/metacall-configure.sh $METACALL_CONFIGURE_OPTIONS
env:
METACALL_CONFIGURE_OPTIONS: ${{ matrix.buildtype }} scripts ports tests sanitizer python java # nodejs python java sanitizer ruby netcore5 typescript file rpc wasm java c cobol rust examples dynamic install pack benchmarks # v8 coverage
METACALL_CONFIGURE_OPTIONS: ${{ matrix.buildtype }} scripts ports tests sanitizer python java ruby # nodejs python java sanitizer netcore5 typescript file rpc wasm java c cobol rust examples dynamic install pack benchmarks # v8 coverage

- name: Build
working-directory: ./build
# TODO: Remove the disable option for fork safe once funchook problem is solved
run: |
cmake -DOPTION_FORK_SAFE=OFF \
-DPython3_INCLUDE_DIRS="$HOME/.pyenv/versions/3.11.1/include/python3.11" \
-DPython3_LIBRARY="$HOME/.pyenv/versions/3.11.1/lib/libpython3.11.dylib" \
-DPython3_EXECUTABLE="$HOME/.pyenv/versions/3.11.1/bin/python3.11" \
-DPython3_ROOT="$HOME/.pyenv/versions/3.11.1" \
-DPython3_VERSION="3.11.1" ..
cmake -DOPTION_FORK_SAFE=OFF ..
bash ../tools/metacall-build.sh $METACALL_BUILD_OPTIONS
env:
METACALL_BUILD_OPTIONS: ${{ matrix.buildtype }} tests
11 changes: 11 additions & 0 deletions tools/metacall-configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

set -euxo pipefail

ROOT_DIR=$(pwd)
BUILD_TYPE=Release
BUILD_PYTHON=0
BUILD_RUBY=0
Expand Down Expand Up @@ -433,6 +434,16 @@ sub_configure() {
BUILD_STRING="$BUILD_STRING -DOPTION_BUILD_THREAD_SANITIZER=Off"
fi

# Split env file line by line and add each line to the build string
CMAKE_CONFIG_FILE=$ROOT_DIR/CMakeConfig.txt
if [ -f $CMAKE_CONFIG_FILE ]; then
while IFS= read -r line
do
echo $line
BUILD_STRING="$BUILD_STRING $line"
done < "$CMAKE_CONFIG_FILE"
fi

# Build type
BUILD_STRING="$BUILD_STRING -DCMAKE_BUILD_TYPE=$BUILD_TYPE"

Expand Down
21 changes: 20 additions & 1 deletion tools/metacall-environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,14 @@ sub_python(){
pyenv rehash
echo -e '\nif command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
source ~/.bash_profile
which python3
mkdir -p build
CMAKE_CONFIG_PATH=$ROOT_DIR/build/CMakeConfig.txt
echo "-DPython3_INCLUDE_DIRS=\"$HOME/.pyenv/versions/3.11.1/include/python3.11\"" >> $CMAKE_CONFIG_PATH
echo "-DPython3_LIBRARY=\"$HOME/.pyenv/versions/3.11.1/lib/libpython3.11.dylib\"" >> $CMAKE_CONFIG_PATH
echo "-DPython3_EXECUTABLE=\"$HOME/.pyenv/versions/3.11.1/bin/python3.11\"" >> $CMAKE_CONFIG_PATH
echo "-DPython3_ROOT=\"$HOME/.pyenv/versions/3.11.1\"" >> $CMAKE_CONFIG_PATH
echo "-DPython3_VERSION=\"3.11.1\"" >> $CMAKE_CONFIG_PATH
echo "-DPython3_FIND_FRAMEWORK=\"NEVER\"" >> $CMAKE_CONFIG_PATH
pip3 install requests
pip3 install setuptools
pip3 install wheel
Expand All @@ -172,6 +179,18 @@ sub_ruby(){
#wget https://deb.nodesource.com/setup_4.x | $SUDO_CMD bash -
#$SUDO_CMD apt-get -y --no-install-recommends install nodejs
#$SUDO_CMD gem install rails
elif [ "${OPERATIVE_SYSTEM}" == "Darwin" ]; then
brew install ruby@3.2
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> /Users/runner/.bash_profile
source ~/.bash_profile
mkdir -p build
CMAKE_CONFIG_PATH=$ROOT_DIR/build/CMakeConfig.txt
RUBY_PREFIX=$(brew --prefix ruby@3.2)
RUBY_VERSION=$(ruby -e 'puts RUBY_VERSION')
echo "-DRuby_INCLUDE_DIR=\"$RUBY_PREFIX/include/ruby-3.2.0\"" >> $CMAKE_CONFIG_PATH
echo "-DRuby_LIBRARY=\"$RUBY_PREFIX/lib/libruby.3.2.dylib\"" >> $CMAKE_CONFIG_PATH
echo "-DRuby_EXECUTABLE=\"$RUBY_PREFIX/bin/ruby\"" >> $CMAKE_CONFIG_PATH
echo "-DRuby_VERSION_STRING=\"$RUBY_VERSION\"" >> $CMAKE_CONFIG_PATH
fi
}

Expand Down

0 comments on commit f85d548

Please sign in to comment.