Archived
1
0

added gdcc example and makefile support

This commit is contained in:
Marrub 2015-06-11 10:32:16 -04:00
parent 5eff934ef0
commit 36e07578a7
3 changed files with 102 additions and 21 deletions

View File

@ -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+=mingw32-gcc CC+=gdcc-cc
MKDIR+=mkdir -p LD+=gdcc-ld
RM+=rm MKDIR+=mkdir
PLFLAGS+=-Wl,--out-implib,bin/libLoveToken.a LIBNAME+=$(OUTDIR)/LoveToken.bin
LIBNAME+=$(OUTDIR)/LoveToken.dll PCFLAGS+=--bc-target=ZDoom -i$(SRCDIR)
RMEXTRA+=bin/libLoveToken.a 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 else
ifeq ($(shell uname -s), Linux) EXAMPLEC+=examples/main.c
CC+=gcc PCFLAGS+=--std=c99 -g -ggdb -O2 -Wall -c -I$(SRCDIR)
MKDIR+=mkdir -p
RM+=rm ifeq ($(OS),Windows_NT)
PCFLAGS+=-fPIC CC+=mingw32-gcc
LIBNAME+=$(OUTDIR)/LoveToken.so 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
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
View 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
View File

@ -0,0 +1,3 @@
[enu default]
EXAMPLESCRIPT="The quick brown_fox jumps over the !Lazy_Dog.;\n 5 ** 5 ** 5 + 3 []";