mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-02-18 13:54:23 -05:00
bazel: build both cli variants as part of devbuild
This commit is contained in:
parent
c62e54831b
commit
26bc653d0e
3
.bazelrc
3
.bazelrc
@ -29,6 +29,9 @@ test --//bazel/settings:tpm_simulator
|
|||||||
# set registry flag alias
|
# set registry flag alias
|
||||||
build --flag_alias=container_prefix=//bazel/settings:container_prefix
|
build --flag_alias=container_prefix=//bazel/settings:container_prefix
|
||||||
|
|
||||||
|
# set cli edition flag alias
|
||||||
|
build --flag_alias=cli_edition=//bazel/settings:cli_edition
|
||||||
|
|
||||||
# build only what is needed for tests
|
# build only what is needed for tests
|
||||||
test --build_tests_only
|
test --build_tests_only
|
||||||
|
|
||||||
|
@ -1,21 +1,28 @@
|
|||||||
load("//bazel/sh:def.bzl", "sh_template")
|
load("//bazel/sh:def.bzl", "sh_template")
|
||||||
|
load(":def.bzl", "cli_edition")
|
||||||
|
|
||||||
sh_template(
|
sh_template(
|
||||||
name = "devbuild",
|
name = "devbuild",
|
||||||
data = [
|
data = [
|
||||||
|
":devbuild_cli_edition",
|
||||||
"//bazel/release:container_sums",
|
"//bazel/release:container_sums",
|
||||||
"//bootstrapper/cmd/bootstrapper:bootstrapper_linux_amd64",
|
"//bootstrapper/cmd/bootstrapper:bootstrapper_linux_amd64",
|
||||||
"//cli:cli_oss_host",
|
"//cli:cli_edition_host",
|
||||||
"//debugd/cmd/cdbg:cdbg_host",
|
"//debugd/cmd/cdbg:cdbg_host",
|
||||||
"//upgrade-agent/cmd:upgrade_agent_linux_amd64",
|
"//upgrade-agent/cmd:upgrade_agent_linux_amd64",
|
||||||
],
|
],
|
||||||
substitutions = {
|
substitutions = {
|
||||||
"@@BOOTSTRAPPER@@": "$(rootpath //bootstrapper/cmd/bootstrapper:bootstrapper_linux_amd64)",
|
"@@BOOTSTRAPPER@@": "$(rootpath //bootstrapper/cmd/bootstrapper:bootstrapper_linux_amd64)",
|
||||||
"@@CDBG@@": "$(rootpath //debugd/cmd/cdbg:cdbg_host)",
|
"@@CDBG@@": "$(rootpath //debugd/cmd/cdbg:cdbg_host)",
|
||||||
"@@CLI@@": "$(rootpath //cli:cli_oss_host)",
|
"@@CLI@@": "$(rootpath //cli:cli_edition_host)",
|
||||||
"@@CONTAINER_SUMS@@": "$(rootpath //bazel/release:container_sums)",
|
"@@CONTAINER_SUMS@@": "$(rootpath //bazel/release:container_sums)",
|
||||||
|
"@@EDITION@@": "$(rootpath :devbuild_cli_edition)",
|
||||||
"@@UPGRADE_AGENT@@": "$(rootpath //upgrade-agent/cmd:upgrade_agent_linux_amd64)",
|
"@@UPGRADE_AGENT@@": "$(rootpath //upgrade-agent/cmd:upgrade_agent_linux_amd64)",
|
||||||
},
|
},
|
||||||
template = "prepare_developer_workspace.sh.in",
|
template = "prepare_developer_workspace.sh.in",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cli_edition(
|
||||||
|
name = "devbuild_cli_edition",
|
||||||
|
)
|
||||||
|
21
bazel/devbuild/def.bzl
Normal file
21
bazel/devbuild/def.bzl
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
"""Bazel rules for devbuild"""
|
||||||
|
|
||||||
|
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
|
||||||
|
|
||||||
|
def _cli_edition_impl(ctx):
|
||||||
|
cli_edition = ctx.attr._cli_edition[BuildSettingInfo].value
|
||||||
|
if cli_edition == None or cli_edition == "":
|
||||||
|
fail("--cli_edition is not set in .bazeloverwriterc")
|
||||||
|
if cli_edition not in ["oss", "enterprise"]:
|
||||||
|
fail("--cli_edition must be 'oss' or 'enterprise' in .bazeloverwriterc")
|
||||||
|
|
||||||
|
output = ctx.actions.declare_file(ctx.label.name + ".txt")
|
||||||
|
ctx.actions.write(output = output, content = cli_edition)
|
||||||
|
return [DefaultInfo(files = depset([output]))]
|
||||||
|
|
||||||
|
cli_edition = rule(
|
||||||
|
implementation = _cli_edition_impl,
|
||||||
|
attrs = {
|
||||||
|
"_cli_edition": attr.label(default = Label("//bazel/settings:cli_edition")),
|
||||||
|
},
|
||||||
|
)
|
@ -24,6 +24,7 @@ cdbg=$(realpath @@CDBG@@)
|
|||||||
stat "${cdbg}" >> /dev/null
|
stat "${cdbg}" >> /dev/null
|
||||||
container_sums=$(realpath @@CONTAINER_SUMS@@)
|
container_sums=$(realpath @@CONTAINER_SUMS@@)
|
||||||
stat "${container_sums}" >> /dev/null
|
stat "${container_sums}" >> /dev/null
|
||||||
|
edition=$(cat @@EDITION@@)
|
||||||
|
|
||||||
cd "${BUILD_WORKING_DIRECTORY}"
|
cd "${BUILD_WORKING_DIRECTORY}"
|
||||||
|
|
||||||
@ -51,8 +52,10 @@ else
|
|||||||
workdir="$1"
|
workdir="$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Using ${edition} cli edition"
|
||||||
|
|
||||||
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${bootstrapper}")" "${workdir}/bootstrapper"
|
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${bootstrapper}")" "${workdir}/bootstrapper"
|
||||||
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${upgrade_agent}")" "${workdir}/upgrade-agent"
|
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${upgrade_agent}")" "${workdir}/upgrade-agent"
|
||||||
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${cli}")" "${workdir}/constellation"
|
|
||||||
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${cdbg}")" "${workdir}/cdbg"
|
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${cdbg}")" "${workdir}/cdbg"
|
||||||
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${container_sums}")" "${workdir}/container_sums.sha256"
|
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${container_sums}")" "${workdir}/container_sums.sha256"
|
||||||
|
ln -sf "$(replace_prefix "${host_cache}" "${builder_cache}" "${cli}")" "${workdir}/constellation"
|
||||||
|
@ -80,8 +80,8 @@ multirun(
|
|||||||
multirun(
|
multirun(
|
||||||
name = "build_and_push",
|
name = "build_and_push",
|
||||||
commands = [
|
commands = [
|
||||||
"//bazel/devbuild:devbuild",
|
|
||||||
"//bazel/release:push",
|
"//bazel/release:push",
|
||||||
|
"//bazel/devbuild:devbuild",
|
||||||
],
|
],
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
@ -41,6 +41,31 @@ string_flag(
|
|||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
string_flag(
|
||||||
|
name = "cli_edition",
|
||||||
|
build_setting_default = "",
|
||||||
|
values = [
|
||||||
|
"",
|
||||||
|
"enterprise",
|
||||||
|
"oss",
|
||||||
|
],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
|
|
||||||
|
config_setting(
|
||||||
|
name = "cli_edition_enterprise",
|
||||||
|
flag_values = {
|
||||||
|
":cli_edition": "enterprise",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
config_setting(
|
||||||
|
name = "cli_edition_oss",
|
||||||
|
flag_values = {
|
||||||
|
":cli_edition": "oss",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
bool_flag(
|
bool_flag(
|
||||||
name = "select_never",
|
name = "select_never",
|
||||||
build_setting_default = False,
|
build_setting_default = False,
|
||||||
|
@ -57,3 +57,15 @@ go_binary(
|
|||||||
"enterprise",
|
"enterprise",
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
alias(
|
||||||
|
name = "cli_edition_host",
|
||||||
|
actual = select(
|
||||||
|
{
|
||||||
|
"//bazel/settings:cli_edition_enterprise": ":cli_enterprise_host",
|
||||||
|
"//bazel/settings:cli_edition_oss": ":cli_oss_host",
|
||||||
|
"//conditions:default": ":cli_oss_host",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
|
@ -46,13 +46,14 @@ cd build
|
|||||||
# and symlink them into the current directory
|
# and symlink them into the current directory
|
||||||
# also push the built container images
|
# also push the built container images
|
||||||
# After the first run, set the pushed imaged to public.
|
# After the first run, set the pushed imaged to public.
|
||||||
bazel run //:devbuild --container_prefix=ghcr.io/USERNAME/constellation
|
bazel run //:devbuild --cli_edition=oss --container_prefix=ghcr.io/USERNAME/constellation
|
||||||
./constellation ...
|
./constellation ...
|
||||||
```
|
```
|
||||||
|
|
||||||
Overwrite the default container_prefix in the `.bazeloverwriterc` in the root of the workspace:
|
Overwrite the default container_prefix in the `.bazeloverwriterc` in the root of the workspace:
|
||||||
```bazel
|
```bazel
|
||||||
# cat .bazeloverwriterc
|
# cat .bazeloverwriterc
|
||||||
|
build --cli_edition=oss
|
||||||
build --container_prefix=ghcr.io/USERNAME/constellation
|
build --container_prefix=ghcr.io/USERNAME/constellation
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user