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

Remote exec fixes #277

Merged
merged 7 commits into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ tasks:

vscode:
extensions:
- BazelBuild.vscode-bazel@0.4.1
- Ionide.Ionide-fsharp@5.7.3
- muhammad-sammy.csharp@1.23.16
- BazelBuild.vscode-bazel@0.5.0
- Ionide.Ionide-fsharp@5.11.1
- muhammad-sammy.csharp@1.24.0

github:
prebuilds:
Expand Down
4 changes: 2 additions & 2 deletions .gitpod/gitpod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ RUN curl -o ibazel_linux_amd64 -fsSL https://github.com/bazelbuild/bazel-watcher
&& chmod +x $HOME/bin/ibazel

# Install buildifier
RUN curl -o buildifier-linux-amd64 -fsSL https://github.com/bazelbuild/buildtools/releases/download/4.2.2/buildifier-linux-amd64 \
RUN curl -o buildifier-linux-amd64 -fsSL https://github.com/bazelbuild/buildtools/releases/download/5.0.1/buildifier-linux-amd64 \
&& mv ./buildifier-linux-amd64 $HOME/bin/buildifier \
&& chmod +x $HOME/bin/buildifier

# Install buildozer
RUN curl -o buildozer-linux-amd64 -fsSL https://github.com/bazelbuild/buildtools/releases/download/4.2.2/buildozer-linux-amd64 \
RUN curl -o buildozer-linux-amd64 -fsSL https://github.com/bazelbuild/buildtools/releases/download/5.0.1/buildozer-linux-amd64 \
&& mv ./buildozer-linux-amd64 $HOME/bin/buildozer \
&& chmod +x $HOME/bin/buildozer
9 changes: 9 additions & 0 deletions dotnet/private/actions/assembly_core.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ def emit_assembly_core_csharp(
arguments = action_args,
mnemonic = "Compile",
tools = runner_tools,
env = {
# Set so that compilations work on remote execution workers that don't have ICU installed
# ICU should not be required during compliation but only at runtime
"DOTNET_SYSTEM_GLOBALIZATION_INVARIANT": "1",
},
progress_message = (
"Compiling " + dotnet.label.package + ":" + dotnet.label.name
),
Expand Down Expand Up @@ -217,6 +222,7 @@ def emit_assembly_core_csharp(

return new_library

# buildifier: disable=unused-variable
def emit_assembly_core_fsharp(
dotnet,
name,
Expand Down Expand Up @@ -407,6 +413,9 @@ def emit_assembly_core_fsharp(
# If the script is in a directory using a 'global.json' then ensure the relevant .NET SDK is installed. The output from '/path/to/dotnet --version' in the directory '/path' was:
# 'The user's home directory could not be determined. Set the 'DOTNET_CLI_HOME' environment variable to specify the directory to use.' and the exit code was '1'.
"DOTNET_CLI_HOME": runner.executable.dirname,
# Set so that compilations work on remote execution workers that don't have ICU installed
# ICU should not be required during compliation but only at runtime
"DOTNET_SYSTEM_GLOBALIZATION_INVARIANT": "1",
},
progress_message = (
"Compiling " + dotnet.label.package + ":" + dotnet.label.name
Expand Down
1 change: 1 addition & 0 deletions dotnet/private/actions/resolve.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ def _ResolveTransitiveLevel9(arg, version):

fail("Unknown argument %s" % arg)

# buildifier: disable=unused-variable
def _ResolveTransitiveLevel10(arg, version):
result = []
if (type(arg)) == "list":
Expand Down
4 changes: 2 additions & 2 deletions dotnet/private/actions/resx_core.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ load(
"DotnetResourceInfo",
)

def _make_runner_arglist(dotnet, source, output, resgen):
def _make_runner_arglist(dotnet, source, output):
args = dotnet.actions.args()

if type(source) == "Target":
Expand Down Expand Up @@ -46,7 +46,7 @@ def emit_resx_core(
else:
result = dotnet.actions.declare_file(out)

args = _make_runner_arglist(dotnet, src, result, customresgen.files_to_run.executable.path)
args = _make_runner_arglist(dotnet, src, result)

# We use the command to extrace shell path and force runfiles creation
resolve = dotnet._ctx.resolve_tools(tools = [customresgen])
Expand Down
8 changes: 0 additions & 8 deletions dotnet/private/context.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ DotnetContextInfo = provider(
},
)

def _declare_file(dotnet, path = None, ext = None, sibling = None):
result = path if path else dotnet._ctx.label.name
if ext:
result += ext
return dotnet.actions.declare_file(result, sibling = sibling)

def new_library(
dotnet,
name = None,
Expand Down Expand Up @@ -137,8 +131,6 @@ def dotnet_context(ctx, lang):
Returns:
DotnetContextInfo: [DotnetContextInfo](api.md#dotnetcontextinfo) provider for ctx rule.
"""
attr = ctx.attr

if lang == "csharp":
toolchain = ctx.toolchains["@io_bazel_rules_dotnet//dotnet:toolchain_type_csharp_core"]
elif lang == "fsharp":
Expand Down
2 changes: 0 additions & 2 deletions dotnet/private/rules/csharp/library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ def _library_impl(ctx):
version = (0, 0, 0, 0, "") if ctx.attr.version == "" else parse_version(ctx.attr.version),
)

runfiles = ctx.runfiles(files = [], transitive_files = library.runfiles)

return [
library,
DefaultInfo(
Expand Down
2 changes: 0 additions & 2 deletions dotnet/private/rules/fsharp/library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ def _library_impl(ctx):
version = (0, 0, 0, 0, "") if ctx.attr.version == "" else parse_version(ctx.attr.version),
)

runfiles = ctx.runfiles(files = [], transitive_files = library.runfiles)

return [
library,
DefaultInfo(
Expand Down
20 changes: 0 additions & 20 deletions dotnet/private/rules/nuget.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ def _dotnet_nuget_impl(
build_file_content = None):
"""dotnet_nuget_impl emits actions for exposing nunit assmebly."""

package = ctx.attr.package
output_dir = ctx.path("")
url = ctx.attr.source + "/" + ctx.attr.package + "/" + ctx.attr.version
ctx.download_and_extract(url, output_dir, ctx.attr.sha256, type = "zip")
Expand Down Expand Up @@ -123,24 +122,6 @@ _FUNC2 = """

"""

def _get_importlib(func, func2, name, lib, ref, deps, files, version):
depsstr = ""
for d in deps:
depsstr += " \"{}\",\n".format(d)
datastr = ""
for f in files:
datastr += " \"{}\",\n".format(f)

if lib != "":
if ref != "" and ref != None:
result = _FUNC_WITH_REF.format(func, name, lib, ref, depsstr, datastr, version)
else:
result = _FUNC.format(func, name, lib, depsstr, datastr, version)
else:
result = _FUNC2.format(func2, name, depsstr, datastr)

return result

def _get_importlib_withframework(func, func2, name, frameworks, lib, ref, deps, files, version):
result = ""
for framework in frameworks:
Expand Down Expand Up @@ -197,7 +178,6 @@ def _nuget_package_impl(ctx):
content = content + """"{}": "{}",""".format(key, val)
content += """}, no_match_error = "framework not known"), visibility=["//visibility:public"])\n"""

package = ctx.attr.package
output_dir = ctx.path("")
urls = [s + "/" + ctx.attr.package + "/" + ctx.attr.version for s in ctx.attr.source]
ctx.download_and_extract(urls, output_dir, ctx.attr.sha256, type = "zip")
Expand Down
8 changes: 0 additions & 8 deletions dotnet/private/rules/resource_core.bzl
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
".resource rules"

load(
"@io_bazel_rules_dotnet//dotnet/private:context.bzl",
"dotnet_context",
)
load(
"@io_bazel_rules_dotnet//dotnet/private:providers.bzl",
"DotnetResourceInfo",
Expand All @@ -13,7 +9,6 @@ load("@rules_dotnet_skylib//lib:paths.bzl", "paths")

def _resource_impl(ctx):
"""core_resource_impl emits actions for embeding file as resource."""
dotnet = dotnet_context(ctx, "csharp")
name = ctx.label.name

resource = DotnetResourceInfo(
Expand All @@ -31,9 +26,6 @@ def _resource_impl(ctx):
]

def _resource_multi_impl(ctx):
dotnet = dotnet_context(ctx, "csharp")
name = ctx.label.name

if ctx.attr.identifierBase != "" and ctx.attr.fixedIdentifierBase != "":
fail("Both identifierBase and fixedIdentifierBase cannot be specified")

Expand Down
1 change: 0 additions & 1 deletion dotnet/private/rules/resx.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def _resx_impl(ctx):

def _resx_multi_impl(ctx):
dotnet = dotnet_context(ctx, "csharp")
name = ctx.label.name

if ctx.attr.identifierBase != "" and ctx.attr.fixedIdentifierBase != "":
fail("Both identifierBase and fixedIdentifierBase cannot be specified")
Expand Down
2 changes: 2 additions & 0 deletions dotnet/toolchain/toolchains.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ _toolchains = _generate_toolchains()

_label_prefix = "@io_bazel_rules_dotnet//dotnet/toolchain:"

# buildifier: disable=unused-variable
def dotnet_register_toolchains(name = None):
"""The macro registers all toolchains."""

Expand Down Expand Up @@ -201,6 +202,7 @@ def declare_toolchains():
)

# buildifier: disable=function-docstring-args
# buildifier: disable=unused-variable
def declare_constraints(name = None):
"""Generates constraint_values and platform targets for valid platforms.
"""
Expand Down