added gdcc example and makefile support
This commit is contained in:
parent
5eff934ef0
commit
36e07578a7
62
Makefile
62
Makefile
|
@ -1,39 +1,59 @@
|
|||
CC=
|
||||
MKDIR=
|
||||
RM=
|
||||
LD=
|
||||
MKDIR=mkdir -p
|
||||
RM=rm
|
||||
PCFLAGS=
|
||||
PLFLAGS=
|
||||
LIBNAME=
|
||||
OUTDIR=bin
|
||||
SRCDIR=src
|
||||
LFLAGS=-shared -g -ggdb
|
||||
CFLAGS=--std=c99 -g -ggdb -O2 -Wall
|
||||
LFLAGS=
|
||||
CFLAGS=
|
||||
RMEXTRA=
|
||||
GDCCBUILD=OFF
|
||||
EXAMPLEO=
|
||||
EXAMPLEC=
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
CC+=mingw32-gcc
|
||||
MKDIR+=mkdir -p
|
||||
RM+=rm
|
||||
PLFLAGS+=-Wl,--out-implib,bin/libLoveToken.a
|
||||
LIBNAME+=$(OUTDIR)/LoveToken.dll
|
||||
RMEXTRA+=bin/libLoveToken.a
|
||||
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
|
||||
ifeq ($(shell uname -s), Linux)
|
||||
CC+=gcc
|
||||
MKDIR+=mkdir -p
|
||||
RM+=rm
|
||||
PCFLAGS+=-fPIC
|
||||
LIBNAME+=$(OUTDIR)/LoveToken.so
|
||||
EXAMPLEC+=examples/main.c
|
||||
PCFLAGS+=--std=c99 -g -ggdb -O2 -Wall -c -I$(SRCDIR)
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
CC+=mingw32-gcc
|
||||
LD+=mingw32-gcc
|
||||
PLFLAGS+=-shared -g -ggdb
|
||||
PLFLAGS2+=-Wl,--out-implib,bin/libLoveToken.a -liconv
|
||||
LIBNAME+=$(OUTDIR)/LoveToken.dll
|
||||
RMEXTRA+=bin/libLoveToken.a
|
||||
else
|
||||
ifeq ($(shell uname -s), Linux)
|
||||
CC+=gcc
|
||||
LD+=gcc
|
||||
PCFLAGS+=-fPIC
|
||||
PLFLAGS2+=-liconv
|
||||
LIBNAME+=$(OUTDIR)/LoveToken.so
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
all:
|
||||
$(MKDIR) $(OUTDIR)
|
||||
$(CC) $(CFLAGS) $(PCFLAGS) -c -o $(OUTDIR)/lt.o $(SRCDIR)/lt.c
|
||||
$(CC) $(LFLAGS) -o $(LIBNAME) $(OUTDIR)/lt.o $(PLFLAGS) -liconv
|
||||
$(CC) $(CFLAGS) $(PCFLAGS) -o $(OUTDIR)/lt.o $(SRCDIR)/lt.c
|
||||
$(LD) $(LFLAGS) $(PLFLAGS) -o $(LIBNAME) $(OUTDIR)/lt.o $(PLFLAGS2)
|
||||
|
||||
clean:
|
||||
$(RM) $(LIBNAME) $(OUTDIR)/lt.o $(RMEXTRA)
|
||||
|
||||
example:
|
||||
$(CC) $(CFLAGS) -I$(SRCDIR) -L$(OUTDIR) -o $(OUTDIR)/example examples/main.c -lLoveToken
|
||||
example: all
|
||||
$(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