Created
January 5, 2019 19:08
-
-
Save tankorsmash/94c5627af27ccf786a18017275481394 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/blink.vcxproj b/blink.vcxproj | |
index 9b7d33d..ca98f43 100644 | |
--- a/blink.vcxproj | |
+++ b/blink.vcxproj | |
@@ -21,7 +21,7 @@ | |
<PropertyGroup Label="Globals"> | |
<ProjectGuid>{188B7270-046B-476D-A32D-34390DA1A885}</ProjectGuid> | |
<Keyword>Win32Proj</Keyword> | |
- <WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion> | |
+ <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion> | |
</PropertyGroup> | |
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | |
<PropertyGroup Label="Configuration"> | |
diff --git a/source/blink.cpp b/source/blink.cpp | |
index 8cc5791..279978d 100644 | |
--- a/source/blink.cpp | |
+++ b/source/blink.cpp | |
@@ -11,16 +11,16 @@ | |
#include <unordered_map> | |
#include <Windows.h> | |
-static std::filesystem::path common_path(const std::vector<std::filesystem::path> &paths) | |
+static std::experimental::filesystem::path common_path(const std::vector<std::experimental::filesystem::path> &paths) | |
{ | |
if (paths.empty()) | |
- return std::filesystem::path(); | |
+ return std::experimental::filesystem::path(); | |
- std::filesystem::path all_common_path = paths[0].parent_path(); | |
+ std::experimental::filesystem::path all_common_path = paths[0].parent_path(); | |
for (auto it = paths.begin() + 1; it != paths.end(); ++it) { | |
- std::filesystem::path common_path; | |
- std::filesystem::path file_directory = it->parent_path(); | |
+ std::experimental::filesystem::path common_path; | |
+ std::experimental::filesystem::path file_directory = it->parent_path(); | |
for (auto it2 = file_directory.begin(), it3 = all_common_path.begin(); it2 != file_directory.end() && it3 != all_common_path.end() && *it2 == *it3; ++it2, ++it3) { | |
common_path /= *it2; | |
} | |
@@ -130,11 +130,11 @@ void blink::application::run() | |
pdb.read_object_files(_object_files); | |
pdb.read_source_files(_source_files); | |
- std::vector<std::filesystem::path> cpp_files; | |
+ std::vector<std::experimental::filesystem::path> cpp_files; | |
for (size_t i = 0; i < _object_files.size(); ++i) | |
{ | |
- if (std::error_code ec; _object_files[i].extension() != ".obj" || !std::filesystem::exists(_object_files[i], ec)) | |
+ if (std::error_code ec; _object_files[i].extension() != ".obj" || !std::experimental::filesystem::exists(_object_files[i], ec)) | |
continue; | |
const auto it = std::find_if(_source_files[i].begin(), _source_files[i].end(), | |
@@ -242,7 +242,7 @@ void blink::application::run() | |
for (auto info = reinterpret_cast<FILE_NOTIFY_INFORMATION *>(watcher_buffer); first_notification || info->NextEntryOffset != 0; | |
first_notification = false, info = reinterpret_cast<FILE_NOTIFY_INFORMATION *>(reinterpret_cast<BYTE *>(info) + info->NextEntryOffset)) | |
{ | |
- std::filesystem::path object_file, source_file = | |
+ std::experimental::filesystem::path object_file, source_file = | |
_source_dir / std::wstring(info->FileName, info->FileNameLength / sizeof(WCHAR)); | |
// Ignore changes to files that are not C++ source files | |
@@ -298,7 +298,7 @@ void blink::application::run() | |
} | |
} | |
-std::string blink::application::build_compile_command_line(const std::filesystem::path &source_file, std::filesystem::path &object_file) | |
+std::string blink::application::build_compile_command_line(const std::experimental::filesystem::path &source_file, std::experimental::filesystem::path &object_file) | |
{ | |
Sleep(100); // Prevent file system error in the new few code lines | |
@@ -307,7 +307,7 @@ std::string blink::application::build_compile_command_line(const std::filesystem | |
// Check if this source file already exists in the application in which case we can read some information from the original object file | |
if (const auto it = std::find_if(_source_files.begin(), _source_files.end(), [&source_file](const auto &module_files) { | |
return std::find_if(module_files.begin(), module_files.end(), [&source_file](const auto &file) { | |
- std::error_code ec; return std::filesystem::equivalent(source_file, file, ec); }) != module_files.end(); | |
+ std::error_code ec; return std::experimental::filesystem::equivalent(source_file, file, ec); }) != module_files.end(); | |
}); it != _source_files.end()) | |
{ | |
object_file = _object_files[std::distance(_source_files.begin(), it)]; | |
diff --git a/source/blink.hpp b/source/blink.hpp | |
index a98cbc7..4397d8f 100644 | |
--- a/source/blink.hpp | |
+++ b/source/blink.hpp | |
@@ -26,15 +26,15 @@ namespace blink | |
application(); | |
void run(); | |
- bool link(const std::filesystem::path &object_file); | |
+ bool link(const std::experimental::filesystem::path &object_file); | |
- std::string build_compile_command_line(const std::filesystem::path &source_file, std::filesystem::path &object_file); | |
+ std::string build_compile_command_line(const std::experimental::filesystem::path &source_file, std::experimental::filesystem::path &object_file); | |
private: | |
uint8_t *_image_base = nullptr; | |
- std::filesystem::path _source_dir; | |
- std::vector<std::filesystem::path> _object_files; | |
- std::vector<std::vector<std::filesystem::path>> _source_files; | |
+ std::experimental::filesystem::path _source_dir; | |
+ std::vector<std::experimental::filesystem::path> _object_files; | |
+ std::vector<std::vector<std::experimental::filesystem::path>> _source_files; | |
std::unordered_map<std::string, void *> _symbols; | |
}; | |
} | |
diff --git a/source/blink_linker.cpp b/source/blink_linker.cpp | |
index 6477b92..d47165c 100644 | |
--- a/source/blink_linker.cpp | |
+++ b/source/blink_linker.cpp | |
@@ -8,6 +8,7 @@ | |
#include <assert.h> | |
#include <Windows.h> | |
#include <TlHelp32.h> | |
+#include <sstream> | |
static void write_jump(uint8_t *address, const uint8_t *jump_target) | |
{ | |
@@ -120,15 +121,20 @@ struct thread_scope_guard : scoped_handle | |
} | |
}; | |
-bool blink::application::link(const std::filesystem::path &path) | |
+bool blink::application::link(const std::experimental::filesystem::path &path) | |
{ | |
thread_scope_guard _scope_guard_; | |
- const scoped_handle file = CreateFileW(path.native().c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); | |
+ std::wstring path_string = path.native(); | |
+ auto path_cstr = path.native().c_str(); | |
+ const scoped_handle file = CreateFileW(path_cstr, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); | |
if (file == INVALID_HANDLE_VALUE) | |
{ | |
- print("Failed to open input file."); | |
+ std::wstringstream ss; | |
+ ss << "Failed to open input file. " << path_string; | |
+ auto qwe = ss.str(); | |
+ //print(ss.str()); | |
return false; | |
} | |
diff --git a/source/pdb_reader.cpp b/source/pdb_reader.cpp | |
index a20b542..7aa813d 100644 | |
--- a/source/pdb_reader.cpp | |
+++ b/source/pdb_reader.cpp | |
@@ -215,7 +215,7 @@ void blink::pdb_reader::read_symbol_table(uint8_t *image_base, std::unordered_ma | |
}, 4); | |
} | |
-void blink::pdb_reader::read_object_files(std::vector<std::filesystem::path> &object_files) | |
+void blink::pdb_reader::read_object_files(std::vector<std::experimental::filesystem::path> &object_files) | |
{ | |
stream_reader stream(msf_reader::stream(3)); | |
@@ -231,13 +231,13 @@ void blink::pdb_reader::read_object_files(std::vector<std::filesystem::path> &ob | |
const auto module_name = stream.read_string(); | |
const auto obj_file_name = stream.read_string(); // Contains the name of the ".lib" if this object file is part of a library | |
- object_files.push_back(module_name); | |
+ object_files.push_back(std::string(module_name)); | |
stream.align(4); | |
} | |
} | |
-void blink::pdb_reader::read_source_files(std::vector<std::vector<std::filesystem::path>> &source_files) | |
+void blink::pdb_reader::read_source_files(std::vector<std::vector<std::experimental::filesystem::path>> &source_files) | |
{ | |
stream_reader stream(msf_reader::stream(3)); | |
@@ -270,12 +270,12 @@ void blink::pdb_reader::read_source_files(std::vector<std::vector<std::filesyste | |
for (uint32_t i = 0; i < module_num_source_files[k]; ++i) | |
{ | |
stream.seek(offset + file_name_offsets[module_file_offsets[k] + i]); | |
- source_files[k].push_back(stream.read_string()); | |
+ source_files[k].push_back(std::string(stream.read_string())); | |
} | |
} | |
} | |
-void blink::pdb_reader::read_link_info(std::filesystem::path &cwd, std::string &cmd) | |
+void blink::pdb_reader::read_link_info(std::experimental::filesystem::path &cwd, std::string &cmd) | |
{ | |
stream_reader stream(this->stream("/LinkInfo")); | |
@@ -285,8 +285,8 @@ void blink::pdb_reader::read_link_info(std::filesystem::path &cwd, std::string & | |
// See https://github.com/Microsoft/microsoft-pdb/blob/master/langapi/include/pdb.h#L500 | |
stream.skip(sizeof(pdb_link_info_header)); | |
- cwd = stream.read_string(); | |
- cmd = stream.read_string(); | |
+ cwd = std::string(stream.read_string()); | |
+ cmd = std::string(stream.read_string()); | |
// Followed by another null-terminated string with all linked libraries | |
} | |
diff --git a/source/pdb_reader.hpp b/source/pdb_reader.hpp | |
index d2d3d9e..dfcf1a2 100644 | |
--- a/source/pdb_reader.hpp | |
+++ b/source/pdb_reader.hpp | |
@@ -70,16 +70,16 @@ namespace blink | |
/// <summary> | |
/// Returns all object file paths that were used to build the application. | |
/// </summary> | |
- void read_object_files(std::vector<std::filesystem::path> &object_files); | |
+ void read_object_files(std::vector<std::experimental::filesystem::path> &object_files); | |
/// <summary> | |
/// Returns all source code file paths that were used to build the application. | |
/// </summary> | |
- void read_source_files(std::vector<std::vector<std::filesystem::path>> &source_files); | |
+ void read_source_files(std::vector<std::vector<std::experimental::filesystem::path>> &source_files); | |
/// <summary> | |
/// Read linker information. | |
/// </summary> | |
- void read_link_info(std::filesystem::path &cwd, std::string &cmd); | |
+ void read_link_info(std::experimental::filesystem::path &cwd, std::string &cmd); | |
/// <summary> | |
/// Returns the hash table of names found in the PDB file. | |
/// </summary> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment