From bde6718b83d45f5e8effc4ac466e3ebc72b3d7f7 Mon Sep 17 00:00:00 2001 From: C0dex73 Date: Sun, 9 Nov 2025 19:29:01 +0100 Subject: [PATCH 1/3] 1.2 --- Makefile | 13 +++++++------ src/app/main.c | 4 +++- src/hello/hello.c | 7 +++++++ src/hello/hello.h | 10 ++++++++++ src/hello/lnk.flags | 1 + vars.mk | 2 +- 6 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 src/hello/hello.c create mode 100644 src/hello/hello.h create mode 100644 src/hello/lnk.flags diff --git a/Makefile b/Makefile index 6fe9406..f39fb35 100644 --- a/Makefile +++ b/Makefile @@ -47,37 +47,38 @@ $(call format_lib,%).$(SLFEXT): $(call format_lib,%) $(foreach exe,$(EXECS),$(BINDIR)/$(exe)): $$(call libexec-to-obj,$$@,%$(DOTEXE)) @echo "building $@ dependencies : $(EDEP)" $(if $(EDEP),$(MAKE) $(EDEP)) + @echo "$(patsubst $(PREFLAG)%,%,$(filter $(PREFLAG)%, $(shell echo $$(shell cat $(dir $<)/$(LINKING_STEP_FLAG_ID).flags 2>/dev/null ||:))))" @echo "linking $^ along $(EDEP) into $@" - $(CC) -o $@ $^ $(call link-deps,$(EDEP)) $(call NFLAGS, $(LINKING_STEP_FLAG_ID)) $(LFLAGS) + $(CC) -o $@ $^ $(call link-deps,$(EDEP)) $(call NFLAGS,$(LINKING_STEP_FLAG_ID)) $(LFLAGS) #^ libraries linking $(foreach lib,$(LIBS),$(BINDIR)/$(lib)): $$(call libexec-to-obj,$$@,$(call format_lib,%)) @echo "building $@ dependencies : $(LDEP)" $(if $(LDEP),$(MAKE) $(LDEP),@echo no dep to build) @echo "linking $^ along $(LDEP) into $@" - $(CC) -shared -o $@ $^ $(call link-deps,$(LDEP)) $(call NFLAGS, $(LINKING_STEP_FLAG_ID)) $(LFLAGS) $(CREATEIMPLIB) + $(CC) -shared -o $@ $^ $(call link-deps,$(LDEP)) $(call NFLAGS,$(LINKING_STEP_FLAG_ID)) $(LFLAGS) $(CREATEIMPLIB) #^ object files assembling %.$(OBJEXT): %.$(ASMEXT) @echo "Assembling $< into $@" - $(CC) -c -o $@ $< $(call NFLAGS, $(ASSEMBLING_STEP_FLAG_ID)) $(ASMFLAGS) + $(CC) -c -o $@ $< $(call NFLAGS,$(ASSEMBLING_STEP_FLAG_ID)) $(ASMFLAGS) #assembly files compiling %.$(ASMEXT): %.$(PPFEXT) @echo "Compiling $< into $@" - $(CC) -S -o $@ $< $(call NFLAGS, $(COMPILING_STEP_FLAG_ID)) $(CMPFLAGS) + $(CC) -S -o $@ $< $(call NFLAGS,$(COMPILING_STEP_FLAG_ID)) $(CMPFLAGS) #preprocessed file preprocessing :) %.$(PPFEXT): %.$(DEPEXT) $$(call getppfdep,$$@) # getppfdep usefull when dep file already exists to determine wether to remake it or not @echo "deps : $^ $(shell cat $<)" @echo "Pre-processing $(shell cat $<) into $@" - $(CC) -E -o $@ $(firstword $(shell cat $<)) $(call NFLAGS, $(PREPROCESSING_STEP_FLAG_ID)) $(PPFLAGS) -D$(shell echo '$(notdir $(patsubst %/,%,$(dir $*)))_EXPORT' | tr '[:lower:]' '[:upper:]') + $(CC) -E -o $@ $(firstword $(shell cat $<)) $(call NFLAGS,$(PREPROCESSING_STEP_FLAG_ID)) $(PPFLAGS) -D$(shell echo '$(notdir $(patsubst %/,%,$(dir $*)))_EXPORT' | tr '[:lower:]' '[:upper:]') #dependency file creation %.$(DEPEXT): %.$(SRCEXT) @echo "Fetching dependencies for $<" - $(CC) -MM $< $(call NFLAGS, $(DEPENDENCY_STEP_FLAG_ID)) $(PPFLAGS) | sed -z 's/ \\\n//g' | cut -f 2 -d ':' | cut -c2- > $@ + $(CC) -MM $< $(call NFLAGS,$(DEPENDENCY_STEP_FLAG_ID)) $(PPFLAGS) | sed -z 's/ \\\n//g' | cut -f 2 -d ':' | cut -c2- > $@ #catch-all rule for source and header files %.$(SRCEXT) %.$(HDREXT): ; diff --git a/src/app/main.c b/src/app/main.c index af6388e..ee0df14 100644 --- a/src/app/main.c +++ b/src/app/main.c @@ -1,6 +1,8 @@ #include +#include int main(){ - printf("Hello World !\n"); + printf("Hello World !\r\n"); + sayHello(); return 0; } diff --git a/src/hello/hello.c b/src/hello/hello.c new file mode 100644 index 0000000..156cdd4 --- /dev/null +++ b/src/hello/hello.c @@ -0,0 +1,7 @@ +#include "hello.h" +#include + +HELLOAPI int sayHello(){ + printf("Hello From Library !\r\n"); + return 0; +} diff --git a/src/hello/hello.h b/src/hello/hello.h new file mode 100644 index 0000000..135d4e9 --- /dev/null +++ b/src/hello/hello.h @@ -0,0 +1,10 @@ +#ifndef __hello_h_ +#define __hello_h_ + +#ifndef HELLOAPI +# define HELLOAPI extern +#endif //HELLOAPI + +HELLOAPI int sayHello(); + +#endif //__hello_h_ diff --git a/src/hello/lnk.flags b/src/hello/lnk.flags new file mode 100644 index 0000000..ab09ebf --- /dev/null +++ b/src/hello/lnk.flags @@ -0,0 +1 @@ +W_-mconsole \ No newline at end of file diff --git a/vars.mk b/vars.mk index 7119309..b9c5ecb 100644 --- a/vars.mk +++ b/vars.mk @@ -98,7 +98,7 @@ ASSEMBLING_STEP_FLAG_ID:=asm COMPILING_STEP_FLAG_ID:=cpl PREPROCESSING_STEP_FLAG_ID:=pp DEPENDENCY_STEP_FLAG_ID:=dep -NFLAGS_lnk=$(patsubst $(PREFLAG)%,%,$(filter $(PREFLAG)%,$(shell echo $$(cat $(dir $^)/$(1).flags 2>/dev/null ||:)))) +NFLAGS=$(patsubst $(PREFLAG)%,%,$(filter $(PREFLAG)%,$(shell echo $$(cat $(dir $<)/$(1).flags 2>/dev/null ||:)))) Vdebug: @echo No debug recipe in vars.mk From ceec97c902373c8570df704e35d3ce3932e3af56 Mon Sep 17 00:00:00 2001 From: C0dex73 Date: Sun, 9 Nov 2025 19:36:17 +0100 Subject: [PATCH 2/3] remove useless command in build workflow --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4200373..5e4ea9b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,7 +47,6 @@ jobs: - name: Build shell: msys2 {0} run: | - which gcc make build DEPLOY=True - name: Compress build into zip archive From 045d5ea0eac679383cac8007f828242b4d45325f Mon Sep 17 00:00:00 2001 From: C0dex73 Date: Sun, 9 Nov 2025 20:07:53 +0100 Subject: [PATCH 3/3] dll-capable headers --- scripts/createnode.sh | 8 +++++--- src/app/main.c | 5 ++--- src/hello/hello.h | 10 ---------- src/hello/lnk.flags | 1 - src/hello/{hello.c => sayhello.c} | 4 ++-- src/hello/sayhello.h | 29 +++++++++++++++++++++++++++++ templates/lib.h | 10 ---------- templates/{lib.c => sayhello.c} | 4 ++-- templates/sayhello.h | 29 +++++++++++++++++++++++++++++ 9 files changed, 69 insertions(+), 31 deletions(-) delete mode 100644 src/hello/hello.h delete mode 100644 src/hello/lnk.flags rename src/hello/{hello.c => sayhello.c} (50%) create mode 100644 src/hello/sayhello.h delete mode 100644 templates/lib.h rename templates/{lib.c => sayhello.c} (60%) create mode 100644 templates/sayhello.h diff --git a/scripts/createnode.sh b/scripts/createnode.sh index c363d73..f7a2558 100755 --- a/scripts/createnode.sh +++ b/scripts/createnode.sh @@ -22,10 +22,12 @@ case $1 in cp ./templates/main.c ./$2/ ;; "-L") - echo "creating library node $2..." + echo "creating library node $2... s/\$1/$(basename ${2^^})/g ./$2/sayhello.c" mkdir -p $2 - cp ./templates/lib.c ./$2/ - cp ./templates/lib.h ./$2/ + cp ./templates/sayhello.c ./$2/ + cp ./templates/sayhello.h ./$2/ + sed -i s/\$1/$(basename ${2^^})/g ./$2/sayhello.h + sed -i s/\$1/$(basename ${2^^})/g ./$2/sayhello.c ;; esac echo "Done" diff --git a/src/app/main.c b/src/app/main.c index ee0df14..cd8c1b4 100644 --- a/src/app/main.c +++ b/src/app/main.c @@ -1,8 +1,7 @@ #include -#include +#include int main(){ printf("Hello World !\r\n"); - sayHello(); - return 0; + return sayHello(); } diff --git a/src/hello/hello.h b/src/hello/hello.h deleted file mode 100644 index 135d4e9..0000000 --- a/src/hello/hello.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __hello_h_ -#define __hello_h_ - -#ifndef HELLOAPI -# define HELLOAPI extern -#endif //HELLOAPI - -HELLOAPI int sayHello(); - -#endif //__hello_h_ diff --git a/src/hello/lnk.flags b/src/hello/lnk.flags deleted file mode 100644 index ab09ebf..0000000 --- a/src/hello/lnk.flags +++ /dev/null @@ -1 +0,0 @@ -W_-mconsole \ No newline at end of file diff --git a/src/hello/hello.c b/src/hello/sayhello.c similarity index 50% rename from src/hello/hello.c rename to src/hello/sayhello.c index 156cdd4..190a551 100644 --- a/src/hello/hello.c +++ b/src/hello/sayhello.c @@ -1,7 +1,7 @@ -#include "hello.h" +#include "sayhello.h" #include HELLOAPI int sayHello(){ - printf("Hello From Library !\r\n"); + printf("Hello From Library !"); return 0; } diff --git a/src/hello/sayhello.h b/src/hello/sayhello.h new file mode 100644 index 0000000..2531b37 --- /dev/null +++ b/src/hello/sayhello.h @@ -0,0 +1,29 @@ +#ifndef __HELLO_sayhello_h_ +#define __HELLO_sayhello_h_ + +//shared library symbols +#ifndef HELLOAPI +# if defined(_WIN32) || defined(__CYGWIN__) +# if defined(HELLO_EXPORT) +# if defined(__GNUC__) +# define HELLOAPI __attribute__ ((dllexport)) extern +# else +# define HELLOAPI __declspec(dllexport) extern +# endif +# else +# if defined(__GNUC__) +# define HELLOAPI __attribute__ ((dllimport)) extern +# else +# define HELLOAPI __declspec(dllimport) extern +# endif +# endif +# elif defined(__GNUC__) && defined(HELLO_EXPORT) +# define HELLOAPI __attribute__ ((visibility ("default"))) extern +# else +# define HELLOAPI extern +# endif +#endif + +HELLOAPI int sayHello(); + +#endif //__HELLO_sayhello_h_ \ No newline at end of file diff --git a/templates/lib.h b/templates/lib.h deleted file mode 100644 index 4158c35..0000000 --- a/templates/lib.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __lib_h_ -#define __lib_h_ - -#ifndef LIBAPI -# define LIBAPI extern -#endif //LIBAPI - -LIBAPI int libfun(); - -#endif //__lib_h_ diff --git a/templates/lib.c b/templates/sayhello.c similarity index 60% rename from templates/lib.c rename to templates/sayhello.c index d028761..c53381d 100644 --- a/templates/lib.c +++ b/templates/sayhello.c @@ -1,7 +1,7 @@ -#include "lib.h" +#include "sayhello.h" #include -int libfun(){ +$1API int sayHello(){ printf("Hello From Library !"); return 0; } diff --git a/templates/sayhello.h b/templates/sayhello.h new file mode 100644 index 0000000..88fdfd5 --- /dev/null +++ b/templates/sayhello.h @@ -0,0 +1,29 @@ +#ifndef __$1_sayhello_h_ +#define __$1_sayhello_h_ + +//shared library symbols +#ifndef $1API +# if defined(_WIN32) || defined(__CYGWIN__) +# if defined($1_EXPORT) +# if defined(__GNUC__) +# define $1API __attribute__ ((dllexport)) extern +# else +# define $1API __declspec(dllexport) extern +# endif +# else +# if defined(__GNUC__) +# define $1API __attribute__ ((dllimport)) extern +# else +# define $1API __declspec(dllimport) extern +# endif +# endif +# elif defined(__GNUC__) && defined($1_EXPORT) +# define $1API __attribute__ ((visibility ("default"))) extern +# else +# define $1API extern +# endif +#endif + +$1API int sayHello(); + +#endif //__$1_sayhello_h_ \ No newline at end of file