Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ jobs:
- name: Build
shell: msys2 {0}
run: |
which gcc
make build DEPLOY=True

- name: Compress build into zip archive
Expand Down
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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): ;
Expand Down
8 changes: 5 additions & 3 deletions scripts/createnode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 3 additions & 2 deletions src/app/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <sayhello.h>

int main(){
printf("Hello World !\n");
return 0;
printf("Hello World !\r\n");
return sayHello();
}
7 changes: 7 additions & 0 deletions src/hello/sayhello.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "sayhello.h"
#include <stdio.h>

HELLOAPI int sayHello(){
printf("Hello From Library !");
return 0;
}
29 changes: 29 additions & 0 deletions src/hello/sayhello.h
Original file line number Diff line number Diff line change
@@ -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_
10 changes: 0 additions & 10 deletions templates/lib.h

This file was deleted.

4 changes: 2 additions & 2 deletions templates/lib.c → templates/sayhello.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "lib.h"
#include "sayhello.h"
#include <stdio.h>

int libfun(){
$1API int sayHello(){
printf("Hello From Library !");
return 0;
}
29 changes: 29 additions & 0 deletions templates/sayhello.h
Original file line number Diff line number Diff line change
@@ -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_
2 changes: 1 addition & 1 deletion vars.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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