aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp
Commit message (Collapse)AuthorAge
* Bazel client: add blaze_util::IsDevNullGravatar Laszlo Csomor2017-07-25
| | | | | | | | | | | | | | | | | | | | | | Add a method to test if a path is /dev/null (or case-insensitive "NUL" on Windows), and use it in blaze::MakeAbsolute. In this commit: - implement blaze_util::IsDevNull with POSIX and Windows semantics + add tests - blaze::MakeAbsolute calls blaze::ConvertPath on its input to convert MSYS paths on Windows - blaze_util::GetCwdW (thus GetCwd) always returns a lowercase path so that it is deterministic - blaze_util::GetCurrentDrive returns lowercase letter to be consisent with blaze::ConvertPath, which also returns a lowercase path Fixes https://github.com/bazelbuild/bazel/issues/3440 Change-Id: I3af5ba0a033d542fe64a676d67f27472298d1089 PiperOrigin-RevId: 163038503
* Windows: add blaze_util::AsAbsoluteWindowsPathGravatar laszlocsomor2017-07-24
| | | | | | | | | | | Replace blaze_util::AsWindowsPathWithUncPrefix with AsAbsoluteWindowsPath, which always returns an absolute path. Fixes https://github.com/bazelbuild/bazel/issues/2935 RELNOTES: none PiperOrigin-RevId: 162727218
* Windows: blaze_util::ChangeDir. uses short pathsGravatar laszlocsomor2017-07-24
| | | | | | | | | | | | | | The current working directory may not be longer than MAX_PATH, otherwise SetCurrentDirectoryW fails. It may, but should not contain a "\\?\" prefix, otherwise the Java code won't be able to parse it. Therefore convert the path to a 8dot3 style path in blaze_util::ChangeDirectory and use SetCurrentDirectoryA. RELNOTES: none PiperOrigin-RevId: 162720636
* Windows: more robust path handling.Gravatar laszlocsomor2017-07-24
| | | | | | | | | | | | | | | In this change: - add support for absolute-on-current-drive paths (e.g. "\foo", meaning "c:\foo") - report error for relative-on-current-drive paths (e.g. "c:" and "c:foo") - report error for remote Windows paths (e.g. "\\servername\path\on\server") - update blaze_util::AsWindowsPath comments - update tests RELNOTES: none PiperOrigin-RevId: 162719763
* Windows: clean up error reportingGravatar Laszlo Csomor2017-07-20
| | | | | | | | | | | | | | | | | | | In this commit: - remove blaze::PrintError in favor of blaze_util::PrintError - remove Ijar's PrintLastErrorMessage in favor of blaze_util::PrintError - use pdie every time path conversion fails, because that indicates a fatal error (bad user input for a path flag, or downright bug) - remove explicitly printing GetLastErrror; pdie and PrintError do it already - unify the pdie/PrintError message formats Fixes https://github.com/bazelbuild/bazel/issues/2935 Change-Id: I5feaf73885cab95c43a28c529ada6942e037b162 PiperOrigin-RevId: 162587490
* Fix typos in messages.Gravatar dslomov2017-07-20
| | | | | RELNOTES: None. PiperOrigin-RevId: 162586748
* Use C++ iterators and iteration during rc file parsing.Gravatar Benjamin Peterson2017-07-19
| | | | | | | | | | | | | | This is a bit more idiomatic and fixes these GCC complaints: src/main/cpp/option_processor.cc: In static member function 'static blaze_exit_code::ExitCode blaze::OptionProcessor::RcFile::Parse(const string&, const string&, int, const blaze::WorkspaceLayout*, std::vector<blaze::OptionProcessor::RcFile*>*, std::map<std::__cxx11::basic_string<char>, std::vector<blaze::OptionProcessor::RcOption> >*, std::__cxx11::list<std::__cxx11::basic_string<char> >*, std::__cxx11::string*)': src/main/cpp/option_processor.cc:92:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int line = 0; line < lines.size(); ++line) { ~~~~~^~~~~~~~~~~~~~ src/main/cpp/option_processor.cc:151:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int word = 1; word < words.size(); ++word) { ~~~~~^~~~~~~~~~~~~~ Change-Id: Ieb0e8f89194fe802f79c729eb7a851ea2dfad665 PiperOrigin-RevId: 162477025
* Implement bash.exe detection logic.Gravatar Dmitry Lomov2017-07-19
| | | | | | | | | | | | | | | | The logic is as follows: 1) search for msys installation 2) search got git-on-Windows installation 3) search in PATH. This happens on every client startup unless BAZEL_SH enviornment variable is set. My measurements show that the time required for this detection is negligible (<10 msec in the worst case). Change-Id: If130e2491a9df5a23954d303f2ccdb932eeed1db PiperOrigin-RevId: 162466913
* PiperOrigin-RevId: 161791822Gravatar lpino2017-07-14
|
* PiperOrigin-RevId: 161571228Gravatar lpino2017-07-12
|
* Ensure that shutdown commands end the server process before completionGravatar mschaller2017-07-12
| | | | | | | | | | | | | | | | | | | | This change ensures that the server process is terminated before the client process terminates, when evaluating a command that shuts down the server. When completing such a command, the server communicates to the client that the server will terminate itself by setting a termination_expected bit in the final RunResponse message. The client then waits up to 60s for the server process to actually terminate. If it does not, then the client SIGKILLs the server. Also makes the gRPC server stop accepting new commands before the shutdown command completes. Drive-by fix to comments on Search{Un,Null}aryOption. RELNOTES: Commands that shut down the server (like "shutdown") now ensure that the server process has terminated before the client process terminates. PiperOrigin-RevId: 161537480
* Delete the unused OptionProcessor::ParseOptions(argc,argv).Gravatar lpino2017-07-11
| | | | PiperOrigin-RevId: 161523047
* Automated rollback of commit 458990b0c155130e242117e2bfc5ebfdf787d2e2.Gravatar Googler2017-07-11
| | | | | | | | | *** Reason for rollback *** A backwards incompatible change for CLI. RELNOTES: Rollback of https://github.com/bazelbuild/bazel/commit/458990b0c155130e242117e2bfc5ebfdf787d2e2 PiperOrigin-RevId: 161457646
* Use a CommandLine struct to store the command line parsed by the ↵Gravatar lpino2017-07-11
| | | | | | | | OptionProcessor. This replaces the startup_args_, command_ and command_argument members to allow a more consistent representation of the command line throughout the class. PiperOrigin-RevId: 161408010
* Raise the maximum number of processes and open files to their maximum.Gravatar jmmv2017-07-11
| | | | | | | | | | | | | | | | | | | Under macOS, the default soft resource limits for open files and concurrent processes are pretty low, but their corresponding hard defaults are reasonable. Because the soft limits are low, Bazel sometimes fails during large builds -- not because of Bazel itself, but because the executed actions do "too much work" or because the --jobs setting was high enough to cause all parallel tasks to exceed the limits. Instead of trying to fix the actions themselves, start by trying to raise the system limits as a best-effort operation. And, given that this code is fairly portable, try to do it on all POSIX systems and not just macOS. Note that, for non-macOS systems, this might still not do what's promised in all circumstances because I'm currently only implementing GetExplicitSystemLimit on macOS. RELNOTES: None. PiperOrigin-RevId: 161401482
* Look at stderr for terminal detection.Gravatar Googler2017-07-10
| | | | | | | | | | | | | | | | | | | | bazel prints all the progress to stderr, yet the decision to switch between "smart" and "dumb" output modes is done based on the stdout and stderr connected terminals. That breaks for a command like this: bazel query 'something' | wc -l Even though all the progress is still output to the terminal through stderr, bazel switches to "dumb" mode, printing progress messages one per line. It seems reasonable to make the "smart"/"dumb" output mode decision based on the stderr only. Tested: With the change "bazel query '...' | wc -l" prints "smart" progress messages. RELNOTES: Check stderr to detect if connected to a terminal. Deprecate --isatty. PiperOrigin-RevId: 161243017
* Open source {workspace_layout,startup_options,option_processor}_test.Gravatar lpino2017-07-05
| | | | | | Additionally rewrite the option_processor_test to make it more flexible. PiperOrigin-RevId: 160958736
* blaze_util_freebsd.cc: gracefully handle server directory being NULLGravatar Klaus Aehlig2017-07-05
| | | | | | | | | | | | Gracefully handle the case that the working directory of the server process no longer exists in the file system. This happens if the directory in which bazel was called gets removed and later a directory with the same name is created; a particular such case is running bazel in integration tests. Closes #3324. PiperOrigin-RevId: 160938332
* cleanup {get,set,unset}env() functions callsGravatar Thiago Farina2017-07-05
| | | | | | | | Instead, let's reuse the cross-platform {Get,Set,Unset}Env() functions when possible. Change-Id: I40b4ff09c66fe238d5b3d70e49f91705cea64b0c PiperOrigin-RevId: 160870850
* Create the StartupFlag class and use it instead of plain list of strings.Gravatar lpino2017-06-30
| | | | | | | | Additionally, add a warning note for developers who wish to delete startup options: they first need to deprecate the flag and once it's a no-op for a sufficient amount of time then they can delete it from the list of valid options. PiperOrigin-RevId: 160546248
* Windows, JNI: move around sourcesGravatar Laszlo Csomor2017-06-29
| | | | | | | | | | | | | | | | Move the Windows JNI C++ sources to a separate package and separate namespace. This no-op refactoring allows other build rules than Bazel's client library to depend on file I/O and/or JNI functionality. A follow-up commit will split the //src/main/native/windows:processes library into :jni-processes and :jni-file. Change-Id: I33c5f8ebd8961cc440db3b4a95ff78024d7c1d74 PiperOrigin-RevId: 160404298
* Make Bazel build with wrapper-free CROSSTOOL on WindowsGravatar Yun Peng2017-06-28
| | | | | Change-Id: I0824332896b776e8296608a6b831abba33697845 PiperOrigin-RevId: 160390320
* Internal changeGravatar Googler2017-06-28
| | | | PiperOrigin-RevId: 160378726
* cpp: add unit tests for MakeAbsolute()Gravatar Thiago Farina2017-06-28
| | | | | | | | | | | While fixing its TODO. Tested with the following command line: $ bazel test //src/test/cpp/... Change-Id: I62d5d0f19b7242fd2eeae7901e1e236c782ebfb5 PiperOrigin-RevId: 160270960
* use procstat_getpathname to get self pathGravatar Jov2017-06-27
| | | | | | | | Use procstat_getpathname instead of /proc/curproc/file to get self path, as /proc do not always exists, and need root privilege to mount. procstat_getpathname is preferred on FreeBSD. Closes #3179. PiperOrigin-RevId: 160260464
* Don't set the +x bit by default on WriteFile().Gravatar lberki2017-06-27
| | | | | | | This change is a spiritual successor of https://bazel-review.googlesource.com/c/7410/ . That one had a merge conflict and it was small enough that a rewrite was easier than updating it. RELNOTES: None. PiperOrigin-RevId: 160251282
* Internal changeGravatar Googler2017-06-27
| | | | PiperOrigin-RevId: 160155305
* Internal changeGravatar Googler2017-06-26
| | | | | RELNOTES: None. PiperOrigin-RevId: 160111047
* Make source code of singlejar and ijar available from @bazel_tools. ,Gravatar Xin Gao2017-06-22
| | | | | | | | | | Please refer to patch set 9 and its CI run for usage and test results. In practice, users should create their own java_toolchain rule in their project's BUILD file, and set the two attributes like above instead of modifying //tools/jdk/BUILD. Change-Id: Ic880f243086b00a58d453a8139ba4c957fe54bc7 PiperOrigin-RevId: 159694649
* Windows, Bazel client: pass Unix root as JVM flagGravatar Laszlo Csomor2017-06-13
| | | | | | | | | | | | | The Bazel client will pass the --host_jvm_args=-Dbazel.windows_unix_root=<path> flag to the server (computed from $BAZEL_SH), and the server will no longer shell out to cygpath to compute this value. Fixes https://github.com/bazelbuild/bazel/issues/2983 Change-Id: Iacc2e2eb70eacafdf7bbcad68d375ba9eadc6ee1 PiperOrigin-RevId: 158830675
* Windows: bazel clean --expunge worksGravatar Laszlo Csomor2017-06-12
| | | | | | | | | | | | | | | Fixes https://github.com/bazelbuild/bazel/issues/1586 Fixes https://github.com/bazelbuild/bazel/issues/2326 This change also undoes https://github.com/bazelbuild/bazel/commit/956810b6ee24289e457a4b8d0a84ff56eb32c264 -- since Bazel now closes its stdout/stderr before cleaning, jvm.out is also closed so we don't need to open it with deletion sharing. RELNOTES: Windows: bazel clean --expunge works Change-Id: I692f2e86a5983cb472a142a093611fd1c694cd3b PiperOrigin-RevId: 158682987
* Bazel client: explain the name of A-server.jarGravatar László Csomor2017-06-07
| | | | | | | | | | Also add a helper method to GlobalVariables to retrieve this path, thus concentrating the assumptions about the layout of extracted_binaries in one place. Change-Id: If172b6f5bf4451845ad89d3d488ef2a2c2e5d286 PiperOrigin-RevId: 158241854
* Fix a bunch of issues related to server startup/shutdown:Gravatar lberki2017-06-06
| | | | | | | | | - Only try to communicate with the server if it passes verification (i.e. the indicated PID exists and its start time is correct) - Use only one thread to delete files on exit - Don't set restart reason to NEW_VERSION unless there is an existing server RELNOTES: None. PiperOrigin-RevId: 158131470
* Windows, jvm.out: create with deletion sharingGravatar Laszlo Csomor2017-06-02
| | | | | | | | | | | | This allows `bazel clean` to delete this file. See https://github.com/bazelbuild/bazel/issues/1586 See https://github.com/bazelbuild/bazel/issues/1906 See https://github.com/bazelbuild/bazel/issues/2480 See https://github.com/bazelbuild/bazel/issues/3043 Change-Id: I245f368c2f2564511bbe6f06193a3ead49724d7b PiperOrigin-RevId: 157818284
* fix signedness warnings in blaze_util_posix.ccGravatar Benjamin Peterson2017-05-31
| | | | | | | | | | if (result != count) { ~~~~~~~^~~~~~~~ Of course, problems arising from this are only theoretical. Change-Id: Id045a97623026e005d40940eb4a7d30d73f4ce32 PiperOrigin-RevId: 157561218
* Windows: ignore envvars with degenerate namesGravatar Laszlo Csomor2017-05-31
| | | | | | | Fixes https://github.com/bazelbuild/bazel/issues/3077 Change-Id: I5f29fdec1f69bdda51fa62be695b8791a45240e9 PiperOrigin-RevId: 157559455
* Make Bazel build without --cpu=x64_windows_msvcGravatar Yun Peng2017-05-30
| | | | | | | | | | | | | | | | After this change, with a Bazel having MSVC as default toolchain, the command to build a MSVC Bazel on Windows is simply: bazel build //src:bazel although bazel build --cpu=x64_windows_msvc //src:bazel is still supported. And the command to build a MSYS Bazel on Windows is: bazel build --cpu=x64_windows_msys //src:bazel Also made //src/test/cpp:blaze_util_test pass without --cpu=x64_windows_msvc Change-Id: Iaf37513c778768d06fb5700442d5229a5f348964 PiperOrigin-RevId: 157446905
* Modify misleading TODO.Gravatar ccalvarin2017-05-26
| | | | | | Unfortunately, we aren't ready to turn logging on by default, so cannot convert die/pdie to FATAL log messages. PiperOrigin-RevId: 157041142
* cpp: remove blaze_util::sys_ioprio_set() call from FreeBSD portGravatar Thiago Farina2017-05-24
| | | | | | | Currently sys_ioprio_set() is only implemented for Linux. Change-Id: Iadacf8fd48a804b981274e92ca3066a403c467fb PiperOrigin-RevId: 156977281
* cpp: change PrintError() to print "ERROR:"Gravatar Thiago Farina2017-05-23
| | | | | | | | | | | As it was suggested in https://bazel-review.googlesource.com/#/c/10875/3/src/main/cpp/util/errors.cc@58 This is because that way it's consistent with the warnings/errors that the Bazel server displays. Change-Id: I65ee961ac4db5b21461fa7f7864e7f3c94a6e4f3 PiperOrigin-RevId: 156884812
* Add new reasons for server restart: PID_FILE_BUT_NO_SERVER, SERVER_VANISHED ↵Gravatar janakr2017-05-17
| | | | | | and SERVER_UNRESPONSIVE, since it looks like these are happening with upsetting frequency in our new grpc world. PiperOrigin-RevId: 156271743
* Fix a typo and remove an unnecessary scary warning submitted in unknown commit.Gravatar lberki2017-05-15
| | | | | RELNOTES: None. PiperOrigin-RevId: 156039435
* cpp: remove out-dated StartServer() documentation commentGravatar Thiago Farina2017-05-15
| | | | | | | | Since commit 1977d92e17e6: ("Various cleanups and refactorings in the client:"), StartServer() does not return a file descriptor anymore. Change-Id: I920240d3aed5f16077bf9f046522b65664319947 PiperOrigin-RevId: 155871851
* Remove all complex logic after forking.Gravatar lberki2017-05-11
| | | | | | | | | | This is so that there is as little room for undesired behavior (e.g. deadlocks), which can happen when multi-threaded programs fork if the code is not written *very* carefully. See the comment before ExecuteDaemon() in blaze_util_posix.cc for an detailed treatise on the matter. RELNOTES: None. PiperOrigin-RevId: 155750707
* Update ExecuteDaemon() on POSIX systems so that the client writes the PID ↵Gravatar lberki2017-05-10
| | | | | | | | | file and not the server. This is so that the server does as few things as possible before exec() (preferably, nothing) so that we don't accidentally call malloc() which would make it possible to deadlock if the server spawned multiple threads before ExecuteDaemon(). RELNOTES: None. PiperOrigin-RevId: 155603273
* Fix compileGravatar kchodorow2017-05-09
| | | | | | See breakage @ http://ci.bazel.io/view/Bazel%20bootstrap%20and%20maintenance/job/Bazel/JAVA_VERSION=1.8,PLATFORM_NAME=freebsd-11/1481/console. PiperOrigin-RevId: 155517063
* Exclude the user-provided blazerc from the deduplication process.Gravatar lpino2017-05-09
| | | | PiperOrigin-RevId: 155491277
* cpp: remove all code supporting kServerPidSymlinkGravatar Thiago Farina2017-05-09
| | | | | | | | By this time (6 months later) Bazel clients should no longer need this. Change-Id: Ib058065a0ff3eedc777e95c7d06602ca6744d42a PiperOrigin-RevId: 155478543
* cpp: add PrintWarning() function to errors.hGravatar Thiago Farina2017-05-09
| | | | | | | | | It provides a single and clean way to output warning messages, and replaces the fprintf(stderr, "Warning: ...\n") or fprintf(stderr, "WARNING: ...\n") calls. Change-Id: I2f8a8f659085b9e57a08b5208a8b8f683a7cd72c PiperOrigin-RevId: 155386233
* cpp: do not mention -1 for command_port optionGravatar Thiago Farina2017-05-08
| | | | | | | | | | | | | -1 is not a valid port number and thus do not mean "no gRPC command server". If you try to pass -1 to command_port you get: $ bazel --command_port=-1 build //... Invalid argument to --command_port: '-1'. Must be a valid port number or 0. Change-Id: I6c17167f6a285b21fcd064cea8bdc7e6770ac984 PiperOrigin-RevId: 155352835