From 471f0a1bb6d419a2e919e9060a6f966269d8ab6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be> Date: Sat, 30 Apr 2011 08:40:55 +0200 Subject: Use standard library naming scheme for Swiften on Linux. diff --git a/Swiften/.gitignore b/Swiften/.gitignore index de234f5..262a301 100644 --- a/Swiften/.gitignore +++ b/Swiften/.gitignore @@ -2,3 +2,4 @@ *.o Swiften.h Version.h +libSwiften.so.* diff --git a/Swiften/SConscript b/Swiften/SConscript index 46b901b..9c91c0d 100644 --- a/Swiften/SConscript +++ b/Swiften/SConscript @@ -18,10 +18,23 @@ if env["SCONS_STAGE"] == "flags" : env["SWIFTEN_VERSION_MAJOR"] = 0 env["SWIFTEN_VERSION_MINOR"] = 0 env["SWIFTEN_VERSION_PATCH"] = 0 + env["SWIFTEN_LIBRARY_ALIASES"] = [] + if env["PLATFORM"] == "win32" : + env["SWIFTEN_LIBRARY"] = "Swiften$SWIFTEN_VERSION_MAJOR" + env["SWIFTEN_LIBRARY_NAME"] = "Swiften$SWIFTEN_VERSION_MAJOR" + if env["PLATFORM"] == "darwin" : + env["SWIFTEN_LIBRARY"] = "Swiften$SWIFTEN_VERSION_MAJOR" + env["SWIFTEN_LIBRARY_NAME"] = "Swiften$SWIFTEN_VERSION_MAJOR" + else : + env["SWIFTEN_LIBRARY"] = "Swiften" + env["SWIFTEN_LIBRARY_NAME"] = "Swiften" + if ARGUMENTS.get("swiften_dll", False) : + env["SWIFTEN_LIBRARY_NAME"] = "libSwiften.so.$SWIFTEN_VERSION_MAJOR" + env["SWIFTEN_LIBRARY_ALIASES"] = ["libSwiften.so", "libSwiften.so.${SWIFTEN_VERSION_MAJOR}.${SWIFTEN_VERSION_MINOR}"] swiften_env = env.Clone() swiften_env["LIBPATH"] = [Dir(".")] - swiften_env["LIBS"] = ["Swiften" + str(swiften_env["SWIFTEN_VERSION_MAJOR"])] + swiften_env["LIBS"] = [swiften_env["SWIFTEN_LIBRARY"]] dep_env = env.Clone() for module in swiften_dep_modules : if env.get(module + "_BUNDLED", False) : @@ -48,17 +61,16 @@ if env["SCONS_STAGE"] == "build" : for module in swiften_dep_modules : swiften_env.UseFlags(swiften_env.get(module + "_FLAGS", {})) swiften_env.UseFlags(swiften_env["PLATFORM_FLAGS"]) - def buildObject(env, sources) : - if ARGUMENTS.get("swiften_dll", False) : - return env.SharedObject(sources) - else : - return env.StaticObject(sources) - swiften_env.AddMethod(buildObject, "SwiftenObject") - + + if ARGUMENTS.get("swiften_dll", False) : + swiften_env.AddMethod(lambda e,s : e.SharedObject(s), "SwiftenObject") + swiften_env.AddMethod(lambda e,l,o : e.SharedLibrary(l,o), "SwiftenLibrary") + else : + swiften_env.AddMethod(lambda e,s : e.StaticObject(s), "SwiftenObject") + swiften_env.AddMethod(lambda e,l,o : e.StaticLibrary(l,o), "SwiftenLibrary") Export("swiften_env") # TODO: Move all this to a submodule SConscript - myenv = swiften_env.Clone() sources = [ "Chat/ChatStateTracker.cpp", "Chat/ChatStateNotifier.cpp", @@ -187,10 +199,16 @@ if env["SCONS_STAGE"] == "build" : "Examples" ]) - if ARGUMENTS.get("swiften_dll", False) : - swiften_lib = myenv.SharedLibrary("Swiften" + str(swiften_env["SWIFTEN_VERSION_MAJOR"]), sources + swiften_env["SWIFTEN_OBJECTS"]) - else : - swiften_lib = myenv.StaticLibrary("Swiften" + str(swiften_env["SWIFTEN_VERSION_MAJOR"]), sources + swiften_env["SWIFTEN_OBJECTS"]) + myenv = swiften_env.Clone() + if ARGUMENTS.get("swiften_dll", False) and myenv["PLATFORM"] == "posix" : + myenv.Append(LINKFLAGS = ["-Wl,-soname,$SWIFTEN_LIBRARY_NAME"]) + swiften_lib = myenv.SwiftenLibrary(swiften_env["SWIFTEN_LIBRARY_NAME"], sources + swiften_env["SWIFTEN_OBJECTS"]) + def symlink(env, target, source) : + if os.path.exists(str(target[0])) : + os.unlink(str(target[0])) + os.symlink(source[0].get_contents(), str(target[0])) + for alias in myenv["SWIFTEN_LIBRARY_ALIASES"] : + myenv.Command(myenv.File(alias), [myenv.Value(swiften_lib[0].name), swiften_lib[0]], symlink) env.Append(UNITTEST_SOURCES = [ File("Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp"), @@ -346,5 +364,7 @@ if env["SCONS_STAGE"] == "build" : # Install swiften if swiften_env.get("SWIFTEN_INSTALLDIR", "") : swiften_env.Install(os.path.join(swiften_env["SWIFTEN_INSTALLDIR"], "lib"), swiften_lib) + for alias in myenv["SWIFTEN_LIBRARY_ALIASES"] : + myenv.Command(myenv.File(os.path.join(swiften_env["SWIFTEN_INSTALLDIR"], "lib", alias)), [env.Value(swiften_lib[0].name), swiften_lib[0]], symlink) for include in swiften_includes : swiften_env.Install(os.path.join(swiften_env["SWIFTEN_INSTALLDIR"], "include", os.path.dirname(include)), "#/" + include) -- cgit v0.10.2-6-g49f6 From dcd86c07e1ecccec63d9076a1ad2f9caf09067c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be> Date: Sat, 30 Apr 2011 10:06:20 +0200 Subject: Substitute SCons variables correctly. diff --git a/Swiften/SConscript b/Swiften/SConscript index 9c91c0d..17294f9 100644 --- a/Swiften/SConscript +++ b/Swiften/SConscript @@ -20,17 +20,17 @@ if env["SCONS_STAGE"] == "flags" : env["SWIFTEN_VERSION_PATCH"] = 0 env["SWIFTEN_LIBRARY_ALIASES"] = [] if env["PLATFORM"] == "win32" : - env["SWIFTEN_LIBRARY"] = "Swiften$SWIFTEN_VERSION_MAJOR" - env["SWIFTEN_LIBRARY_NAME"] = "Swiften$SWIFTEN_VERSION_MAJOR" - if env["PLATFORM"] == "darwin" : - env["SWIFTEN_LIBRARY"] = "Swiften$SWIFTEN_VERSION_MAJOR" - env["SWIFTEN_LIBRARY_NAME"] = "Swiften$SWIFTEN_VERSION_MAJOR" + env["SWIFTEN_LIBRARY"] = env.subst("Swiften$SWIFTEN_VERSION_MAJOR") + env["SWIFTEN_LIBRARY_NAME"] = env.subst("Swiften$SWIFTEN_VERSION_MAJOR") + elif env["PLATFORM"] == "darwin" : + env["SWIFTEN_LIBRARY"] = env.subst("Swiften$SWIFTEN_VERSION_MAJOR") + env["SWIFTEN_LIBRARY_NAME"] = env.subst("Swiften$SWIFTEN_VERSION_MAJOR") else : env["SWIFTEN_LIBRARY"] = "Swiften" env["SWIFTEN_LIBRARY_NAME"] = "Swiften" if ARGUMENTS.get("swiften_dll", False) : - env["SWIFTEN_LIBRARY_NAME"] = "libSwiften.so.$SWIFTEN_VERSION_MAJOR" - env["SWIFTEN_LIBRARY_ALIASES"] = ["libSwiften.so", "libSwiften.so.${SWIFTEN_VERSION_MAJOR}.${SWIFTEN_VERSION_MINOR}"] + env["SWIFTEN_LIBRARY_NAME"] = env.subst("libSwiften.so.$SWIFTEN_VERSION_MAJOR") + env["SWIFTEN_LIBRARY_ALIASES"] = ["libSwiften.so", env.subst("libSwiften.so.${SWIFTEN_VERSION_MAJOR}.${SWIFTEN_VERSION_MINOR}")] swiften_env = env.Clone() swiften_env["LIBPATH"] = [Dir(".")] -- cgit v0.10.2-6-g49f6