Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow customizing "BUILD" as a package-specification file #552

Closed
cgrushko opened this issue Nov 3, 2015 · 19 comments
Closed

Allow customizing "BUILD" as a package-specification file #552

cgrushko opened this issue Nov 3, 2015 · 19 comments
Assignees
Labels
category: misc > misc P1 I'll work on this now. (Assignee required) type: feature request
Milestone

Comments

@cgrushko
Copy link
Contributor

cgrushko commented Nov 3, 2015

Most OS X installations have a case-sensitive filesystem, so "BUILD" is the same as "build".

Some teams have directories/files named "build" in their projects, which poses a double challenge:

  1. Bazel might choke on these directories/files.
  2. Scripts could unintentionally damage Bazel's BUILD files.

At least as a transitionary-aid for other teams, it would be useful to customize the file-name that Bazel uses to define packages.

Suggestion: add a WORKSPACE rule to define a different file-name.

@adamhowardprice
Copy link

👍 It is very common to have a build folder at the top level of an iOS or Android project for Xcode to put locally built artifacts and generated files. We make this assumption on our CI as well.

I wonder why Bazel allows you to customize the location of a BUILD file for an external repo (via the build_file attr on a git_repository) but won't let you customize the BUILD file in the workspace root.

It would be as simple as specifying in the WORKSPACE something like workspace_build_file = "workspace.BUILD".

@damienmg
Copy link
Contributor

I don't think that's a good idea. We will ends-up having different build file everywhere. We should instead do file type detection and not try to parse a directory as a build file :)

@damienmg damienmg added type: bug P2 We'll consider working on this in future. (Assignee optional) type: feature request and removed type: bug labels Nov 17, 2015
@cgrushko
Copy link
Contributor Author

@damienmg the problem we ran into was the opposite - existing scripts (as well as Gradle, in its default configuration) were stepping on the BUILD files we wrote.

@adamhowardprice
Copy link

If the concern is that we will have different build files everywhere, maybe we could solve this problem by detecting build files by looking for files either called BUILD (as we do today) or Buildfile (similar to Makefile, Gemfile, etc). That seems unique enough that it won't be trampled by scripts, and also a familiar pattern for developers.

@adamhowardprice
Copy link

Alternatively, Bazelfile?

@damienmg
Copy link
Contributor

SGTM BUILD.bazel ? (someone was proposing an extension to make it work outside).

@dmaclach
Copy link
Contributor

Please don't reuse extensions that are already in use for different file types (i.e. please don't use .bzl). BUILD.bld?

@davidzchen
Copy link
Member

If we are adding an extension, I vote in favor of BUILD.bazel. Another benefit of this is that it is straightforward for people to say:

build dot Bazel

Similarly, Gradle's build files are build.gradle.

@damienmg damienmg assigned damienmg and unassigned cgrushko Jan 21, 2016
@damienmg damienmg added P1 I'll work on this now. (Assignee required) and removed P2 We'll consider working on this in future. (Assignee optional) labels Feb 4, 2016
@mightyguava
Copy link

I also need this while trying to migrate from pants, as it also uses BUILD files for the same purpose as bazel but with a different syntax...

@damienmg damienmg assigned katre and unassigned damienmg Jun 14, 2016
@damienmg damienmg added this to the 0.6 milestone Jun 14, 2016
@katre katre self-assigned this Jun 14, 2016
@damienmg
Copy link
Contributor

@katre @jhfield: Too many people reassigning this bug at the same time? :)

@katre
Copy link
Member

katre commented Jun 14, 2016

I'm looking into it, I promise! :)

@katre
Copy link
Member

katre commented Sep 27, 2016

Just as an update, work is in progress, I have a mostly working solution but there are a lot of tests to fix up as a result.

@mightyguava
Copy link

mightyguava commented Sep 27, 2016

As a transitory aid, until this is done, I made a really simple script to patch Bazel. We managed to transition successfully from pants with a ~2 week overlap and then went back to the vanilla Bazel binary after.

find . -type f | grep -E '\.(md|patch|vm|html|bzl|java|c|cc|h|proto|txt|sh|bash|git_log)$' | xargs sed -r -i"" -e 's/\bBUILD\b/UCBUILD/g'
find . -type f | grep -E '(_bazel|Makefile|WORKSPACE|UCBUILD)' | xargs sed -r -i"" -e 's/\bBUILD\b/UCBUILD/g'
find . -type f | grep 'UCBUILD' | xargs rename 's/\bBUILD\b/UCBUILD/'

@robertwb
Copy link

Has there been any decision as to what the extension/name of this BUILD file not named BUILD is going to be?

@katre
Copy link
Member

katre commented Oct 10, 2016

The alternate name will be BUILD.bazel. I have the code for this change
mostly working and plan to pick it back up shortly.

On Mon, Oct 10, 2016, 1:54 PM Robert Bradshaw [email protected]
wrote:

Has there been any decision as to what the extension/name of this BUILD
file not named BUILD is going to be?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#552 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAT7f4ocvnBZ1qCxagMdW9IJNCJO6IfFks5qynu9gaJpZM4GalKt
.

@ixdy
Copy link
Contributor

ixdy commented Oct 24, 2016

@katre any ETA? this is a pretty frustrating issue for us.

@katre
Copy link
Member

katre commented Oct 28, 2016

@ixdy Sorry for the slow reply.

I have a change ready and in testing. There's some cleanup I need to do before I can start working to get it out, but it should be in review next week.

@venantius
Copy link

Chiming in from Airbnb eng -- we're looking to migrate off of Gradle as well as some of the other folks in this thread and we've run into this issue as well. Would love to see this fix released as soon as it's ready.

@katre
Copy link
Member

katre commented Nov 11, 2016

I have just this evening submitted the fix for this issue. It should be pushed to GitHub in the next day or so and then be in the December release (presumably 0.4.2, but we will see what the version is).

k8s-github-robot pushed a commit to kubernetes/kubernetes that referenced this issue Dec 15, 2016
Automatic merge from submit-queue

Rename root BUILD to BUILD.bazel, and rename build-tools/ back to build/

**What this PR does / why we need it**: undoes #35453. `build-tools/` was intended to be a temporary workaround until bazelbuild/bazel#552 was fixed, which is has been, as of bazel 0.4.1.

**Which issue this PR fixes**: fixes #38126

FYI @thockin 

since this is likely to be rebase hell, my list of actions:
```console
$ git mv BUILD BUILD.bazel
$ git commit -a
$ git mv build-tools/ build/
$ sift -l 'build-tools' | xargs sed -i -e 's:build-tools/:build/:g'
$ git checkout HEAD docs/
$ git commit -a
```
bazel-io pushed a commit to bazelbuild/tulsi that referenced this issue Feb 7, 2017
[BUILD.bazel](https://github.com/bazelbuild/bazel/blob/master/src/main
/java/com/google/devtools/build/lib/skyframe/PackageLookupValue.java#L
55) is a valid BuildFilename (see 
bazelbuild/bazel#552), so it must be 
selectable when adding packages in Tulsi.

--
Change-Id: Ieb2c0c1dd78fd99c1bd98b0567e60658f8dce593
Reviewed-on: #2
PiperOrigin-RevId: 146696005
MOS_MIGRATED_REVID=146696005
perotinus pushed a commit to kubernetes-retired/cluster-registry that referenced this issue Sep 2, 2017
Automatic merge from submit-queue

Rename root BUILD to BUILD.bazel, and rename build-tools/ back to build/

**What this PR does / why we need it**: undoes #35453. `build-tools/` was intended to be a temporary workaround until bazelbuild/bazel#552 was fixed, which is has been, as of bazel 0.4.1.

**Which issue this PR fixes**: fixes #38126

FYI @thockin 

since this is likely to be rebase hell, my list of actions:
```console
$ git mv BUILD BUILD.bazel
$ git commit -a
$ git mv build-tools/ build/
$ sift -l 'build-tools' | xargs sed -i -e 's:build-tools/:build/:g'
$ git checkout HEAD docs/
$ git commit -a
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: misc > misc P1 I'll work on this now. (Assignee required) type: feature request
Projects
None yet
Development

No branches or pull requests