Set up scons build system

- In its current state, it produces a valid, launchable Mac application package, though one that's not redistributable (relies on system-installed libraries)
- Partial support is already in-place for a Windows build
This commit is contained in:
2015-09-11 19:15:56 -04:00
parent a0e2cb6e8d
commit 832b8b5f91
15 changed files with 362 additions and 8 deletions

4
.gitignore vendored
View File

@@ -49,6 +49,10 @@ src/*.vsproj/Debug/
src/*.vsproj/Release/
src/*.vsproj/*/ipch/
# SCons junk files
.sconsign.dblite
build/
# Generated NSIS script file
src/*.vsproj/Installer/data.nsi

117
SConstruct Normal file
View File

@@ -0,0 +1,117 @@
import os.path as path
platform = ARGUMENTS.get('OS', Platform())
if str(platform) not in ("darwin", "windows"):
print "Sorry, your platform is not supported."
print "Platform is:", platform
print "Specify OS=<your-platform> if you believe this is incorrect."
print "(Supported platforms are: darwin, windows)"
Exit(1)
env = Environment()
env.VariantDir('#build/obj', 'src')
env.VariantDir('#build/obj/test', 'test')
env.Append(CONFIGUREDIR='#build/conf', CONFIGURELOG='#build/conf/config.log')
# We don't run any configuration tests yet, but we probably will eventually
if str(platform) == "darwin":
env.Append(CPPFLAGS="-std=c++11 -stdlib=libc++")
env["CC"] = 'clang'
env["CXX"] = 'clang++'
env.Append(BUILDERS={
'Nib': Builder(
action = "ibtool --compile $TARGET $SOURCE",
suffix = ".nib",
src_suffix = ".xib"
)
})
def build_app_package(env, source, build_dir, info):
source_name = source[0].name
pkg_path = path.join(build_dir, "%s.app/Contents/" % source_name)
nib = env.Nib(info['nib'].replace('rsrc', 'build/obj'), info['nib'])
icons = [path.join("#rsrc/icons/mac/", x + ".icns") for x in Split(info['icons'])]
env.Install(path.join(pkg_path, "MacOS"), source)
env.Install(path.join(pkg_path, "Resources"), icons + nib)
env.InstallAs(path.join(pkg_path, "Info.plist"), info['plist'])
env.Command(path.join(pkg_path, 'PkgInfo'), '', action="echo 'APPL%s' > $TARGET" % info['creator'])
elif str(platform) == "windows":
def build_app_package(env, source, build_dir, info):
env.Install("#build/Blades of Exile/", source)
env.AddMethod(build_app_package, "Package")
env.Append(CPPDEFINES="TIXML_USE_TICPP")
# Include directories
env.Append(CPPPATH=Split("""
#src/
#src/classes/
#src/tools/
#src/tools/gzstream/
#src/tools/resmgr/
#src/dialogxml/
#src/dialogxml/xml-parser/
"""))
# Linked libraries
bundled_libs = Split("""
boost_system
boost_filesystem
boost_thread
sfml-audio
sfml-graphics
sfml-system
sfml-window
""")
env.Append(LIBS = bundled_libs + ["z"])
if str(platform) == "darwin":
env.Append(LIBS=Split("""
objc
c++
"""))
env.Append(FRAMEWORKS=Split("""
OpenGL
Cocoa
"""))
else:
env.Append(LIBS=Split("""
GL
"""))
Export("env platform")
# Gather common sources
common_classes, party_classes = SConscript("src/classes/SConscript")
tools = SConscript("src/tools/SConscript")
dlog_util = SConscript("src/dialogxml/SConscript")
common_sources = common_classes + dlog_util + tools
install_dir = "#build/Blades of Exile"
Export("install_dir party_classes common_sources")
# Programs
# The VariantDir directives near the top mean that the SConscript files are
# copied from src/ and test/ into the corresponding build/obj/ location.
# Thus, any edits to them should be made there.
SConscript([
"build/obj/SConscript",
"build/obj/pcedit/SConscript",
"build/obj/scenedit/SConscript",
"build/obj/test/SConscript"
])
# Data files
data_dir = path.join(install_dir, "/data")
Export("data_dir")
SConscript(["rsrc/SConscript", "doc/SConscript"])

6
doc/SConscript Normal file
View File

@@ -0,0 +1,6 @@
import os.path as path
Import("env install_dir")
env.Install(path.join(install_dir, "docs"), [Dir('editor'), Dir('game'), Dir('img')])

20
rsrc/SConscript Normal file
View File

@@ -0,0 +1,20 @@
import os.path as path
Import("env data_dir install_dir")
# Data
env.Install(data_dir, Dir("cursors"))
env.Install(data_dir, Dir("dialogs"))
env.Install(data_dir, Dir("fonts"))
env.Install(data_dir, Dir("graphics"))
env.Install(data_dir, Dir("sounds"))
env.Install(data_dir, Dir("strings"))
env.Install(path.join(data_dir, "shaders"), Glob("#src/tools/mask.*"))
# Scenarios
env.Install(path.join(install_dir, "Blades of Exile Scenarios"), Glob("Blades of Exile Scenarios/*.exs") + Glob("Blades of Exile Scenarios/*.meg"))
env.Install(path.join(install_dir, "Blades of Exile Base"), Glob("Blades of Exile Bases/*.exs"))

View File

@@ -151,7 +151,7 @@
</dict>
</array>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<string>Blades of Exile</string>
<key>CFBundleIconFile</key>
<string>BoE</string>
<key>CFBundleIdentifier</key>

View File

@@ -636,7 +636,7 @@
915E09071A316D6A008BDF00 /* map_parse.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = map_parse.hpp; sourceTree = "<group>"; };
915E09081A316D89008BDF00 /* map_parse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = map_parse.cpp; sourceTree = "<group>"; };
9169C31B1B37A5D50041002B /* Blades of Exile.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Blades of Exile.app"; sourceTree = BUILT_PRODUCTS_DIR; };
9169C31D1B37A5D50041002B /* Blades of Exile Character Editor.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Blades of Exile Character Editor.app"; sourceTree = BUILT_PRODUCTS_DIR; };
9169C31D1B37A5D50041002B /* BoE Character Editor.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "BoE Character Editor.app"; sourceTree = BUILT_PRODUCTS_DIR; };
9169C31F1B37A5D50041002B /* BoE Scenario Editor.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "BoE Scenario Editor.app"; sourceTree = BUILT_PRODUCTS_DIR; };
9178235C1B2EA0C5007F3444 /* vorbisenc.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = vorbisenc.framework; path = ../../../../../../Library/Frameworks/vorbisenc.framework; sourceTree = "<group>"; };
917823671B2F32DD007F3444 /* vorbisfile.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = vorbisfile.framework; path = ../../../../../../Library/Frameworks/vorbisfile.framework; sourceTree = "<group>"; };
@@ -976,7 +976,7 @@
911F2D981B98F43B00E3102E /* libCommon.a */,
911F2D9D1B98F44700E3102E /* libCommon-Party.a */,
9169C31B1B37A5D50041002B /* Blades of Exile.app */,
9169C31D1B37A5D50041002B /* Blades of Exile Character Editor.app */,
9169C31D1B37A5D50041002B /* BoE Character Editor.app */,
9169C31F1B37A5D50041002B /* BoE Scenario Editor.app */,
91CC172D1B421C0A003D9A69 /* boe_test */,
);
@@ -1506,7 +1506,7 @@
);
name = "Blades of Exile Character Editor";
productName = "Blades of Exile Character Editor";
productReference = 9169C31D1B37A5D50041002B /* Blades of Exile Character Editor.app */;
productReference = 9169C31D1B37A5D50041002B /* BoE Character Editor.app */;
productType = "com.apple.product-type.application";
};
91B3EF3E0F969F0000BF5B67 /* BoE Scenario Editor */ = {
@@ -2165,7 +2165,7 @@
"-lCommon",
);
OTHER_LDFLAGS_QUOTED_FOR_TARGET_1 = "-L\"$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/\"";
PRODUCT_NAME = "Blades of Exile Character Editor";
PRODUCT_NAME = "BoE Character Editor";
WRAPPER_EXTENSION = app;
};
name = Debug;
@@ -2190,7 +2190,7 @@
"-lCommon",
);
OTHER_LDFLAGS_QUOTED_FOR_TARGET_1 = "-L\"$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/\"";
PRODUCT_NAME = "Blades of Exile Character Editor";
PRODUCT_NAME = "BoE Character Editor";
WRAPPER_EXTENSION = app;
};
name = Release;

50
src/SConscript Normal file
View File

@@ -0,0 +1,50 @@
Import("env platform common_sources party_classes install_dir")
game_sources = Split("""
boe.actions.cpp
boe.combat.cpp
boe.dlgutil.cpp
boe.fileio.cpp
boe.graphics.cpp
boe.graphutil.cpp
boe.infodlg.cpp
boe.itemdata.cpp
boe.items.cpp
boe.locutils.cpp
boe.main.cpp
boe.monster.cpp
boe.newgraph.cpp
boe.party.cpp
boe.specials.cpp
boe.startup.cpp
boe.text.cpp
boe.town.cpp
boe.townspec.cpp
pcedit/pc.editors.cpp
tools/fileio_party.cpp
""")
if str(platform) == "darwin":
game_sources.extend(Split("""
boe.appleevents.mm
boe.menus.mac.mm
"""))
elif str(platform) == "windows":
game_sources.extend(Split("""
boe.menus.win.cpp
"""))
boe = env.Program("#build/bin/Blades of Exile", common_sources + party_classes + game_sources)
if str(platform) == "darwin":
boe_info = {
'nib': '#rsrc/menus/game',
'plist': 'BoE-Info.plist',
'creator': 'blx!',
'icons': 'BoE boegraphics boeresources boesave boesounds',
}
elif str(platform) == "windows":
pass
env.Package(boe, install_dir, boe_info)

36
src/classes/SConscript Normal file
View File

@@ -0,0 +1,36 @@
Import("env")
common_classes = Split("""
estreams.cpp
item.cpp
location.cpp
monster.cpp
outdoors.cpp
regtown.cpp
scenario.cpp
shop.cpp
special.cpp
spell.cpp
talking.cpp
terrain.cpp
tmpltown.cpp
town.cpp
vehicle.cpp
""")
party_classes = Split("""
creatlist.cpp
creature.cpp
living.cpp
party.cpp
pc.cpp
universe.cpp
""")
common = env.StaticLibrary("#build/lib/common", common_classes)
party = env.StaticLibrary("#build/lib/common_party", party_classes)
ret = (common, party)
Return("ret")

6
src/dialogxml/SConscript Normal file
View File

@@ -0,0 +1,6 @@
Import("env")
dlog_util = env.StaticLibrary("#build/lib/dlogutil", Glob("*.cpp") + Glob("xml-parser/*.cpp"))
Return("dlog_util")

View File

@@ -32,7 +32,7 @@
</dict>
</array>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<string>BoE Character Editor</string>
<key>CFBundleIconFile</key>
<string>BoECharEd</string>
<key>CFBundleIdentifier</key>

35
src/pcedit/SConscript Normal file
View File

@@ -0,0 +1,35 @@
Import("env platform common_sources party_classes install_dir")
pced_sources = Split("""
pc.action.cpp
pc.editors.cpp
pc.fileio.cpp
pc.graphics.cpp
pc.main.cpp
../tools/fileio_party.cpp
""")
if str(platform) == "darwin":
pced_sources.extend(Split("""
pc.appleevents.mm
pc.menus.mac.mm
"""))
elif str(platform) == "windows":
pced_sources.extend(Split("""
pc.menus.win.cpp
"""))
pced = env.Program("#build/bin/BoE Character Editor", common_sources + party_classes + pced_sources)
if str(platform) == "darwin":
pced_info = {
'nib': '#rsrc/menus/pcedit',
'plist': 'BoECharEd-Info.plist',
'creator': 'blxe',
'icons': 'BoECharEd',
}
elif str(platform) == "windows":
pass
env.Package(pced, install_dir, pced_info)

View File

@@ -33,7 +33,7 @@
</dict>
</array>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<string>BoE Scenario Editor</string>
<key>CFBundleIconFile</key>
<string>BoEScenEd</string>
<key>CFBundleIdentifier</key>

37
src/scenedit/SConscript Normal file
View File

@@ -0,0 +1,37 @@
Import("env platform common_sources install_dir")
scened_sources = Split("""
scen.actions.cpp
scen.btnmg.cpp
scen.core.cpp
scen.fileio.cpp
scen.graphics.cpp
scen.keydlgs.cpp
scen.main.cpp
scen.townout.cpp
""")
if str(platform) == "darwin":
scened_sources.extend(Split("""
scen.appleevents.mm
scen.menus.mac.mm
"""))
elif str(platform) == "windows":
scened_sources.extend(Split("""
scen.menus.win.cpp
"""))
scened = env.Program("#build/bin/BoE Scenario Editor", common_sources + scened_sources)
if str(platform) == "darwin":
scened_info = {
'nib': '#rsrc/menus/scenedit',
'plist': 'BoEScenEd-Info.plist',
'creator': 'BlEd',
'icons': 'boescenario BoEScenEd',
}
elif str(platform) == "windows":
pass
env.Package(scened, install_dir, scened_info)

35
src/tools/SConscript Normal file
View File

@@ -0,0 +1,35 @@
Import("env platform")
tools = Split("""
fileio_scen.cpp
fileio.cpp
graphtool.cpp
map_parse.cpp
mathutil.cpp
porting.cpp
soundtool.cpp
specials_parse.cpp
tarball.cpp
undo.cpp
gzstream/gzstream.cpp
""")
if str(platform) == "darwin":
tools.extend(Split("""
cursors.mac.mm
prefs.mac.mm
qdpict.cpp
winutil.mac.mm
"""))
elif str(platform) == "windows":
tools.extend(Split("""
cursors.win.cpp
menu_accel.win.cpp
prefs.win.cpp
winutil.win.cpp
"""))
tools_obj = env.StaticLibrary("#build/lib/tools", tools)
Return("tools_obj")

8
test/SConscript Normal file
View File

@@ -0,0 +1,8 @@
Import("env platform party_classes common_sources")
test_sources = Glob("""*.cpp""") + Split("""
#src/scenedit/scen.fileio.cpp
""")
test = env.Program("#build/bin/boe_test", party_classes + common_sources + test_sources)