Current section
Files
Jump to
Current section
Files
priv/hex-packaging/hex-compile-hook-script.sh
#!/bin/sh
# Not using set -e: http://mywiki.wooledge.org/BashFAQ/105
usage="$(basename $0): a script for the compilation to happen correctly when creating an hex package."
# See the pre_hooks key in rebar-for-hex.config.
echo " Hex compile hook script started: preparing for package in $(pwd)..."
# Typically run, for a package foo, from _build/default/lib/foo.
# Securing all files needed for a proper build:
for f in priv/hex-packaging/root/GNUmake* ; do ln -sf $f ; done || exit 5
# For its makefiles that are included from the root ones:
#ln -sf priv/hex-packaging/doc/
/bin/cp -rf priv/hex-packaging/doc/ . || exit 10
# Does mostly for the current package, seen as a dependency, what is done by the
# package itself when creating an OTP application for it (see the
# rebar3-{create-tree, populate-build-tree, etc.} make targets) - except we
# directly work in from the application package root (ex: from
# "_build/default/lib/myriad") rather than from its vanilla source tree:
# Like the rebar3-create-tree target:
mkdir -p doc ebin include priv src test || exit 15
make -s all || exit 20
# Like the rebar3-copy-beams target:
find src -name '*.beam' -a ! -name '*_test.beam' -exec /bin/cp -f '{}' ebin/ ';' || exit 25
find src test* -name '*.hrl' -exec /bin/cp -f '{}' include/ ';' || exit 30
echo " Successful end of hex compile hook script"
# Hides the source files, otherwise rebar will attempt to recompile them (
find src -name '*rl' -exec /bin/mv -f '{}' '{}'-h ';'