summaryrefslogtreecommitdiffstats
blob: 19dc1e71567dd5d8170f8ffa463fec58dfe4e8b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import Version

Import(["env", "conf_env"])

if env["SCONS_STAGE"] == "build" :
	lib_env = env.Clone()
	lib_env.UseFlags(env["LUA_FLAGS"])
	lib_env.UseFlags(env["SWIFTEN_FLAGS"])
	lib_env.UseFlags(env["SWIFTEN_DEP_FLAGS"])
	sluift_lib = lib_env.StaticLibrary("SluiftCore", [
			"Lua/Value.cpp",
			"sluift.cpp"
		]);

	myenv = env.Clone()
	myenv.Append(LIBS = sluift_lib)
	myenv.UseFlags(env["LUA_FLAGS"])
	myenv.UseFlags(env["SWIFTEN_FLAGS"])
	myenv.UseFlags(env["SWIFTEN_DEP_FLAGS"])
	myenv["SHLIBPREFIX"] = ""
	if myenv["PLATFORM"] == "win32" :
		myenv.Append(CPPDEFINES = ["SLUIFT_BUILD_DLL"])
	elif myenv["PLATFORM"] == "darwin" :
		myenv["SHLIBSUFFIX"] = ".so"

	myenv["SLUIFT_VERSION"] = Version.getBuildVersion("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()

	myenv.Command("lua.c", ["#/3rdParty/Lua/src/lua.c", myenv.Value(myenv["SLUIFT_VERSION"])], env.Action(patchLua, cmdstr = "$GENCOMSTR"))
	if myenv.get("HAVE_READLINE", False) :
		myenv.Append(CPPDEFINES = ["LUA_USE_READLINE"])
		myenv.MergeFlags(myenv["READLINE_FLAGS"])
	env["SLUIFT"] = myenv.Program("sluift", [
			"lua.c",
			"linit.c",
		])

	myenv.WriteVal("dll.c", myenv.Value(""))
	myenv.SharedLibrary("sluift", ["dll.c"])