Skip to content
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
31 changes: 17 additions & 14 deletions buck2/cpp/.buckconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@
# limitations under the License.

[cells]
root = .
prelude = prelude
toolchains = toolchains
none = none
root = .
prelude = prelude
toolchains = toolchains
none = none

[cell_aliases]
config = prelude
ovr_config = prelude
fbcode = none
fbsource = none
fbcode_macros = none
buck = none
config = prelude
ovr_config = prelude
fbcode = none
fbsource = none
fbcode_macros = none
buck = none

# Uses a copy of the prelude bundled with the buck2 binary. You can alternatively delete this
# section and vendor a copy of the prelude to the `prelude` directory of your project.
[external_cells]
prelude = bundled
prelude = bundled

[parser]
target_platform_detector_spec = target:root//...->prelude//platforms:default
target_platform_detector_spec = target:root//...->root//platforms:remote_platform

[buck2]
digest_algorithms = SHA256
Expand All @@ -44,7 +44,10 @@ cas_address = <CLUSTER_NAME>.cluster.engflow.com
http_headers = <AUTH_HTTP_HEADERS>

[build]
execution_platforms = root//platforms:remote_platform
execution_platforms = root//platforms:remote_platform

[project]
ignore = .git
ignore = .git

[re]
remote_execution_test_build_mode = root//platforms:remote_execution_action_keys
9 changes: 0 additions & 9 deletions buck2/cpp/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@ cxx_binary(
name = "main",
srcs = ["main.cpp"],
link_style = "static",
exec_compatible_with = ["//platforms:remote_platform"],
default_target_platform = "//platforms:remote_platform",
)

cxx_binary(
name = "cpp",
srcs = ["main.cc"],
deps = [":cpp_lib"],
exec_compatible_with = ["//platforms:remote_platform"],
default_target_platform = "//platforms:remote_platform",
)

cxx_library(
Expand All @@ -35,8 +31,6 @@ cxx_library(
],
exported_headers = glob(["**/*.h"]),
visibility = ["PUBLIC"],
exec_compatible_with = ["//platforms:remote_platform"],
default_target_platform = "//platforms:remote_platform",
)

cxx_test(
Expand All @@ -45,7 +39,4 @@ cxx_test(
deps = [
":cpp_lib",
],
exec_compatible_with = ["//platforms:remote_platform"],
default_target_platform = "//platforms:remote_platform",
remote_execution_action_key_providers = "//platforms:remote_execution_action_keys",
)
4 changes: 2 additions & 2 deletions buck2/cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ Clone the repository and replace the relevant configs in `.buckconfig`.
Build the example:

```
buck2 build //:cpp_lib
buck2 build --remote-only //:cpp_lib
```

Test the example:

```
buck2 test //:cpp_test
buck2 test --remote-only //:cpp_test
```
27 changes: 15 additions & 12 deletions buck2/golang/.buckconfig
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
[cells]
root = .
prelude = prelude
toolchains = toolchains
none = none
root = .
prelude = prelude
toolchains = toolchains
none = none

[cell_aliases]
config = prelude
fbcode = none
fbsource = none
buck = none
config = prelude
fbcode = none
fbsource = none
buck = none

[external_cells]
prelude = bundled
prelude = bundled

[parser]
target_platform_detector_spec = target:root//...->prelude//platforms:default
target_platform_detector_spec = target:root//...->root//platforms:remote_platform

[buck2]
digest_algorithms = SHA256
Expand All @@ -26,7 +26,10 @@ cas_address = <CLUSTER_NAME>.cluster.engflow.com
http_headers = <AUTH_HTTP_HEADERS>

[build]
execution_platforms = root//platforms:remote_platform
execution_platforms = root//platforms:remote_platform

[project]
ignore = .git
ignore = .git

[re]
remote_execution_test_build_mode = root//platforms:remote_execution_action_keys
6 changes: 3 additions & 3 deletions buck2/golang/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ It is based on three existing samples in the Buck2 upstream repo and the EngFlow
In the `platforms` cell we specify:
* The platform used for remote execution in this project `root//platforms:remote_platform`, which includes the definition of the Docker image used for remote execution, and that defines constraints for targets to run in the remote execution environment. This platform provides an `ExecutionPlatformRegistrationInfo`.
* The action keys `root//platforms:remote_execution_action_keys`, which provides a default `BuildModeInfo` that is needed for RE of tests to function properly.
* The platform `image` configured in `platforms/defs.bzl`, notably, uses a different image than other Buck2 samples in this repo. Specifically, it uses a public AWS image that has `go` preinstalled. This is because, unlike Bazel go rules, Buck2 go rules do not include a hermetic go binary.
* The platform `image` configured in `platforms/defs.bzl`, notably, uses a different image than other Buck2 samples in this repo. Specifically, it uses a public AWS image that has `go` preinstalled. This is because, unlike Bazel go rules, Buck2 go rules do not include a hermetic go binary. Image details can be found in https://gallery.ecr.aws/docker/library/golang. he Dockerfile can be found in https://github.com/docker-library/golang/blob/master/1.23/bookworm/Dockerfile.

In the `toolchains` cell we specify:

Expand All @@ -27,13 +27,13 @@ The `main` cell and `library` cell:
To test this cell with RE run (after setting up `.buckconfig` as indicated below):

```
buck2 test //go/greeting:greeting_test
buck2 test --remote-only //go/greeting:greeting_test
```

You can also build the `main` for this sample by running:

```
buck2 build //go:hello
buck2 build --remote-only //go:hello
```

### Relevant configs in `.buckconfig`
Expand Down
1 change: 0 additions & 1 deletion buck2/golang/go/greeting/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ go_library(
go_test(
name = "greeting_test",
srcs = glob(["*.go"]),
remote_execution_action_key_providers = "//platforms:remote_execution_action_keys",
)
4 changes: 3 additions & 1 deletion buck2/golang/platforms/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def _platforms(ctx):

# A bookworm image with go pre-installed.
# Unlike Bazel go_toolchain, Buck2 go_toolchain does not include a hermetic go binary. Image details can be found in https://gallery.ecr.aws/docker/library/golang.
# The Dockerfile can be found in https://github.com/docker-library/golang/blob/master/1.23/bookworm/Dockerfile.
image = "docker://public.ecr.aws/docker/library/golang:1.23.3-bookworm@sha256:3f3b9daa3de608f3e869cd2ff8baf21555cf0fca9fd34251b8f340f9b7c30ec5"
name = ctx.label.raw_target()
platform = ExecutionPlatformInfo(
Expand All @@ -46,6 +47,7 @@ def _platforms(ctx):
return [
DefaultInfo(),
ExecutionPlatformRegistrationInfo(platforms = [platform]),
PlatformInfo(label = str(name), configuration = configuration),
]

def _action_keys(ctx):
Expand All @@ -55,7 +57,7 @@ def _action_keys(ctx):
]

platforms = rule(
attrs = {},
attrs = {},
impl = _platforms
)

Expand Down
27 changes: 15 additions & 12 deletions buck2/python/.buckconfig
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
[cells]
root = .
prelude = prelude
toolchains = toolchains
none = none
root = .
prelude = prelude
toolchains = toolchains
none = none

[cell_aliases]
config = prelude
fbcode = none
fbsource = none
buck = none
config = prelude
fbcode = none
fbsource = none
buck = none

[external_cells]
prelude = bundled
prelude = bundled

[parser]
target_platform_detector_spec = target:root//...->prelude//platforms:default
target_platform_detector_spec = target:root//...->root//platforms:remote_platform

[buck2]
digest_algorithms = SHA256
Expand All @@ -26,7 +26,10 @@ cas_address = <CLUSTER_NAME>.cluster.engflow.com
http_headers = <AUTH_HTTP_HEADERS>

[build]
execution_platforms = root//platforms:remote_platform
execution_platforms = root//platforms:remote_platform

[project]
ignore = .git
ignore = .git

[re]
remote_execution_test_build_mode = root//platforms:remote_execution_action_keys
4 changes: 2 additions & 2 deletions buck2/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The `main` cell and `library` cell:
To test these cells with RE run (after setting up `.buckconfig` as indicated below):

```
buck2 build //main:check_main
buck2 build --remote-only //main:check_main
```

The `hello` cell:
Expand All @@ -36,7 +36,7 @@ The `hello` cell:
To test this cell with RE run (after setting up `.buckconfig` as indicated below):

```
buck2 test //hello:hello_unittest_test
buck2 test --remote-only //hello:hello_unittest_test
```

### Relevant configs in `.buckconfig`
Expand Down
1 change: 0 additions & 1 deletion buck2/python/hello/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ python_test(
name = "hello_unittest_test",
srcs = ["hello_unittest_test.py"],
deps = [":hellolib"],
remote_execution_action_key_providers = "//platforms:remote_execution_action_keys",
)
3 changes: 2 additions & 1 deletion buck2/python/platforms/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def _platforms(ctx):
return [
DefaultInfo(),
ExecutionPlatformRegistrationInfo(platforms = [platform]),
PlatformInfo(label = str(name), configuration = configuration),
]

def _action_keys(ctx):
Expand All @@ -54,7 +55,7 @@ def _action_keys(ctx):
]

platforms = rule(
attrs = {},
attrs = {},
impl = _platforms
)

Expand Down
3 changes: 3 additions & 0 deletions buck2/rust/.buckconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ execution_platforms = root//platforms:remote_platform

[project]
ignore = .git

[re]
remote_execution_test_build_mode = root//platforms:remote_execution_action_keys
5 changes: 0 additions & 5 deletions buck2/rust/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,4 @@ rust_test(
["test/**/*.rs"],
),
deps = [":library"],
# TODO: remove these once https://github.com/facebook/buck2/pull/826 gets merged.
remote_execution_action_key_providers = select({
"//platforms:engflow": "//platforms:remote_execution_action_keys",
"DEFAULT": None,
}),
)
10 changes: 0 additions & 10 deletions buck2/rust/platforms/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,11 @@
load(":defs.bzl", "platforms")
load(":defs.bzl", "action_keys")

constraint_setting(
name = "re_provider"
)

constraint_value(
name = "engflow",
constraint_setting = ":re_provider",
)

# This platform configures details of remote execution.
platforms(
name = "remote_platform",
cpu_configuration = "config//cpu:x86_64",
os_configuration = "config//os:linux",
re_provider = ":engflow",
)

# This action_key provides a default BuildModeInfo that is needed for RE of tests to function properly.
Expand Down
2 changes: 0 additions & 2 deletions buck2/rust/platforms/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def _platforms(ctx):
constraints = dict()
constraints.update(ctx.attrs.cpu_configuration[ConfigurationInfo].constraints)
constraints.update(ctx.attrs.os_configuration[ConfigurationInfo].constraints)
constraints.update(ctx.attrs.re_provider[ConfigurationInfo].constraints)
configuration = ConfigurationInfo(
constraints = constraints,
values = {},
Expand Down Expand Up @@ -63,7 +62,6 @@ platforms = rule(
attrs = {
"cpu_configuration": attrs.dep(providers = [ConfigurationInfo]),
"os_configuration": attrs.dep(providers = [ConfigurationInfo]),
"re_provider": attrs.dep(providers = [ConfigurationInfo]),
},
impl = _platforms
)
Expand Down
4 changes: 2 additions & 2 deletions infra/setup-buck2.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
set -xe

# Get the Buck2 binary - pinned to https://github.com/facebook/buck2/releases/tag/2024-12-16
curl -L -O https://github.com/facebook/buck2/releases/download/2024-12-16/buck2-x86_64-unknown-linux-musl.zst
# Get the Buck2 binary - pinned to https://github.com/facebook/buck2/releases/tag/2024-03-01
curl -L -O https://github.com/facebook/buck2/releases/download/2025-03-01/buck2-x86_64-unknown-linux-musl.zst

# Unpack the binary.
unzstd buck2-x86_64-unknown-linux-musl.zst
Expand Down
12 changes: 6 additions & 6 deletions infra/test-buck2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ alias buck2="$(realpath buck2-exe)"

# Run cpp example
cd buck2/cpp
buck2 build //:cpp_lib
buck2 test //:cpp_test
buck2 build --remote-only //:cpp_lib
buck2 test --remote-only //:cpp_test
cd ..

# Run python example
cd python
buck2 build //main:check_main
buck2 test //hello:hello_unittest_test
buck2 build --remote-only //main:check_main
buck2 test --remote-only //hello:hello_unittest_test
cd ..

# Run go example
cd golang
buck2 build //go:hello
buck2 test //go/greeting:greeting_test
buck2 build --remote-only //go:hello
buck2 test --remote-only //go/greeting:greeting_test
cd ..

# Run rust example
Expand Down