aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp/blaze_util_posix.cc
Commit message (Collapse)AuthorAge
* 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
* 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
* 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: mock out read/write callsGravatar Laszlo Csomor2016-11-28
| | | | | | | | | | | | | | | | | | | | | | | | | Make blaze::ReadFileDescriptor(int fd, ...) and blaze::WriteFile(int fd, ...) platform-independent by mocking out the read(2) and write(2) calls. Also rename ReadFileDescriptor to ReadFrom and introduce a new WriteTo method that encapsulates WriteFile's prior logic. In particular these functions now take a read_func/write_func function argument instead of a file descriptor, so the read(2)/write(2) calls can be mocked out. This allows us to use these functions on Windows too, where read(2)/write(2) are not implemented, and we can inject a different read_func/write_func. See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=140195973
* 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: 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: delete and don't use the server.pidGravatar Laszlo Csomor2016-11-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upon startup the Bazel client checks if there's already a running server process and if so then connects to it. We achieve this by checking if there's a symlink in the server directory called served.pid, pointing to /proc/<server_pid>. If so, we read the symlink's target and extract the PID; otherwise we check if there's a file in the server's directory (server.pid.txt) that contains the PID and read it from there. Since the PID file is always there, we don't need the symlink, plus on Windows we don't support symlinks anyway, which is the real motivation for this change. Just ignoring the PID symlink is not enough, we need to actively delete it so that switching between Bazel versions (one that writes a PID symlink and one that doesn't) won't result in having a symlink and PID file with different PIDs and clients trying to kill the wrong server process / not killing one that they should. See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=140117287
* 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
* Global cleanup change.Gravatar Googler2016-11-11
| | | | | -- MOS_MIGRATED_REVID=138816624
* Bazel client: wrap some POSIX functionsGravatar Laszlo Csomor2016-11-10
| | | | | | | | | | | | | | This change: - starts using blaze_util::CanAccess and blaze_util::PathExists instead of access(2) - implements and starts using blaze_util::GetCwd instead of getcwd(2) - implements and starts using blaze_util::ChangeDirectory instead of chdir(2) - adds tests for the new wrapper methods -- MOS_MIGRATED_REVID=138750297
* Reap the direct child process when double-forking to daemonize.Gravatar Lukacs Berki2016-10-28
| | | | | | | Otherwise, it'd only be reaped by init when the client terminates. -- MOS_MIGRATED_REVID=137502970
* cpp: convert ServerPidFile() and ServerPidSymlink() into constantsGravatar Thiago Farina2016-09-21
| | | | | | | | | | | These two functions have no logic inside it, they just return a string, and a string that does not change, so they might be better expressed as real C/C++ constants. This might as well generate some better (and less) code anyway. -- Change-Id: I78673c537c17c2665a74c5778e45a4d41a5f7b50 Reviewed-on: https://bazel-review.googlesource.com/#/c/6114 MOS_MIGRATED_REVID=133805201
* More client fixes:Gravatar Lukacs Berki2016-09-13
| | | | | | | | - Use an explicit cast to void to tell the compiler that we are intentionally ignoring return values. - Delete the unused function GetPeerProcessId() -- MOS_MIGRATED_REVID=132970162
* Placate the compiler.Gravatar Sasha Smundak2016-07-26
| | | | | | | | | | | | Address the following warnings from the compiler: * "control reaches end of non-void function [-Wreturn-type]" * "dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]" * "ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result [-Wunused-result]" * "ignoring return value of 'int ftruncate(int, __off_t)', declared with attribute warn_unused_result [-Wunused-result]" * "ignoring return value of 'int dup(int)', declared with attribute warn_unused_result [-Wunused-result]" -- MOS_MIGRATED_REVID=128375065
* Fixed repository.which() on WindowsGravatar Yun Peng2016-07-15
| | | | | | | | | Also removed previous workaround in cc_configure.bzl -- Change-Id: I6dcd039fc5e18af8f2d21969641d6bbd05c8badc Reviewed-on: https://bazel-review.googlesource.com/#/c/4034 MOS_MIGRATED_REVID=127518922
* Added include requirements for errno, printf, getenvGravatar Douglas Dawson2016-07-14
| | | | | | | | Closes #1419. -- Reviewed-on: https://github.com/bazelbuild/bazel/pull/1419 MOS_MIGRATED_REVID=127326203
* Replace override declarations with "virtual" so that we build on Ubuntu 12.04 .Gravatar Lukacs Berki2016-06-07
| | | | | | | Fixes #1336. -- MOS_MIGRATED_REVID=124231262
* Linux-specific: check if the stray server process we are about to kill -9 is ↵Gravatar Lukacs Berki2016-05-02
| | | | | | | | | | | actually a server process. This should be implemented for other OSes, too, but OS X seems to lack a procfs and it's not clear how to discover anything about a process based on its PID and of course, Windows is a wholly different cup of tea. More work for #930. -- MOS_MIGRATED_REVID=121262673
* Various cleanups and refactorings in the client:Gravatar Lukacs Berki2016-05-02
| | | | | | | | | | | | - Made the control flow much simpler and more understandable - Added some documentation about the interplay of the client and the server - Abstracted out POSIX mechanisms from blaze.cc so that they can be implemented properly on Windows - Added assertions that the methods on BlazeServer are called when they should be Polish for #930. -- MOS_MIGRATED_REVID=121256601
* Make compilation on Windows work again.Gravatar Lukacs Berki2016-04-28
| | | | | | | | | Fixes #1205 . -- Change-Id: Ifd35cf141737f755b499a786cf9663153cd2cf53 Reviewed-on: https://bazel-review.googlesource.com/#/c/3513/ MOS_MIGRATED_REVID=120998788
* Use the Win32 API to create and query junctions in the C++ client.Gravatar Lukacs Berki2016-04-28
| | | | | | | | | This change makes it possible to build Bazel with itself in server mode. Progress towards #930 . Does not completely fix it because there are still a bunch of issues that need to be taken care of, but it's usable. -- MOS_MIGRATED_REVID=120994369
* Use native process control on Windows to launch subprocesses.Gravatar Lukacs Berki2016-04-27
| | | | | | | | | This is necessary because msys2 signals don't work on native Win32 processes, for example, java.exe . Forcefully terminating the process still doesn't work because it uses signals. It's a-coming. -- MOS_MIGRATED_REVID=120903711
* Windows: use junctions to link to installation directory.Gravatar Dmitry Lomov2016-02-19
| | | | | | | | | | Win32 have no good API for that (basically we need to resort to ioctl call). Shelling out to mklink. Needed for #276. -- MOS_MIGRATED_REVID=115040968
* Rationalize copyright headersGravatar Damien Martin-Guillerez2015-09-25
| | | | | | | | | | | The headers were modified with `find . -type f -exec 'sed' '-Ei' 's|Copyright 201([45]) Google|Copyright 201\1 The Bazel Authors|' '{}' ';'` And manual edit for not Google owned copyright. Because of the nature of ijar, I did not modified the header of file owned by Alan Donovan. The list of authors were extracted from the git log. It is missing older Google contributors that can be added on-demand. -- MOS_MIGRATED_REVID=103938715
* Avoid command line argument mangling on Windows.Gravatar Dmitry Lomov2015-08-12
exec(3) under mingw converts every command line argument that looks like Unix path into Windows path when executing non-mingw images (criteria for non-mingw image is that the image does not depend on msys-<version>.dll). This affects bazel labels (`//foo:bar` becomes `/foo:bar` for example). This CL: 1) Replaces usage of execv(3) with Windows-native CreateProcess. 2) Converts all command line arguments that are indeed paths into Windows paths. -- MOS_MIGRATED_REVID=100386350