summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cheri/Makefile2
-rw-r--r--etc/loc.mk13
-rw-r--r--mips/Makefile6
-rw-r--r--riscv/Makefile7
4 files changed, 28 insertions, 0 deletions
diff --git a/cheri/Makefile b/cheri/Makefile
index fb54f103..a5df5f1e 100644
--- a/cheri/Makefile
+++ b/cheri/Makefile
@@ -40,6 +40,8 @@ cheri128: $(CHERI128_SAILS) $(CHERI_MAIN)
cheri128_trace: $(CHERI128_SAILS) $(CHERI_MAIN)
$(SAIL) -ocaml_trace -o $@ $^
+LOC_FILES:=$(CHERI_SAILS) $(CHERI_MAIN)
+include ../etc/loc.mk
# TODO Using bit lists for now in Lem generation; for machine words,
# monomorphisation is needed due to some variable length bitvectors, e.g. in
diff --git a/etc/loc.mk b/etc/loc.mk
new file mode 100644
index 00000000..bf79a723
--- /dev/null
+++ b/etc/loc.mk
@@ -0,0 +1,13 @@
+TEMPDIR:=sloc_tmp
+loc: $(LOC_FILES)
+ @rm -rf $(TEMPDIR)
+ @mkdir -p $(TEMPDIR)
+ @cp $^ $(TEMPDIR)
+ @for f in $(TEMPDIR)/*.sail; do mv "$$f" "$${f%.sail}.c"; done
+ @sloccount --details $(TEMPDIR) | grep ansic
+ @sloccount $(TEMPDIR) | grep ansic
+ rm -rf $(TEMPDIR)
+
+cloc: $(LOC_FILES)
+ cloc --by-file --force-lang C,sail $^
+
diff --git a/mips/Makefile b/mips/Makefile
index 00703f62..6e3ef49e 100644
--- a/mips/Makefile
+++ b/mips/Makefile
@@ -28,5 +28,11 @@ M%.thy: m%.lem m%_types.lem mips_extras.lem
lem -isa -outdir . -lib $(SAIL_DIR)/src/gen_lib -lib $(SAIL_DIR)/src/lem_interp $^
sed -i 's/datatype ast/datatype (plugins only: size) ast/' M$*_types.thy
+LOC_FILES:=$(MIPS_PRE) $(MIPS_TLB) $(MIPS_SAILS) $(MIPS_MAIN)
+include ../etc/loc.mk
+
+cloc: $(LOC_FILES)
+ cloc --by-file --force-lang C,sail $^
+
clean:
rm -rf mips Mips.thy mips.lem _sbuild
diff --git a/riscv/Makefile b/riscv/Makefile
index 781ec354..3cd235a7 100644
--- a/riscv/Makefile
+++ b/riscv/Makefile
@@ -34,6 +34,13 @@ Riscv.thy: riscv.lem riscv_extras.lem
riscv.lem: $(SAIL_SRCS) Makefile
$(SAIL_DIR)/sail -lem -o riscv -lem_mwords -lem_lib Riscv_extras $(SAIL_SRCS)
+# we exclude prelude.sail here, most code there should move to sail lib
+LOC_FILES:=$(SAIL_SRCS) main.sail
+include ../etc/loc.mk
+
+cloc: $(LOC_FILES)
+ cloc --by-file --force-lang C,sail $^
+
clean:
-rm -rf riscv _sbuild
-rm -f riscv.lem riscv_types.lem