Compiler fails looking for wrong file name with extended include
A framework for modular scripting
Brought to you by:
konsolebox
Hi,
I have a bash project which I want to bundle using compiler (directly using compilers branch).
Structure is like this
src/
bin/
main
lib/
colors.sh
when I run compiler using
gawk -f modules/compiler/compiler.gawk -- -a src/lib -O -x src/bin/main
I get the following error
compiler: truncate: compiler.main.obj
compiler: truncate: compiler.calls.obj
compiler: truncate: compiler.comp.obj
compiler: walk: /home/xxx/projects/myproject/src/bin/main
compiler: walk: /home/xxx/projects/myproject/src/libcolors.sh
compiler: /home/xxx/projects/myproject/src/bin/main: line 8: includex "lib/*.sh":
Failure: File is not readable: /home/xxx/projects/myproject/src/libcolors.sh
Compiler seems to be using an invalid filel path. It should be home/xxx/projects/myproject/src/lib/colors.sh
The main script is as follows:
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
includex "*.sh"
function main() {
if [[ -z ${1:-} ]]; then
echo "Missing command"
echo "Usage: main <command> [<args>]"
else
"$1"
fi
}
if [[ ${BASH_SOURCE[0]} != "$0" ]]; then
export -f main
else
main "${@}"
exit $?
fi
# vim:set ft=sh
Hi, thanks for the report.
This probably was caused by the use of the simpler function compiler_getcleanpath instead of compiler_getabspath. The first function strips the trailing '/' for the "prefix". I'll see how I could fix this right away. If you're in a hurry, please consider using the version of the compiler before it used getcleanpath:
https://sourceforge.net/p/loader/code/ci/2efde141546b8e7871ce121fb02d8c0e2e9bfc6b/tree/compiler.gawk?format=raw
So, I ended up just reverting the commit to avoid complicating the code. I hope it works for you. I staged a release for it that would automatically be published in 3 days. Please tell me if you find more issues.
Here's the new commit which includes the revert. It's not much different compared to the one I just mentioned.
https://sourceforge.net/p/loader/code/ci/789d76ff810f3be3976d7389acb793ba4b6d335a/tree/compiler.gawk
Thanks, it is sorted.