Work on build system
This commit is contained in:
parent
e35dea7bce
commit
979e483f1f
41
Makefile
41
Makefile
@ -1,11 +1,46 @@
|
|||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-g
|
CFLAGS=-g -Isrc/lib/lua -Iinclude
|
||||||
SRCDIR=src/c/
|
SRCDIR=src/c
|
||||||
|
CORELUA = src/lua/core
|
||||||
|
LIBS=-llua
|
||||||
|
|
||||||
OBJ=$(SRCDIR)main.o
|
GENERATED=include/luares.h src/c/gen/luares.c
|
||||||
|
LUAPARAMS = $(CORELUA) include/luares.h src/c/gen/luares.c lua_
|
||||||
|
LFLAGS=$(LIBS)
|
||||||
|
OBJ=\
|
||||||
|
$(SRCDIR)/main.o \
|
||||||
|
$(SRCDIR)/gen/luares.o
|
||||||
|
|
||||||
|
BUILDDIRECTORIES = $(patsubst $(SOURCE)%, $(BUILD)%, $(SRCDIRECTORIES))
|
||||||
|
#Rules
|
||||||
|
#Build
|
||||||
|
all: smallclean $(BUILDDIRECTORIES) luaresources lupi
|
||||||
|
|
||||||
|
smallclean:
|
||||||
|
find . -name '*~' -type f -exec rm {} \;
|
||||||
|
|
||||||
|
build: clean all
|
||||||
|
|
||||||
lupi: $(OBJ)
|
lupi: $(OBJ)
|
||||||
$(CC) $(LFLAGS) $^ -o $@
|
$(CC) $(LFLAGS) $^ -o $@
|
||||||
|
|
||||||
$(OBJ): %.o: %.c
|
$(OBJ): %.o: %.c
|
||||||
$(CC) -c $(CFLAGS) $< -o $@
|
$(CC) -c $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
#Resources
|
||||||
|
luaresources: cleanresourcues
|
||||||
|
scripts/txt2c $(LUAPARAMS)
|
||||||
|
|
||||||
|
$(BUILDDIRECTORIES):
|
||||||
|
mkdir $@
|
||||||
|
|
||||||
|
#Clean rules
|
||||||
|
cleanresourcues:
|
||||||
|
-rm -f $(GENERATED)
|
||||||
|
|
||||||
|
mkdir -p src/c/gen/
|
||||||
|
touch src/c/gen/luares.c
|
||||||
|
touch include/luares.h
|
||||||
|
|
||||||
|
clean : cleanresourcues
|
||||||
|
-rm -f $(OBJ)
|
0
include/luares.h
Normal file
0
include/luares.h
Normal file
0
include/lupi.h
Normal file
0
include/lupi.h
Normal file
40
scripts/txt2c
Executable file
40
scripts/txt2c
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# $1 scripts folder
|
||||||
|
# $2 file to generate OUTPUTH C
|
||||||
|
# $3 file to generate OUTPUTH H
|
||||||
|
# $4 prefix
|
||||||
|
|
||||||
|
LUAFILES="$1/*"
|
||||||
|
OUTPUTH="$2"
|
||||||
|
OUTPUTC="$3"
|
||||||
|
PREFIX="$4"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
outname="$(basename "$OUTPUTH")"
|
||||||
|
outname="${outname%.*}"
|
||||||
|
guard=$(echo "$outname" | tr '[:lower:]' '[:upper:]')
|
||||||
|
guard="$guard""_H"
|
||||||
|
|
||||||
|
printf "#ifndef %s\n" "$guard" >> "$OUTPUTH"
|
||||||
|
printf "#define %s\n" "$guard" >> "$OUTPUTH"
|
||||||
|
|
||||||
|
for file in $LUAFILES
|
||||||
|
do
|
||||||
|
|
||||||
|
filename="$(basename "$file")"
|
||||||
|
filename="${filename%.*}"
|
||||||
|
|
||||||
|
echo "extern char $PREFIX$filename[];" >> "$OUTPUTH"
|
||||||
|
|
||||||
|
|
||||||
|
echo "char $PREFIX$filename[] = {" >> "$OUTPUTC"
|
||||||
|
echo " " $(xxd -i < "$file") ",0x00" >> "$OUTPUTC"
|
||||||
|
echo "};" >> "$OUTPUTC"
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "#endif" >> "$OUTPUTH"
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
@ -1,5 +1,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "luares.h"
|
||||||
|
|
||||||
int main (void) {
|
int main (void) {
|
||||||
puts("LuPI 2");
|
puts("LuPI 2\n");
|
||||||
|
puts(lua_init);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
1
src/lua/core/init.lua
Normal file
1
src/lua/core/init.lua
Normal file
@ -0,0 +1 @@
|
|||||||
|
print("HeelloLua")
|
Loading…
Reference in New Issue
Block a user