Improve build scripts
The build system hadn't been touched in a while, so it needed some cleaning up. I moved ocarina-specific files into the ocarina/ directory and use the ocarina/Sconscript to set up build commands. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
44
Sconstruct
|
@ -7,13 +7,10 @@ if config.DEBUG == True:
|
|||
FLAGS = ["-Wall", "-Werror", "-g", "-DDEBUG"]
|
||||
POSTFIX = "-debug"
|
||||
|
||||
env = Environment(CCFLAGS = FLAGS)
|
||||
config.env = Environment(CCFLAGS = FLAGS)
|
||||
if ARGUMENTS.get('VERBOSE') != "1":
|
||||
env.Append(CXXCOMSTR = "C++ $TARGET")
|
||||
env.Append(LINKCOMSTR = "Linking $TARGET")
|
||||
env.Append(CPPPATH = "include")
|
||||
|
||||
config.env = env
|
||||
config.env.Append(CXXCOMSTR = "C++ $TARGET")
|
||||
config.env.Append(LINKCOMSTR = "Linking $TARGET")
|
||||
|
||||
# Make sure these directories exist before doing anything
|
||||
if not os.path.exists("bin"):
|
||||
|
@ -21,30 +18,11 @@ if not os.path.exists("bin"):
|
|||
if not os.path.exists("lib"):
|
||||
os.mkdir("lib")
|
||||
|
||||
def directory(dirs):
|
||||
objs = []
|
||||
for dir in dirs:
|
||||
files = SConscript("%s/Sconscript" % dir)
|
||||
if files:
|
||||
objs.append(files)
|
||||
return objs
|
||||
config.include = SConscript("include/Sconscript")
|
||||
config.libsaria = SConscript("libsaria/Sconscript")
|
||||
|
||||
def app_directory(app, dirs):
|
||||
name = config.application
|
||||
config.application = app
|
||||
ret = directory(dirs)
|
||||
config.application = name
|
||||
return ret
|
||||
|
||||
def symlink(target, source, env):
|
||||
os.symlink(str(source[0]), str(target[0]))
|
||||
|
||||
SConscript(['include/Sconscript'])
|
||||
ocarina = env.Program('bin/ocarina-player', directory(["libsaria", "ocarina"]))
|
||||
oc_link = env.Command("ocarina.bin", "bin/ocarina-player", symlink)
|
||||
oc_other = app_directory("ocarina", ["scripts", "images", "xml"])
|
||||
Default([ocarina, oc_link, oc_other])
|
||||
env.Alias("ocarina", [ocarina, oc_link, oc_other])
|
||||
ocarina = SConscript("ocarina/Sconscript")
|
||||
Default(ocarina)
|
||||
|
||||
# Install bin/ and lib/
|
||||
def install_dirs(dirs):
|
||||
|
@ -53,13 +31,13 @@ def install_dirs(dirs):
|
|||
target = os.path.join(config.PREFIX, dir)
|
||||
for file in os.listdir(dir):
|
||||
source = os.path.join(dir, file)
|
||||
env.Install(target, source)
|
||||
config.env.Install(target, source)
|
||||
res += [target]
|
||||
return res
|
||||
|
||||
dirs = install_dirs(["bin/", "lib/"])
|
||||
env.Alias("install", dirs)
|
||||
env.Command("uninstall", None, Delete(FindInstalledFiles()))
|
||||
config.env.Alias("install", dirs)
|
||||
config.env.Command("uninstall", None, Delete(FindInstalledFiles()))
|
||||
|
||||
# Clean up the build directory
|
||||
clean = Clean(ocarina, ["include/version.h", "bin/", "lib/"])
|
||||
|
@ -87,4 +65,4 @@ def prepare_release(target, source, env):
|
|||
f.write(line)
|
||||
f.close()
|
||||
|
||||
env.Command("release", None, [prepare_release])
|
||||
config.env.Command("release", None, [prepare_release])
|
||||
|
|
11
config.py
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/python
|
||||
import os
|
||||
import os, shutil
|
||||
|
||||
MAJOR = 5
|
||||
MINOR = 11
|
||||
|
@ -21,8 +21,15 @@ PREFIX = "/usr"
|
|||
|
||||
|
||||
env = None
|
||||
application = "libsaria"
|
||||
include = []
|
||||
libsaria = []
|
||||
|
||||
def get_cpp_files():
|
||||
dirs = [x[0] for x in os.walk(".")]
|
||||
return [env.Glob(dir + "/*.cpp") for dir in dirs]
|
||||
|
||||
def copy(target, source, env):
|
||||
shutil.copy(str(source[0]), str(target[0]))
|
||||
|
||||
def symlink(target, source, env):
|
||||
os.symlink(str(source[0]), str(target[0]))
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
import shutil
|
||||
from config import *
|
||||
|
||||
lib = "../lib/" + application + "/%s"
|
||||
|
||||
def copy_image(target, source, env):
|
||||
dst = str(target[0].rfile())
|
||||
src = str(source[0].rfile())
|
||||
shutil.copy(src, dst)
|
||||
|
||||
images = []
|
||||
if application == "ocarina":
|
||||
images = ["ocarina.png", "ocarina512.png"]
|
||||
|
||||
files = []
|
||||
for image in images:
|
||||
dst = lib % image
|
||||
files.append(env.Command(dst, image, copy_image))
|
||||
|
||||
Return('files')
|
|
@ -10,3 +10,5 @@ for line in open("version.tmpl", "r"):
|
|||
line = line.replace("__VERSION__", str(version))
|
||||
f.write(line)
|
||||
f.close()
|
||||
|
||||
env.Append(CPPPATH = os.path.join(os.getcwd()))
|
||||
|
|
|
@ -1,8 +1,20 @@
|
|||
#!/usr/bin/python
|
||||
import config
|
||||
from config import *
|
||||
|
||||
config.env.ParseConfig('pkg-config --cflags --libs gtk+-2.0')
|
||||
config.env.ParseConfig('pkg-config --cflags --libs gmodule-export-2.0')
|
||||
env.ParseConfig('pkg-config --cflags --libs gtk+-2.0')
|
||||
env.ParseConfig('pkg-config --cflags --libs gmodule-export-2.0')
|
||||
|
||||
files = config.get_cpp_files()
|
||||
Return('files')
|
||||
files = get_cpp_files()
|
||||
|
||||
extra_files = [
|
||||
("../bin/ocarina-player", "../ocarina.bin", symlink),
|
||||
("ocarina.xml", "../lib/ocarina/ocarina.xml", copy),
|
||||
("images/ocarina.png", "../lib/ocarina/ocarina.png", copy),
|
||||
]
|
||||
|
||||
build = [env.Program("../bin/ocarina-player", libsaria + files)]
|
||||
for (src, dst, func) in extra_files:
|
||||
build.append(env.Command(dst, src, func))
|
||||
|
||||
env.Alias("ocarina", build)
|
||||
Return('build')
|
||||
|
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 988 B After Width: | Height: | Size: 988 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
@ -1,17 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
import shutil
|
||||
from config import *
|
||||
|
||||
lib = "../lib/" + application + "/%s"
|
||||
|
||||
def copy_xml(target, source, env):
|
||||
dst = str(target[0].rfile())
|
||||
src = str(source[0].rfile())
|
||||
shutil.copy(src, dst)
|
||||
|
||||
files = []
|
||||
if application == "ocarina":
|
||||
dst = lib % "ocarina.xml"
|
||||
files.append(AlwaysBuild(env.Command(dst, "ocarina.xml", copy_xml)))
|
||||
|
||||
Return('files')
|