B3U6WQSHDHQWSUHLMJMVRMSYJXVK5JPKTNX4NMWJGIDS7FOSR3ZQC
XDOIJC2EM756OI6FDIAE4NSOWXO3OJSS5H2BIG4HY3PPBODYY66QC
RGJW3YTXML556YLAFHZSTEONWXRJ23PGW7Z6SKT3BV63ZEPWDTXAC
7KS22PCEQW4NFNBIGVRIPLZ4VZL4W7WPNPGA7B23CYUIXZB37IBQC
KP5ZHGFKZZV35ZEH2AZW2HAFF6XXTK4XVLUI3D62ZTBPNOTQJONAC
Q7P6NO6DTAU3Z7JQ6HNQIQPGWPQHW37RRI5A5HDJYNC7IJCQ4XSQC
I2I3WERCRM7KAHR477JRZSN5XNXUIAWMDFQK25LV6L7VDZJTTANQC
WYN7KNH7TNW3CFN5BCUUWJYMDRDVXH4YRTRIKTXGIEWVEUCOFJRQC
library lnx-libuv --pkg-config libuv
library lnx-glfw3 --pkg-config glfw3 --lflag -lGL
library lnx-sqlite3 --pkg-config sqlite3
library lnx-libuv --pkg-config libuv
library lnx-glfw3 --pkg-config glfw3 --lflag -lGL
library lnx-sqlite3 --pkg-config sqlite3
while (( "$#" )); do
local arg=$1
shift
if [[ $arg = --command ]]; then
command=$1
shift
elif [[ $arg = --generator ]]; then
generator=1
elif [[ $arg = --implicit ]]; then
implicit_dependencies="$implicit_dependencies $1"
shift
elif [[ $arg = --deps ]]; then
deps="$1"
shift
elif [[ $arg = --depfile ]]; then
depfile="$1"
shift
fi
done
while (( "$#" )); do
local arg=$1
shift
if [[ $arg = --command ]]; then
command=$1
shift
elif [[ $arg = --generator ]]; then
generator=1
elif [[ $arg = --implicit ]]; then
implicit_dependencies="$implicit_dependencies $1"
shift
elif [[ $arg = --deps ]]; then
deps="$1"
shift
elif [[ $arg = --depfile ]]; then
depfile="$1"
shift
fi
done
echo "rule $name"
if [[ ! -z $command ]]; then
echo " command = $command"
fi
if [[ ! -z $deps ]]; then
echo " deps = $deps"
fi
if [[ ! -z $depfile ]]; then
echo " depfile = $depfile"
fi
if [[ ! -z $generator ]]; then
echo " generator = 1"
fi
echo "rule $name"
if [[ ! -z $command ]]; then
echo " command = $command"
fi
if [[ ! -z $deps ]]; then
echo " deps = $deps"
fi
if [[ ! -z $depfile ]]; then
echo " depfile = $depfile"
fi
if [[ ! -z $generator ]]; then
echo " generator = 1"
fi
while (( "$#" )); do
local arg=$1
shift
if [[ $arg = --implicit ]]; then
implicit_dependencies="$implicit_dependencies $1"
shift
elif [[ $arg = --flags ]]; then
flags=$1
shift
else
inputs="$inputs $arg"
fi
done
while (( "$#" )); do
local arg=$1
shift
if [[ $arg = --implicit ]]; then
implicit_dependencies="$implicit_dependencies $1"
shift
elif [[ $arg = --flags ]]; then
flags=$1
shift
else
inputs="$inputs $arg"
fi
done
local platform=lnx
local sources=
local objects=
local executable=
local phony=
local include_directories=
local defines=
local private_defines=
local cflags=
local lflags=
local implicit_dependencies=
local link_dependencies=
local platform=lnx
local sources=
local objects=
local executable=
local phony=
local include_directories=
local defines=
local private_defines=
local cflags=
local lflags=
local implicit_dependencies=
local link_dependencies=
local PKG_CONFIG=PKG_CONFIG_${platform}
local CC=CC_${platform}
local LINK=LINK_${platform}
local EXE=EXE_${platform}
local CFLAGS=CFLAGS_${platform}
local LFLAGS=LFLAGS_${platform}
local AR=AR_${platform}
local PKG_CONFIG=PKG_CONFIG_${platform}
local CC=CC_${platform}
local LINK=LINK_${platform}
local EXE=EXE_${platform}
local CFLAGS=CFLAGS_${platform}
local LFLAGS=LFLAGS_${platform}
local AR=AR_${platform}
while (( "$#" )); do
local arg=$1
shift
if [[ $arg = --executable ]]; then
executable=1
elif [[ $arg = --phony ]]; then
phony=1
elif [[ $arg = --include-directory ]]; then
include_directories="$include_directories -I$1"
shift
elif [[ $arg = --cflag ]]; then
cflags="$cflags $1"
shift
elif [[ $arg = --lflag ]]; then
lflags="$lflags $1"
shift
elif [[ $arg = --implicit ]]; then
implicit_dependencies="$implicit_dependencies $1"
shift
elif [[ $arg = --define ]]; then
defines="$defines -D$1"
shift
elif [[ $arg = --define-private ]]; then
private_defines="$private_defines -D$1"
shift
elif [[ $arg = --pkg-config ]]; then
cflags="$cflags $(pkg-config --cflags $1)"
lflags="$lflags $(pkg-config --libs $1)"
shift
while (( "$#" )); do
local arg=$1
shift
if [[ $arg = --executable ]]; then
executable=1
elif [[ $arg = --phony ]]; then
phony=1
elif [[ $arg = --include-directory ]]; then
include_directories="$include_directories -I$1"
shift
elif [[ $arg = --cflag ]]; then
cflags="$cflags $1"
shift
elif [[ $arg = --lflag ]]; then
lflags="$lflags $1"
shift
elif [[ $arg = --implicit ]]; then
implicit_dependencies="$implicit_dependencies $1"
shift
elif [[ $arg = --define ]]; then
defines="$defines -D$1"
shift
elif [[ $arg = --define-private ]]; then
private_defines="$private_defines -D$1"
shift
elif [[ $arg = --pkg-config ]]; then
cflags="$cflags $(pkg-config --cflags $1)"
lflags="$lflags $(pkg-config --libs $1)"
shift
else
local tgt=${target_defined[$arg]}
if [[ -z "$tgt" ]]; then
if [[ -z "$phony" ]]; then
sources="$sources $arg"
no_c=${arg%.c}
[ $arg = $no_c ] && echo "only c sources can be used, got $arg"
objects="$objects \$builddir/${platform}-${no_c//\//-}.o"
local tgt=${target_defined[$arg]}
if [[ -z "$tgt" ]]; then
if [[ -z "$phony" ]]; then
sources="$sources $arg"
no_c=${arg%.c}
[ $arg = $no_c ] && echo "only c sources can be used, got $arg"
objects="$objects \$builddir/${platform}-${no_c//\//-}.o"
else
phony="$phony $arg"
fi
else
include_directories="$include_directories ${target_include_directories[$arg]}"
defines="$defines ${target_defines[$arg]}"
cflags="$cflags ${target_cflags[$arg]}"
lflags="$lflags ${target_lflags[$arg]}"
implicit_dependencies="$implicit_dependencies ${target_implicit_dependencies[$arg]}"
link_dependencies="$link_dependencies ${target_link_dependencies[$arg]}"
fi
phony="$phony $arg"
done
else
include_directories="$include_directories ${target_include_directories[$arg]}"
defines="$defines ${target_defines[$arg]}"
cflags="$cflags ${target_cflags[$arg]}"
lflags="$lflags ${target_lflags[$arg]}"
implicit_dependencies="$implicit_dependencies ${target_implicit_dependencies[$arg]}"
link_dependencies="$link_dependencies ${target_link_dependencies[$arg]}"
fi
fi
done
if [[ ! -z "$sources" ]]; then
RULE_DEFINES=$(echo $defines $private_defines | uniq)
rule ${name}_cc \
--command "${!CC} -MD -MF \$out.d $include_directories $RULE_DEFINES ${!CFLAGS} $cflags -c \$in -o \$out" \
--depfile "\$out.d" \
--deps "gcc"
if [[ ! -z "$sources" ]]; then
RULE_DEFINES=$(echo $defines $private_defines | uniq)
rule ${name}_cc \
--command "${!CC} -MD -MF \$out.d $include_directories $RULE_DEFINES ${!CFLAGS} $cflags -c \$in -o \$out" \
--depfile "\$out.d" \
--deps "gcc"
for src in $sources; do
no_c=${src%.c}
build "\$builddir/${platform}-${no_c//\//-}.o" ${name}_cc $src --implicit "$implicit_dependencies"
done
for src in $sources; do
no_c=${src%.c}
build "\$builddir/${platform}-${no_c//\//-}.o" ${name}_cc $src --implicit "$implicit_dependencies"
done
if [[ ! -z "$executable" ]]; then
rule ${name}_link \
--command "${!LINK} ${!CFLAGS} $cflags \$in ${!LFLAGS} -L\$builddir/${platform}-lib $lflags -o \$out"
if [[ ! -z "$executable" ]]; then
# ⍷⌾⌽ in BQN. Deduplicate _under_ Reverse
cleaned_lflags=$(tr ' ' '\n' <<<"$lflags" | tac | awk '!u[$0]++' | tac | tr '\n' ' ')
cleaned_link_dependencies=$(tr ' ' '\n' <<<"$link_dependencies" | tac | awk '!u[$0]++' | tac | tr '\n' ' ')
build \$builddir/$name${!EXE} ${name}_link $objects --implicit "$link_dependencies"
else
rule ${name}_ar \
--command "rm -f \$out && ${!AR} crs \$out \$in"
rule ${name}_link \
--command "${!LINK} ${!CFLAGS} $cflags \$in ${!LFLAGS} -L\$builddir/${platform}-lib $cleaned_lflags -o \$out"
lflags="-l$name $lflags" # break append convention so libraries are linked from child to parent
link_dependencies="$link_dependencies \$builddir/${platform}-lib/lib${name}.a"
fi
build \$builddir/${platform}-lib/lib${name}.a ${name}_ar $objects
lflags="-l$name $lflags" # break append convention so libraries are linked from child to parent
link_dependencies="$link_dependencies \$builddir/${platform}-lib/lib${name}.a"
target_defined[$name]=1
target_include_directories[$name]=$(echo $include_directories | uniq)
target_defines[$name]=$(echo $defines | uniq)
target_cflags[$name]=$(echo $cflags | uniq)
target_lflags[$name]=$(echo $lflags | uniq)
target_implicit_dependencies[$name]=$implicit_dependencies
target_link_dependencies[$name]=$link_dependencies
target_defined[$name]=1
target_include_directories[$name]=$(echo $include_directories | uniq)
target_defines[$name]=$(echo $defines | uniq)
target_cflags[$name]=$(echo $cflags | uniq)
target_lflags[$name]=$(echo $lflags | uniq)
target_implicit_dependencies[$name]=$implicit_dependencies
target_link_dependencies[$name]=$link_dependencies