Skip to content

Commit

Permalink
Refactor Spack support
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkuhn committed Sep 5, 2018
1 parent 7b93233 commit bfe3a27
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 178 deletions.
8 changes: 7 additions & 1 deletion scripts/benchmark.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# JULEA - Flexible storage framework
# Copyright (C) 2017-2018 Michael Kuhn
Expand All @@ -23,16 +23,22 @@ SELF_DIR="${SELF_PATH%/*}"
SELF_BASE="${SELF_PATH##*/}"

. "${SELF_DIR}/common"
. "${SELF_DIR}/spack"

set_glib_options
set_path
set_library_path

run_benchmark ()
{
# FIXME should use functions instead of setup.sh
setup.sh start
julea-benchmark "$@" || true
setup.sh stop
}

SPACK_DIR="$(get_directory "${SELF_DIR}/..")/dependencies"

spack_load_dependencies

run_benchmark "$@"
5 changes: 5 additions & 0 deletions scripts/environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ SELF_DIR="${SELF_PATH%/*}"
SELF_BASE="${SELF_PATH##*/}"

. "${SELF_DIR}/common"
. "${SELF_DIR}/spack"

set_glib_options
set_path
#set_library_path
#set_pkg_config_path

SPACK_DIR="$(get_directory "${SELF_DIR}/..")/dependencies"

spack_load_dependencies
93 changes: 3 additions & 90 deletions scripts/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,95 +23,8 @@ SELF_DIR="${SELF_PATH%/*}"
SELF_BASE="${SELF_PATH##*/}"

. "${SELF_DIR}/common"
. "${SELF_DIR}/spack"

spack_clone ()
{
local spack_commit
local spack_dir
SPACK_DIR="$(get_directory "${SELF_DIR}/..")/dependencies"

spack_commit='ca2e1e9019c50b905662b63041695bbbe6ad7630'
spack_dir="$(get_directory "${SELF_DIR}/..")/dependencies"

if test ! -d "${spack_dir}"
then
git clone https://github.com/LLNL/spack.git "${spack_dir}"
fi

cd "${spack_dir}"

git fetch

git reset --hard "${spack_commit}"
}

spack_install ()
{
local spack_dir
local spack_pkg

spack_dir="$(get_directory "${SELF_DIR}/../dependencies")"
spack_pkg="$1"

test -n "${spack_dir}" || return 1
test -d "${spack_dir}" || return 1
test -n "${spack_pkg}" || return 1

./bin/spack install "${spack_pkg}"
}

install_dependency ()
{
local pkg_config
local spack_pkg

pkg_config="$1"
spack_pkg="$2"

test -n "${pkg_config}" || return 1
test -n "${spack_pkg}" || return 1

if ! pkg-config --exists "${pkg_config}"
then
spack_install "${spack_pkg}"
fi
}

install_dependency_bin ()
{
local bin
local spack_pkg

bin="$1"
spack_pkg="$2"

test -n "${bin}" || return 1
test -n "${spack_pkg}" || return 1

if ! command -v "${bin}" > /dev/null 2>&1
then
spack_install "${spack_pkg}"
fi
}

spack_clone

# Required for Spack itself
spack_install environment-modules

# FIXME install all dependencies via Spack even if they are available locally?

# Required for Waf
install_dependency_bin pkg-config pkgconfig

# Mandatory dependencies
install_dependency glib-2.0 glib
install_dependency libbson-1.0 libbson

# Optional dependencies
install_dependency leveldb leveldb
install_dependency lmdb lmdb
install_dependency libmongoc-1.0 libmongoc
install_dependency sqlite3 sqlite

#install_dependency_bin mpicc mpi
#install_dependency_bin otfconfig otf
spack_install_dependencies
147 changes: 147 additions & 0 deletions scripts/spack
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#!/bin/sh

# JULEA - Flexible storage framework
# Copyright (C) 2017-2018 Michael Kuhn
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

spack_clone ()
{
local spack_commit

spack_commit='ca2e1e9019c50b905662b63041695bbbe6ad7630'

test -n "${SPACK_DIR}" || return 1

if test ! -d "${SPACK_DIR}"
then
git clone https://github.com/LLNL/spack.git "${SPACK_DIR}"
fi

test -d "${SPACK_DIR}" || return 1

(
cd "${SPACK_DIR}"

git fetch
git reset --hard "${spack_commit}"
)

return 0
}

spack_init ()
{
local modules_dir
local spack_env

test -n "${SPACK_DIR}" || return 1
test -d "${SPACK_DIR}" || return 1

spack_env="${SPACK_DIR}/share/spack/setup-env.sh"

test -f "${spack_env}" || return 1

if ! command -v module > /dev/null 2>&1
then
modules_dir="$("${SPACK_DIR}/bin/spack" location --install-dir environment-modules)"

if test -f "${modules_dir}/Modules/init/bash"
then
. "${modules_dir}/Modules/init/bash"
elif test -f '/etc/profile.d/modules.sh'
then
. /etc/profile.d/modules.sh
fi
fi

. "${spack_env}"

return 0
}

spack_install ()
{
local spack_pkg

spack_pkg="$1"

test -n "${SPACK_DIR}" || return 1
test -d "${SPACK_DIR}" || return 1
test -n "${spack_pkg}" || return 1

(
cd "${SPACK_DIR}"

./bin/spack install "${spack_pkg}"
)
}

spack_load ()
{
local spack_pkg

spack_pkg="$1"

test -n "${spack_pkg}" || return 1

spack load --dependencies "${spack_pkg}"
}

spack_get_dependencies ()
{
local dependencies

dependencies=''

# Required for Waf
dependencies="${dependencies} pkgconfig"

# Mandatory dependencies
dependencies="${dependencies} glib"
dependencies="${dependencies} libbson"

# Optional dependencies
dependencies="${dependencies} leveldb"
dependencies="${dependencies} lmdb"
dependencies="${dependencies} libmongoc"
dependencies="${dependencies} sqlite"

#dependencies="${dependencies} mpi"
#dependencies="${dependencies} otf"

printf '%s' "${dependencies}"
}

spack_load_dependencies ()
{
if spack_init
then
for dependency in $(spack_get_dependencies)
do
spack_load "${dependency}"
done
fi
}

spack_install_dependencies ()
{
if spack_clone
then
for dependency in $(spack_get_dependencies)
do
spack_install "${dependency}"
done
fi
}
9 changes: 8 additions & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# JULEA - Flexible storage framework
# Copyright (C) 2017-2018 Michael Kuhn
Expand All @@ -23,6 +23,7 @@ SELF_DIR="${SELF_PATH%/*}"
SELF_BASE="${SELF_PATH##*/}"

. "${SELF_DIR}/common"
. "${SELF_DIR}/spack"

set_glib_options
set_path
Expand All @@ -32,11 +33,17 @@ run_test ()
{
local build_dir

# julea-test does not get installed, so we have to find it in the build directory.
build_dir="$(get_directory "${SELF_DIR}/../build")"

# FIXME should use functions instead of setup.sh
setup.sh start
gtester --keep-going --verbose "$@" "${build_dir}/test/julea-test" || true
setup.sh stop
}

SPACK_DIR="$(get_directory "${SELF_DIR}/..")/dependencies"

spack_load_dependencies

run_test "$@"

0 comments on commit bfe3a27

Please sign in to comment.