This repository has been archived on 2024-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
ale/dmd-wrapper

41 lines
921 B
Text
Raw Permalink Normal View History

#!/bin/bash -eu
2016-10-03 18:20:13 +00:00
# Author: w0rp <devw0rp@gmail.com>
# Description: This script wraps DMD so we can get something which is capable of reading
# D code from stdin.
temp_file=`mktemp`
mv "$temp_file" "$temp_file".d
temp_file="$temp_file".d
trap "rm $temp_file" EXIT
while read; do
echo "$REPLY" >> "$temp_file"
done
# Read imports from DUB.
original_path="$(pwd)"
path="$original_path"
import_line_options=''
# We need to look for variable configuration files in parent directories.
while [ "$path" != '/' ]; do
if [ -f "$path/dub.sdl" ] || [ -f "$path/dub.json" ] || [ -f "$path/package.json" ]; then
cd "$path"
while read import_line; do
import_line_options="$import_line_options -I$import_line"
done <<< "$(dub describe --import-paths)"
cd "$original_path"
break
fi
path="$(dirname "$path")"
done
dmd $import_line_options "$@" "$temp_file"