From a9844a31c639ed5e0c8efee92d644557b8410429 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 10 Mar 2016 10:04:43 +0200 Subject: Derive target class from target triplet for some targets --- butl/triplet | 16 ++++++++++++++-- butl/triplet.cxx | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) (limited to 'butl') diff --git a/butl/triplet b/butl/triplet index f61493d..44b5195 100644 --- a/butl/triplet +++ b/butl/triplet @@ -56,8 +56,8 @@ namespace butl // strategy for (presumably less common) cases were we don't split things // correctly. // - // Note also that the version splitting is only done for certain, - // commonly-used targets. + // Note also that the version splitting is only done for certain commonly- + // used targets. // // Some examples of canonicalization and splitting: // @@ -75,6 +75,17 @@ namespace butl // x86_64-linux-gnux32 x86_64 linux-gnux32 // x86_64-microsoft-win32-msvc14.0 x86_64 microsoft win32-msvc 14.0 // + // Similar to version splitting, for certain commonly-used targets we also + // derive the "target class" which can be used as a shorthand, more + // convenient way to identify a targets. If the target is not recognized, + // then the special 'other' value is used. Currently the following classes + // are recognized: + // + // linux *-*-linux-* + // macosx *-apple-darwin* + // freebsd *-*-freebsd* + // windows *-*-win32-* | *-*-mingw32 + // // References: // // 1. The libtool repository contains the PLATFORM file that lists many known @@ -88,6 +99,7 @@ namespace butl std::string vendor; std::string system; std::string version; + std::string class_; // Parse the triplet optionally returning the canonicalized string. Throw // std::invalid_argument if the triplet is not recognizable. diff --git a/butl/triplet.cxx b/butl/triplet.cxx index 8369539..39057a3 100644 --- a/butl/triplet.cxx +++ b/butl/triplet.cxx @@ -103,7 +103,7 @@ namespace butl *c += system; } - // Finally, extract VERSION for some recognized systems. + // Extract VERSION for some recognized systems. // string::size_type v (0); if (system.compare (0, (v = 6), "darwin") == 0 || @@ -118,5 +118,18 @@ namespace butl version.assign (system, v, string::npos); system.resize (system.size () - version.size ()); } + + // Determine class for some recognized systems. + // + if (system.compare (0, 5, "linux") == 0) + class_ = "linux"; + else if (vendor == "apple" && system == "darwin") + class_ = "macosx"; + else if (system == "freebsd") + class_ = "freebsd"; + else if (system.compare (0, 5, "win32") == 0 || system == "mingw32") + class_ = "windows"; + else + class_ = "other"; } } -- cgit v1.1