aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2016-06-28 13:00:14 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2016-07-01 15:46:53 +0300
commitec7b7e37ce97d25adc209befb2c12cf16eb06ef1 (patch)
treebcb5b911b0d6579cf1d8c2e6ca4ac13383ca08f9
parent86db4fb7388285adc24e3aa6eb3f7ec68efd15f4 (diff)
Port to MSVC
-rw-r--r--build2/b.cxx4
-rw-r--r--build2/bin/target.cxx2
-rw-r--r--build2/cli/target.cxx4
-rw-r--r--build2/cxx/target.cxx14
-rw-r--r--build2/cxx/utility.cxx6
-rw-r--r--build2/diagnostics27
-rw-r--r--build2/scope.cxx4
-rw-r--r--build2/target.cxx7
-rw-r--r--build2/variable5
-rw-r--r--build2/variable.cxx15
-rw-r--r--build2/variable.txx4
11 files changed, 44 insertions, 48 deletions
diff --git a/build2/b.cxx b/build2/b.cxx
index 713b227..3be9f95 100644
--- a/build2/b.cxx
+++ b/build2/b.cxx
@@ -5,10 +5,6 @@
#include <time.h> // tzset()
#include <string.h> // strerror()
-#include <stdlib.h> // getenv()
-#include <unistd.h> // getuid()
-#include <sys/types.h> // uid_t
-
#include <sstream>
#include <cstring> // strcmp(), strchr()
#include <typeinfo>
diff --git a/build2/bin/target.cxx b/build2/bin/target.cxx
index b0ce6d5..f141d97 100644
--- a/build2/bin/target.cxx
+++ b/build2/bin/target.cxx
@@ -10,7 +10,7 @@ namespace build2
{
namespace bin
{
- constexpr const char ext_var[] = "extension";
+ extern const char ext_var[] = "extension"; // VC 19 rejects constexpr.
static target*
obja_factory (const target_type&,
diff --git a/build2/cli/target.cxx b/build2/cli/target.cxx
index 52ddd17..e3d1526 100644
--- a/build2/cli/target.cxx
+++ b/build2/cli/target.cxx
@@ -15,8 +15,8 @@ namespace build2
{
// cli
//
- constexpr const char cli_ext_var[] = "extension";
- constexpr const char cli_ext_def[] = "cli";
+ extern const char cli_ext_var[] = "extension"; // VC 19 rejects constexpr.
+ extern const char cli_ext_def[] = "cli";
const target_type cli::static_type
{
diff --git a/build2/cxx/target.cxx b/build2/cxx/target.cxx
index c5b5080..22ace50 100644
--- a/build2/cxx/target.cxx
+++ b/build2/cxx/target.cxx
@@ -10,9 +10,9 @@ namespace build2
{
namespace cxx
{
- constexpr const char ext_var[] = "extension";
+ extern const char ext_var[] = "extension"; // VC 19 rejects constexpr.
- constexpr const char hxx_ext_def[] = "hxx";
+ extern const char hxx_ext_def[] = "hxx";
const target_type hxx::static_type
{
"hxx",
@@ -24,7 +24,7 @@ namespace build2
false
};
- constexpr const char ixx_ext_def[] = "ixx";
+ extern const char ixx_ext_def[] = "ixx";
const target_type ixx::static_type
{
"ixx",
@@ -36,7 +36,7 @@ namespace build2
false
};
- constexpr const char txx_ext_def[] = "txx";
+ extern const char txx_ext_def[] = "txx";
const target_type txx::static_type
{
"txx",
@@ -48,7 +48,7 @@ namespace build2
false
};
- constexpr const char cxx_ext_def[] = "cxx";
+ extern const char cxx_ext_def[] = "cxx";
const target_type cxx::static_type
{
"cxx",
@@ -60,7 +60,7 @@ namespace build2
false
};
- constexpr const char h_ext_def[] = "h";
+ extern const char h_ext_def[] = "h";
const target_type h::static_type
{
"h",
@@ -72,7 +72,7 @@ namespace build2
false
};
- constexpr const char c_ext_def[] = "c";
+ extern const char c_ext_def[] = "c";
const target_type c::static_type
{
"c",
diff --git a/build2/cxx/utility.cxx b/build2/cxx/utility.cxx
index 0f4eb08..ed57fd2 100644
--- a/build2/cxx/utility.cxx
+++ b/build2/cxx/utility.cxx
@@ -36,9 +36,9 @@ namespace build2
// @@ Is mapping for 14 and 17 correct? Maybe Update 2 for 14?
//
- if ((v == "11" && cver <= 16) || // C++11 since VS2010/10.0.
- (v == "14" && cver <= 19) || // C++14 since VS2015/14.0.
- (v == "17" && cver <= 20)) // C++17 since VS20??/15.0.
+ if ((v == "11" && cver < 16) || // C++11 since VS2010/10.0.
+ (v == "14" && cver < 19) || // C++14 since VS2015/14.0.
+ (v == "17" && cver < 20)) // C++17 since VS20??/15.0.
{
fail << "C++" << v << " is not supported by "
<< cast<string> (rs["cxx.signature"]) <<
diff --git a/build2/diagnostics b/build2/diagnostics
index c0ba6ec..8aedf13 100644
--- a/build2/diagnostics
+++ b/build2/diagnostics
@@ -140,7 +140,7 @@ namespace build2
diag_record (const diag_mark<B>& m)
: empty_ (true), epilogue_ (nullptr) { *this << m;}
- ~diag_record () noexcept(false);
+ ~diag_record () noexcept (false);
void
append (diag_epilogue e) const
@@ -159,30 +159,25 @@ namespace build2
// Move constructible-only type.
//
- /*
- @@ libstdc++ doesn't yet have the ostringstream move support.
-
+ // Older versions of libstdc++ don't have the ostringstream move support
+ // and accuratly detecting its version is non-trivial. So we always use
+ // the pessimized implementation with libstdc++. Luckily, GCC doesn't seem
+ // to be needing move due to copy/move elision.
+ //
diag_record (diag_record&& r)
+#ifndef __GLIBCXX__
: os_ (move (r.os_))
- {
- empty_ = r.empty_;
- r.empty_ = true;
-
- epilogue_ = r.epilogue_;
- r.epilogue_ = nullptr;
- }
- */
-
- diag_record (diag_record&& r)
+#endif
{
empty_ = r.empty_;
epilogue_ = r.epilogue_;
if (!empty_)
{
- assert (false); //@@ Stream verbosity will not be transferred.
+#ifdef __GLIBCXX__
+ stream_verb (os_, stream_verb (r.os_));
os_ << r.os_.str ();
-
+#endif
r.empty_ = true;
r.epilogue_ = nullptr;
}
diff --git a/build2/scope.cxx b/build2/scope.cxx
index c9a8ab9..0ef8de6 100644
--- a/build2/scope.cxx
+++ b/build2/scope.cxx
@@ -540,7 +540,9 @@ namespace build2
return r;
}
- constexpr const char derived_tt_ext_var[] = "extension";
+ // VC 19 rejects constexpr.
+ //
+ extern const char derived_tt_ext_var[] = "extension";
pair<reference_wrapper<const target_type>, bool> scope::
derive_target_type (const string& name, const target_type& base)
diff --git a/build2/target.cxx b/build2/target.cxx
index 2e500aa..12bbfd1 100644
--- a/build2/target.cxx
+++ b/build2/target.cxx
@@ -498,8 +498,8 @@ namespace build2
: &extension_pool.find (ext)));
}
- constexpr const char file_ext_var[] = "extension";
- constexpr const char file_ext_def[] = "";
+ extern const char file_ext_var[] = "extension"; // VC 19 rejects constexpr.
+ extern const char file_ext_def[] = "";
const target_type file::static_type
{
@@ -613,7 +613,8 @@ namespace build2
false
};
- constexpr const char man1_ext[] = "1";
+ extern const char man1_ext[] = "1"; // VC 19 rejects constexpr.
+
const target_type man1::static_type
{
"man1",
diff --git a/build2/variable b/build2/variable
index a63b5b4..5b9189c 100644
--- a/build2/variable
+++ b/build2/variable
@@ -216,7 +216,10 @@ namespace build2
// fit will have to be handled with an extra dynamic allocation.
//
std::aligned_storage<sizeof (name)>::type data_;
- static const size_t size_ = sizeof (data_);
+
+ // VC 19 needs decltype.
+ //
+ static const size_t size_ = sizeof (decltype (data_));
// Make sure we have sufficient storage for untyped values.
//
diff --git a/build2/variable.cxx b/build2/variable.cxx
index 65bc023..67efc95 100644
--- a/build2/variable.cxx
+++ b/build2/variable.cxx
@@ -333,7 +333,7 @@ namespace build2
throw invalid_argument (string ());
}
- constexpr const char* const value_traits<bool>::type_name = "bool";
+ const char* const value_traits<bool>::type_name = "bool";
const value_type value_traits<bool>::value_type
{
@@ -373,7 +373,7 @@ namespace build2
throw invalid_argument (string ());
}
- constexpr const char* const value_traits<uint64_t>::type_name = "uint64";
+ const char* const value_traits<uint64_t>::type_name = "uint64";
const value_type value_traits<uint64_t>::value_type
{
@@ -459,7 +459,7 @@ namespace build2
return s;
}
- constexpr const char* const value_traits<string>::type_name = "string";
+ const char* const value_traits<string>::type_name = "string";
const value_type value_traits<string>::value_type
{
@@ -504,7 +504,7 @@ namespace build2
throw invalid_argument (string ());
}
- constexpr const char* const value_traits<path>::type_name = "path";
+ const char* const value_traits<path>::type_name = "path";
const value_type value_traits<path>::value_type
{
@@ -547,7 +547,7 @@ namespace build2
throw invalid_argument (string ());
}
- constexpr const char* const value_traits<dir_path>::type_name = "dir_path";
+ const char* const value_traits<dir_path>::type_name = "dir_path";
const value_type value_traits<dir_path>::value_type
{
@@ -580,8 +580,7 @@ namespace build2
return abs_dir_path (move (d));
}
- constexpr const char* const value_traits<abs_dir_path>::type_name =
- "abs_dir_path";
+ const char* const value_traits<abs_dir_path>::type_name = "abs_dir_path";
const value_type value_traits<abs_dir_path>::value_type
{
@@ -616,7 +615,7 @@ namespace build2
return names_view (&v.as<name> (), 1);
}
- constexpr const char* const value_traits<name>::type_name = "name";
+ const char* const value_traits<name>::type_name = "name";
const value_type value_traits<name>::value_type
{
diff --git a/build2/variable.txx b/build2/variable.txx
index 6d3121a..a3511d4 100644
--- a/build2/variable.txx
+++ b/build2/variable.txx
@@ -275,7 +275,7 @@ namespace build2
value_traits<T>::type_name) + 's';
template <typename T>
- const value_type value_traits<vector<T>>::value_type
+ const value_type value_traits<vector<T>>::value_type = // VC 19 wants =.
{
value_traits<vector<T>>::type_name.c_str (),
sizeof (vector<T>),
@@ -436,7 +436,7 @@ namespace build2
value_traits<V>::type_name + "_map";
template <typename K, typename V>
- const value_type value_traits<std::map<K, V>>::value_type
+ const value_type value_traits<std::map<K, V>>::value_type = // VC 19 wants =.
{
value_traits<map<K, V>>::type_name.c_str (),
sizeof (map<K, V>),