Updated build.py to handle embed src dir; moved embedded font to dir

This commit is contained in:
rxi
2016-09-29 20:04:04 +01:00
parent 0f97340b7d
commit f30e2e2c54
4 changed files with 40 additions and 1380 deletions

View File

@@ -1,17 +1,20 @@
#!/usr/bin/python2.7
import os, sys
import os, sys, shutil, re, textwrap
COMPILER = "i586-pc-msdosdjgpp-gcc"
SRC_DIR = "src"
BIN_DIR = "bin"
BIN_NAME = "love.exe"
COMPILER = "i586-pc-msdosdjgpp-gcc"
SRC_DIR = "src"
BIN_DIR = "bin"
BIN_NAME = "love.exe"
EMBED_DIR = "src/embed"
TEMPSRC_DIR = ".tempsrc"
CFLAGS = ["-O3", "-Wall", "-s", "-Wno-misleading-indentation"]
DLIBS = ["m"]
DEFINES = ["DMT_ABORT_NULL", "LUA_COMPAT_ALL"]
CFLAGS = [ "-O3", "-Wall", "-s", "-Wno-misleading-indentation" ]
DLIBS = [ "m" ]
DEFINES = [ "DMT_ABORT_NULL", "LUA_COMPAT_ALL" ]
INCLUDES = [ TEMPSRC_DIR ]
def strformat(fmt, var):
def fmt(fmt, var):
for k in var:
fmt = fmt.replace("{%s}" % str(k), var[k])
return fmt
@@ -21,20 +24,40 @@ def listdir(path):
return [os.path.join(dp, f) for dp, dn, fn in os.walk(path) for f in fn]
def make_c_include(name, data):
name = re.sub("[^a-z0-9]", "_", name.lower())
res = "static const char " + name + "[] = {"
for c in data:
res += str(ord(c)) + ", "
res = res.rstrip(", ") + "};"
return name, textwrap.fill(res, width=79)
def main():
os.chdir(sys.path[0])
if not os.path.exists(BIN_DIR):
os.makedirs(BIN_DIR)
if not os.path.exists(TEMPSRC_DIR):
os.makedirs(TEMPSRC_DIR)
embedded_files = listdir(EMBED_DIR)
for filename in embedded_files:
name = os.path.basename(filename)
name, text = make_c_include(name, open(filename).read())
open("%s/%s.h" % (TEMPSRC_DIR, name), "wb").write(text)
cfiles = filter(lambda x:x.endswith((".c", ".C")), listdir(SRC_DIR))
cmd = strformat(
"{compiler} {flags} {defines} -o {outfile} {srcfiles} {libs} {argv}",
cmd = fmt(
"{compiler} {flags} {defines} {includes} -o {outfile} {srcfiles} {libs} {argv}",
{
"compiler" : COMPILER,
"flags" : " ".join(CFLAGS),
"defines" : " ".join(map(lambda x: "-D " + x, DEFINES)),
"includes" : " ".join(map(lambda x: "-I " + x, INCLUDES)),
"outfile" : BIN_DIR + "/" + BIN_NAME,
"srcfiles" : " ".join(cfiles),
"libs" : " ".join(map(lambda x: "-l" + x, DLIBS)),
@@ -44,6 +67,10 @@ def main():
print "compiling..."
res = os.system(cmd)
print "deleting temporary files..."
if os.path.exists(TEMPSRC_DIR):
shutil.rmtree(TEMPSRC_DIR)
print "done" + (" with errors" if res else "")

BIN
src/embed/font.ttf Normal file

Binary file not shown.

View File

@@ -101,8 +101,8 @@ fail:
const char *font_initEmbedded(font_t *self, int ptsize) {
#include "font_embedded.c"
return initFont(self, font_data, 8);
#include "font_ttf.h"
return initFont(self, font_ttf, 8);
}

File diff suppressed because it is too large Load Diff