From 832b8b5f91389ce27d84b917df9ca1aaafe7b4d6 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Fri, 11 Sep 2015 19:15:56 -0400 Subject: [PATCH] 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 --- .gitignore | 4 + SConstruct | 117 ++++++++++++++++++++++++++++++ doc/SConscript | 6 ++ rsrc/SConscript | 20 +++++ src/BoE-Info.plist | 2 +- src/BoE.xcodeproj/project.pbxproj | 10 +-- src/SConscript | 50 +++++++++++++ src/classes/SConscript | 36 +++++++++ src/dialogxml/SConscript | 6 ++ src/pcedit/BoECharEd-Info.plist | 2 +- src/pcedit/SConscript | 35 +++++++++ src/scenedit/BoEScenEd-Info.plist | 2 +- src/scenedit/SConscript | 37 ++++++++++ src/tools/SConscript | 35 +++++++++ test/SConscript | 8 ++ 15 files changed, 362 insertions(+), 8 deletions(-) create mode 100644 SConstruct create mode 100644 doc/SConscript create mode 100644 rsrc/SConscript create mode 100644 src/SConscript create mode 100644 src/classes/SConscript create mode 100644 src/dialogxml/SConscript create mode 100644 src/pcedit/SConscript create mode 100644 src/scenedit/SConscript create mode 100644 src/tools/SConscript create mode 100644 test/SConscript diff --git a/.gitignore b/.gitignore index f9403563..d879e5b5 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/SConstruct b/SConstruct new file mode 100644 index 00000000..1215af67 --- /dev/null +++ b/SConstruct @@ -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= 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"]) + diff --git a/doc/SConscript b/doc/SConscript new file mode 100644 index 00000000..28f6b9bb --- /dev/null +++ b/doc/SConscript @@ -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')]) diff --git a/rsrc/SConscript b/rsrc/SConscript new file mode 100644 index 00000000..2b6756e0 --- /dev/null +++ b/rsrc/SConscript @@ -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")) diff --git a/src/BoE-Info.plist b/src/BoE-Info.plist index 28b8f664..1dcd649f 100644 --- a/src/BoE-Info.plist +++ b/src/BoE-Info.plist @@ -151,7 +151,7 @@ CFBundleExecutable - ${EXECUTABLE_NAME} + Blades of Exile CFBundleIconFile BoE CFBundleIdentifier diff --git a/src/BoE.xcodeproj/project.pbxproj b/src/BoE.xcodeproj/project.pbxproj index 93a519c6..46725030 100755 --- a/src/BoE.xcodeproj/project.pbxproj +++ b/src/BoE.xcodeproj/project.pbxproj @@ -636,7 +636,7 @@ 915E09071A316D6A008BDF00 /* map_parse.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = map_parse.hpp; sourceTree = ""; }; 915E09081A316D89008BDF00 /* map_parse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = map_parse.cpp; sourceTree = ""; }; 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 = ""; }; 917823671B2F32DD007F3444 /* vorbisfile.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = vorbisfile.framework; path = ../../../../../../Library/Frameworks/vorbisfile.framework; sourceTree = ""; }; @@ -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; diff --git a/src/SConscript b/src/SConscript new file mode 100644 index 00000000..1964cddd --- /dev/null +++ b/src/SConscript @@ -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) diff --git a/src/classes/SConscript b/src/classes/SConscript new file mode 100644 index 00000000..f251f3e5 --- /dev/null +++ b/src/classes/SConscript @@ -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") diff --git a/src/dialogxml/SConscript b/src/dialogxml/SConscript new file mode 100644 index 00000000..9e8cd433 --- /dev/null +++ b/src/dialogxml/SConscript @@ -0,0 +1,6 @@ + +Import("env") + +dlog_util = env.StaticLibrary("#build/lib/dlogutil", Glob("*.cpp") + Glob("xml-parser/*.cpp")) + +Return("dlog_util") \ No newline at end of file diff --git a/src/pcedit/BoECharEd-Info.plist b/src/pcedit/BoECharEd-Info.plist index 50b5f466..94db3695 100644 --- a/src/pcedit/BoECharEd-Info.plist +++ b/src/pcedit/BoECharEd-Info.plist @@ -32,7 +32,7 @@ CFBundleExecutable - ${EXECUTABLE_NAME} + BoE Character Editor CFBundleIconFile BoECharEd CFBundleIdentifier diff --git a/src/pcedit/SConscript b/src/pcedit/SConscript new file mode 100644 index 00000000..fece679d --- /dev/null +++ b/src/pcedit/SConscript @@ -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) diff --git a/src/scenedit/BoEScenEd-Info.plist b/src/scenedit/BoEScenEd-Info.plist index 62ff7553..605ea4d6 100644 --- a/src/scenedit/BoEScenEd-Info.plist +++ b/src/scenedit/BoEScenEd-Info.plist @@ -33,7 +33,7 @@ CFBundleExecutable - ${EXECUTABLE_NAME} + BoE Scenario Editor CFBundleIconFile BoEScenEd CFBundleIdentifier diff --git a/src/scenedit/SConscript b/src/scenedit/SConscript new file mode 100644 index 00000000..f25e34fc --- /dev/null +++ b/src/scenedit/SConscript @@ -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) diff --git a/src/tools/SConscript b/src/tools/SConscript new file mode 100644 index 00000000..a7a645e1 --- /dev/null +++ b/src/tools/SConscript @@ -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") \ No newline at end of file diff --git a/test/SConscript b/test/SConscript new file mode 100644 index 00000000..c3d807d5 --- /dev/null +++ b/test/SConscript @@ -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)