Skip to content

Commit 6a9fe14

Browse files
Initial commit
fbshipit-source-id: 38182c9de097e3893c12e841e89c1b809c806b20
0 parents  commit 6a9fe14

File tree

1,136 files changed

+346826
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,136 files changed

+346826
-0
lines changed

.buckconfig

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[executorch]
2+
is_oss = 1
3+
4+
[buildfile]
5+
name = TARGETS
6+
7+
[repositories]
8+
root = .
9+
prelude = third-party/prelude
10+
shim = shim
11+
12+
[repository_aliases]
13+
config = prelude
14+
ovr_config = prelude
15+
toolchains = shim
16+
fbcode = shim
17+
fbcode_macros = shim
18+
fbsource = shim
19+
buck = shim
20+
21+
[cxx]
22+
cxxflags = -g -std=c++17
23+
24+
[parser]
25+
target_platform_detector_spec = target:root//...->prelude//platforms:default target:shim//...->prelude//platforms:default

.ci/docker/README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Docker images for Executorch CI
2+
3+
This directory contains everything needed to build the Docker images
4+
that are used in Executorch CI. The content of this directory are copied
5+
from PyTorch CI https://github.com/pytorch/pytorch/tree/main/.ci/docker.
6+
It also uses the same directory structure as PyTorch.
7+
8+
## Contents
9+
10+
* `build.sh` -- dispatch script to launch all builds
11+
* `common` -- scripts used to execute individual Docker build stages
12+
* `ubuntu` -- Dockerfile for Ubuntu image for CPU build and test jobs
13+
14+
## Usage
15+
16+
```bash
17+
# Generic usage
18+
./build.sh "${IMAGE_NAME}" "${DOCKER_BUILD_PARAMETERS}"
19+
20+
# Build a specific image
21+
./build.sh executorch-ubuntu-22.04-clang12 -t myimage:latest
22+
23+
# Set CLANG version (see build.sh) and build image
24+
CLANG_VERSION=11 ./build.sh executorch-ubuntu-22.04-clang11 -t myimage:latest
25+
```

.ci/docker/build.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -ex
9+
10+
IMAGE_NAME="$1"
11+
shift
12+
13+
echo "Building ${IMAGE_NAME} Docker image"
14+
15+
OS=ubuntu
16+
OS_VERSION=22.04
17+
CLANG_VERSION=12
18+
PYTHON_VERSION=3.10
19+
MINICONDA_VERSION='23.5.1-0'
20+
21+
docker build \
22+
--no-cache \
23+
--progress=plain \
24+
--build-arg "OS_VERSION=${OS_VERSION}" \
25+
--build-arg "CLANG_VERSION=${CLANG_VERSION}" \
26+
--build-arg "PYTHON_VERSION=${PYTHON_VERSION}" \
27+
--build-arg "MINICONDA_VERSION=${MINICONDA_VERSION}" \
28+
-f "${OS}"/Dockerfile \
29+
"$@" \
30+
.

.ci/docker/common/install_base.sh

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -ex
9+
10+
install_ubuntu() {
11+
apt-get update
12+
13+
apt-get install -y --no-install-recommends \
14+
build-essential \
15+
ca-certificates \
16+
curl \
17+
git \
18+
wget \
19+
sudo \
20+
vim \
21+
jq \
22+
vim \
23+
unzip \
24+
gdb \
25+
rsync
26+
27+
# Cleanup package manager
28+
apt-get autoclean && apt-get clean
29+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
30+
}
31+
32+
# Install base packages depending on the base OS
33+
ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
34+
case "$ID" in
35+
ubuntu)
36+
install_ubuntu
37+
;;
38+
*)
39+
echo "Unable to determine OS..."
40+
exit 1
41+
;;
42+
esac

.ci/docker/common/install_buck.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -ex
9+
10+
install_ubuntu() {
11+
apt-get update
12+
apt-get install -y zstd
13+
14+
wget -q https://github.com/facebook/buck2/releases/download/2023-07-18/buck2-x86_64-unknown-linux-gnu.zst
15+
zstd -d buck2-x86_64-unknown-linux-gnu.zst -o buck2
16+
17+
chmod +x buck2
18+
mv buck2 /usr/bin/
19+
20+
rm buck2-x86_64-unknown-linux-gnu.zst
21+
# Cleanup package manager
22+
apt-get autoclean && apt-get clean
23+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
24+
}
25+
26+
# Install base packages depending on the base OS
27+
ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
28+
case "$ID" in
29+
ubuntu)
30+
install_ubuntu
31+
;;
32+
*)
33+
echo "Unable to determine OS..."
34+
exit 1
35+
;;
36+
esac

.ci/docker/common/install_clang.sh

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -ex
9+
10+
install_ubuntu() {
11+
apt-get update
12+
13+
apt-get install -y --no-install-recommends clang-"$CLANG_VERSION"
14+
apt-get install -y --no-install-recommends llvm-"$CLANG_VERSION"
15+
# Also require LLD linker from llvm
16+
apt-get install -y lld
17+
18+
# Use update-alternatives to make this version the default
19+
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-"$CLANG_VERSION" 50
20+
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-"$CLANG_VERSION" 50
21+
# Override cc/c++ to clang as well
22+
update-alternatives --install /usr/bin/cc cc /usr/bin/clang 50
23+
update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 50
24+
25+
# Cleanup package manager
26+
apt-get autoclean && apt-get clean
27+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
28+
}
29+
30+
if [ -n "$CLANG_VERSION" ]; then
31+
# Install base packages depending on the base OS
32+
ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
33+
case "$ID" in
34+
ubuntu)
35+
install_ubuntu
36+
;;
37+
*)
38+
echo "Unable to determine OS..."
39+
exit 1
40+
;;
41+
esac
42+
fi

.ci/docker/common/install_conda.sh

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -ex
9+
10+
# shellcheck source=/dev/null
11+
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
12+
13+
install_miniconda() {
14+
BASE_URL="https://repo.anaconda.com/miniconda"
15+
CONDA_FILE="Miniconda3-py${PYTHON_VERSION//./}_${MINICONDA_VERSION}-Linux-x86_64.sh"
16+
17+
mkdir -p /opt/conda
18+
chown ci-user:ci-user /opt/conda
19+
20+
pushd /tmp
21+
wget -q "${BASE_URL}/${CONDA_FILE}"
22+
# Install miniconda
23+
as_ci_user bash "${CONDA_FILE}" -b -f -p "/opt/conda"
24+
# Clean up the download file
25+
rm "${CONDA_FILE}"
26+
popd
27+
28+
sed -e 's|PATH="\(.*\)"|PATH="/opt/conda/bin:\1"|g' -i /etc/environment
29+
export PATH="/opt/conda/bin:$PATH"
30+
}
31+
32+
install_python() {
33+
pushd /opt/conda
34+
# Install the correct Python version
35+
as_ci_user conda create -n "py_${PYTHON_VERSION}" -y --file /opt/conda/conda-env-ci.txt python="${PYTHON_VERSION}"
36+
popd
37+
}
38+
39+
install_pip_dependencies() {
40+
pushd /opt/conda
41+
# Install all Python dependencies, including PyTorch
42+
pip_install -r /opt/conda/requirements-ci.txt
43+
pip_install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
44+
popd
45+
}
46+
47+
install_miniconda
48+
install_python
49+
install_pip_dependencies

.ci/docker/common/install_user.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -ex
9+
10+
# Same as ec2-user
11+
echo "ci-user:x:1000:1000::/var/lib/ci-user:" >> /etc/passwd
12+
echo "ci-user:x:1000:" >> /etc/group
13+
# Needed on Focal or newer
14+
echo "ci-user:*:19110:0:99999:7:::" >> /etc/shadow
15+
16+
# Create $HOME
17+
mkdir -p /var/lib/ci-user
18+
chown ci-user:ci-user /var/lib/ci-user
19+
20+
# Allow sudo
21+
echo 'ci-user ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/ci-user
22+
23+
# Test that sudo works
24+
sudo -u ci-user sudo -v

.ci/docker/common/utils.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
as_ci_user() {
9+
# NB: unsetting the environment variables works around a conda bug
10+
# https://github.com/conda/conda/issues/6576
11+
# NB: Pass on PATH and LD_LIBRARY_PATH to sudo invocation
12+
# NB: This must be run from a directory that the user has access to
13+
sudo -E -H -u ci-user env -u SUDO_UID -u SUDO_GID -u SUDO_COMMAND -u SUDO_USER env "PATH=${PATH}" "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" "$@"
14+
}
15+
16+
conda_install() {
17+
# Ensure that the install command don't upgrade/downgrade Python
18+
# This should be called as
19+
# conda_install pkg1 pkg2 ... [-c channel]
20+
as_ci_user conda install -q -n "py_${PYTHON_VERSION}" -y python="${PYTHON_VERSION}" "$@"
21+
}
22+
23+
conda_run() {
24+
as_ci_user conda run -n "py_${PYTHON_VERSION}" --no-capture-output "$@"
25+
}
26+
27+
pip_install() {
28+
as_ci_user conda run -n "py_${PYTHON_VERSION}" pip install --progress-bar off "$@"
29+
}

.ci/docker/conda-env-ci.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# TODO: We might need to update this to install flatbuffers from the pinned commit
2+
# in fbcode/executorch/third-party/flatbuffers.submodule.txt
3+
flatbuffers=2.0.0

.ci/docker/requirements-ci.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
mpmath==1.3.0
2+
PyYAML==6.0.1
3+
ruamel.yaml==0.17.32
4+
sympy==1.12

.ci/docker/ubuntu/Dockerfile

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
ARG OS_VERSION
2+
3+
FROM ubuntu:${OS_VERSION}
4+
5+
ARG OS_VERSION
6+
7+
ENV DEBIAN_FRONTEND noninteractive
8+
9+
# Install common dependencies
10+
COPY ./common/install_base.sh install_base.sh
11+
RUN bash ./install_base.sh && rm install_base.sh
12+
13+
# Install clang
14+
ARG CLANG_VERSION
15+
COPY ./common/install_clang.sh install_clang.sh
16+
RUN bash ./install_clang.sh && rm install_clang.sh
17+
18+
# Setup buck
19+
COPY ./common/install_buck.sh install_buck.sh
20+
RUN bash ./install_buck.sh && rm install_buck.sh
21+
22+
# Setup user
23+
COPY ./common/install_user.sh install_user.sh
24+
RUN bash ./install_user.sh && rm install_user.sh
25+
26+
# Install conda and other dependencies
27+
ARG MINICONDA_VERSION
28+
ARG PYTHON_VERSION
29+
ENV PYTHON_VERSION=$PYTHON_VERSION
30+
ENV PATH /opt/conda/envs/py_$PYTHON_VERSION/bin:/opt/conda/bin:$PATH
31+
COPY requirements-ci.txt /opt/conda/
32+
COPY conda-env-ci.txt /opt/conda/
33+
COPY ./common/install_conda.sh install_conda.sh
34+
COPY ./common/utils.sh utils.sh
35+
RUN bash ./install_conda.sh && rm install_conda.sh utils.sh /opt/conda/requirements-ci.txt /opt/conda/conda-env-ci.txt
36+
37+
USER ci-user
38+
CMD ["bash"]

.clang-tidy

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
# NOTE there must be no spaces before the '-', so put the comma last.
3+
InheritParentConfig: true
4+
Checks: '
5+
-facebook-hte-BadMemberName,
6+
-facebook-hte-NullableReturn,
7+
'
8+
AnalyzeTemporaryDtors: false
9+
CheckOptions:
10+
...

0 commit comments

Comments
 (0)