1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-12-23 12:56:53 +01:00
trexio/tools/build_trexio.sh

92 lines
2.1 KiB
Bash
Raw Normal View History

#!/bin/bash
2021-04-30 13:51:15 +02:00
# Check that script is executed from tools directory
if [[ $(basename $PWD) != "tools" ]] ; then
echo "This script should run in the tools directory"
2021-03-18 17:30:48 +01:00
exit -1
fi
2021-04-30 14:12:23 +02:00
TREXIO_ROOT=$(dirname "${PWD}../")
# First define readonly global variables.
readonly SRC=${TREXIO_ROOT}/src
readonly TOOLS=${TREXIO_ROOT}/tools
2021-04-30 14:12:23 +02:00
2021-04-30 13:51:15 +02:00
# Go to src directory
2021-04-30 14:12:23 +02:00
cd ${SRC}
2021-04-30 13:51:15 +02:00
2021-03-18 17:30:48 +01:00
# We want the script to crash on the 1st error:
set -e
2021-04-30 13:51:15 +02:00
# Create directories for templates
2021-03-17 14:33:32 +01:00
echo "create populated directories"
mkdir -p templates_front/populated
mkdir -p templates_text/populated
mkdir -p templates_hdf5/populated
2021-03-18 17:30:48 +01:00
# It is important to ad '--' to rm because it tells rm that what follows are
# not options. It is safer.
2021-04-30 13:51:15 +02:00
# Cleaning of existing data
2021-03-17 14:33:32 +01:00
echo "remove existing templates"
2021-03-22 16:15:37 +01:00
rm -f -- templates_front/*.{c,h,f90}
rm -f -- templates_text/*.{c,h}
rm -f -- templates_hdf5/*.{c,h}
2021-03-17 14:33:32 +01:00
echo "clean populated directories"
2021-03-19 09:12:10 +01:00
rm -f -- templates_front/populated/*
rm -f -- templates_text/populated/*
rm -f -- templates_hdf5/populated/*
2021-04-30 13:51:15 +02:00
# Function to produce TREXIO source files from org-mode files
function tangle()
{
local command="(org-babel-tangle-file \"$1\")"
emacs --batch \
--eval "(require 'org)" \
--eval "(org-babel-do-load-languages 'org-babel-load-languages '((python . t)))" \
--eval "(setq org-confirm-babel-evaluate nil)" \
--eval "$command"
}
2021-04-30 13:51:15 +02:00
# Produce source files for front end
2021-03-17 14:33:32 +01:00
echo "tangle org files to generate templates"
cd templates_front
tangle templator_front.org
2021-03-17 14:33:32 +01:00
cd ..
2021-04-30 13:51:15 +02:00
# Produce source files for TEXT back end
2021-03-17 14:33:32 +01:00
cd templates_text
tangle templator_text.org
2021-03-17 14:33:32 +01:00
cd ..
2021-04-30 13:51:15 +02:00
# Produce source files for HDF5 back end
2021-03-17 14:33:32 +01:00
cd templates_hdf5
tangle templator_hdf5.org
2021-03-17 14:33:32 +01:00
cd ..
2021-04-30 13:51:15 +02:00
# Populate templates with TREXIO structure according to trex.json file
2021-03-17 14:33:32 +01:00
echo "run generator script to populate templates"
cp ${TOOLS}/generator.py ${SRC}
2021-03-18 17:30:48 +01:00
python3 generator.py
rm -f -- ${SRC}/generator.py
2021-04-30 13:51:15 +02:00
# Put pieces of source files together
2021-03-17 14:33:32 +01:00
echo "compile populated files in the lib source files "
cd templates_front
source build.sh
cp trexio* ../
cd ..
2021-05-05 11:37:48 +02:00
mv trexio.h trexio_f.f90 ../include
cd templates_text
source build.sh
cp trexio* ../
cd ..
cd templates_hdf5
source build.sh
cp trexio* ../
cd ..