aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-06-24 20:48:32 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2023-06-24 22:10:50 +0300
commit422b6c976e28445d2a6e14586fa416b0f16c093f (patch)
treea6bf3364cec45ed0c5d48e346a76a98fe9d0094a /scripts
downloadcopyjit-422b6c976e28445d2a6e14586fa416b0f16c093f.tar.gz
copyjit-422b6c976e28445d2a6e14586fa416b0f16c093f.zip
initial commit
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/gen-deps35
-rwxr-xr-xscripts/gen-ops20
-rwxr-xr-xscripts/license11
-rwxr-xr-xscripts/warn-undocumented6
4 files changed, 72 insertions, 0 deletions
diff --git a/scripts/gen-deps b/scripts/gen-deps
new file mode 100755
index 0000000..e9c7a51
--- /dev/null
+++ b/scripts/gen-deps
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+gencommon () {
+ lint="build/${s%.*}${1}.l"
+ dep="build/${s%.*}${1}.d"
+ obj="build/${s%.*}${1}"
+
+ echo "${dep}:" >> deps.mk
+ echo "include ${dep}" >> deps.mk
+ echo "${obj}: ${s}" >> deps.mk
+}
+
+genobjs () {
+ gencommon ".o"
+ echo "${obj}: ${s}" >> deps.mk
+ echo " \$(COMPILE) -c \$< -o \$@" >> deps.mk
+
+ echo "${lint}: ${s}" >> deps.mk
+ echo " \$(LINT) -c ${s} -o /dev/null" >> deps.mk
+}
+
+case "${1}" in
+ --sources)
+ func=genobjs
+ ;;
+esac
+
+# create all subdirectories
+mkdir -p $(echo "${2}" | xargs dirname | uniq | sed 's|^|build/|g')
+
+for s in ${2}
+do
+ ${func} ${suffix}
+ echo ${obj}
+done
diff --git a/scripts/gen-ops b/scripts/gen-ops
new file mode 100755
index 0000000..d7a981a
--- /dev/null
+++ b/scripts/gen-ops
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+genobjs () {
+ obj="build/${s%.*}.o"
+ bin="build/${s%.*}.bin"
+ echo "${obj}: ${s}" >> deps.mk
+ echo " \$(OP_COMPILE) -c \$< -o \$@" >> deps.mk
+ echo "${bin}: lib/prune" >> deps.mk
+ echo "${bin}: ${obj}" >> deps.mk
+ echo " \$(OBJCOPY) -j .text -Obinary \$< \$@" >> deps.mk
+ echo " ./lib/prune lib/empty.bin ${bin}" >> deps.mk
+ echo "${bin}"
+}
+
+mkdir -p $(echo "${1}" | xargs dirname | uniq | sed 's|^|build/|g')
+
+for s in ${1}
+do
+ genobjs
+done
diff --git a/scripts/license b/scripts/license
new file mode 100755
index 0000000..2a2de9b
--- /dev/null
+++ b/scripts/license
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+SPDX="/* SPDX-License-Identifier: GPL-3.0-or-later */"
+
+for f in "$@"
+do
+ if [ "$(head -1 "$f")" != "${SPDX}" ]
+ then
+ sed -i "1i${SPDX}\n" "$f"
+ fi
+done
diff --git a/scripts/warn-undocumented b/scripts/warn-undocumented
new file mode 100755
index 0000000..f1367bd
--- /dev/null
+++ b/scripts/warn-undocumented
@@ -0,0 +1,6 @@
+#!/bin/sh
+# look through all files for either @file or \file, grep -c will report
+# ./example.file:0 if it is not found.
+find src -iname '*.[ch]' -exec \
+ grep -c '[@\]file' {} \+ \
+ | awk -F':' '$2 == 0 {print "Undocumented file:", $1}'