aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornicole mazzuca <mazzucan@outlook.com>2020-05-20 10:10:26 -0700
committerGitHub <noreply@github.com>2020-05-20 10:10:26 -0700
commit9d9a50bc9823ca1673019aa18f23d28c7a1d2ff9 (patch)
tree54c5f724a2cc2414dfb1978edeb4dd201b50ba51
parent9b4535e7ee7673fb8515d1f4f256990423a0d952 (diff)
downloadvcpkg-9d9a50bc9823ca1673019aa18f23d28c7a1d2ff9.tar.gz
vcpkg-9d9a50bc9823ca1673019aa18f23d28c7a1d2ff9.zip
[vcpkg] fix extern C around ctermid (#11343)
Additionally, move the system_header invocations to their own header file, <vcpkg/base/system_header.h>
-rw-r--r--toolsrc/include/pch.h21
-rw-r--r--toolsrc/include/vcpkg-test/util.h2
-rw-r--r--toolsrc/include/vcpkg/base/system_headers.h35
-rw-r--r--toolsrc/src/vcpkg-test/system.cpp10
-rw-r--r--toolsrc/src/vcpkg-test/util.cpp12
-rw-r--r--toolsrc/src/vcpkg.cpp13
-rw-r--r--toolsrc/src/vcpkg/base/files.cpp5
-rw-r--r--toolsrc/src/vcpkgmetricsuploader.cpp3
8 files changed, 53 insertions, 48 deletions
diff --git a/toolsrc/include/pch.h b/toolsrc/include/pch.h
index 03e3f59f7..e23230f6e 100644
--- a/toolsrc/include/pch.h
+++ b/toolsrc/include/pch.h
@@ -1,22 +1,12 @@
#pragma once
#include <vcpkg/base/pragmas.h>
+#include <vcpkg/base/system_headers.h>
#if defined(_WIN32)
-#define NOMINMAX
-#define WIN32_LEAN_AND_MEAN
-
-#pragma warning(suppress : 4768)
-#include <windows.h>
-
-#pragma warning(suppress : 4768)
-#include <Shlobj.h>
-
#include <process.h>
#include <shellapi.h>
#include <winhttp.h>
-#else
-#include <unistd.h>
#endif
#include <algorithm>
@@ -29,13 +19,15 @@
#include <cstdarg>
#include <cstddef>
#include <cstdint>
-#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
#include <cstring>
+
#if VCPKG_USE_STD_FILESYSTEM
#include <filesystem>
#else
+#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
#include <experimental/filesystem>
#endif
+
#include <fstream>
#include <functional>
#include <iomanip>
@@ -55,11 +47,6 @@
#include <sys/time.h>
#endif
-#include <sys/types.h>
-// glibc defines major and minor in sys/types.h, and should not
-#undef major
-#undef minor
-
#include <system_error>
#include <thread>
#include <time.h>
diff --git a/toolsrc/include/vcpkg-test/util.h b/toolsrc/include/vcpkg-test/util.h
index b6ea4b01d..9321f3fd2 100644
--- a/toolsrc/include/vcpkg-test/util.h
+++ b/toolsrc/include/vcpkg-test/util.h
@@ -1,3 +1,5 @@
+#include <vcpkg/base/system_headers.h>
+
#include <catch2/catch.hpp>
#include <vcpkg/base/pragmas.h>
diff --git a/toolsrc/include/vcpkg/base/system_headers.h b/toolsrc/include/vcpkg/base/system_headers.h
new file mode 100644
index 000000000..9af5bfd92
--- /dev/null
+++ b/toolsrc/include/vcpkg/base/system_headers.h
@@ -0,0 +1,35 @@
+#pragma once
+
+#if defined(_WIN32)
+
+#define NOMINMAX
+#define WIN32_LEAN_AND_MEAN
+
+#pragma warning(suppress : 4768)
+#include <windows.h>
+
+#pragma warning(suppress : 4768)
+#include <Shlobj.h>
+
+#else // ^^^^ Windows / Unix vvvv
+
+// 2020-05-19: workaround for a c standard library bug
+// ctermid is not behind an `extern "C"` barrier, so it's linked incorrectly.
+// This has been reported; remove it after 2023-05-19
+#if __APPLE__
+extern "C" {
+#endif
+
+#include <unistd.h>
+
+#if __APPLE__
+}
+#endif
+
+#endif
+
+#include <sys/types.h>
+// glibc defines major and minor in sys/types.h, and should not
+#undef major
+#undef minor
+
diff --git a/toolsrc/src/vcpkg-test/system.cpp b/toolsrc/src/vcpkg-test/system.cpp
index 6b9dfaf95..6e87f9b3e 100644
--- a/toolsrc/src/vcpkg-test/system.cpp
+++ b/toolsrc/src/vcpkg-test/system.cpp
@@ -1,4 +1,4 @@
-#define _POSIX_C_SOURCE 200112L
+#include <vcpkg/base/system_headers.h>
#include <catch2/catch.hpp>
#include <string>
@@ -8,14 +8,6 @@
#include <vcpkg/base/strings.h>
#include <vcpkg/base/system.h>
-#if defined(_WIN32)
-#define _NOMINMAX
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#else
-#include <stdlib.h>
-#endif
-
using vcpkg::Optional;
using vcpkg::StringView;
using vcpkg::ZStringView;
diff --git a/toolsrc/src/vcpkg-test/util.cpp b/toolsrc/src/vcpkg-test/util.cpp
index 8ead355f1..ce38e62e4 100644
--- a/toolsrc/src/vcpkg-test/util.cpp
+++ b/toolsrc/src/vcpkg-test/util.cpp
@@ -1,3 +1,5 @@
+#include <vcpkg/base/system_headers.h>
+
#include <catch2/catch.hpp>
#include <vcpkg-test/util.h>
@@ -20,15 +22,13 @@
#define FILESYSTEM_SYMLINK_UNIX 1
#define FILESYSTEM_SYMLINK_NONE 2
-#if defined(__cpp_lib_filesystem)
+#if VCPKG_USE_STD_FILESYSTEM
#define FILESYSTEM_SYMLINK FILESYSTEM_SYMLINK_STD
-#include <filesystem> // required for filesystem::create_{directory_}symlink
#elif !defined(_MSC_VER)
#define FILESYSTEM_SYMLINK FILESYSTEM_SYMLINK_UNIX
-#include <unistd.h>
#else
@@ -169,10 +169,10 @@ namespace vcpkg::Test
#if FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_STD
if (can_create_symlinks())
{
- std::filesystem::path targetp = target.native();
- std::filesystem::path filep = file.native();
+ fs::path targetp = target.native();
+ fs::path filep = file.native();
- std::filesystem::create_symlink(targetp, filep, ec);
+ fs::stdfs::create_symlink(targetp, filep, ec);
}
else
{
diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp
index 7f9decce1..e1a0a2a0b 100644
--- a/toolsrc/src/vcpkg.cpp
+++ b/toolsrc/src/vcpkg.cpp
@@ -1,17 +1,6 @@
#include <vcpkg/base/pragmas.h>
-#if defined(_WIN32)
-#define NOMINMAX
-#define WIN32_LEAN_AND_MEAN
-#include <Windows.h>
-
-#pragma warning(push)
-#pragma warning(disable : 4768)
-#include <ShlObj.h>
-#pragma warning(pop)
-#else
-#include <unistd.h>
-#endif
+#include <vcpkg/base/system_headers.h>
#include <vcpkg/base/chrono.h>
#include <vcpkg/base/files.h>
diff --git a/toolsrc/src/vcpkg/base/files.cpp b/toolsrc/src/vcpkg/base/files.cpp
index 7f4d18616..0ef2fa992 100644
--- a/toolsrc/src/vcpkg/base/files.cpp
+++ b/toolsrc/src/vcpkg/base/files.cpp
@@ -11,9 +11,8 @@
#if !defined(_WIN32)
#include <fcntl.h>
#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-#endif // ^^^ !defined(_WIN32)
+#endif
+
#if defined(__linux__)
#include <sys/sendfile.h>
#elif defined(__APPLE__)
diff --git a/toolsrc/src/vcpkgmetricsuploader.cpp b/toolsrc/src/vcpkgmetricsuploader.cpp
index 2239fe750..95195b3be 100644
--- a/toolsrc/src/vcpkgmetricsuploader.cpp
+++ b/toolsrc/src/vcpkgmetricsuploader.cpp
@@ -3,7 +3,8 @@
#include <vcpkg/base/checks.h>
#include <vcpkg/base/files.h>
-#include <Windows.h>
+#include <vcpkg/base/system_headers.h>
+#include <shellapi.h>
using namespace vcpkg;