Skip to content

Commit

Permalink
Do not link if compilation was not successful
Browse files Browse the repository at this point in the history
  • Loading branch information
crosire committed Dec 8, 2018
1 parent a8325d3 commit 23f4a4f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 10 additions & 4 deletions source/blink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ blink::application::application() :

if (path.find("c:\\program files") == std::string::npos &&
path.find("f:\\dd") == std::string::npos &&
path.find("d:\\agent\\_work\\3\\s") == std::string::npos &&
path.find("d:\\agent\\_work") == std::string::npos &&
path.rfind(".cpp") != std::string::npos)
{
print(" Found source file: " + path);
Expand Down Expand Up @@ -254,9 +254,15 @@ void blink::application::run()
print(line.c_str());
}

if (message.find("compile complete") != std::string::npos)
const size_t offset = message.find("compile complete");
if (offset != std::string::npos)
{
print("Finished compiling \"" + _compiled_module_file + "\".");
const std::string exit_code = message.substr(offset + 17 /* strlen("compile complete ") */, message.find('\n', offset) - offset - 18);

print("Finished compiling \"" + _compiled_module_file + "\" with code " + exit_code + ".");

if (exit_code != "0") // Do not link if compilation was not successful
_compiled_module_file.clear();

_executing = false;
}
Expand Down Expand Up @@ -303,7 +309,7 @@ void blink::application::run()
cmdline += " /Fo\"" + _compiled_module_file + "\""; // Output object file
cmdline += " \"" + path + "\""; // Input source code file

cmdline += "\necho compile complete\n"; // Message used to confirm that compile finished in message loop above
cmdline += "\necho compile complete %errorlevel%\n"; // Message used to confirm that compile finished in message loop above

// Execute compiler command line
WriteFile(_compiler_stdin, cmdline.c_str(), static_cast<DWORD>(cmdline.size()), &size, nullptr);
Expand Down
6 changes: 5 additions & 1 deletion source/file_watcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ blink::file_watcher::file_watcher(const std::string &path) : _path(path), _buffe
_handle = CreateFileA(path.c_str(), FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, nullptr);
_completion_handle = CreateIoCompletionPort(_handle, nullptr, reinterpret_cast<ULONG_PTR>(_handle), 1);

OVERLAPPED overlapped = { };
OVERLAPPED overlapped = {};
ReadDirectoryChangesW(_handle, _buffer.get(), buffer_size, TRUE, FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_FILE_NAME, nullptr, &overlapped, nullptr);
}
blink::file_watcher::~file_watcher()
Expand Down Expand Up @@ -51,6 +51,10 @@ bool blink::file_watcher::check(std::vector<std::string> &modifications)
record = reinterpret_cast<FILE_NOTIFY_INFORMATION *>(reinterpret_cast<BYTE *>(record) + record->NextEntryOffset);
}

// Avoid duplicated notifications
// TODO: Find a proper solution
Sleep(100);

overlapped->hEvent = nullptr;

ReadDirectoryChangesW(_handle, _buffer.get(), buffer_size, TRUE, FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_FILE_NAME, nullptr, overlapped, nullptr);
Expand Down

0 comments on commit 23f4a4f

Please sign in to comment.