Skip to content

Commit

Permalink
build: Add support for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
varungandhi-src committed Apr 6, 2023
1 parent 9e9cd72 commit 1cdd696
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 7 deletions.
14 changes: 7 additions & 7 deletions indexer/os/BUILD
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# NOTE(ref: based-on-sorbet): Based on Sorbet's common/os package.
cc_library(
name = "os",
srcs = [
"Os.h",
"Os.cc",
] + select({
"@platforms//os:linux": ["Linux.cc"],
"@platforms//os:macos": ["macOS.cc"],
}),
srcs = glob(
[
"*.cc",
"*.h",
],
allow_empty = False,
),
hdrs = [
"Os.h",
],
Expand Down
49 changes: 49 additions & 0 deletions indexer/os/Windows.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#ifdef _WIN32

#include <string>

#include <libloaderapi.h>
#include <processthreadsapi.h>
#include <windef.h>
#include <windows.h>

#include "indexer/os/Os.h"

namespace scip_clang {

std::string exec(std::string cmd) {
// FIXME(def: windows-support) Implement this if needed for addr2line
return "";
}

std::string addr2line(std::string_view programName, void const *const *addr,
int count) {
// FIXME(def: windows-support)
return "";
}

std::string getProgramName() {
char buf[MAX_PATH];
GetModuleFileNameA(nullptr, buf, MAX_PATH);
return buf;
}

bool setCurrentThreadName(std::string_view name) {
std::wstring wstr = std::wstring(name.begin(), name.end());
SetThreadDescription(GetCurrentThread(), wstr.c_str());
return true;
}

bool amIBeingDebugged() {
// FIXME(def: windows-support)
return false;
}

bool stopInDebugger() {
// FIXME(def: windows-support)
return false;
}

} // namespace scip_clang

#endif

0 comments on commit 1cdd696

Please sign in to comment.