From 23173ae2c7dfc4d0a86092c7c118f6852aedea4c Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 26 Oct 2009 21:52:11 +0000 Subject: Cleanup. svn-id: r45421 --- tools/create_msvc/create_msvc.cpp | 21 +++++++++++++-------- tools/create_msvc/create_msvc.h | 11 +++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/tools/create_msvc/create_msvc.cpp b/tools/create_msvc/create_msvc.cpp index 47f9a6bdbc..8cfed79ebf 100644 --- a/tools/create_msvc/create_msvc.cpp +++ b/tools/create_msvc/create_msvc.cpp @@ -144,13 +144,11 @@ int main(int argc, char *argv[]) { for (EngineDescList::iterator j = setup.engines.begin(); j != setup.engines.end(); ++j) j->enable = true; } else if (!setEngineBuildState(name, setup.engines, true)) { - FeatureList::iterator feature = std::find(setup.features.begin(), setup.features.end(), name); - if (feature == setup.features.end()) { + // If none found, we'll try the features list + if (!setFeatureBuildState(name, setup.features, true)) { std::cerr << "ERROR: \"" << name << "\" is neither an engine nor a feature!\n"; return -1; } - - feature->enable = true; } } else if (!strncmp(argv[i], "--disable-", 10)) { const char *name = &argv[i][10]; @@ -164,13 +162,10 @@ int main(int argc, char *argv[]) { j->enable = false; } else if (!setEngineBuildState(name, setup.engines, false)) { // If none found, we'll try the features list - FeatureList::iterator feature = std::find(setup.features.begin(), setup.features.end(), name); - if (feature == setup.features.end()) { + if (!setFeatureBuildState(name, setup.features, false)) { std::cerr << "ERROR: \"" << name << "\" is neither an engine nor a feature!\n"; return -1; } - - feature->enable = false; } } else if (!strcmp(argv[i], "--file-prefix")) { if (i + 1 >= argc) { @@ -542,6 +537,16 @@ StringList getFeatureLibraries(const FeatureList &features) { return libraries; } +bool setFeatureBuildState(const std::string &name, FeatureList &features, bool enable) { + FeatureList::iterator i = std::find(features.begin(), features.end(), name); + if (i != features.end()) { + i->enable = enable; + return true; + } else { + return false; + } +} + namespace { typedef std::map UUIDMap; diff --git a/tools/create_msvc/create_msvc.h b/tools/create_msvc/create_msvc.h index 093b73e4de..17830ff8c6 100644 --- a/tools/create_msvc/create_msvc.h +++ b/tools/create_msvc/create_msvc.h @@ -163,6 +163,17 @@ StringList getFeatureDefines(const FeatureList &features); */ StringList getFeatureLibraries(const FeatureList &features); +/** + * Sets the state of a given feature. This can be used to + * either include or exclude an feature. + * + * @param name Name of the feature. + * @param features List of features to operate on. + * @param enable Whether the feature should be enabled or disabled. + * @return "true", when it succeeded, "false" otherwise. + */ +bool setFeatureBuildState(const std::string &name, FeatureList &features, bool enable); + /** * Structure to describe a MSVC build setup. * -- cgit v1.2.3