summaryrefslogtreecommitdiffstats
blob: dd06d6140607adf448f94437f1058a58660c4539 (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
52
53
54
55
56
57
58
import os.path

Import("env")

def replaceSwiftenPath(input) :
    return input.replace(env.Dir("#").abspath, "#")

def cStringVariable(env, cVar, sconsVar) :
    result = "static const char* " + cVar + "[] = {\n"
    # FIXME: Probably not very robust
    for var in sconsVar.split(" ") :
        result += "\t\"" + env.subst(var).replace("\\", "\\\\") + "\",\n"
    result += "\t0\n"
    result += "};\n"
    return result

config_flags = ""

swiften_env = env.Clone()
swiften_env.UseFlags(swiften_env["SWIFTEN_FLAGS"])
swiften_env.UseFlags(swiften_env["SWIFTEN_DEP_FLAGS"])

cppflags = replaceSwiftenPath(" ".join([
    swiften_env.subst("$CPPFLAGS").replace("-isystem ","-I"),
    swiften_env.subst("$_CPPDEFFLAGS"), 
    swiften_env.subst("$_CPPINCFLAGS")]))
config_flags += cStringVariable(swiften_env, "CPPFLAGS", cppflags)

libflags = replaceSwiftenPath(" ".join([
        swiften_env.subst("$_LIBDIRFLAGS"), 
        swiften_env.subst("$_LIBFLAGS"), 
        swiften_env.subst("$_FRAMEWORKPATH"), 
        swiften_env.subst("$_FRAMEWORKS"), 
        swiften_env.subst("$_FRAMEWORKSFLAGS")
    ]))
config_flags += cStringVariable(swiften_env, "LIBFLAGS", libflags)

config_env = env.Clone()
config_env.Append(CPPDEFINES = ["SWIFTEN_STATIC"])

# Create a local copy of Paths.cpp to avoid a Swiften dependency
config_env.Install(".", [
    "#/Swiften/Base/Paths.cpp",
    "#/Swiften/Base/Path.cpp",
    "#/Swiften/Base/String.cpp",
])
config_env.UseFlags(config_env["BOOST_FLAGS"])
config_env.UseFlags(config_env["PLATFORM_FLAGS"])
config_env.WriteVal("swiften-config.h", config_env.Value(config_flags))
swiften_config = config_env.Program("swiften-config", [
        "Paths.cpp",
        "Path.cpp",
        "String.cpp",
        "swiften-config.cpp"
    ])

if swiften_env.get("SWIFTEN_INSTALLDIR", "") :
    swiften_env.Install(os.path.join(swiften_env["SWIFTEN_INSTALLDIR"], "bin"), swiften_config)