-
Notifications
You must be signed in to change notification settings - Fork 1
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
Improve Windows support and make the top-level buildozer target public #17
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
exports_files(["buildozer.template.sh", "buildozer.template.bat"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@echo off | ||
SETLOCAL ENABLEEXTENSIONS | ||
SETLOCAL ENABLEDELAYEDEXPANSION | ||
|
||
set MF=MANIFEST | ||
set PATH=%SYSTEMROOT%\system32 | ||
|
||
REM Lookup the buildozer binary in the runfiles manifest. | ||
for /F "tokens=2* usebackq" %%i in (`findstr.exe /l /c:"%%BUILDOZER_RLOCATIONPATH%% " "%MF%"`) do ( | ||
set BUILDOZER=%%i | ||
set BUILDOZER=!BUILDOZER:/=\! | ||
) | ||
if "!BUILDOZER!" equ "" ( | ||
echo>&2 ERROR: %%BUILDOZER_RLOCATIONPATH%% not found in runfiles. | ||
exit /b 1 | ||
) | ||
|
||
REM Run the newly found full path to the executable within the build's workspace. | ||
cd %BUILD_WORKSPACE_DIRECTORY% | ||
!BUILDOZER! %* | ||
if %ERRORLEVEL% neq 0 ( | ||
exit /b %ERRORLEVEL% | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,8 @@ sh_binary( | |
}, | ||
srcs = ["run_buildozer.sh"], | ||
) | ||
|
||
alias( | ||
name = "buildozer_alias", | ||
actual = "@buildozer", | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of injecting this variable, we should be able to just use
buildozer_binary/buildozer
(plus the OS-dependent extension). That avoids having to stamp in the path, which in turn allows us to avoid the.bat
script. It looks pretty good (thanks for giving me an idea of what that would look like!), but I'm not sure that it fully follows the runfiles discovery process - for example, what if someone builds with runfiles enabled on Windows?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having an inner repo for the binary requires a rendered script. As far as I know, there is no other way to locate the binary when runfiles are disabled - which is the default state of a Windows box.
When running in command prompt, batch is also required. Here is a stock windows box with bazelisk only:
I updated the batch file to be a bit smarter. This is generally modeled after https://github.com/bazelbuild/bazel-skylib/blob/main/rules/diff_test.bzl, but unfortunately the test wrapper provides the runfiles envvars that make their runfiles discovery simpler, so we have a sillier MANIFEST direct lookup.
I think we need a batch runfiles library, only 10k lines of batch and you've got a repo mapping baby.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The batch script looks pretty accurate now, but I think that we can still avoid it. Please take a look at #23, which is based on your PR but hardcodes the rlocationpath with an apparent repository name. It doesn't work on 6.2.0 as the runfiles library had a bug, but it works on 6.x.