aboutsummaryrefslogtreecommitdiff
path: root/libbutl/target-triplet.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbutl/target-triplet.cxx')
-rw-r--r--libbutl/target-triplet.cxx53
1 files changed, 26 insertions, 27 deletions
diff --git a/libbutl/target-triplet.cxx b/libbutl/target-triplet.cxx
index db71e3c..e28f119 100644
--- a/libbutl/target-triplet.cxx
+++ b/libbutl/target-triplet.cxx
@@ -1,33 +1,9 @@
// file : libbutl/target-triplet.cxx -*- C++ -*-
// license : MIT; see accompanying LICENSE file
-#ifndef __cpp_modules_ts
-#include <libbutl/target-triplet.mxx>
-#endif
-
-// C includes.
-
-#ifndef __cpp_lib_modules_ts
-#include <string>
-#include <ostream>
+#include <libbutl/target-triplet.hxx>
#include <stdexcept> // invalid_argument
-#endif
-
-// Other includes.
-
-#ifdef __cpp_modules_ts
-module butl.target_triplet;
-
-// Only imports additional to interface.
-#ifdef __clang__
-#ifdef __cpp_lib_modules_ts
-import std.core;
-import std.io;
-#endif
-#endif
-
-#endif
using namespace std;
@@ -112,6 +88,13 @@ namespace butl
if (system.front () == '-' || system.back () == '-')
bad ("invalid os/kernel/abi");
+ // Canonicalize SYSTEM.
+ //
+ if (system == "linux")
+ system = "linux-gnu"; // Per config.sub.
+ else if (system == "windows-gnu" && vendor == "w64") // Clang's innovation.
+ system = "mingw32";
+
// Extract VERSION for some recognized systems.
//
string::size_type v (0);
@@ -129,6 +112,14 @@ namespace butl
version.assign (system, v, string::npos);
system.resize (system.size () - version.size ());
}
+ else if (vendor == "apple" && system.compare (0, 3, "ios") == 0)
+ {
+ // Handle iosNN[-...].
+ //
+ string::size_type p (system.find ('-'));
+ version.assign (system, 3, p == string::npos ? p : p - 3);
+ system.erase (3, version.size ());
+ }
// Determine class for some recognized systems.
//
@@ -136,6 +127,8 @@ namespace butl
class_ = "linux";
else if (vendor == "apple" && system == "darwin")
class_ = "macos";
+ else if (vendor == "apple" && system.compare (0, 3, "ios") == 0)
+ class_ = "ios";
else if (system == "freebsd" ||
system == "openbsd" ||
system == "netbsd")
@@ -167,7 +160,10 @@ namespace butl
if (!version.empty ())
{
- r += version;
+ if (vendor == "apple" && system.compare (0, 3, "ios") == 0)
+ r.insert (r.size () - system.size () + 3, version);
+ else
+ r += version;
}
return r;
@@ -191,7 +187,10 @@ namespace butl
if (!version.empty ())
{
- r += version;
+ if (vendor == "apple" && system.compare (0, 3, "ios") == 0)
+ r.insert (r.size () - system.size () + 3, version);
+ else
+ r += version;
}
return r;