From c057e14b2027ce2e9300d2ba63d516105910299b Mon Sep 17 00:00:00 2001 From: jpaquim Date: Sat, 11 Oct 2025 16:02:02 +0100 Subject: [PATCH 1/6] Fix dependencies and variable names in Makefile --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 6e7033241..bf7a2b51a 100644 --- a/Makefile +++ b/Makefile @@ -261,6 +261,7 @@ $(JANET_STATIC_LIBRARY): $(JANET_TARGET_OBJECTS) # Testing assumes HOSTCC=CC TEST_SCRIPTS=$(wildcard test/suite*.janet) +EXAMPLE_SCRIPTS=$(wildcard examples/*.janet) repl: $(JANET_TARGET) $(RUN) ./$(JANET_TARGET) @@ -273,15 +274,15 @@ VALGRIND_COMMAND=valgrind --leak-check=full --quiet valgrind: $(JANET_TARGET) $(VALGRIND_COMMAND) ./$(JANET_TARGET) -test: $(JANET_TARGET) $(TEST_PROGRAMS) +test: $(JANET_TARGET) $(TEST_SCRIPTS) $(EXAMPLE_SCRIPTS) for f in test/suite*.janet; do $(RUN) ./$(JANET_TARGET) "$$f" || exit; done for f in examples/*.janet; do $(RUN) ./$(JANET_TARGET) -k "$$f"; done -valtest: $(JANET_TARGET) $(TEST_PROGRAMS) +valtest: $(JANET_TARGET) $(TEST_SCRIPTS) $(EXAMPLE_SCRIPTS) for f in test/suite*.janet; do $(VALGRIND_COMMAND) ./$(JANET_TARGET) "$$f" || exit; done for f in examples/*.janet; do ./$(JANET_TARGET) -k "$$f"; done -callgrind: $(JANET_TARGET) +callgrind: $(JANET_TARGET) $(TEST_SCRIPTS) for f in test/suite*.janet; do valgrind --tool=callgrind ./$(JANET_TARGET) "$$f" || exit; done ######################## From 56027227fb92815f76f242625ed43e140f7a0269 Mon Sep 17 00:00:00 2001 From: jpaquim Date: Sat, 11 Oct 2025 16:11:05 +0100 Subject: [PATCH 2/6] Add missing phony targets and documentation for install-{jpm,spork}-git --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index bf7a2b51a..c35945076 100644 --- a/Makefile +++ b/Makefile @@ -414,9 +414,6 @@ clean: -rm -rf build vgcore.* callgrind.* -rm -rf test/install/build test/install/modpath -test-install: - echo "JPM has been removed from default install." - help: @echo @echo 'Janet: A Dynamic Language & Bytecode VM' @@ -438,6 +435,9 @@ help: @echo " make format Format Janet's own source files" @echo ' make grammar Generate a TextMate language grammar' @echo + @echo ' make install-jpm-git Install jpm into the current filesystem' + @echo ' make install-spork-git Install spork into the current filesystem' + @echo -.PHONY: clean install repl debug valgrind test \ +.PHONY: clean install install-jpm-git install-spork-git repl debug valgrind test \ valtest dist uninstall docs grammar format help compile-commands From c29195596e1f81244434d1347a73e6b464483f4f Mon Sep 17 00:00:00 2001 From: jpaquim Date: Sat, 11 Oct 2025 16:29:14 +0100 Subject: [PATCH 3/6] Adapt generated file comments to build type --- src/boot/boot.janet | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/boot/boot.janet b/src/boot/boot.janet index fa21e55d2..5f49a0319 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -4934,7 +4934,9 @@ "src/core/wrap.c"]) # Print janet.c to stdout - (print "/* Amalgamated build - DO NOT EDIT */") + (if (has-value? boot/args "image-only") + (print "/* Image-only build - DO NOT EDIT */") + (print "/* Amalgamated build - DO NOT EDIT */")) (print "/* Generated from janet version " janet/version "-" janet/build " */") (print "#define JANET_BUILD \"" janet/build "\"") (print ```#define JANET_AMALG```) From 511c1f4b0a1b977fc721ece6e0f24a9deac87f34 Mon Sep 17 00:00:00 2001 From: jpaquim Date: Sat, 11 Oct 2025 16:32:24 +0100 Subject: [PATCH 4/6] Refactor with image-only variable --- src/boot/boot.janet | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/boot/boot.janet b/src/boot/boot.janet index 5f49a0319..9f7fd34ba 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -4934,16 +4934,15 @@ "src/core/wrap.c"]) # Print janet.c to stdout - (if (has-value? boot/args "image-only") - (print "/* Image-only build - DO NOT EDIT */") - (print "/* Amalgamated build - DO NOT EDIT */")) + (def image-only (has-value? boot/args "image-only")) + (print "/* " (if image-only "Image-only" "Amalgamated") " build - DO NOT EDIT */") (print "/* Generated from janet version " janet/version "-" janet/build " */") (print "#define JANET_BUILD \"" janet/build "\"") (print ```#define JANET_AMALG```) (defn do-one-file [fname] - (unless (has-value? boot/args "image-only") + (unless image-only (print "\n/* " fname " */") (print "#line 0 \"" fname "\"\n") (def source (slurp fname)) From a7764664235e739804c4714c55557116bcaf9851 Mon Sep 17 00:00:00 2001 From: jpaquim Date: Sat, 11 Oct 2025 17:42:47 +0100 Subject: [PATCH 5/6] Add $(RUN) for valgrind/callgrind, add dedicated callgrind-test target --- Makefile | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index c35945076..acacc0c42 100644 --- a/Makefile +++ b/Makefile @@ -269,7 +269,8 @@ repl: $(JANET_TARGET) debug: $(JANET_TARGET) $(DEBUGGER) ./$(JANET_TARGET) -VALGRIND_COMMAND=valgrind --leak-check=full --quiet +VALGRIND_COMMAND=$(RUN) valgrind --leak-check=full --quiet +CALLGRIND_COMMAND=$(RUN) valgrind --tool=callgrind valgrind: $(JANET_TARGET) $(VALGRIND_COMMAND) ./$(JANET_TARGET) @@ -280,10 +281,14 @@ test: $(JANET_TARGET) $(TEST_SCRIPTS) $(EXAMPLE_SCRIPTS) valtest: $(JANET_TARGET) $(TEST_SCRIPTS) $(EXAMPLE_SCRIPTS) for f in test/suite*.janet; do $(VALGRIND_COMMAND) ./$(JANET_TARGET) "$$f" || exit; done - for f in examples/*.janet; do ./$(JANET_TARGET) -k "$$f"; done + for f in examples/*.janet; do $(VALGRIND_COMMAND) ./$(JANET_TARGET) -k "$$f"; done -callgrind: $(JANET_TARGET) $(TEST_SCRIPTS) - for f in test/suite*.janet; do valgrind --tool=callgrind ./$(JANET_TARGET) "$$f" || exit; done +callgrind: $(JANET_TARGET) + $(CALLGRIND_COMMAND) ./$(JANET_TARGET) + +calltest: $(JANET_TARGET) $(TEST_SCRIPTS) $(EXAMPLE_SCRIPTS) + for f in test/suite*.janet; do $(CALLGRIND_COMMAND) ./$(JANET_TARGET) "$$f" || exit; done + for f in examples/*.janet; do $(CALLGRIND_COMMAND) ./$(JANET_TARGET) -k "$$f"; done ######################## ##### Distribution ##### @@ -425,7 +430,8 @@ help: @echo ' make test Test a built Janet' @echo ' make valgrind Assess Janet with Valgrind' @echo ' make callgrind Assess Janet with Valgrind, using Callgrind' - @echo ' make valtest Run the test suite with Valgrind to check for memory leaks' + @echo ' make valtest Run the test suite and examples with Valgrind to check for memory leaks' + @echo ' make calltest Run the test suite and examples with Callgrind' @echo ' make dist Create a distribution tarball' @echo ' make docs Generate documentation' @echo ' make debug Run janet with GDB or LLDB' @@ -440,4 +446,4 @@ help: @echo .PHONY: clean install install-jpm-git install-spork-git repl debug valgrind test \ - valtest dist uninstall docs grammar format help compile-commands + valtest callgrind callgrind-test dist uninstall docs grammar format help compile-commands From 95abff31d97276b9b422bc9bbcd41d24cfdcde62 Mon Sep 17 00:00:00 2001 From: jpaquim Date: Sat, 11 Oct 2025 17:48:23 +0100 Subject: [PATCH 6/6] Fix file mention in CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 234700846..2be36b1d8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -61,7 +61,7 @@ ensure a consistent code style for C. ## Janet style -All janet code in the project should be formatted similar to the code in core.janet. +All janet code in the project should be formatted similar to the code in src/boot/boot.janet. The auto formatting from janet.vim will work well. ## Typo Fixing and One-Line changes