Skip to content

Commit

Permalink
build: rename 'prepare_build_context' (#4003)
Browse files Browse the repository at this point in the history
Rename to reflect that this step isn't necessarily associated
with building and is simply a step to prepare a hermetic environment
to either build or execute things against.
  • Loading branch information
vindard authored Feb 15, 2024
1 parent dab5cc1 commit 11b65dc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion toolchains/workspace-pnpm/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export_file(
)

export_file(
name = "prepare_build_context.py",
name = "prepare_package_context.py",
visibility = ["PUBLIC"],
)

Expand Down
16 changes: 8 additions & 8 deletions toolchains/workspace-pnpm/macros.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ build_node_modules = rule(
)

def tsc_build_impl(ctx: AnalysisContext) -> list[DefaultInfo]:
build_context = prepare_build_context(ctx)
build_context = prepare_package_context(ctx)

out = ctx.actions.declare_output("dist", dir = True)
pnpm_toolchain = ctx.attrs._workspace_pnpm_toolchain[WorkspacePnpmToolchainInfo]
Expand Down Expand Up @@ -436,7 +436,7 @@ def prod_tsc_build_bin(
)

def next_build_impl(ctx: AnalysisContext) -> list[[DefaultInfo, RunInfo]]:
build_context = prepare_build_context(ctx)
build_context = prepare_package_context(ctx)

out = ctx.actions.declare_output("dist", dir = True)
pnpm_toolchain = ctx.attrs._workspace_pnpm_toolchain[WorkspacePnpmToolchainInfo]
Expand Down Expand Up @@ -574,19 +574,19 @@ _next_build_bin = rule(
},
)

BuildContext = record(
PackageContext = record(
workspace_root = field(Artifact),
)

def prepare_build_context(ctx: AnalysisContext) -> BuildContext:
def prepare_package_context(ctx: AnalysisContext) -> PackageContext:
workspace_root = ctx.actions.declare_output("__workspace", dir = True)

pnpm_toolchain = ctx.attrs._workspace_pnpm_toolchain[WorkspacePnpmToolchainInfo]
package_dir = cmd_args(ctx.label.package).relative_to(ctx.label.cell_root)

cmd = cmd_args(
ctx.attrs._python_toolchain[PythonToolchainInfo].interpreter,
pnpm_toolchain.prepare_build_context[DefaultInfo].default_outputs,
pnpm_toolchain.prepare_package_context[DefaultInfo].default_outputs,
"--package-dir",
package_dir,
"--node-modules-path",
Expand All @@ -605,9 +605,9 @@ def prepare_build_context(ctx: AnalysisContext) -> BuildContext:
cmd.add(cmd_args(src, format = name + "={}"))
cmd.add(workspace_root.as_output())

ctx.actions.run(cmd, category = "prepare_build_context", identifier = ctx.label.package)
ctx.actions.run(cmd, category = "prepare_package_context", identifier = ctx.label.package)

return BuildContext(
return PackageContext(
workspace_root = workspace_root,
)

Expand All @@ -621,7 +621,7 @@ def _npm_test_impl(
RunInfo,
ExternalRunnerTestInfo,
]]:
build_context = prepare_build_context(ctx)
build_context = prepare_package_context(ctx)

pnpm_toolchain = ctx.attrs._workspace_pnpm_toolchain[WorkspacePnpmToolchainInfo]

Expand Down
8 changes: 4 additions & 4 deletions toolchains/workspace-pnpm/toolchain.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WorkspacePnpmToolchainInfo = provider(fields = [
"build_node_modules",
"build_npm_bin",
"prepare_build_context",
"prepare_package_context",
"compile_typescript",
"package_prod_tsc_build",
"package_prod_tsc_build_bin",
Expand All @@ -20,7 +20,7 @@ def workspace_pnpm_toolchain_impl(ctx) -> list[[DefaultInfo, WorkspacePnpmToolch
WorkspacePnpmToolchainInfo(
build_node_modules = ctx.attrs._build_node_modules,
build_npm_bin = ctx.attrs._build_npm_bin,
prepare_build_context = ctx.attrs._prepare_build_context,
prepare_package_context = ctx.attrs._prepare_package_context,
compile_typescript = ctx.attrs._compile_typescript,
package_prod_tsc_build = ctx.attrs._package_prod_tsc_build,
package_prod_tsc_build_bin = ctx.attrs._package_prod_tsc_build_bin,
Expand All @@ -40,8 +40,8 @@ workspace_pnpm_toolchain = rule(
"_build_npm_bin": attrs.dep(
default = "toolchains//workspace-pnpm:build_npm_bin.py",
),
"_prepare_build_context": attrs.dep(
default = "toolchains//workspace-pnpm:prepare_build_context.py",
"_prepare_package_context": attrs.dep(
default = "toolchains//workspace-pnpm:prepare_package_context.py",
),
"_compile_typescript": attrs.dep(
default = "toolchains//workspace-pnpm:compile_typescript.py",
Expand Down

0 comments on commit 11b65dc

Please sign in to comment.