Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
purkhusid committed Apr 3, 2024
1 parent 1486f73 commit 4746e94
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 18 deletions.
3 changes: 1 addition & 2 deletions docs/defs.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dotnet/private/providers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ DotnetBinaryInfo = provider(
"app_host": "File: The apphost executable",
"dll": "File: The main binary dll",
"transitive_runtime_deps": "list[DotnetAssemblyRuntimeInfo]: The transitive runtime dependencies of the binary",
"runtime_pack_info": "DotnetRuntimePackInfo: The runtime pack for the binary",
},
)

Expand Down
1 change: 1 addition & 0 deletions dotnet/private/rules/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ bzl_library(
deps = [
"//dotnet/private:providers",
"//dotnet/private/sdk/apphost_packs:apphost_pack_transition",
"//dotnet/private/sdk/runtime_packs:runtime_pack_transition",
"//dotnet/private/sdk/targeting_packs:targeting_pack_transition",
"//dotnet/private/transitions:default_transition",
"//dotnet/private/transitions:tfm_transition",
Expand Down
5 changes: 5 additions & 0 deletions dotnet/private/rules/common/attrs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
load("@bazel_skylib//lib:dicts.bzl", "dicts")
load("//dotnet/private:providers.bzl", "DotnetAssemblyCompileInfo", "DotnetAssemblyRuntimeInfo")
load("//dotnet/private/sdk/apphost_packs:apphost_pack_transition.bzl", "apphost_pack_transition")
load("//dotnet/private/sdk/runtime_packs:runtime_pack_transition.bzl", "runtime_pack_transition")
load("//dotnet/private/sdk/targeting_packs:targeting_pack_transition.bzl", "targeting_pack_transition")
load("//dotnet/private/transitions:default_transition.bzl", "default_transition")
load("//dotnet/private/transitions:tfm_transition.bzl", "tfm_transition")
Expand Down Expand Up @@ -194,6 +195,10 @@ BINARY_COMMON_ATTRS = {
default = "//dotnet/private/sdk/apphost_packs:apphost_pack",
cfg = apphost_pack_transition,
),
"_runtime_pack": attr.label(
default = "//dotnet/private/sdk/runtime_packs:runtime_pack",
cfg = runtime_pack_transition,
),
}

# These are attributes that are common across all the binary/library/test C# rules
Expand Down
3 changes: 2 additions & 1 deletion dotnet/private/rules/common/binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ load(
"is_standard_framework",
"to_rlocation_path",
)
load("//dotnet/private:providers.bzl", "DotnetApphostPackInfo", "DotnetBinaryInfo")
load("//dotnet/private:providers.bzl", "DotnetApphostPackInfo", "DotnetBinaryInfo", "DotnetRuntimePackInfo")

def _create_shim_exe(ctx, dll):
windows_constraint = ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]
Expand Down Expand Up @@ -156,6 +156,7 @@ def build_binary(ctx, compile_action):
dll = dll,
app_host = app_host,
transitive_runtime_deps = transitive_runtime_deps,
runtime_pack_info = ctx.attr._runtime_pack[0][DotnetRuntimePackInfo],
)

return [default_info, dotnet_binary_info, compile_provider, runtime_provider]
17 changes: 3 additions & 14 deletions dotnet/private/rules/publish_binary/publish_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ Rules for compiling F# binaries.

load("@bazel_skylib//lib:shell.bzl", "shell")
load("//dotnet/private:common.bzl", "generate_depsjson", "generate_runtimeconfig", "to_rlocation_path")
load("//dotnet/private:providers.bzl", "DotnetAssemblyCompileInfo", "DotnetAssemblyRuntimeInfo", "DotnetBinaryInfo", "DotnetRuntimePackInfo")
load("//dotnet/private/sdk/runtime_packs:runtime_pack_transition.bzl", "runtime_pack_transition")
load("//dotnet/private:providers.bzl", "DotnetAssemblyCompileInfo", "DotnetAssemblyRuntimeInfo", "DotnetBinaryInfo")
load("//dotnet/private/transitions:tfm_transition.bzl", "tfm_transition")

def _copy_file(script_body, src, dst, is_windows):
Expand Down Expand Up @@ -154,8 +153,8 @@ def _publish_binary_impl(ctx):
target_framework = ctx.attr.target_framework
is_self_contained = ctx.attr.self_contained
assembly_name = assembly_runtime_info.name
runtime_pack_info = ctx.attr._runtime_pack[0][DotnetRuntimePackInfo] if is_self_contained else None
runtime_identifier = ctx.attr._runtime_pack[0][DotnetRuntimePackInfo].runtime_identifier
runtime_pack_info = binary_info.runtime_pack_info if is_self_contained else None
runtime_identifier = binary_info.runtime_pack_info.runtime_identifier
roll_forward_behavior = ctx.attr.roll_forward_behavior

(executable, runfiles) = _copy_to_publish(
Expand Down Expand Up @@ -216,12 +215,6 @@ publish_binary = rule(
cfg = tfm_transition,
mandatory = True,
),
"project_sdk": attr.string(
doc = "The project SDK that is being targeted. " +
"See https://learn.microsoft.com/en-us/dotnet/core/project-sdk/overview",
default = "default",
values = ["default", "web"],
),
"self_contained": attr.bool(
doc = """
Whether the binary should be self-contained.
Expand Down Expand Up @@ -249,10 +242,6 @@ publish_binary = rule(
default = "Minor",
values = ["Minor", "Major", "LatestPatch", "LatestMinor", "LatestMajor", "Disable"],
),
"_runtime_pack": attr.label(
default = "//dotnet/private/sdk/runtime_packs:runtime_pack",
cfg = runtime_pack_transition,
),
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
Expand Down
1 change: 0 additions & 1 deletion examples/aspnetcore/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ csharp_binary(
publish_binary(
name = "publish",
binary = ":aspnetcore",
project_sdk = "web",
self_contained = True,
target_framework = "net6.0",
)

0 comments on commit 4746e94

Please sign in to comment.