summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Config')
-rw-r--r--Swiften/Config/SConscript54
-rw-r--r--Swiften/Config/swiften-config.cpp190
2 files changed, 123 insertions, 121 deletions
diff --git a/Swiften/Config/SConscript b/Swiften/Config/SConscript
index 837884b..dd06d61 100644
--- a/Swiften/Config/SConscript
+++ b/Swiften/Config/SConscript
@@ -3,16 +3,16 @@ import os.path
Import("env")
def replaceSwiftenPath(input) :
- return input.replace(env.Dir("#").abspath, "#")
+ 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
+ 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 = ""
@@ -21,36 +21,38 @@ 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")]))
+ 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")
- ]))
+ 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",
+ "#/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"
- ])
+ "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)
+ swiften_env.Install(os.path.join(swiften_env["SWIFTEN_INSTALLDIR"], "bin"), swiften_config)
diff --git a/Swiften/Config/swiften-config.cpp b/Swiften/Config/swiften-config.cpp
index be94c25..2b66989 100644
--- a/Swiften/Config/swiften-config.cpp
+++ b/Swiften/Config/swiften-config.cpp
@@ -1,126 +1,126 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
+#include <Swiften/Config/swiften-config.h>
+
#include <iostream>
+#include <string>
#include <boost/algorithm/string.hpp>
+#include <boost/filesystem.hpp>
+#include <boost/program_options.hpp>
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/variables_map.hpp>
-#include <boost/program_options.hpp>
#include <boost/version.hpp>
-#include <boost/filesystem.hpp>
-#include <string>
-#include <Swiften/Base/Platform.h>
-#include <Swiften/Base/Paths.h>
#include <Swiften/Base/Path.h>
+#include <Swiften/Base/Paths.h>
+#include <Swiften/Base/Platform.h>
#include <Swiften/Version.h>
-#include "swiften-config.h"
-
using namespace Swift;
static void printFlags(const std::vector<std::string>& flags) {
- for (size_t i = 0; i < flags.size(); ++i) {
- if (i > 0) {
- std::cout << " ";
- }
- std::cout << flags[i];
- }
- std::cout << std::endl;
+ for (size_t i = 0; i < flags.size(); ++i) {
+ if (i > 0) {
+ std::cout << " ";
+ }
+ std::cout << flags[i];
+ }
+ std::cout << std::endl;
}
int main(int argc, char* argv[]) {
- boost::program_options::options_description desc;
- desc.add_options()
- ("help", "Show this help message")
- ("version", "Show version information")
- ("libs", "List the library flags")
- ("cflags", "List the compiler & preprocessor flags")
- ;
- boost::program_options::variables_map vm;
- try {
- boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
- boost::program_options::notify(vm);
- }
- catch (const boost::program_options::unknown_option& option) {
+ boost::program_options::options_description desc;
+ desc.add_options()
+ ("help", "Show this help message")
+ ("version", "Show version information")
+ ("libs", "List the library flags")
+ ("cflags", "List the compiler & preprocessor flags")
+ ;
+ boost::program_options::variables_map vm;
+ try {
+ boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
+ boost::program_options::notify(vm);
+ }
+ catch (const boost::program_options::unknown_option& option) {
#if BOOST_VERSION >= 104200
- std::cout << "Ignoring unknown option " << option.get_option_name() << std::endl;
+ std::cout << "Ignoring unknown option " << option.get_option_name() << std::endl;
#else
- std::cout << "Error: " << option.what() << std::endl;
+ std::cout << "Error: " << option.what() << std::endl;
#endif
- }
- catch (const boost::program_options::error& e) {
- std::cout << "Error: " << e.what() << std::endl;
- return -1;
- }
+ }
+ catch (const boost::program_options::error& e) {
+ std::cout << "Error: " << e.what() << std::endl;
+ return -1;
+ }
- if (vm.count("help") > 0) {
- std::cout << "swiften-config outputs the Swiften build options." << std::endl;
- std::cout << std::endl;
- std::cout << "Usage: swiften-config [OPTIONS]..." << std::endl;
- std::cout << std::endl;
- std::cout << desc << "\n";
- return 0;
- }
- if (vm.count("version") > 0) {
- std::cout << "swiften-config " << SWIFTEN_VERSION_STRING << std::endl;
- return 0;
- }
+ if (vm.count("help") > 0) {
+ std::cout << "swiften-config outputs the Swiften build options." << std::endl;
+ std::cout << std::endl;
+ std::cout << "Usage: swiften-config [OPTIONS]..." << std::endl;
+ std::cout << std::endl;
+ std::cout << desc << "\n";
+ return 0;
+ }
+ if (vm.count("version") > 0) {
+ std::cout << "swiften-config " << SWIFTEN_VERSION_STRING << std::endl;
+ return 0;
+ }
- // Read in all variables
- std::vector<std::string> libs;
- for (size_t i = 0; LIBFLAGS[i]; ++i) {
- libs.push_back(LIBFLAGS[i]);
- }
- std::vector<std::string> cflags;
- for (size_t i = 0; CPPFLAGS[i]; ++i) {
- cflags.push_back(CPPFLAGS[i]);
- }
+ // Read in all variables
+ std::vector<std::string> libs;
+ for (size_t i = 0; LIBFLAGS[i]; ++i) {
+ libs.push_back(LIBFLAGS[i]);
+ }
+ std::vector<std::string> cflags;
+ for (size_t i = 0; CPPFLAGS[i]; ++i) {
+ cflags.push_back(CPPFLAGS[i]);
+ }
- // Detect whether we're running in-place or not
- boost::filesystem::path executablePath = Paths::getExecutablePath();
- boost::filesystem::path topSourcePath = executablePath / ".." / "..";
- boost::filesystem::path topInstallPath = executablePath / "..";
- bool inPlace = !boost::filesystem::exists(topInstallPath / "include" / "Swiften" / "Swiften.h");
+ // Detect whether we're running in-place or not
+ boost::filesystem::path executablePath = Paths::getExecutablePath();
+ boost::filesystem::path topSourcePath = executablePath / ".." / "..";
+ boost::filesystem::path topInstallPath = executablePath / "..";
+ bool inPlace = !boost::filesystem::exists(topInstallPath / "include" / "Swiften" / "Swiften.h");
- // Replace "#" variables with the correct path
- for(size_t i = 0; i < libs.size(); ++i) {
- if (inPlace) {
- std::string lib = libs[i];
- boost::replace_all(lib, "#", pathToString(topSourcePath));
- libs[i] = lib;
- }
- else {
- std::string lib = libs[i];
- boost::replace_all(lib, "#", pathToString(topInstallPath / "lib"));
- boost::erase_all(lib, "/Swiften");
- libs[i] = lib;
- }
- }
- for(size_t i = 0; i < cflags.size(); ++i) {
- if (inPlace) {
- std::string cflag = cflags[i];
- boost::replace_all(cflag, "#", pathToString(topSourcePath));
- cflags[i] = cflag;
- }
- else {
- std::string cflag = cflags[i];
- boost::replace_all(cflag, "#", pathToString(topInstallPath / "include"));
- cflags[i] = cflag;
- }
- }
+ // Replace "#" variables with the correct path
+ for(auto & i : libs) {
+ if (inPlace) {
+ std::string lib = i;
+ boost::replace_all(lib, "#", pathToString(topSourcePath));
+ i = lib;
+ }
+ else {
+ std::string lib = i;
+ boost::replace_all(lib, "#", pathToString(topInstallPath / "lib"));
+ boost::erase_all(lib, "/Swiften");
+ i = lib;
+ }
+ }
+ for(auto & i : cflags) {
+ if (inPlace) {
+ std::string cflag = i;
+ boost::replace_all(cflag, "#", pathToString(topSourcePath));
+ i = cflag;
+ }
+ else {
+ std::string cflag = i;
+ boost::replace_all(cflag, "#", pathToString(topInstallPath / "include"));
+ i = cflag;
+ }
+ }
- // Print the requested variable
- if (vm.count("libs") > 0) {
- printFlags(libs);
- }
- if (vm.count("cflags") > 0) {
- printFlags(cflags);
- }
- return 0;
+ // Print the requested variable
+ if (vm.count("libs") > 0) {
+ printFlags(libs);
+ }
+ if (vm.count("cflags") > 0) {
+ printFlags(cflags);
+ }
+ return 0;
}