Skip to content

Commit a3ba0a9

Browse files
Re-sync with internal repository
The internal and external repositories are out of sync. This Pull Request attempts to brings them back in sync by patching the GitHub repository. Please carefully review this patch. You must disable ShipIt for your project in order to merge this pull request. DO NOT IMPORT this pull request. Instead, merge it directly on GitHub using the MERGE BUTTON. Re-enable ShipIt after merging. fbshipit-source-id: 5ae3bf83255b1e60370cf5a4d8d0467336a361ea
1 parent d52c6d7 commit a3ba0a9

9 files changed

Lines changed: 129 additions & 20126 deletions

File tree

.buckconfig.d/antlir.generated.buckconfig

Lines changed: 0 additions & 14 deletions
This file was deleted.

.buckconfig.d/common.buckconfig

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[cells]
2+
prelude = prelude
3+
none = none
4+
5+
[cell_aliases]
6+
config = prelude
7+
ovr_config = prelude
8+
bazel_skylib = gh_facebook_buck2_shims_meta
9+
buck = gh_facebook_buck2_shims_meta
10+
fbcode = gh_facebook_buck2_shims_meta
11+
fbcode_macros = gh_facebook_buck2_shims_meta
12+
fbsource = gh_facebook_buck2_shims_meta
13+
shim = gh_facebook_buck2_shims_meta
14+
toolchains = gh_facebook_buck2_shims_meta
15+
16+
[external_cells]
17+
prelude = bundled
18+
19+
[build]
20+
execution_platforms = prelude//platforms:default
21+
22+
[parser]
23+
target_platform_detector_spec = target:root//...->prelude//platforms:default target:shim//...->prelude//platforms:default

build/buck2/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Easy buck2 builds for Facebook projects
2+
3+
This directory contains buck2 targets designed to simplify buck2 builds of
4+
Meta open source projects.
5+
6+
The most notable target is `//build/buck2/install_deps`, which will attempt to
7+
discover and install necessary third party packages from apt / dnf / etc.
8+
See the "repos" directory for the currently supported platforms.
9+
10+
## Deployment
11+
12+
This directory is copied literally into a number of different Facebook open
13+
source repositories. Any change made to code in this directory will be
14+
automatically be replicated by our open source tooling into all GitHub hosted
15+
repositories that use `buck2`. Typically this directory is copied
16+
into the open source repositories as `build/buck2/`.

build/buck2/install_deps/BUCK

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This source code is licensed under the LICENSE file found in the root
4+
# directory of this source tree.
5+
load("@fbcode_macros//build_defs:native_rules.bzl", "buck_sh_binary")
6+
7+
oncall("open_source")
8+
9+
buck_sh_binary(
10+
name = "install_deps",
11+
main = "install_deps.sh",
12+
resources = glob(["repos/*"]),
13+
)
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/sh
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
#
4+
# This source code is licensed under the LICENSE file found in the root
5+
# directory of this source tree.
6+
7+
if [ -z "$INSTALL_COMMAND" ]; then
8+
if [ -f /etc/os-release ]; then
9+
. /etc/os-release;
10+
fi
11+
12+
if command -v brew >/dev/null; then
13+
ID="homebrew";
14+
fi
15+
16+
if [ -f "$BUCK_DEFAULT_RUNTIME_RESOURCES/repos/$ID" ]; then
17+
# shellcheck disable=SC1090
18+
. "$BUCK_DEFAULT_RUNTIME_RESOURCES/repos/$ID";
19+
else
20+
echo "Unable to determine platform id / install commands";
21+
return 1;
22+
fi
23+
fi
24+
25+
if [ -z "${BUCK2_COMMAND}" ]; then
26+
if command -v buck2 >/dev/null; then
27+
BUCK2_COMMAND="buck2"
28+
elif command -v dotslash >/dev/null && [ -f ./buck2 ]; then
29+
BUCK2_COMMAND="dotslash ./buck2"
30+
else
31+
echo "Unable to determine buck2 command";
32+
return 1;
33+
fi
34+
fi
35+
36+
__confirm() {
37+
echo "Press \"y\" to continue"
38+
read -r REPLY
39+
expr "X$REPLY" : '^X[Yy]$' >/dev/null
40+
}
41+
42+
PKG_FILE=$(mktemp /tmp/buck2-install-pkgs.XXXXXX)
43+
44+
if ! command -v jq >/dev/null; then
45+
echo "Failed to find jq command, attempting to install with"
46+
echo
47+
echo "$INSTALL_COMMAND" jq
48+
echo
49+
if __confirm; then
50+
eval "$INSTALL_COMMAND jq"
51+
else
52+
echo "Not confirmed, exiting";
53+
exit 1
54+
fi
55+
fi
56+
57+
eval "$BUCK2_COMMAND cquery 'kind(system_packages, deps(//...))' \\
58+
--output-attribute=packages --modifier $ID --json 2>/dev/null \\
59+
| jq -r '.[].packages[]' \\
60+
| sort \\
61+
| uniq \\
62+
> $PKG_FILE"
63+
64+
echo "About to install the project dependencies with the following command:"
65+
echo
66+
eval "cat $PKG_FILE | xargs echo $INSTALL_COMMAND"
67+
echo
68+
if __confirm; then
69+
eval "cat $PKG_FILE | xargs -r $INSTALL_COMMAND"
70+
else
71+
echo "Not installing dependencies"
72+
fi
73+
74+
rm "$PKG_FILE"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INSTALL_COMMAND="sudo -E dnf install -y"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INSTALL_COMMAND="brew install"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INSTALL_COMMAND="sudo -E apt-get install -y"

0 commit comments

Comments
 (0)