aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp/blaze_util_windows.cc
Commit message (Collapse)AuthorAge
...
* Bazel client, Windows: fix compilation for MSVCGravatar Laszlo Csomor2017-02-03
| | | | | | | | | Fixes https://github.com/bazelbuild/bazel/issues/2479 See https://github.com/bazelbuild/bazel/issues/2107 -- PiperOrigin-RevId: 146454894 MOS_MIGRATED_REVID=146454894
* Bazel client, Windows: impl. GetTerminalColumnsGravatar László Csomor2017-02-02
| | | | | | | | -- Change-Id: Ib13e22c6a47084d4f9b9ab2d9505b334870212fe Reviewed-on: https://cr.bazel.build/8573 PiperOrigin-RevId: 146363390 MOS_MIGRATED_REVID=146363390
* Bazel client, Windows: use CreateFileWGravatar Laszlo Csomor2017-01-18
| | | | | | | | | | | | | | | | | | | | | | Use CreateFileW in blaze_util_windows.cc when opening the "jvm.out" file. This allows supporting long paths. Also use AsWindowsPathWithUncPrefix instead of just AsWindowsPath plus manually adding the UNC prefix. Also fix a compilation error in file_windows_test.cc, I'm surprised the CI system didn't catch this, maybe we aren't running this test there. See https://github.com/bazelbuild/bazel/issues/2107 See https://github.com/bazelbuild/bazel/issues/2181 -- PiperOrigin-RevId: 144813245 MOS_MIGRATED_REVID=144813245
* Bazel client, Windows: implement envvar handlingGravatar Laszlo Csomor2017-01-18
| | | | | | | | | | | Implement GetEnv, SetEnv, UnsetEnv, and use it in some locations, plus add some tests. See https://github.com/bazelbuild/bazel/issues/2107 -- PiperOrigin-RevId: 144808435 MOS_MIGRATED_REVID=144808435
* Bazel client: split CanAccess to specific methodsGravatar Laszlo Csomor2017-01-11
| | | | | | | | | | | | | | The new methods (CanReadFile, CanExecuteFile, CanAccessDirectory) are a lot easier to implement on Windows than a generic CanAccess. On POSIX these methods are just a wrapper around the now static-visible CanAccess(). See https://github.com/bazelbuild/bazel/issues/2107 -- PiperOrigin-RevId: 144176710 MOS_MIGRATED_REVID=144176710
* Windows: implement and use AsShortWindowsPathGravatar Laszlo Csomor2017-01-10
| | | | | | | | | | | | | | | | | | Because CreateProcessW doesn't support long paths, not even with the "\\?\" prefix [1], we need to convert long paths to short ones to spawn processes. This change implements the corresponding function and uses it in blaze_util_windows. [1] https://github.com/bazelbuild/bazel/issues/2181#issuecomment-270696173 See https://github.com/bazelbuild/bazel/issues/2107 See https://github.com/bazelbuild/bazel/issues/2181 -- PiperOrigin-RevId: 144062404 MOS_MIGRATED_REVID=144062404
* blaze_util_windows: use ostringstream to build cmdGravatar Laszlo Csomor2017-01-09
| | | | | | | | | | | Use std::ostringstream instead of string concats when building a command line, for more efficiency. See https://github.com/bazelbuild/bazel/issues/2107 -- PiperOrigin-RevId: 143947880 MOS_MIGRATED_REVID=143947880
* Revert "blaze_util_windows: use CreateFileW" Gravatar John Cater2017-01-06
| | | | | | | | | | | | This is for #2344. This reverts commit 116d039ccb49ec71c2ea9626d8a0a0aee5cbabc0. -- Change-Id: I4a8bc697c608c0f61af5bef8ff41faea96424ac3 Reviewed-on: https://cr.bazel.build/8095 PiperOrigin-RevId: 143708707 MOS_MIGRATED_REVID=143708707
* Use _ instead of $ on Windows to avoid shell expansion issues. Gravatar John Cater2017-01-05
| | | | | | | | | | Fixes #2342. -- Change-Id: I4e6511a5d65a534757bdb6b4b05c9e1bd43ad2d8 Reviewed-on: https://cr.bazel.build/8093 PiperOrigin-RevId: 143695463 MOS_MIGRATED_REVID=143695463
* blaze_util_windows: use CreateFileWGravatar Laszlo Csomor2017-01-05
| | | | | | | | | See https://github.com/bazelbuild/bazel/issues/2107 See https://github.com/bazelbuild/bazel/issues/2181 -- PiperOrigin-RevId: 143655738 MOS_MIGRATED_REVID=143655738
* blaze_util_windows: remove AsWpathGravatar Laszlo Csomor2017-01-05
| | | | | | | | Use blaze_util::AsWindowsPath instead. -- PiperOrigin-RevId: 143652527 MOS_MIGRATED_REVID=143652527
* Bazel client: implement PathExists on WindowsGravatar Laszlo Csomor2017-01-05
| | | | | | | | | | | | | | | | | | | | Checking if a path exists is surprisingly hard on Windows. The most convenient API functions are PathFileExists and GetFileAttributes but neither of them follows junctions. To check if a junction is dangling, we have to resolve it all the way. This change adds a JunctionResolver class to file_windows, which can resolve junctions (if they aren't dangling) and non-junctions (in this case just checks their existence). See https://github.com/bazelbuild/bazel/issues/2107 See https://github.com/bazelbuild/bazel/issues/2181 -- PiperOrigin-RevId: 143645274 MOS_MIGRATED_REVID=143645274
* Bazel client: add comments, delete dead codeGravatar Laszlo Csomor2016-12-22
| | | | | | | | | | In this change: - add TODOs and comments - inline blaze::ExitImmediately at call sites -- PiperOrigin-RevId: 142671757 MOS_MIGRATED_REVID=142671757
* Bazel client: generalize path handlingGravatar Laszlo Csomor2016-12-19
| | | | | | | | | | | | | | Use/implement utility methods to join paths, check if they are the root directory or are absolute, etc. Doing so (instead of say checking if a path starts with "/") allows for correct behavior on Windows. See https://github.com/bazelbuild/bazel/issues/2107 -- PiperOrigin-RevId: 142446027 MOS_MIGRATED_REVID=142446027
* Bazel client, Windows: implement GetUserNameGravatar Laszlo Csomor2016-12-15
| | | | | | | | See https://github.com/bazelbuild/bazel/issues/2107 -- PiperOrigin-RevId: 142128121 MOS_MIGRATED_REVID=142128121
* Bazel client: get rid of RunProgramGravatar Laszlo Csomor2016-12-15
| | | | | | | | | | | | | | | | | | Move GetJvmVersion from blaze_util to blaze_util_platform, and remove the RunProgram declaration from blaze_util.h. Since GetJvmVersion is the only user of RunProgram this is safe to do, and allows making RunProgram static as well as simplifying its implementation on Windows, while also changing it to use CreateProcessW instead of CreateProcessA. See https://github.com/bazelbuild/bazel/issues/2181 -- PiperOrigin-RevId: 142122045 MOS_MIGRATED_REVID=142122045
* blaze_util_windows: use some widechar Win32 APIGravatar Laszlo Csomor2016-12-15
| | | | | | | | | | | | | | | | | | | | | | | | | In this change: - implement PrintErrorW (copy of PrintError but uses FormatMessageW) - use GetModuleFileNameW in GetSelfPath and do not worry about UNC paths, we'll automatically handle them in the future when we use widechar functions everywhere. Until then, if a path happens to have the "\\?\" prefix and that causes an error, we won't be worse off than today; today we just call `pdie` - use GetTempPathW in GetOutputRoot; in theory this might also return an UNC path but again that shouldn't be a problem - add comments for the arguments of CreateFileA and CreateProcessA calls, to make the code a bit more readable See https://github.com/bazelbuild/bazel/issues/2181 -- PiperOrigin-RevId: 142118854 MOS_MIGRATED_REVID=142118854
* move MakeDirectories() into file_platform.hGravatar Thiago Farina2016-12-07
| | | | | | | | | | | | | | This way we can remove the dependency on blaze_util (which is Bazel's client specific) from singlejar. This work was made possible by commit 49970e0136d0: ("Bazel client: platform-specific {Read,Write}File"). -- Change-Id: I6e95fb9119a271e4d48cbe2eefc1d5354ee188aa Reviewed-on: https://cr.bazel.build/7650 PiperOrigin-RevId: 141294165 MOS_MIGRATED_REVID=141294165
* Windows: explicitly use ASCII-version of Win32 APIGravatar Laszlo Csomor2016-12-05
| | | | | | | | | | | This way it's easier to find the functions we need to change to widechar version. See https://github.com/bazelbuild/bazel/issues/2181 -- PiperOrigin-RevId: 141043389 MOS_MIGRATED_REVID=141043389
* Bazel client: make it compile with MSVCGravatar Laszlo Csomor2016-11-28
| | | | | | | | | | | | | | | | | | | | | | | | | Final modifications to the Bazel client code so we can compile //src/main/cpp/...:all using MSVC. Yay! We still have some dependencies that don't compile with MSVC, namely Ijar, build-runfiles, process-wrapper, and process-tools. Still, this change is a huge success, because now we can add regression tests to prevent people from introducing breaking changes to the client that would break Windows/MSVC compilation. It's important to point out that we can only build this library for now, most functions in file_windows.cc and blaze_util_windows.cc have an empty body (they just call `pdie`). See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=140348351
* Bazel client: more platform-specific logicGravatar Laszlo Csomor2016-11-28
| | | | | | | | | | Move terminal-querying functions and GetUserName from blaze_util.cc into blaze_util_<platform>. See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=140346402
* Bazel client: platform-specific {Read,Write}FileGravatar Laszlo Csomor2016-11-28
| | | | | | | | | | | | | | | | Move blaze::ReadFile and blaze::WriteFile to file.h and file_platform.h (thus into the blaze_util namespace), and update references. This allows us to implement these methods in a platform-specific way. Also move UnlinkPath. See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=140328273
* Bazel client: platform-dependent lock handlingGravatar Laszlo Csomor2016-11-28
| | | | | | | | | | Move blaze::AcquireLock and blaze::ReleaseLock into blaze_util_<platform>. See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=140200355
* Bazel client: platform-dependent signal handlingGravatar Laszlo Csomor2016-11-24
| | | | | | | | | | Move the signal handling code from blaze.cc into blaze_util_<platform>. See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=140134781
* Bazel client: fix compilation on WindowsGravatar Laszlo Csomor2016-11-24
| | | | | | | | | Add "#include <fcntl.h>". See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=140131127
* Bazel client: depend less on <unistd.h>Gravatar Laszlo Csomor2016-11-24
| | | | | | | | | | | | | | | | | We moved most of the functionality (e.g. _exit, SetupStreams) into blaze_util_<platform> or changed to alternative functions (fwrite + stderr instead of write + STDERR_HANDLE). This change brings us closer to compiling blaze.cc with MSVC. We still have to move signal handlers out of blaze.cc as well as code dealing with the server PID. See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=140123945
* Bazel client: reduce dependency on POSIX APIGravatar Laszlo Csomor2016-11-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can now compile blaze_util_windows.cc with MSVC, yay! (when building //src:bazel --cpu=x64_windows_msvc -k). There are a lot of #ifdef's and TODOs so this is a modest victory for now. In this change: - change blaze::MakeDirectories to return bool instead of int, since that's how it was used anyway, and to expect the permission mask as unsigned int instead of mode_t, since the former is good enough and compatible with mode_t on POSIX while mode_t is not defined on Windows - move blaze::MakeDirectories into blaze_util_<platform> - implement envvar-handling in blaze_util_<platform> and use it everywhere See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=139887503
* Bazel client: reduce dependency on <unistd.h>Gravatar Laszlo Csomor2016-11-18
| | | | | | | | | | | | | | | | | | In this change: - rename WriteFileToStreamOrDie to WriteFileToStderrOrDie (since we only ever used it for stderr) - replace open/write/read/close operations with blaze_util::ReadFile/WriteFile - wrap ToString(getpid()) in a utility function - move SyncFile to file_<platform> -- MOS_MIGRATED_REVID=139560397
* Bazel client: no more `stat` usageGravatar Laszlo Csomor2016-11-17
| | | | | -- MOS_MIGRATED_REVID=139436876
* Bazel client: platform-dependent GetHashedBaseDirGravatar Laszlo Csomor2016-11-16
| | | | | | | | | | Move the hashed base directory computation logic into blaze_util_<platform>.cc in order to clean up the call site and move platform-dependent code out the client's main file. -- MOS_MIGRATED_REVID=139319487
* Windows, bazel client: compile more with MSVCGravatar Laszlo Csomor2016-11-09
| | | | | | | | | | | | In this commit: - update GetOutputRoot with a MSVC-specific code path, plus add more env vars to check for the temp directory path in the MSYS-specific code path - add error handling to GetSelfPath -- MOS_MIGRATED_REVID=138611621
* Bazel, Windows: implement a precise clockGravatar Laszlo Csomor2016-11-08
The simplest clock on Windows is timeGetTime(), but its precision is ~15ms, which is not good enough. This commit implements blaze_util::WindowsClock that wraps a more precise clock, accessible through QueryPerformanceCounter. This change also deletes blaze_util_msvc.cc which was recently forked off blaze_util_mingw.cc, because forking didn't turn out to be necessary. As part of this merging, I also renamed the file to blaze_util_windows.cc -- MOS_MIGRATED_REVID=138506308