added gdcc example and makefile support
This commit is contained in:
parent
5eff934ef0
commit
36e07578a7
50
Makefile
50
Makefile
|
@ -1,39 +1,59 @@
|
||||||
CC=
|
CC=
|
||||||
MKDIR=
|
LD=
|
||||||
RM=
|
MKDIR=mkdir -p
|
||||||
|
RM=rm
|
||||||
PCFLAGS=
|
PCFLAGS=
|
||||||
PLFLAGS=
|
PLFLAGS=
|
||||||
LIBNAME=
|
LIBNAME=
|
||||||
OUTDIR=bin
|
OUTDIR=bin
|
||||||
SRCDIR=src
|
SRCDIR=src
|
||||||
LFLAGS=-shared -g -ggdb
|
LFLAGS=
|
||||||
CFLAGS=--std=c99 -g -ggdb -O2 -Wall
|
CFLAGS=
|
||||||
RMEXTRA=
|
RMEXTRA=
|
||||||
|
GDCCBUILD=OFF
|
||||||
|
EXAMPLEO=
|
||||||
|
EXAMPLEC=
|
||||||
|
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(GDCCBUILD),ON)
|
||||||
|
CC+=gdcc-cc
|
||||||
|
LD+=gdcc-ld
|
||||||
|
MKDIR+=mkdir
|
||||||
|
LIBNAME+=$(OUTDIR)/LoveToken.bin
|
||||||
|
PCFLAGS+=--bc-target=ZDoom -i$(SRCDIR)
|
||||||
|
LFLAGS+=--bc-target=ZDoom
|
||||||
|
EXAMPLEC+=examples/gdcc.c
|
||||||
|
# These are completely arbitrary.
|
||||||
|
EXAMPLEO+=$(OUTDIR)/libc.ir $(OUTDIR)/libGDCC.ir $(OUTDIR)/libGDCC-c.ir $(OUTDIR)/libGDCC-ZDACS-asm.ir
|
||||||
|
else
|
||||||
|
EXAMPLEC+=examples/main.c
|
||||||
|
PCFLAGS+=--std=c99 -g -ggdb -O2 -Wall -c -I$(SRCDIR)
|
||||||
|
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
CC+=mingw32-gcc
|
CC+=mingw32-gcc
|
||||||
MKDIR+=mkdir -p
|
LD+=mingw32-gcc
|
||||||
RM+=rm
|
PLFLAGS+=-shared -g -ggdb
|
||||||
PLFLAGS+=-Wl,--out-implib,bin/libLoveToken.a
|
PLFLAGS2+=-Wl,--out-implib,bin/libLoveToken.a -liconv
|
||||||
LIBNAME+=$(OUTDIR)/LoveToken.dll
|
LIBNAME+=$(OUTDIR)/LoveToken.dll
|
||||||
RMEXTRA+=bin/libLoveToken.a
|
RMEXTRA+=bin/libLoveToken.a
|
||||||
else
|
else
|
||||||
ifeq ($(shell uname -s), Linux)
|
ifeq ($(shell uname -s), Linux)
|
||||||
CC+=gcc
|
CC+=gcc
|
||||||
MKDIR+=mkdir -p
|
LD+=gcc
|
||||||
RM+=rm
|
|
||||||
PCFLAGS+=-fPIC
|
PCFLAGS+=-fPIC
|
||||||
|
PLFLAGS2+=-liconv
|
||||||
LIBNAME+=$(OUTDIR)/LoveToken.so
|
LIBNAME+=$(OUTDIR)/LoveToken.so
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(MKDIR) $(OUTDIR)
|
$(MKDIR) $(OUTDIR)
|
||||||
$(CC) $(CFLAGS) $(PCFLAGS) -c -o $(OUTDIR)/lt.o $(SRCDIR)/lt.c
|
$(CC) $(CFLAGS) $(PCFLAGS) -o $(OUTDIR)/lt.o $(SRCDIR)/lt.c
|
||||||
$(CC) $(LFLAGS) -o $(LIBNAME) $(OUTDIR)/lt.o $(PLFLAGS) -liconv
|
$(LD) $(LFLAGS) $(PLFLAGS) -o $(LIBNAME) $(OUTDIR)/lt.o $(PLFLAGS2)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(LIBNAME) $(OUTDIR)/lt.o $(RMEXTRA)
|
$(RM) $(LIBNAME) $(OUTDIR)/lt.o $(RMEXTRA)
|
||||||
|
|
||||||
example:
|
example: all
|
||||||
$(CC) $(CFLAGS) -I$(SRCDIR) -L$(OUTDIR) -o $(OUTDIR)/example examples/main.c -lLoveToken
|
$(CC) $(CFLAGS) $(PCFLAGS) -o $(OUTDIR)/example.o $(EXAMPLEC)
|
||||||
|
$(LD) $(LFLAGS) -o $(OUTDIR)/example $(OUTDIR)/example.o $(EXAMPLEO) $(OUTDIR)/lt.o $(PLFLAGS2)
|
||||||
|
|
58
examples/gdcc.c
Normal file
58
examples/gdcc.c
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
// This file is placed under public domain.
|
||||||
|
#include "lt.h"
|
||||||
|
#include <ACS_Zandronum.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define Print(...) \
|
||||||
|
( \
|
||||||
|
ACS_BeginPrint(), \
|
||||||
|
__nprintf(__VA_ARGS__), \
|
||||||
|
ACS_EndPrint() \
|
||||||
|
)
|
||||||
|
#define Log(...) \
|
||||||
|
( \
|
||||||
|
ACS_BeginLog(), \
|
||||||
|
__nprintf(__VA_ARGS__), \
|
||||||
|
ACS_EndLog() \
|
||||||
|
)
|
||||||
|
|
||||||
|
[[extern("ACS"), call("ScriptS"), script("Enter")]]
|
||||||
|
void ExampleRunScript()
|
||||||
|
{
|
||||||
|
LT_Config initCfg = { 0 };
|
||||||
|
LT_Init(initCfg);
|
||||||
|
|
||||||
|
LT_OpenFile(s"EXAMPLESCRIPT");
|
||||||
|
|
||||||
|
LT_Token tk = LT_GetToken();
|
||||||
|
|
||||||
|
ACS_Delay(15);
|
||||||
|
|
||||||
|
Print("Printing out the parsed tokens to the console in 3...");
|
||||||
|
ACS_Delay(35);
|
||||||
|
Print("2...");
|
||||||
|
ACS_Delay(35);
|
||||||
|
Print("1...");
|
||||||
|
ACS_Delay(35);
|
||||||
|
Print("Showtime!");
|
||||||
|
ACS_Delay(35);
|
||||||
|
|
||||||
|
while (tk.token != LT_TkNames[TOK_EOF])
|
||||||
|
{
|
||||||
|
if (tk.string != NULL)
|
||||||
|
{
|
||||||
|
Log("%s - %s", tk.token, tk.string);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log(tk.token);
|
||||||
|
}
|
||||||
|
|
||||||
|
tk = LT_GetToken();
|
||||||
|
|
||||||
|
ACS_Delay(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
LT_Quit();
|
||||||
|
LT_CloseFile();
|
||||||
|
}
|
3
examples/language.txt
Normal file
3
examples/language.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[enu default]
|
||||||
|
|
||||||
|
EXAMPLESCRIPT="The quick brown_fox jumps over the !Lazy_Dog.;\n 5 ** 5 ** 5 + 3 []";
|
Reference in New Issue
Block a user