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 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/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 af6388e..cd8c1b4 100644 --- a/src/app/main.c +++ b/src/app/main.c @@ -1,6 +1,7 @@ #include +#include int main(){ - printf("Hello World !\n"); - return 0; + printf("Hello World !\r\n"); + return sayHello(); } diff --git a/src/hello/sayhello.c b/src/hello/sayhello.c new file mode 100644 index 0000000..190a551 --- /dev/null +++ b/src/hello/sayhello.c @@ -0,0 +1,7 @@ +#include "sayhello.h" +#include + +HELLOAPI int sayHello(){ + 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 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