aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2016-10-10 23:07:29 -0700
committerRobert Schumacher <roschuma@microsoft.com>2016-10-10 23:07:29 -0700
commit9e1d40e4dc313de2e6de0ac4f60a2df224215ae2 (patch)
treebc60827a29151d7829f4b6fdeaa8d6f60e8f8258
parentc494892eb24ce6f84c777f24dfceb71a4988fd24 (diff)
parent23f187a45766057ef76baba9dc912270b403cb7d (diff)
downloadvcpkg-9e1d40e4dc313de2e6de0ac4f60a2df224215ae2.tar.gz
vcpkg-9e1d40e4dc313de2e6de0ac4f60a2df224215ae2.zip
Merge branch 'master' of https://github.com/microsoft/vcpkg
-rw-r--r--ports/harfbuzz/CONTROL4
-rw-r--r--ports/harfbuzz/portfile.cmake52
-rw-r--r--toolsrc/include/Stopwatch.h40
-rw-r--r--toolsrc/include/vcpkg_Strings.h5
-rw-r--r--toolsrc/include/vcpkg_System.h2
-rw-r--r--toolsrc/src/Stopwatch.cpp104
-rw-r--r--toolsrc/src/commands_installation.cpp2
-rw-r--r--toolsrc/src/main.cpp2
-rw-r--r--toolsrc/src/post_build_lint.cpp49
-rw-r--r--toolsrc/src/vcpkg_System.cpp6
-rw-r--r--toolsrc/vcpkgcommon/vcpkgcommon.vcxproj2
-rw-r--r--toolsrc/vcpkgcommon/vcpkgcommon.vcxproj.filters6
12 files changed, 264 insertions, 10 deletions
diff --git a/ports/harfbuzz/CONTROL b/ports/harfbuzz/CONTROL
new file mode 100644
index 000000000..4922a6fff
--- /dev/null
+++ b/ports/harfbuzz/CONTROL
@@ -0,0 +1,4 @@
+Source: harfbuzz
+Version: 1.3.2
+Description: HarfBuzz OpenType text shaping engine
+Build-depends: ragel
diff --git a/ports/harfbuzz/portfile.cmake b/ports/harfbuzz/portfile.cmake
new file mode 100644
index 000000000..fcdbf11e5
--- /dev/null
+++ b/ports/harfbuzz/portfile.cmake
@@ -0,0 +1,52 @@
+# Common Ambient Variables:
+# VCPKG_ROOT_DIR = <C:\path\to\current\vcpkg>
+# TARGET_TRIPLET is the current triplet (x86-windows, etc)
+# PORT is the current port name (zlib, etc)
+# CURRENT_BUILDTREES_DIR = ${VCPKG_ROOT_DIR}\buildtrees\${PORT}
+# CURRENT_PACKAGES_DIR = ${VCPKG_ROOT_DIR}\packages\${PORT}_${TARGET_TRIPLET}
+#
+
+include(${CMAKE_TRIPLET_FILE})
+include(vcpkg_common_functions)
+set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/harfbuzz-1.3.2)
+find_program(NMAKE nmake)
+
+vcpkg_download_distfile(ARCHIVE
+ URLS "https://www.freedesktop.org/software/harfbuzz/release/harfbuzz-1.3.2.tar.bz2"
+ FILENAME "harfbuzz-1.3.2.tar.bz2"
+ SHA512 19f846ee75d8a2d94da2a2b489fa8e54a5120599f998e451187f6695aa3931b28c491bbc0837892eaaebbd1da3441effe01f5f2470454f83cfa6a7c510ebcb32
+)
+vcpkg_extract_source_archive(${ARCHIVE})
+
+vcpkg_execute_required_process(
+ COMMAND ${NMAKE} -f Makefile.vc CFG=debug
+ WORKING_DIRECTORY ${SOURCE_PATH}/win32/
+ LOGNAME nmake-build-${TARGET_TRIPLET}-debug
+)
+
+vcpkg_execute_required_process(
+ COMMAND ${NMAKE} -f Makefile.vc CFG=release
+ WORKING_DIRECTORY ${SOURCE_PATH}/win32/
+ LOGNAME nmake-build-${TARGET_TRIPLET}-release
+)
+
+file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}/debug" NATIVE_PACKAGES_DIR_DBG)
+
+vcpkg_execute_required_process(
+ COMMAND ${NMAKE} -f Makefile.vc CFG=debug PREFIX=${NATIVE_PACKAGES_DIR_DBG} install
+ WORKING_DIRECTORY ${SOURCE_PATH}/win32/
+ LOGNAME nmake-install-${TARGET_TRIPLET}-debug
+)
+file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
+
+file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}" NATIVE_PACKAGES_DIR_REL)
+
+vcpkg_execute_required_process(
+ COMMAND ${NMAKE} -f Makefile.vc CFG=release PREFIX=${NATIVE_PACKAGES_DIR_REL} install
+ WORKING_DIRECTORY ${SOURCE_PATH}/win32/
+ LOGNAME nmake-install-${TARGET_TRIPLET}-release
+)
+
+# Handle copyright
+file(COPY ${CURRENT_BUILDTREES_DIR}/src/harfbuzz-1.3.2/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/harfbuzz)
+file(RENAME ${CURRENT_PACKAGES_DIR}/share/harfbuzz/COPYING ${CURRENT_PACKAGES_DIR}/share/harfbuzz/copyright)
diff --git a/toolsrc/include/Stopwatch.h b/toolsrc/include/Stopwatch.h
new file mode 100644
index 000000000..2bd5c31bf
--- /dev/null
+++ b/toolsrc/include/Stopwatch.h
@@ -0,0 +1,40 @@
+#pragma once
+
+#include <chrono>
+#include <string>
+
+namespace vcpkg
+{
+ class Stopwatch
+ {
+ public:
+ static Stopwatch createUnstarted();
+
+ static Stopwatch createStarted();
+
+ bool isRunning() const;
+
+ Stopwatch& start();
+
+ Stopwatch& stop();
+
+ Stopwatch& reset();
+
+ template <class TimeUnit>
+ TimeUnit elapsed() const
+ {
+ return std::chrono::duration_cast<TimeUnit>(elapsedNanos());
+ }
+
+ std::string toString() const;
+
+ private:
+ Stopwatch();
+
+ std::chrono::nanoseconds elapsedNanos() const;
+
+ bool m_isRunning;
+ std::chrono::nanoseconds m_elapsedNanos;
+ std::chrono::steady_clock::time_point m_startTick;
+ };
+}
diff --git a/toolsrc/include/vcpkg_Strings.h b/toolsrc/include/vcpkg_Strings.h
index 2aa99afe0..70526198c 100644
--- a/toolsrc/include/vcpkg_Strings.h
+++ b/toolsrc/include/vcpkg_Strings.h
@@ -19,6 +19,11 @@ namespace vcpkg {namespace Strings {namespace details
return s;
}
+ inline double to_printf_arg(const double s)
+ {
+ return s;
+ }
+
inline size_t to_printf_arg(const size_t s)
{
return s;
diff --git a/toolsrc/include/vcpkg_System.h b/toolsrc/include/vcpkg_System.h
index f47fc9aab..c420464c1 100644
--- a/toolsrc/include/vcpkg_System.h
+++ b/toolsrc/include/vcpkg_System.h
@@ -64,7 +64,7 @@ namespace vcpkg {namespace System
return println(c, Strings::format(messageTemplate, messageArgs...).c_str());
}
- struct Stopwatch
+ struct Stopwatch2
{
int64_t start_time, end_time, freq;
diff --git a/toolsrc/src/Stopwatch.cpp b/toolsrc/src/Stopwatch.cpp
new file mode 100644
index 000000000..035d54c2b
--- /dev/null
+++ b/toolsrc/src/Stopwatch.cpp
@@ -0,0 +1,104 @@
+#include "Stopwatch.h"
+#include "vcpkg_Checks.h"
+
+namespace vcpkg
+{
+ Stopwatch Stopwatch::createUnstarted()
+ {
+ return Stopwatch();
+ }
+
+ Stopwatch Stopwatch::createStarted()
+ {
+ return Stopwatch().start();
+ }
+
+ bool Stopwatch::isRunning() const
+ {
+ return this->m_isRunning;
+ }
+
+ Stopwatch& Stopwatch::start()
+ {
+ Checks::check_exit(!this->m_isRunning, "This stopwatch is already running.");
+ this->m_isRunning = true;
+ this->m_startTick = std::chrono::high_resolution_clock::now();
+ return *this;
+ }
+
+ Stopwatch& Stopwatch::stop()
+ {
+ auto tick = std::chrono::high_resolution_clock::now();
+ Checks::check_exit(this->m_isRunning, "This stopwatch is already stopped.");
+ this->m_isRunning = false;
+ this->m_elapsedNanos += tick - this->m_startTick;
+ return *this;
+ }
+
+ Stopwatch& Stopwatch::reset()
+ {
+ this->m_elapsedNanos = std::chrono::nanoseconds();
+ this->m_isRunning = false;
+ return *this;
+ }
+
+ std::string Stopwatch::toString() const
+ {
+ using std::chrono::hours;
+ using std::chrono::minutes;
+ using std::chrono::seconds;
+ using std::chrono::milliseconds;
+ using std::chrono::microseconds;
+ using std::chrono::nanoseconds;
+ using std::chrono::duration_cast;
+
+ auto nanos = elapsedNanos();
+ auto nanos_as_double = static_cast<double>(nanos.count());
+
+ if (duration_cast<hours>(nanos) > hours())
+ {
+ auto t = nanos_as_double / duration_cast<nanoseconds>(hours(1)).count();
+ return Strings::format("%.4g h", t);
+ }
+
+ if (duration_cast<minutes>(nanos) > minutes())
+ {
+ auto t = nanos_as_double / duration_cast<nanoseconds>(minutes(1)).count();
+ return Strings::format("%.4g min", t);
+ }
+
+ if (duration_cast<seconds>(nanos) > seconds())
+ {
+ auto t = nanos_as_double / duration_cast<nanoseconds>(seconds(1)).count();
+ return Strings::format("%.4g s", t);
+ }
+
+ if (duration_cast<milliseconds>(nanos) > milliseconds())
+ {
+ auto t = nanos_as_double / duration_cast<nanoseconds>(milliseconds(1)).count();
+ return Strings::format("%.4g ms", t);
+ }
+
+ if (duration_cast<microseconds>(nanos) > microseconds())
+ {
+ auto t = nanos_as_double / duration_cast<nanoseconds>(microseconds(1)).count();
+ return Strings::format("%.4g micros", t);
+ }
+
+ return Strings::format("%.4g ns", nanos_as_double);
+ }
+
+ Stopwatch::Stopwatch() : m_isRunning(false), m_elapsedNanos(), m_startTick()
+ {
+ }
+
+ std::chrono::nanoseconds Stopwatch::elapsedNanos() const
+ {
+ if (this->m_isRunning)
+ {
+ return std::chrono::high_resolution_clock::now() - this->m_startTick + this->m_elapsedNanos;
+ }
+
+ return this->m_elapsedNanos;
+ }
+}
diff --git a/toolsrc/src/commands_installation.cpp b/toolsrc/src/commands_installation.cpp
index 6fe6aa9a1..7e7da9e3f 100644
--- a/toolsrc/src/commands_installation.cpp
+++ b/toolsrc/src/commands_installation.cpp
@@ -31,7 +31,7 @@ namespace vcpkg
port_dir.generic_wstring(),
ports_cmake_script_path.generic_wstring());
- System::Stopwatch timer;
+ System::Stopwatch2 timer;
timer.start();
int return_code = System::cmd_execute(command);
timer.stop();
diff --git a/toolsrc/src/main.cpp b/toolsrc/src/main.cpp
index f3d68f5dd..2200cd105 100644
--- a/toolsrc/src/main.cpp
+++ b/toolsrc/src/main.cpp
@@ -153,7 +153,7 @@ static void loadConfig()
}
}
-static System::Stopwatch g_timer;
+static System::Stopwatch2 g_timer;
static std::string trim_path_from_command_line(const std::string& full_command_line)
{
diff --git a/toolsrc/src/post_build_lint.cpp b/toolsrc/src/post_build_lint.cpp
index 2b2812d73..1905b48f9 100644
--- a/toolsrc/src/post_build_lint.cpp
+++ b/toolsrc/src/post_build_lint.cpp
@@ -4,6 +4,7 @@
#include <iterator>
#include <functional>
#include "vcpkg_System.h"
+#include <set>
namespace fs = std::tr2::sys;
@@ -279,16 +280,43 @@ namespace vcpkg
static lint_status check_architecture(const std::string& expected_architecture, const std::vector<fs::path>& files)
{
+ // static const std::regex machine_regex = std::regex(R"###([0-9A-F]+ machine \([^)]+\))###");
+
+ // Parenthesis is there to avoid some other occurrences of the word "machine". Those don't match the expected regex.
+ static const std::string machine_string_scan = "machine (";
+
std::vector<file_and_arch> binaries_with_invalid_architecture;
+ std::set<fs::path> binaries_with_no_architecture(files.cbegin(), files.cend());
+
for (const fs::path& f : files)
{
- const std::wstring cmd_line = Strings::wformat(LR"("%s" /headers "%s" | findstr machine)", DUMPBIN_EXE.native(), f.native());
+ const std::wstring cmd_line = Strings::wformat(LR"("%s" /headers "%s")", DUMPBIN_EXE.native(), f.native());
System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line);
Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line));
- if (Strings::case_insensitive_ascii_find(ec_data.output, expected_architecture) == ec_data.output.end())
+ const std::string& s = ec_data.output;
+
+ for (size_t start, end, idx = s.find(machine_string_scan); idx != std::string::npos; idx = s.find(machine_string_scan, end))
{
- binaries_with_invalid_architecture.push_back({f, ec_data.output});
+ // Skip the space directly in front of "machine" and find the previous one. Get the index of the char after it.
+ // Go no further than a newline
+ start = std::max(s.find_last_of('\n', idx - 2) + 1, s.find_last_of(' ', idx - 2) + 1);
+
+ // Find the first close-parenthesis. Get the index of the char after it
+ // Go no futher than a newline
+ end = std::min(s.find_first_of('\n', idx) + 1, s.find_first_of(')', idx) + 1);
+
+ std::string machine_line(s.substr(start, end - start));
+
+ if (Strings::case_insensitive_ascii_find(machine_line, expected_architecture) != machine_line.end())
+ {
+ binaries_with_no_architecture.erase(f);
+ }
+ else
+ {
+ binaries_with_invalid_architecture.push_back({f, machine_line});
+ break; // If one erroneous entry is found, we can abort this file
+ }
}
}
@@ -299,7 +327,20 @@ namespace vcpkg
for (const file_and_arch& b : binaries_with_invalid_architecture)
{
System::println(" %s", b.file.generic_string());
- System::println("Expected %s, but was:\n %s", expected_architecture, b.actual_arch);
+ System::println("Expected %s, but was: %s", expected_architecture, b.actual_arch);
+ }
+ System::println("");
+
+ return lint_status::ERROR;
+ }
+
+ if (!binaries_with_no_architecture.empty())
+ {
+ System::println(System::color::warning, "Unable to detect architecture in the following files:");
+ System::println("");
+ for (const fs::path& b : binaries_with_no_architecture)
+ {
+ System::println(" %s", b.generic_string());
}
System::println("");
diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp
index 4dc37857d..cc7080069 100644
--- a/toolsrc/src/vcpkg_System.cpp
+++ b/toolsrc/src/vcpkg_System.cpp
@@ -90,20 +90,20 @@ namespace vcpkg {namespace System
return ret;
}
- void Stopwatch::start()
+ void Stopwatch2::start()
{
static_assert(sizeof(start_time) == sizeof(LARGE_INTEGER), "");
QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER*>(&start_time));
}
- void Stopwatch::stop()
+ void Stopwatch2::stop()
{
QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER*>(&end_time));
QueryPerformanceFrequency(reinterpret_cast<LARGE_INTEGER*>(&freq));
}
- double Stopwatch::microseconds() const
+ double Stopwatch2::microseconds() const
{
return (reinterpret_cast<const LARGE_INTEGER*>(&end_time)->QuadPart -
reinterpret_cast<const LARGE_INTEGER*>(&start_time)->QuadPart) * 1000000.0 / reinterpret_cast<const LARGE_INTEGER*>(&freq)->QuadPart;
diff --git a/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj b/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj
index d5e68fde3..218a826ad 100644
--- a/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj
+++ b/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj
@@ -120,6 +120,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
+ <ClCompile Include="..\src\Stopwatch.cpp" />
<ClCompile Include="..\src\vcpkg_Checks.cpp" />
<ClCompile Include="..\src\vcpkg_Files.cpp" />
<ClCompile Include="..\src\vcpkg_Strings.cpp" />
@@ -128,6 +129,7 @@
<ItemGroup>
<ClInclude Include="..\include\expected.h" />
<ClInclude Include="..\include\opt_bool.h" />
+ <ClInclude Include="..\include\Stopwatch.h" />
<ClInclude Include="..\include\vcpkg_Checks.h" />
<ClInclude Include="..\include\vcpkg_Files.h" />
<ClInclude Include="..\include\vcpkg_Graphs.h" />
diff --git a/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj.filters b/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj.filters
index ae747d687..4d40bfbe2 100644
--- a/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj.filters
+++ b/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj.filters
@@ -27,6 +27,9 @@
<ClCompile Include="..\src\vcpkg_Files.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\src\Stopwatch.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\vcpkg_Checks.h">
@@ -56,5 +59,8 @@
<ClInclude Include="..\include\vcpkg_Sets.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\include\Stopwatch.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
</Project> \ No newline at end of file