-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Windows,Skylark: write rule migration guide #3889
Comments
Bumping to P1 -- we committed to doing this work in Q4'2017. |
I plan to work on this next week. |
Some things I've hit:
Something that would be interesting is any advice for making the best of unsandboxed execution. For example, we're able to vendor the C# compiler via an external package, but we rely on the system-wide .NET framework installation. My assumption (we haven't got to the point of cache sharing yet) is that these unsandboxed/unvendored resources won't contribute to the digests used in caching. This could lead (naturally) to non-repeatable builds in a way that could be dangerous with cache-sharing. My guess at what I'll have to do is find some proxy to include as an input from outside the sandbox (e.g. there are files/registry keys that indicate the specific .NET framework release number) and "hope for the best". Any kind of insight here would be really helpful. If there's specific things we should document as rule authors on this topic that'd be good to know. |
I'd like to see a section on dealing with runfiles:
- which environment variables to discover location of the runfiles manifest
- avoid using runfiles for things which could just be inputs to the action
- whether to use runfiles manifest on non-Windows platforms
- how to patch tools that expect to read from the filesystem to do a lookup
through the manifest file instead (including helpers in many languages)
- how this applies in tests as well that rely on $TEST_SRCDIR
…On Thu, Dec 14, 2017 at 7:57 AM Jacob Parker ***@***.***> wrote:
Some things I've hit:
- Windows command line length limits. Many(?) tools use the "response
file" idiom which (usually?) maps to Bazel's param files (via ctx.Args)
directly (example PR:
https://github.com/bazelbuild/rules_dotnet/pull/47/files )
- ctx.actions.run should be used when possible (vs. the deprecated
ctx.action) to avoid bash
- Bash/etc. on windows should be avoided if possible (general perf,
difficulty with consistent environment, weird edge cases like #4013
<#4013>)
- Path length limits: a lot of tools (e.g. the C# compiler IIRC) are
still very limited. I don't think this has come up yet for me in
rule-writing specifically but maybe it could be a factor (we do set
--output_user_root to C:\tmp to generally mitigate this.)
Something that would be interesting is any advice for making the best of
unsandboxed execution. For example, we're able to vendor the C# compiler
via an external package, but we rely on the system-wide .NET framework
installation. My assumption (we haven't got to the point of cache sharing
yet) is that these unsandboxed/unvendored resources won't contribute to the
digests used in caching. This could lead (naturally) to non-repeatable
builds in a way that could be dangerous with cache-sharing.
My guess at what I'll have to do is find some proxy to include as an input
from outside the sandbox (e.g. there are files/registry keys that indicate
the specific .NET framework release number) and "hope for the best". Any
kind of insight here would be really helpful. If there's specific things we
should document as rule authors on this topic that'd be good to know.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3889 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAC5IzY-v-vk9WqIJAwP9wd9nh9VVlEEks5tAUVNgaJpZM4P1DsG>
.
|
Thank you @j3parker and @alexeagle , these are insightful and valuable ideas and questions. I'll incorporate them / their answers in the doc.
Frankly I have no good answer at the moment. (For the record, we don't know about the feasibility of sandboxing on Windows.)
That'd be one option. Another is to create a local repository for the .NET framework and write the .NET rules such that their actions depend on that local repository. Thanks for mentioning runfiles, I'll write a section on that. There's also #4279. |
Update: sorry for having dropped the ball on this issue. I never submitted any docs. @j3parker and @alexeagle , do you think it's still worthwhile to publish best practices for writing platform-aware Skylark rules? |
Yes, absolutely worthwhile.
…On Wed, May 16, 2018 at 1:59 AM László Csomor ***@***.***> wrote:
Update: sorry for having dropped the ball on this issue. I never submitted
any docs. @j3parker <https://github.com/j3parker> and @alexeagle
<https://github.com/alexeagle> , do you think it's still worthwhile to
publish best practices for writing platform-aware Skylark rules?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3889 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAC5I6Igt2sARiAg4vtVb--HNfseErXfks5ty-qMgaJpZM4P1DsG>
.
|
Thanks for the feedback. I'll try to get something done before the end of this quarter. |
@filipesilva suggested (#6764 (comment)) (in response to my question: "Where would you look for [this guide]?"):
|
Is there any preliminary version of this guide somewhere? Would be very useful for porting rules_haskell to Windows. |
Sorry, there isn't yet. Here are some tips that will go into that doc: Actions
Windows specific
Misc
|
Some more: cmd.exe
|
Question: do genrules on Windows use Bash? Does Bazel ship with a Bash layer for Windows? |
Yes, genrule uses Bash even on Windows. Bazel does not ship bash in the binary, it must be installed from Git (Git bash) or Msys2. |
So if I run Bazel in PowerShell, genrules will not work? Is it recommended to run Bazel in Git Bash / Msys2? |
Bazel works in any Windows shell (cmd, powershell and bash). It is just that Bazel will internally call bash for genrule, sh_test, sh_binary etc. |
OK, that sounds like what I was hoping for! 🙂 Just to clarify, if I run Bazel in PowerShell, and then build a |
It is better to set |
@njlr :
Correct. As @rongjiecomputer says, better to set I advise against using Git Bash as |
See bazelbuild#3889 Change-Id: Id768d8bd0cb996af566cdda518772ea329e5c6b2
See bazelbuild#3889 Change-Id: Id768d8bd0cb996af566cdda518772ea329e5c6b2
See bazelbuild#3889 Change-Id: Id768d8bd0cb996af566cdda518772ea329e5c6b2
See bazelbuild#3889 Change-Id: Id768d8bd0cb996af566cdda518772ea329e5c6b2 Closes bazelbuild#8420. Change-Id: I59c7952582decee585bbb23f7e8dc6d88e21aa73 PiperOrigin-RevId: 249431252
I'm closing this one because @laszlocsomor has done an excellent job in https://docs.bazel.build/versions/master/skylark/windows_tips.html Please file new issue or PR if you think anything else should be added in that guide. |
Write a guide on how to write portable Skylark rules.
The text was updated successfully, but these errors were encountered: