From 80f84a4d538592fd8411c556421e2b09caae10c0 Mon Sep 17 00:00:00 2001 From: Thomas Walker Lynch Date: Tue, 10 Mar 2026 10:52:41 +0000 Subject: [PATCH] working single gate for implementation example/makefile --- developer/authored/Greeter/Greeter.lib.c | 26 ++++++++++------------ developer/authored/Greeter/Math.lib.c | 14 ++++++------ developer/authored/Greeter/hello.CLI.c | 10 ++++----- developer/tool/make | 23 +++++++++++-------- developer/tool/makefile | 8 +++++++ shared/tool/makefile/Harmony.mk | 2 +- shared/tool/makefile/target_library_CLI.mk | 8 ++++++- 7 files changed, 53 insertions(+), 38 deletions(-) diff --git a/developer/authored/Greeter/Greeter.lib.c b/developer/authored/Greeter/Greeter.lib.c index b7be528..4c9b9db 100644 --- a/developer/authored/Greeter/Greeter.lib.c +++ b/developer/authored/Greeter/Greeter.lib.c @@ -1,26 +1,24 @@ -#ifndef GREETER_LIB_C -#define GREETER_LIB_C -#ifndef FACE - #define GREETER_IMPL +#ifndef ExampleGreet·Greeter·ONCE +#define ExampleGreet·Greeter·ONCE + +#ifndef ExampleGreet·Greeter + #define ExampleGreet·Greeter #endif -#define FACE -#include "math.lib.c" -#undef FACE +#include "Math.lib.c" -void Greet·hello_loop(int count); +void ExampleGreet·Greeter·hello_loop(int count); -#ifdef GREETER_IMPL +#ifdef ExampleGreet·Greeter #include -void Greet·hello_loop(int count){ +void ExampleGreet·Greeter·hello_loop(int count){ for(int TM = 0; TM < count; ++TM){ - int current_count = Math·add(TM ,1); + int current_count = ExampleGreet·Math·add(TM ,1); printf("Hello iteration: %d\n" ,current_count); } } -#endif // GREETER_IMPL -#endif // GREETER_LIB_C - +#endif // ExampleGreet·Greeter +#endif // ExampleGreet·Greeter·ONCE diff --git a/developer/authored/Greeter/Math.lib.c b/developer/authored/Greeter/Math.lib.c index 220b392..99dec03 100644 --- a/developer/authored/Greeter/Math.lib.c +++ b/developer/authored/Greeter/Math.lib.c @@ -1,17 +1,17 @@ -#ifndef ExampleGreet·math·ONCE -#define ExampleGreet·math·ONCE +#ifndef ExampleGreet·Math·ONCE +#define ExampleGreet·Math·ONCE -#ifndef ExampleGreet·math - #define ExampleGreet·math +#ifndef ExampleGreet·Math + #define ExampleGreet·Math #endif int ExampleGreet·Math·add(int a ,int b); -#ifdef ExampleGreet·math +#ifdef ExampleGreet·Math int ExampleGreet·Math·add(int a ,int b){ return a + b; } -#endif // ExampleGreet·math -#endif // ExampleGreet·math·ONCE +#endif // ExampleGreet·Math +#endif // ExampleGreet·Math·ONCE diff --git a/developer/authored/Greeter/hello.CLI.c b/developer/authored/Greeter/hello.CLI.c index d498dbf..8427efb 100644 --- a/developer/authored/Greeter/hello.CLI.c +++ b/developer/authored/Greeter/hello.CLI.c @@ -1,15 +1,13 @@ #include #include -#define FACE -#include "math.lib.c" -#include "greeter.lib.c" -#undef FACE +#include "Math.lib.c" +#include "Greeter.lib.c" void CLI(void){ - int base_count = Math·add(1 ,2); + int base_count = ExampleGreet·Math·add(1 ,2); printf("Calculated base loop count: %d\n" ,base_count); - Greet·hello_loop(base_count); + ExampleGreet·Greeter·hello_loop(base_count); } int main(int argc ,char **argv){ diff --git a/developer/tool/make b/developer/tool/make index 740321f..1c5922c 100755 --- a/developer/tool/make +++ b/developer/tool/make @@ -1,19 +1,24 @@ #!/usr/bin/env bash script_afp=$(realpath "${BASH_SOURCE[0]}") -# input guards +setup_must_be="developer/tool/setup" +if [ "$SETUP" != "$setup_must_be" ]; then + echo "$(script_fp):: error: must be run in the $setup_must_be environment" + exit 1 +fi - setup_must_be="developer/tool/setup" - if [ "$SETUP" != "$setup_must_be" ]; then - echo "$(script_fp):: error: must be run in the $setup_must_be environment" - exit 1 - fi - -set -e +set -euo pipefail # RT-style shell safety set -x + # Command is first, Namespace is second + CMD="${1:-usage}" + NAMESPACE_ARG="${2:-}" + cd "$REPO_HOME/developer" || exit 1 - /bin/make -f tool/makefile $@ + + # Pass both to the orchestrator + NAMESPACE="$NAMESPACE_ARG" /bin/make -f tool/makefile "$CMD" set +x echo "$(script_fn) done." + diff --git a/developer/tool/makefile b/developer/tool/makefile index 2d5d057..98d86a0 100644 --- a/developer/tool/makefile +++ b/developer/tool/makefile @@ -5,6 +5,12 @@ RT_MAKEFILE_DP := $(REPO_HOME)/shared/tool/makefile include $(RT_MAKEFILE_DP)/Harmony.mk +# If a namespace is provided, update the source directory +ifneq ($(NAMESPACE),) + C_SOURCE_DIR := authored/$(NAMESPACE) + export C_SOURCE_DIR +endif + .PHONY: usage usage: @printf "Usage: make [usage|version|information|all|lib|CLI|kmod|clean]\n" @@ -23,6 +29,8 @@ information: @printf "local ----------------------------------------\n" -@echo CURDIR='$(CURDIR)' @echo REPO_HOME="$(REPO_HOME)" + @echo NAMESPACE="$(NAMESPACE)" + @echo C_SOURCE_DIR="$(C_SOURCE_DIR)" @echo KMOD_BUILD_DIR="/lib/modules/$(shell uname -r)/build" @echo CURDIR="$(CURDIR)" @printf "target_library_CLI.mk ----------------------------------------\n" diff --git a/shared/tool/makefile/Harmony.mk b/shared/tool/makefile/Harmony.mk index da5efc6..f46a73d 100644 --- a/shared/tool/makefile/Harmony.mk +++ b/shared/tool/makefile/Harmony.mk @@ -14,7 +14,6 @@ CFLAGS += -MMD -MP CFLAGS += -include "$(REPO_HOME)/shared/tool/makefile/RT_global.h" CFLAGS += -I $(C_SOURCE_DIR) - # Project administrators can override this in their local makefile LIBRARY_NAME ?= $(PROJECT) LIBRARY_NAME := $(subst -,_,$(LIBRARY_NAME)) @@ -33,3 +32,4 @@ KMOD_CCFLAGS ?= -I $(KMOD_SOURCE_DIR) # Pass the global header to Kbuild exactly as done for user-space KMOD_CCFLAGS += -include $(REPO_HOME)/shared/tool/makefile/RT_global.h KMOD_OUTPUT_DIR ?= scratchpad/kmod + diff --git a/shared/tool/makefile/target_library_CLI.mk b/shared/tool/makefile/target_library_CLI.mk index 2d28b76..65b71ad 100644 --- a/shared/tool/makefile/target_library_CLI.mk +++ b/shared/tool/makefile/target_library_CLI.mk @@ -100,9 +100,15 @@ clean: # recipes +#$(OBJECT_DIR)/%.o: $(C_SOURCE_DIR)/%.c +# @mkdir -p $(OBJECT_DIR) +# $(C) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< + +# The local logic checks if NAMESPACE is defined, and if the target is a .lib.o file $(OBJECT_DIR)/%.o: $(C_SOURCE_DIR)/%.c @mkdir -p $(OBJECT_DIR) - $(C) $(CFLAGS) -o $@ -c $< + $(C) $(CFLAGS) $(if $(and $(NAMESPACE),$(findstring .lib,$@)),-D$(NAMESPACE)·$(basename $*),) -o $@ -c $< + $(MACHINE_DIR)/%: $(OBJECT_DIR)/%.CLI.o @mkdir -p $(MACHINE_DIR) -- 2.20.1