aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/cmdline/Label.java
Commit message (Collapse)AuthorAge
* Set the version of a computed node to the max of its child versions rather ↵Gravatar janakr2018-07-11
| | | | | | | | | | | | | | | | | than the graph version when that is feasible. * It's not feasible when the computation accesses outside state, i.e. is non-hermetic, so see below. * It's also more complicated (and not worth the trouble) when the computation is taking place just for the error status. Have SkyFunctionName declare whether the function it corresponds to is hermetic or non-hermetic. Only non-hermetically-generated SkyValues can be directly marked changed, and non-hermetic SkyFunctions have their values saved at the graph version, not the max of the child versions. All SkyFunctions are hermetic except for the ones that can be explicitly dirtied. A marked-hermetic SkyFunction that has a transient error due to filesystem access can be re-evaluated and get the correct version: if it throws an IOException at version 1 and then, when re-evaluated at version 2 with unchanged dependencies, has a value, the version will be version 1. All Skyframe unit tests that were doing non-hermetic things to nodes need to declare that those nodes are non-hermetic. I tried to make the minimal set of changes there, so that we had good incidental coverage of hermetic+non-hermetic nodes. Also did some drive-by clean-ups around that code. Artifacts are a weird case, since they're doing untracked filesystem access (for source directories). Using max(child versions) for them gives rise to the following correctness bug: 1. do a build at v1 that creates a FileStateValue for dir/ at v1. Then at v2, add a file to dir/ and do a build that consumes dir/ as a source artifact. Now the artifact for dir/ will (incorrectly) have v1. Then at v1, do that build again. We'll consume the "artifact from the future". However, this can only have an effect when using the local action cache, since the incorrect value of the artifact (the mtime) is only consumed by the action cache. Bazel is already broken in this way (incremental builds don't invalidate directories), so this change doesn't make things worse. PiperOrigin-RevId: 204210719
* Rollback of ↵Gravatar twerth2018-07-04
| | | | | | | https://github.com/bazelbuild/bazel/commit/732dc512801c32207c252a76ca8d9e5544560339. RELNOTES: Allow @ in package names. PiperOrigin-RevId: 203270369
* Automated refactor of Label.parseAbsolute() to always pass a repository mappingGravatar dannark2018-06-27
| | | | | RELNOTES: None PiperOrigin-RevId: 202360925
* Enforce that repository mapping is never null (it can be empty).Gravatar dannark2018-06-26
| | | | | RELNOTES: None PiperOrigin-RevId: 202167782
* Remove Label.parseAbsolute(string, boolean). The goal is to get rid of all ↵Gravatar dannark2018-06-22
| | | | | | | label methods that don't explicitly pass a repository mapping. RELNOTES: None PiperOrigin-RevId: 201717665
* Automated rollback of commit 5a9befc5602e71f7512074c303afbdcff5617cca.Gravatar twerth2018-06-22
| | | | | | | | RELNOTES: None *** Reason for rollback *** PiperOrigin-RevId: 201686843
* Take into account repository mapping when processing labels inside BUILD ↵Gravatar dannark2018-06-21
| | | | | | | | | | | | | | | | | | | | | | | | | files within external repositories. For example: a/BUILD genrule( name = "a", srcs = ["@x//:x.txt"], outs = ["result.txt"], cmd = "echo hello > \$(location result.txt)" ) If the main workspace file references that repository with a rule: local_repository( name = "other_repo", path = "../a", repo_mapping = {"@x" : "@y"} ) Then when a/BUILD is evaluated, the string "@x//:x.txt" will be turned into a Label "@y//:x.txt" RELNOTES: None PiperOrigin-RevId: 201562148
* Automated rollback of commit 2b015c53c89815472923d8ea0c94640b7db2fa20.Gravatar twerth2018-06-21
| | | | | | RELNOTES[NEW]: Allow @ in package names. PiperOrigin-RevId: 201487916
* Automated rollback of commit 1615da781db78b7a910daf89720189c2b2e73dbe.Gravatar Googler2018-06-14
| | | | | | *** Reason for rollback *** PiperOrigin-RevId: 200605975
* Allow @ in package names.Gravatar twerth2018-06-14
| | | | | | | | | | To disambiguate: - @foo refers to the external dependency @foo//:foo (as before this change). - //@foo refers to the target //@foo:@foo (i.e. in the default workspace). RELNOTES[NEW]: Allow @ in package names. PiperOrigin-RevId: 200541716
* Remap repository names inside load statements in BUILD files if the ↵Gravatar dannark2018-06-12
| | | | | | | | | | | | | | | | | | | repository name is remapped. For example if main/WORKSPACE contains: local_repository( name = "a", path = "../a", repo_mapping = {"@x" : "@y"}, ) a/BUILD load("@x//:sample.bzl", "sample") Then the load in a/BUILD will be resolved as "@y//:sample.bzl" RELNOTES: None PiperOrigin-RevId: 200227431
* Fast-path Label#equals by first comparing the interned PackageIdentifier.Gravatar shreyax2018-06-02
| | | | PiperOrigin-RevId: 199007753
* Automated rollback of commit ca598fb9445627e9734c2900bc6b11430250d453.Gravatar dannark2018-04-10
| | | | | | | | | | | | | *** Reason for rollback *** breaks guitar tests *** Original change description *** Disallow labels of the form ////foo. RELNOTES: Labels of the form ////foo are disallowed. PiperOrigin-RevId: 192393660
* Disallow labels of the form ////foo.Gravatar carmi2018-04-10
| | | | | RELNOTES: Labels of the form ////foo are disallowed. PiperOrigin-RevId: 192329081
* Deletes CODEC fields now that they are no longer needed.Gravatar shahan2018-02-28
| | | | PiperOrigin-RevId: 187397314
* Move CommandLine, CommandLineItem, and ParamFileInfo from ↵Gravatar tomlu2018-02-15
| | | | | | | | | lib.analysis.actions -> lib.actions. These are fundamental types that want to sit alongside types like Spawn. RELNOTES: None PiperOrigin-RevId: 185887971
* Remove label name interning.Gravatar tomlu2018-02-12
| | | | | | | | We already intern the labels themselves. Benchmarks do not show any further gain by interning the label names. RELNOTES: None PiperOrigin-RevId: 185394812
* Replace path implementation.Gravatar tomlu2018-02-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Path and PathFragment have been replaced with String-based implementations. They are pretty similar, but each method is dissimilar enough that I did not feel sharing code was appropriate. A summary of changes: PATH ==== * Subsumes LocalPath (deleted, its tests repurposed) * Use a simple string to back Path * Path instances are no longer interned; Reference equality will no longer work * Always normalized (same as before) * Some operations will now be slower, like instance compares (which were previously just a reference check) * Multiple identical paths will now consume more memory since they are not interned PATH FRAGMENT ============= * Use a simple string to back PathFragment * No more segment arrays with interned strings * Always normalized * Remove isNormalized * Replace some isNormalizied uses with containsUpLevelReferences() to check if path fragments try to escape their scope * To check if user input is normalized, supply static methods on PathFragment to validate the string before constructing a PathFragment * Because PathFragments are always normalized, we have to replace checks for literal "." from PathFragment#getPathString to PathFragment#getSafePathString. The latter returns "." for the empty string. * The previous implementation supported efficient segment semantics (segment count, iterating over segments). This is now expensive since we do longer have a segment array. ARTIFACT ======== * Remove Path instance. It is instead dynamically constructed on request. This is necessary to avoid this CL becoming a memory regression. RELNOTES: None PiperOrigin-RevId: 185062932
* Add CommandLineItem interface.Gravatar tomlu2018-01-25
| | | | | | | | This interface makes it clearer in the type system exactly how items that go into a CustomCommandLine are turned into strings. It is a preparatory change to allow command line fingerprints to be more cheaply calculated, but it is valuable in itself from a code quality standpoint. PiperOrigin-RevId: 183274022
* Stop memoizing Label#hashCode()Gravatar michajlo2018-01-09
| | | | | | | | | | | | Both members of Label (String & PackageIdentifier) have memoized hash codes so this should be marginally more expensive but probably not noticably so. The benefit is it makes Label objects smaller in certain vm conditions. As to why things were the way they were, I believe this is from before PackageIdentifier memoized its hashCode. RELNOTES: None PiperOrigin-RevId: 181362077
* Initial @AutoCodec implementation.Gravatar Googler2017-12-13
| | | | PiperOrigin-RevId: 178994972
* Replace all usages of Blaze's Preconditions class with guava.Gravatar tomlu2017-11-09
| | | | | | | | Blaze had its own class to avoid GC from varargs array creation for the precondition happy path. Guava now (mostly) implements these, making it unnecessary to maintain our own. This change was almost entirely automated by search-and-replace. A few BUILD files needed fixing up since I removed an export of preconditions from lib:util, which was all done by add_deps. There was one incorrect usage of Preconditions that was caught by error prone (which checks Guava's version of Preconditions) that I had to change manually. PiperOrigin-RevId: 175033526
* Rename Label.EXTERNAL_PACKAGE_FILE_NAME to WORKSPACE_FILE_NAMEGravatar ulfjack2017-10-27
| | | | | | | This more clearly indicates what this is. Also change some hard-coded uses to use the constant instead. PiperOrigin-RevId: 173658659
* Remove deprecated legacy string representations of Skylark objectsGravatar vladmos2017-10-13
| | | | | | | | RELNOTES[INC]: The flag --incompatible_descriptive_string_representations is no longer available, old style string representations of objects are not supported anymore. PiperOrigin-RevId: 171952621
* Clean up Label validation, and introduce a factory method for constructing a ↵Gravatar nharmata2017-08-08
| | | | | | | Label without validation. RELNOTES: None PiperOrigin-RevId: 164479651
* Make SkyKey.argument a default methodGravatar ulfjack2017-07-25
| | | | | | | Almost all implementations simply return this, all of which can be removed now. PiperOrigin-RevId: 163046912
* Skylark, docs: fix docs of Label.relative(name)Gravatar laszlocsomor2017-07-10
| | | | | | | | | | It appeared in the docs that the function had no argument. Fixes https://github.com/bazelbuild/bazel/issues/3339 RELNOTES: none PiperOrigin-RevId: 161388878
* Clean up string representations for labelsGravatar vladmos2017-07-05
| | | | | | | | | | | If --incompatible_descriptive_string_representations is passed, labels are converted to strings using `repr` differently: `Label("//package:name")` instead of `"//package:name"` This CL doesn't affect representations of other object types but provides the necessary infrastructure for it. PiperOrigin-RevId: 160955284
* Refactor PrinterGravatar vladmos2017-07-03
| | | | | | | It's now easier to customize Printer if in different situations objects should be printed differently. Also its API is cleaner now. Names of methods of SkylarkValue objects now reflect names of Skylark functions: SkylarkValue#repr and SkylarkPrintableValue#str. PiperOrigin-RevId: 160635154
* Automated conversion to Java 8Gravatar laurentlb2017-06-30
| | | | | | | With a few manual fixes for readability. RELNOTES: None. PiperOrigin-RevId: 160582556
* Make SkyKey an interface, and start the migration of not creating SkyKey ↵Gravatar janakr2017-05-04
| | | | | | wrapper objects: for OwnedArtifacts, which are the most numerous during builds, and for Labels for TransitiveTraversalValues, which are the most numerous during queries. PiperOrigin-RevId: 154989520
* Automated g4 rollback of commit 7beadb7277453efec7e12b925005e7f0e003b592.Gravatar nharmata2017-05-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | *** Reason for rollback *** Original CL was rolled backed incorrectly. See post-submit discussion on http://https://github.com/bazelbuild/bazel/commit/7beadb7277453efec7e12b925005e7f0e003b592. *** Original change description *** Automated g4 rollback of commit 38b835097f9ae9a6062172b8a33ec2e2d1edde20. *** Reason for rollback *** Breaking Bazel build on linux, see http://ci.bazel.io/job/bazel-tests/733/ Repro: bazel build //src/test/java/com/google/devtools/build/lib:packages_test Found by bisecting. *** Original change description *** Only allocate some formerly frequently allocated PathFragment objects once. This reduces both gc churn and retained memory usage. RELNOTES: None PiperOrigin-RevId: 154839279
* Automated g4 rollback of commit 38b835097f9ae9a6062172b8a33ec2e2d1edde20.Gravatar dmarting2017-05-02
| | | | | | | | | | | | | | | | | | | *** Reason for rollback *** Breaking Bazel build on linux, see http://ci.bazel.io/job/bazel-tests/733/ Repro: bazel build //src/test/java/com/google/devtools/build/lib:packages_test Found by bisecting. *** Original change description *** Only allocate some formerly frequently allocated PathFragment objects once. This reduces both gc churn and retained memory usage. RELNOTES: None PiperOrigin-RevId: 154821457
* Only allocate some formerly frequently allocated PathFragment objects once.Gravatar nharmata2017-05-02
| | | | | | This reduces both gc churn and retained memory usage. PiperOrigin-RevId: 154718782
* Refactor all ctor callsites of PathFragment to instead call a static ↵Gravatar nharmata2017-04-05
| | | | | | | | | | | | 'create' method. This paves the way for changing PathFragment to e.g. an abstract class with multiple subclasses. This way we can split out the windows-specific stuff into one of these concrete classes, making the code more readable and also saving memory (since the shallow heap size of the NonWindowsPathFragment subclass will hopefully be smaller than that of the current PathFragment). This also lets us pursue gc churn optimizations. We can now do interning in PathFragment#create and can also get rid of unnecessary intermediate PathFragment allocations. RELNOTES: None PiperOrigin-RevId: 152145768
* Extract a SpawnRunner interfaceGravatar ulfjack2017-04-04
| | | | | | | | | | | | | | | | | | | | | The RemoteSpawnRunner now implements the SpawnRunner interface. Note that Google's internal implementations were also retrofitted, and SpawnRunner is intended as a stable interface; that's also why I decided to move all params into SpawnExecutionPolicy, which is, unfortunately, not quite done yet. The specification of SpawnRunner is also still incomplete. In particular, it is still missing execution info keys, as well as inputs and outputs handling. This is a step towards unifying all SpawnStrategy implementations, with the SpawnRunner implementations performing the actual Spawn execution. There should be no user-visible semantic changes to the code, but one small fix: - GrpcActionCache was trying to download files even if there were none PiperOrigin-RevId: 152105696
* Fix Label.toShorthandString() with non-main/default repositoryGravatar Googler2017-03-20
| | | | | | | | (repository name was added twice in a non-shorthand result). -- PiperOrigin-RevId: 150437337 MOS_MIGRATED_REVID=150437337
* Rollback of commit 4b73e972d909bcd533f2f9940f95a00b9b73bdde.Gravatar Dmitry Lomov2017-02-17
| | | | | | | | | | | | | | | | | | | | | | | *** Reason for rollback *** Broke tests on CI: http://ci.bazel.io/job/bazel-tests/570/ *** Original change description *** Roll forward execroot change RELNOTES[INC]: Previously, an external repository would be symlinked into the execution root at execroot/local_repo/external/remote_repo. This changes it to be at execroot/remote_repo. This may break genrules/Skylark actions that hardcode execution root paths. If this causes breakages for you, ensure that genrules are using $(location :target) to access files and Skylark rules are using http://bazel.io/docs/skylark/lib/File.html's path, dirname, etc. functions. Cust... -- PiperOrigin-RevId: 147833177 MOS_MIGRATED_REVID=147833177
* Roll forward execroot changeGravatar Kristina Chodorow2017-02-16
| | | | | | | | | | | | | | | | | RELNOTES[INC]: Previously, an external repository would be symlinked into the execution root at execroot/local_repo/external/remote_repo. This changes it to be at execroot/remote_repo. This may break genrules/Skylark actions that hardcode execution root paths. If this causes breakages for you, ensure that genrules are using $(location :target) to access files and Skylark rules are using http://bazel.io/docs/skylark/lib/File.html's path, dirname, etc. functions. Custom crosstools that hardcode external/<repo> paths will have to be updated. Issue #1262. -- PiperOrigin-RevId: 147726370 MOS_MIGRATED_REVID=147726370
* Introduce BlazeInterners, a Blaze-specific wrapper around Guava's Interners ↵Gravatar Nathan Harmata2016-11-24
| | | | | | | | | | | that makes an appropriate call to Interners.InternerBuilder#concurrencyLevel. For current readers of this CL, I used this class everywhere in the Blaze codebase. For future readers of this CL, this class should be used to create an Interner in the Blaze codebase. -- MOS_MIGRATED_REVID=140063271
* Allow labels like @foo//:foo to be shortened @fooGravatar Justine Tunney2016-11-22
| | | | | | | | | Fixes #1924 RELNOTES: Labels like "@foo//:foo" can now be written as "@foo" in build files -- MOS_MIGRATED_REVID=139848658
* Rollback of commit 82d43279f93d95e4c41b4bc598a3cc05ddd1ae1a.Gravatar Laszlo Csomor2016-09-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | *** Reason for rollback *** Breaks TensorFlow and other Bazel jobs on ci.bazel.io *** Original change description *** Change execution root for external repositories to be ../repo Some of the important aspect of this change: * Remote repos in the execution root are under output_base/execroot/repo_name, so the prefix is ../repo_name (to escape the local workspace name). * Package roots for external repos were previously "output_base/", they are now output_base/external/repo_name (which means source artifacts always have a relative path from their repository). * Outputs are under bazel-bin/external/repo_name/ (or similarly under genfiles). Note that this is a bit of a change from how this was implemented in the previous cl. Fixes #1262. RELNOTES[INC]: Previously, an external repository would be symlinked into the execution root at execroot/local_repo/external/remote_repo. This changes it to be at execroot/remote_repo. This may break genrules/Skylark actions that hardcode execution root paths. If this causes breakages for you, ensure that genrules are using $(location :target) to access files and Skylark rules are using http://bazel.io/docs/skylark/lib/File.html's path, dirname, etc. functions. Roll forward of bdfd58a. -- MOS_MIGRATED_REVID=133709658
* Change execution root for external repositories to be ../repoGravatar Kristina Chodorow2016-09-20
| | | | | | | | | | | | | | | | | | | | | | | Some of the important aspect of this change: * Remote repos in the execution root are under output_base/execroot/repo_name, so the prefix is ../repo_name (to escape the local workspace name). * Package roots for external repos were previously "output_base/", they are now output_base/external/repo_name (which means source artifacts always have a relative path from their repository). * Outputs are under bazel-bin/external/repo_name/ (or similarly under genfiles). Note that this is a bit of a change from how this was implemented in the previous cl. Fixes #1262. RELNOTES[INC]: Previously, an external repository would be symlinked into the execution root at execroot/local_repo/external/remote_repo. This changes it to be at execroot/remote_repo. This may break genrules/Skylark actions that hardcode execution root paths. If this causes breakages for you, ensure that genrules are using $(location :target) to access files and Skylark rules are using http://bazel.io/docs/skylark/lib/File.html's path, dirname, etc. functions. Roll forward of bdfd58a. -- MOS_MIGRATED_REVID=133606309
* Rename some PackageId and RepositoryName fields/methods in prep for deep ↵Gravatar Kristina Chodorow2016-07-28
| | | | | | | | | | | | | execroot change This is in prep for making the execution root path for external repositories ../repo_name (instead of external/repo_name). Right now, the getRunfilesPath() returns that path, so that is renamed getExecRoot() (since the runfiles are really just a reflection of the execRoot structure). getSourceRoot() replaces getPathFragment, which has always been a confusing name (it's not clear from the name what the difference is between it and getPackageFragment()). It returns the relative path to source files for external repositories (external/repo_name). Also renamed/moved to more sensible class a few static RepositoryName fields. -- MOS_MIGRATED_REVID=128594419
* java_proto_library: add support for avoiding generating code for protos that ↵Gravatar Carmi Grushko2016-07-15
| | | | | | | are already compiled into a proto runtime. -- MOS_MIGRATED_REVID=127489419
* Make repository name warning less noisyGravatar Kristina Chodorow2016-07-01
| | | | | | | This way it won't print if the repo maintainer doesn't set the repo name. -- MOS_MIGRATED_REVID=126300205
* Reorganize Skylark Reference documentation.Gravatar Dmitry Lomov2016-06-29
| | | | | -- MOS_MIGRATED_REVID=126081020
* Fix some GC churn issues when dealing with Labels:Gravatar Eric Fellheimer2016-06-27
| | | | | | | | - reduce use of #substring(), which must copy the sub-region of the string - specialize hashCode() implementation so that we don't need to push objects into an array. -- MOS_MIGRATED_REVID=125798978
* Rollback of commit bdfd58a8ca2ed5735d6aaa5b238fb0f689515724.Gravatar Laurent Le Brun2016-06-20
| | | | | -- MOS_MIGRATED_REVID=125160288
* Make the execution root match the runfiles tree structure for external ↵Gravatar Kristina Chodorow2016-06-17
| | | | | | | | | | | | | | | | | | | | | repositories One interesting side effect of how this is implemented is that for external repositories, bin/ and genfiles/ are combined. External repo output is under bazel-out/local-fastbuild/repo_name for each repo. Fixes #1262. RELNOTES[INC]: Previously, an external repository would be symlinked into the execution root at execroot/local_repo/external/remote_repo. This changes it to be at execroot/remote_repo. This may break genrules/Skylark actions that hardcode execution root paths. If this causes breakages for you, ensure that genrules are using $(location :target) to access files and Skylark rules are using http://bazel.io/docs/skylark/lib/File.html's path, dirname, etc. functions. -- MOS_MIGRATED_REVID=125095799