Load setup files instead of sourcing them
- needed for same setup files to work on Windows (where PowerShell is used instead of bash) - removes ugly bashism to allow overriding from .travis.yml - adds a proper (yet small) syntax Also adds tests for the new syntax and updates the README.
This commit is contained in:
21
README.md
21
README.md
@@ -71,15 +71,15 @@ example.
|
||||
|
||||
E.g., a setup file `stable.set` specifying
|
||||
```
|
||||
MODULES="sncseq asyn"
|
||||
MODULES=sncseq asyn
|
||||
|
||||
BASE=${BASE:-R3.15.6}
|
||||
ASYN=${ASYN:-R4-34}
|
||||
SNCSEQ=${SNCSEQ:-R2-2-7}
|
||||
BASE=R3.15.6
|
||||
ASYN=R4-34
|
||||
SNCSEQ=R2-2-7
|
||||
```
|
||||
will compile against the EPICS Base release 3.15.6, the Sequencer
|
||||
release 2.2.7 and release 4.34 of asyn.
|
||||
(The `${VAR:-default}` form allows overriding from `.travis.yml`.)
|
||||
(Any settings can be overridden from `.travis.yml`.)
|
||||
|
||||
4. Create a configuration for the CI service by copying one of
|
||||
the examples provided in the service specific subdirectory
|
||||
@@ -106,14 +106,19 @@ latest released versions and one for the development branches.
|
||||
|
||||
## Setup File Syntax
|
||||
|
||||
Setup files are sourced by the bash scripts. They are found by searching
|
||||
Setup files are loaded by the bash scripts. They are found by searching
|
||||
the locations in `SETUP_PATH` (space or colon separated list of directories,
|
||||
relative to your module's root directory).
|
||||
|
||||
Setup files can include other setup files by calling `source_set <setup>`
|
||||
Setup files can include other setup files by calling `include <setup>`
|
||||
(omitting the `.set` extension of the setup file). The configured
|
||||
`SETUP_PATH` is searched for the include.
|
||||
|
||||
Any `VAR=value` setting of a variable is only executed if `VAR` is unset or
|
||||
empty. That way any settings can be overridden by settings in `.travis.yml`.
|
||||
|
||||
Empty lines or lines starting with `#` are ignored.
|
||||
|
||||
`MODULES="<list of names>"` should list the dependencies (software modules)
|
||||
by using their well-known slugs, separated by spaces.
|
||||
EPICS Base (slug: `base`) will always be a dependency and will be added and
|
||||
@@ -132,8 +137,6 @@ be a *tag* name (in that case the module is checked out into Travis' cache
|
||||
system) or a *branch* name (in that case the module is always checked out
|
||||
and recompiled as part of the job). [default: `master`]
|
||||
|
||||
(Use the `${VAR:-default}` form to allow overriding from `.travis.yml`.)
|
||||
|
||||
`FOO_REPONAME=<name>` Set the name of the remote repository as `<name>.git`.
|
||||
[default is the slug in lower case: `foo`]
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
MODULES=""
|
||||
MODULES=
|
||||
|
||||
BASE=${BASE:-R3.15.6}
|
||||
BASE=R3.15.6
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
MODULES="sncseq"
|
||||
|
||||
BASE=${BASE:-7.0}
|
||||
SNCSEQ=${SNCSEQ:-R2-2-7}
|
||||
BASE=7.0
|
||||
SNCSEQ=R2-2-7
|
||||
|
||||
10
test02.set
Normal file
10
test02.set
Normal file
@@ -0,0 +1,10 @@
|
||||
# a comment, then an empty line
|
||||
|
||||
# a comment that is indented
|
||||
BASE=foo
|
||||
# include an existing file
|
||||
include test01
|
||||
|
||||
FOO=bar
|
||||
FOO2=bar bar2
|
||||
FOO3=bar bar2
|
||||
4
test03.set
Normal file
4
test03.set
Normal file
@@ -0,0 +1,4 @@
|
||||
# Check for avoiding multiple includions
|
||||
|
||||
include test01
|
||||
include test01
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
# Module ci-scripts unit tests
|
||||
|
||||
@@ -62,9 +62,20 @@ fn_exists add_dependency || die "function add_dependency missing from SCRIPTDIR/
|
||||
SETUP_DIRS= source_set test01 | grep -q "(SETUP_PATH) is empty" || die "empty search path not detected"
|
||||
source_set xxdoesnotexistxx | grep -q "does not exist" || die "missing setup file not detected"
|
||||
source_set test01 | grep -q "Loading setup file" || die "test01 setup file not found"
|
||||
BASE=foo
|
||||
unset SEEN_SETUPS
|
||||
export BASE=foo
|
||||
source_set test01
|
||||
[ "$BASE" = "foo" ] || die "preset module (BASE) version does not override test01 setup file"
|
||||
[ "$BASE" = "foo" ] || die "preset module BASE version does not override test01 setup file (expected foo got $BASE)"
|
||||
unset SEEN_SETUPS
|
||||
BASE=
|
||||
source_set test02
|
||||
[ "$BASE" = "foo" ] || die "BASE set in test02 does not override included test01 setup file (expected foo got $BASE)"
|
||||
[ "$FOO" = "bar" ] || die "Setting of single word does not work"
|
||||
[ "$FOO2" = "bar bar2" ] || die "Setting of multiple words does not work"
|
||||
[ "$FOO3" = "bar bar2" ] || die "Indented setting of multiple words does not work"
|
||||
[ "$SNCSEQ" = "R2-2-7" ] || die "Setup test01 was not included"
|
||||
unset SEEN_SETUPS
|
||||
source_set test03 | grep -q "Ignoring already included setup file" || die "test01 setup file included twice"
|
||||
|
||||
# test default settings file
|
||||
######################################################################
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Set VV in .travis.yml to make scripts verbose
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Set VV in .travis.yml to make scripts verbose
|
||||
|
||||
@@ -33,8 +33,9 @@ fold_end() {
|
||||
#
|
||||
# Source a settings file (extension .set) found in the SETUP_DIRS path
|
||||
# May be called recursively (from within a settings file)
|
||||
declare -a SEEN_SETUPS
|
||||
source_set() {
|
||||
local set_file=$1
|
||||
local set_file=${1//[$'\r']}
|
||||
local set_dir
|
||||
local found=0
|
||||
if [ -z "${SETUP_DIRS}" ]
|
||||
@@ -46,8 +47,30 @@ source_set() {
|
||||
do
|
||||
if [ -e $set_dir/$set_file.set ]
|
||||
then
|
||||
if [[ " ${SEEN_SETUPS[@]} " =~ " $set_dir/$set_file.set " ]]
|
||||
then
|
||||
echo "Ignoring already included setup file $set_dir/$set_file.set"
|
||||
return
|
||||
fi
|
||||
SEEN_SETUPS+=($set_dir/$set_file.set)
|
||||
echo "Loading setup file $set_dir/$set_file.set"
|
||||
. $set_dir/$set_file.set
|
||||
local line
|
||||
while read -r line
|
||||
do
|
||||
[ -z "$line" ] && continue
|
||||
echo $line | grep -q "^#" && continue
|
||||
if echo $line | grep -q "^include\W"
|
||||
then
|
||||
source_set $(echo $line | awk '{ print $2 }')
|
||||
continue
|
||||
fi
|
||||
if echo "$line" | grep -q "^\w\+="
|
||||
then
|
||||
IFS== read var value <<< "${line//[$'\r']}"
|
||||
value=$(sed "s/^\(\"\)\(.*\)\1\$/\2/g" <<< "$value") # remove surrounding quotes
|
||||
eval [ "\${$var}" ] || eval "$var=\$value"
|
||||
fi
|
||||
done < $set_dir/$set_file.set
|
||||
found=1
|
||||
break
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user