import Version, os.path Import(["env", "conf_env"]) if env["SCONS_STAGE"] == "build" and not GetOption("help") and not env.get("HAVE_LUA", 0) : print "Warning: Lua was not found. Sluift will not be built." if "Sluift" in env["PROJECTS"] : env["PROJECTS"].remove("Sluift") elif env["SCONS_STAGE"] == "build" : sluift_sources = [ "Lua/Value.cpp", "Lua/Exception.cpp", "Lua/Check.cpp", "Lua/FunctionRegistration.cpp", "Lua/FunctionRegistry.cpp", "Lua/LuaUtils.cpp", "LuaElementConvertors.cpp", "LuaElementConvertor.cpp", "Response.cpp", "ElementConvertors/BodyConvertor.cpp", "ElementConvertors/VCardUpdateConvertor.cpp", "ElementConvertors/PubSubEventConvertor.cpp", "ElementConvertors/RawXMLElementConvertor.cpp", "ElementConvertors/DOMElementConvertor.cpp", "ElementConvertors/DefaultElementConvertor.cpp", "ElementConvertors/DiscoInfoConvertor.cpp", "ElementConvertors/DiscoItemsConvertor.cpp", "ElementConvertors/FormConvertor.cpp", "ElementConvertors/SoftwareVersionConvertor.cpp", "ElementConvertors/VCardConvertor.cpp", "ClientHelpers.cpp", "SluiftClient.cpp", "boot.c", "client.cpp", "sluift.cpp" ] sluift_sources += env.SConscript("ElementConvertors/SConscript") sluift_env = env.Clone() sluift_env.UseFlags(env.get("LUA_FLAGS", {})) sluift_env.UseFlags(env["SWIFTEN_FLAGS"]) sluift_env.UseFlags(env["SWIFTEN_DEP_FLAGS"]) sluift_env["SHLIBPREFIX"] = "" if sluift_env["PLATFORM"] == "win32" : sluift_env.Append(CPPDEFINES = ["SLUIFT_BUILD_DLL"]) elif sluift_env["PLATFORM"] == "darwin" : sluift_env["SHLIBSUFFIX"] = ".so" # Generate a customized lua.c sluift_env["SLUIFT_VERSION"] = Version.getBuildVersion(env.Dir("#").abspath, "sluift") def patchLua(env, target, source) : f = open(source[0].abspath, "r") contents = f.read() f.close() if env["PLATFORM"] == "win32" : key = "Z" else : key = "D" contents = contents.replace("LUA_RELEASE", "\"== Sluift XMPP Console (%(version)s) == \\nPress Ctrl-%(key)s to exit\"" % {"version": source[1].get_contents(), "key" : key}) contents = contents.replace("LUA_COPYRIGHT", "") f = open(target[0].abspath, "w") f.write(contents) f.close() sluift_env.Command("lua.c", ["#/3rdParty/Lua/src/lua.c", sluift_env.Value(sluift_env["SLUIFT_VERSION"])], env.Action(patchLua, cmdstr = "$GENCOMSTR")) # Generate boot.cpp def generate_embedded_lua(env, target, source) : f = open(source[0].abspath, "r") data = f.read() f.close() f = open(target[0].abspath, "w") f.write('const char ' + source[0].name.replace(".", "_") + "[] = \"" + data.replace("\\", "\\\\").replace("\n", "\\n").replace('"', '\\"') + "\";") f.close() sluift_env.Command("boot.c", ["boot.lua"], env.Action(generate_embedded_lua, cmdstr="$GENCOMSTR")) if sluift_env.get("HAVE_READLINE", False) : sluift_env.Append(CPPDEFINES = ["LUA_USE_READLINE"]) sluift_env.MergeFlags(sluift_env["READLINE_FLAGS"]) sluift_env.WriteVal("dll.c", sluift_env.Value("")) sluift_sources = [env.File(x) for x in sluift_sources] for sluift_variant in ['dll', 'exe'] : SConscript(["SConscript.variant"], variant_dir = sluift_variant, duplicate = 0, exports = ['sluift_sources', 'sluift_variant', 'sluift_env'])