Skip to content

Commit

Permalink
Merge pull request #84 from sandialabs/dev-weh
Browse files Browse the repository at this point in the history
Reworking build script logic and documentation
  • Loading branch information
whart222 authored May 26, 2024
2 parents 5deb875 + 7112e62 commit 418c77d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 38 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
- uses: actions/checkout@v3
- name: run cmake
run: |
mkdir build
cd build
mkdir _build
cd _build
cmake ..
- name: build
run: |
cd build
cd _build
make
coek-build-and-test-with-tpls:
Expand All @@ -31,8 +31,8 @@ jobs:
- uses: actions/checkout@v3
- name: build tpls with Spack and then Coek
run: |
./build_dev.sh
./build.sh
- name: test
run: |
cd build
cd _build
make test
42 changes: 27 additions & 15 deletions build_dev.sh → build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash -e
#
# This scripts builds Coek in the `build` directory to support local
# This scripts builds Coek in the `_build` directory to support local
# development and debugging.
#
# This uses Spack to install third-party dependencies in the `spack` directory.
# This uses Spack to install third-party dependencies in the `_spack` directory.
#
with_python="OFF"
spack_reinstall=0
Expand All @@ -12,7 +12,7 @@ clang=0
for arg ; do
case "$arg" in
--help)
echo "build_dev.sh [--python] [--clang] [--spack-reinstall] [--spack-dev] [--help]"
echo "build.sh [--python] [--clang] [--spack-reinstall] [--spack-dev] [--help]"
exit
;;
--python)
Expand All @@ -34,22 +34,33 @@ for arg ; do
esac
done

export SPACK_HOME=`pwd`/spack
#
# Setup directories
#
export SPACK_HOME=`pwd`/_spack
echo "SPACK_HOME=${SPACK_HOME}"
if [[ "${spack_reinstall}" -eq 1 ]]; then
rm -Rf ${SPACK_HOME}
fi
\rm -Rf _build
#
# Configure gurobi
#
if [[ -z "${GUROBI_HOME}" ]]; then
with_gurobi="OFF"
else
with_gurobi="ON"
fi

#
# Configure clang
#
if [[ $clang -eq 1 ]]; then
export CXX=clang++
export CC=clang
fi

if [[ "${spack_reinstall}" -eq 1 ]]; then
rm -Rf ${SPACK_HOME}
fi
#
# Install spack
#
if test -d ${SPACK_HOME}; then
echo ""
echo "WARNING: Spack directory exists."
Expand All @@ -59,9 +70,9 @@ else
echo "Installing Coek dependencies using Spack"
echo ""
if [[ "$spack_dev" -eq 0 ]]; then
git clone https://github.com/or-fusion/spack.git
git clone https://github.com/or-fusion/spack.git _spack
else
git clone [email protected]:or-fusion/spack.git
git clone [email protected]:or-fusion/spack.git _spack
fi
. ${SPACK_HOME}/share/spack/setup-env.sh
spack env create coekenv
Expand All @@ -70,11 +81,12 @@ else
spack install
spack env deactivate
fi

#
# Install coek
#
echo "Building Coek"
echo ""
\rm -Rf build
mkdir build
cd build
mkdir _build
cd _build
cmake -DCMAKE_PREFIX_PATH=${SPACK_HOME}/var/spack/environments/coekenv/.spack-env/view -Dwith_python=${with_python} -Dwith_gurobi=$with_gurobi -Dwith_highs=ON -Dwith_cppad=ON -Dwith_fmtlib=ON -Dwith_rapidjson=ON -Dwith_catch2=ON -Dwith_tests=ON -Dwith_asl=ON -Dwith_openmp=OFF ..
make -j20
37 changes: 19 additions & 18 deletions lib/coek/doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@ Installing Coek

There are several options for installing Coek:

* Installing with the top-level ``build_dev.sh`` script.
* Installing with the top-level ``build.sh`` script.
* Install the latest release or development branch using Spack
* Install from source using CMake

Installing with ``build_dev.sh``
Installing with ``build.sh``
--------------------------------

Developers will find the top-level ``build_dev.sh`` script useful for setting up a
Developers will find the top-level ``build.sh`` script useful for setting up a
build environment after cloning the Coek repository. Thus, Coek can be installed as follows:

.. code-block:: bash
git clone [email protected]:sandialabs/coek.git
./build_dev.sh
./build.sh
This script combines many elements of the detailed installation procedures documented below:

* Dependent packages are installed using Spack into the ``spack`` directory
* Dependent packages are installed using Spack into the ``_spack`` directory

* Coek is configured to build with Gurobi if the ``GUROBI_HOME`` environment variable is specified

* Coek is configured to build with Highs and Ipopt. Ipopt is dynamically linked at runtime.

* Coek is built within the ``build`` directory
* Coek is built within the ``_build`` directory

Installing with Spack
---------------------
Expand All @@ -44,13 +44,13 @@ Coek can be installed using the OR-Fusion clone of Spack:

.. code-block:: bash
git clone [email protected]:or-fusion/spack.git
git clone [email protected]:or-fusion/spack.git _spack
Spack includes scripts that configure the user's shell environment to use Spack commands. For example, you can configure a BASH environment after cloning Spack:

.. code-block:: bash
. spack/share/spack/setup-env.sh
. _spack/share/spack/setup-env.sh
Creating a Spack Environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -73,7 +73,7 @@ be further customized by the user either directly or via Spack commands.

.. code-block:: bash
spack/var/spack/environments/coekenv/spack.yaml
_spack/var/spack/environments/coekenv/spack.yaml
When done using a Spack environment, you can deactivate the environment with:

Expand Down Expand Up @@ -177,8 +177,9 @@ with the standard CMake build steps:
.. code-block:: bash
git clone [email protected]:sandialabs/coek.git
mkdir build
cd build
cd coek
mkdir _build
cd _build
cmake ..
make
Expand Down Expand Up @@ -224,9 +225,9 @@ Coek's CMake configuration includes a deprecated ``install_tpls`` target to buil

.. code-block:: bash
git clone [email protected]:or-fusion/spack.git
cd spack
. spack/share/spack/setup-env.sh
git clone [email protected]:or-fusion/spack.git _spack
cd _spack
. share/spack/setup-env.sh
spack env create coekenv
spack env activate coekenv
spack add cppad fmt rapidjson catch2
Expand All @@ -236,12 +237,12 @@ Coek's CMake configuration includes a deprecated ``install_tpls`` target to buil
git clone [email protected]:sandialabs/coek.git
cd coek
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=`pwd`/../spack/var/spack/environments/coekenv/.spack-env/view -Dwith_python=ON -Dwith_gurobi=ON -Dwith_cppad=ON -Dwith_fmtlib=ON -Dwith_rapidjson=ON -Dwith_tests=ON ..
mkdir _build
cd _build
cmake -DCMAKE_PREFIX_PATH=`pwd`/../_spack/var/spack/environments/coekenv/.spack-env/view -Dwith_python=ON -Dwith_gurobi=ON -Dwith_cppad=ON -Dwith_fmtlib=ON -Dwith_rapidjson=ON -Dwith_tests=ON ..
make -j20
Coek includes a ``build_dev.sh`` script that executes a variant of this script.
Coek includes a ``build.sh`` script that executes a variant of this script.

.. note::

Expand Down

0 comments on commit 418c77d

Please sign in to comment.