-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8947039
Showing
5,512 changed files
with
512,635 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
build --enable_platform_specific_config | ||
|
||
# Configure C++ 20, clang as default | ||
build:linux --repo_env=BAZEL_CXXOPTS="-std=c++20" --cxxopt=-std=c++20 --cxxopt=-Wno-c++20-extensions --repo_env=CC=clang | ||
build:macos --repo_env=BAZEL_CXXOPTS="-std=c++20" --cxxopt=-std=c++20 --cxxopt=-Wno-c++20-extensions --repo_env=CC=clang | ||
build:windows --repo_env=BAZEL_CXXOPTS="/std:c++20" --cxxopt=/std:c++20 | ||
|
||
build:release --define build_config=release -c opt --copt=-O3 | ||
build:reldebug --define build_config=reldebug -c opt --copt=-O3 --copt=-g --linkopt=-g | ||
build:debug --define build_config=debug -c dbg --copt=-g | ||
build:fastbuild --define build_config=fastbuild -c fastbuild | ||
build --define build_config=fastbuild -c fastbuild | ||
|
||
# Windows-specific reldebug config (useful for profiling on windows) | ||
build:windows_release -c opt --copt="/O2" --copt="/Gy" --copt="/arch:AVX2" --copt="/DNDEBUG" | ||
build:windows_reldebug -c opt --copt="/O2" --copt="/Gy" --copt="/arch:AVX2" --copt="/DNDEBUG" --copt="/Z7" --linkopt="/DEBUG:FULL" | ||
|
||
# Required for bazel_clang_tidy to operate as expected | ||
build:clang-tidy --aspects clang-tidy/clang-tidy.bzl%clang_tidy_aspect | ||
build:clang-tidy --output_groups=report --keep_going | ||
|
||
# Enable use of remote cache with application default credentials by default. | ||
# CI can override with --google_credentials flag. | ||
# This is disabled by default because it requires the user to be logged into | ||
# gcloud, however if that is possible, you can create a `.bazelrc` file in your | ||
# home directory that has the line: | ||
# | ||
# build --config=with-remote-cache | ||
# | ||
# in it and you can then use the remote cache locally. | ||
build:with-remote-cache --remote_cache=https://storage.googleapis.com/biomes-bazel-cache --google_default_credentials | ||
|
||
# Enables remote cache to be explicitly disabled. | ||
build:no-remote-cache --nogoogle_default_credentials --remote_cache= | ||
|
||
# Regardless of how many CPUs are available (is independently set via | ||
# --local_cpu_resources), set --jobs to a large value so that we permit | ||
# downloading of many remotely cached artifacts in parallel. Apologies | ||
# in advance for those with more than 256 cores. | ||
build --jobs 256 | ||
|
||
# Don't import system environment variables, like PATH. Makes remote cache | ||
# hits across machines a lot more likely. | ||
build --incompatible_strict_action_env | ||
|
||
# If there's a problem with the network, fallback to a local build. | ||
build --remote_local_fallback | ||
|
||
# Don't wait for results to finish uploading to remote cache before returning. | ||
build --bes_upload_mode=fully_async | ||
|
||
# Fix the wrong default that comes from Google's internal monorepo by using | ||
# __init__.py to delimit a Python package | ||
build --incompatible_default_to_explicit_init_py | ||
|
||
# Improve performance of sandbox by skipping the older | ||
# my_repo/external/other_repo symlinks. | ||
build --nolegacy_external_runfiles | ||
|
||
# Don't add tar outputs to remote cache, they're fast to just compute. | ||
build --modify_execution_info=PackageTar=+no-remote | ||
|
||
# Ensure that you don't accidentally make non-hermetic actions/tests which | ||
# depend on remote services. Tag an individual target with | ||
# tags=["requires-network"] to opt-out of the enforcement. | ||
build --sandbox_default_allow_network=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
6.3.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CompileFlags: | ||
Add: [-Iexternal/emscripten_bin_linux/emscripten/system/include] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** @type {import('dependency-cruiser').IConfiguration} */ | ||
module.exports = { | ||
forbidden: [ | ||
{ | ||
name: "shared-restrict-deps", | ||
severity: "error", | ||
comment: | ||
"Modules in shared folders should not depend on client/server modules.", | ||
from: { | ||
path: ["^src/shared/"], | ||
pathNot: "/test/", | ||
}, | ||
to: { | ||
path: "^src", | ||
pathNot: [ | ||
"^src/shared/", | ||
"^src/gen/shared/", | ||
"^src/third-party/", | ||
"^src/cayley/", | ||
"^src/galois/js/interface/asset_paths.ts", | ||
"^src/galois/js/assets/", | ||
], | ||
}, | ||
}, | ||
{ | ||
name: "third-party-restrict-deps", | ||
severity: "error", | ||
comment: | ||
"Modules in src/shared should not depend on modules outside of src/shared.", | ||
from: { | ||
path: ["^src/third-party"], | ||
}, | ||
to: { | ||
path: "^src", | ||
pathNot: ["^src/third-party"], | ||
}, | ||
}, | ||
{ | ||
name: "galois-restrict-deps", | ||
severity: "error", | ||
comment: | ||
"Modules in src/galois/js should not depend on modules outside of src/shared.", | ||
from: { | ||
path: "^src/galois/js", | ||
pathNot: ["^src/galois/js/publish", "^src/galois/js/interface"], | ||
}, | ||
to: { | ||
path: "^src", | ||
pathNot: ["^src/shared", "^src/gen/(shared|galois)", "^src/galois/js"], | ||
}, | ||
}, | ||
], | ||
|
||
options: { | ||
doNotFollow: { | ||
path: "node_modules", | ||
}, | ||
tsPreCompilationDeps: true, | ||
tsConfig: { | ||
fileName: "tsconfig.json", | ||
}, | ||
enhancedResolveOptions: { | ||
exportsFields: ["exports"], | ||
conditionNames: ["import", "require", "node", "default"], | ||
mainFields: ["main", "types"], | ||
}, | ||
reporterOptions: { | ||
dot: { | ||
collapsePattern: "node_modules/[^/]+", | ||
}, | ||
archi: { | ||
collapsePattern: | ||
"^(packages|src|lib|app|bin|test(s?)|spec(s?))/[^/]+|node_modules/[^/]+", | ||
}, | ||
text: { | ||
highlightFocused: true, | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# This file describes the development environment for Biomes. | ||
FROM ubuntu:22.04 | ||
|
||
LABEL description="Linux development environment for building biomes." | ||
|
||
# Install some basic development tools. | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
RUN apt-get update --fix-missing && apt-get -y install \ | ||
curl \ | ||
perl \ | ||
sudo \ | ||
locales \ | ||
bzip2 \ | ||
bash \ | ||
xz-utils \ | ||
htop \ | ||
git \ | ||
git-lfs \ | ||
wget \ | ||
vim \ | ||
man \ | ||
pkg-config \ | ||
yasm \ | ||
gnupg \ | ||
make \ | ||
cmake \ | ||
clang \ | ||
clangd \ | ||
python-is-python3 \ | ||
pip \ | ||
binutils \ | ||
gdb \ | ||
g++ \ | ||
clang-tidy \ | ||
clang-format \ | ||
apt-transport-https \ | ||
build-essential \ | ||
libcairo2-dev \ | ||
libpango1.0-dev \ | ||
libjpeg-dev \ | ||
libgif-dev \ | ||
librsvg2-dev \ | ||
# To enable SSH access to remote workspaces (e.g. codespaces). | ||
openssh-server \ | ||
# For software EGL/GLES2. | ||
libgles2-mesa-dev \ | ||
rsync \ | ||
&& apt-get clean && apt-get purge && apt-get autoremove --purge -y | ||
|
||
# Setup our locale. | ||
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen | ||
RUN locale-gen en_US.UTF-8 | ||
ENV LANG en_US.UTF-8 | ||
|
||
# Prepare to create a non-root user for the container work, since node doesn't | ||
# like it when it's run as root. | ||
ARG DOCKER_USER_NAME=docker-user | ||
ARG DOCKER_USER_UID=1000 | ||
ARG DOCKER_USER_GID=${DOCKER_USER_UID} | ||
|
||
# Create the user | ||
RUN groupadd --gid ${DOCKER_USER_GID} ${DOCKER_USER_NAME} \ | ||
&& useradd --uid ${DOCKER_USER_UID} --gid ${DOCKER_USER_GID} -m ${DOCKER_USER_NAME} \ | ||
&& echo ${DOCKER_USER_NAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${DOCKER_USER_NAME} \ | ||
&& chmod 0440 /etc/sudoers.d/${DOCKER_USER_NAME} | ||
|
||
# Set the default user to something other than root, node doesn't like being | ||
# run as root. | ||
USER ${DOCKER_USER_NAME} | ||
ENV HOME /home/${DOCKER_USER_NAME} | ||
|
||
# Create this in advance as "docker-user" so that it doesn't instead get created | ||
# as root. | ||
RUN mkdir -p ${HOME}/.vscode-server/extensions | ||
|
||
# Install nvm. | ||
ENV NVM_DIR ${HOME}/.nvm | ||
ENV NODE_VERSION 20.0.0 | ||
|
||
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash \ | ||
&& . "$NVM_DIR/nvm.sh" \ | ||
&& nvm install ${NODE_VERSION} \ | ||
&& nvm alias default ${NODE_VERSION} \ | ||
&& nvm use default | ||
|
||
ENV PATH ${NVM_DIR}/versions/node/v${NODE_VERSION}/bin:$PATH | ||
|
||
# Install yarn. | ||
RUN npm install -g yarn | ||
|
||
# Install Bazel. | ||
RUN npm install -g @bazel/bazelisk | ||
|
||
# Install buildifier for vscode bazel file formatting support. | ||
RUN sudo wget -O /usr/bin/buildifier https://github.com/bazelbuild/buildtools/releases/download/0.29.0/buildifier | ||
RUN sudo chmod 755 /usr/bin/buildifier | ||
|
||
# Install gcloud CLI. | ||
RUN curl -s https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-428.0.0-linux-x86_64.tar.gz | tar xvz -C ${HOME} && \ | ||
${HOME}/google-cloud-sdk/install.sh --quiet --usage-reporting false --path-update true --command-completion true | ||
|
||
# Install kubectl. | ||
RUN ${HOME}/google-cloud-sdk/bin/gcloud components install kubectl | ||
|
||
# Install Flux CLI. | ||
RUN curl -s https://fluxcd.io/install.sh | sudo bash | ||
|
||
# Install Rust to get access to the Rust CLI tools. | ||
RUN curl https://sh.rustup.rs/?version=1.66 -sSf | bash -s -- -y | ||
ENV PATH="${HOME}/.cargo/bin:${PATH}" | ||
RUN rustup target add wasm32-wasi | ||
RUN rustup target add wasm32-unknown-unknown | ||
|
||
# Install some helpful WASM inspection tools like wasm2wat | ||
RUN sudo apt install wabt | ||
|
||
# Install Redis | ||
# We install from source because there are no Redis 7 packages available on | ||
# Ubuntu 22. | ||
ARG REDIS_VERSION=redis-7.0.8 | ||
RUN curl -s https://download.redis.io/releases/${REDIS_VERSION}.tar.gz | tar xvz -C ${HOME} \ | ||
&& make -j`nproc` -C ${HOME}/${REDIS_VERSION} \ | ||
&& sudo make install -C ${HOME}/${REDIS_VERSION} \ | ||
&& rm -rf ${HOME}/${REDIS_VERSION} | ||
|
||
# Remember our console history between sessions. | ||
ENV COMMAND_HISTORY_DIR ${HOME}/commandhistory | ||
RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=${COMMAND_HISTORY_DIR}/.bash_history" \ | ||
&& mkdir -p ${COMMAND_HISTORY_DIR} \ | ||
&& echo $SNIPPET >> "${HOME}/.bashrc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Developing inside a Container | ||
|
||
VSCode provides extensive support for developing inside of a container. Their official [Developing inside a Container](https://code.visualstudio.com/docs/remote/containers) documentation details the process. All of the logic for configuring the development container and environment lives inside this `.devcontainer` directory. | ||
|
||
In summary, VSCode on your desktop will create a docker image and starts a VSCode server within it that it then connects to similar to how VSCode would remotely connect to another machine over SSH. This has the advantage of providing a consistent and well-defined coding environment (including automatic installation of recommended vscode extensions) to work within. | ||
|
||
## Getting Started | ||
|
||
To make use of this feature, you'll first need to install the VSCode `ms-vscode-remote.remote-containers` extension. After that, whenever you `Open Folder` a folder that contains a `.devcontainer` directory, such as this `biomes` repository, VSCode will prompty you if you'd like to re-open it in a container, or you can open the command palette and select `Remote-Containers: Open folder in container...`. When you do open the container VSCode will build a docker image from [.devccontainer/Dockerfile](./Dockerfile)` (the result will be cached for next time) and then drop you into it. The source code will be mounted within the container from your host file system. | ||
|
||
### Linux Prerequisites | ||
|
||
Ensure Docker is installed, e.g. `sudo apt install docker.io`. | ||
|
||
### Windows and Mac Prerequisites | ||
|
||
Ensure that [Docker Desktop](https://www.docker.com/products/docker-desktop) is installed. Note that you will still find yourself in a Linux environment within the container. Docker Desktop works on these platforms by setting up a virtual machine see [The Magic Behind the Scenes of Docker Desktop](https://www.docker.com/blog/the-magic-behind-the-scenes-of-docker-desktop/). | ||
|
||
Note that there are some awkward artifacts when running with the source code bind mounted from a Windows host filesystem into a Linux docker filesystem, like bad file permissions and some latency when format-on-save is run. You should clone the repository inside of [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/), and then from there open the folder within docker (so this would be Docker in WSL), and everything will work as expected. | ||
|
||
## Sharing your host SSH keys (e.g. for GitHub) with the container | ||
|
||
See the [Sharing Git credentials with your container](https://code.visualstudio.com/docs/remote/containers#_sharing-git-credentials-with-your-container) article from Microsoft on how to set this up. In short, you'll need to start a SSH agent on your host, and VSCode will take care of forwarding that into the container. Make sure you run `ssh-add` on your host, so that your key is visible to the SSH agent. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// For format details, see https://aka.ms/vscode-remote/devcontainer.json, or | ||
// see https://code.visualstudio.com/docs/remote/containers for the top-level | ||
// VS Code documentation about developing inside a container. | ||
{ | ||
"name": "biomes", | ||
"context": ".", | ||
"dockerFile": "Dockerfile", | ||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"terminal.integrated.profiles.linux": { | ||
"bash": { | ||
"path": "bash", | ||
"icon": "terminal-bash", | ||
} | ||
}, | ||
"terminal.integrated.defaultProfile.linux": "bash", | ||
}, | ||
"extensions": [ | ||
// Extensions for TypeScript coding environment. | ||
"dbaeumer.vscode-eslint", | ||
"esbenp.prettier-vscode", | ||
// Extensions to support C++ builds. | ||
"llvm-vs-code-extensions.vscode-clangd", | ||
"xaver.clang-format", | ||
"notskm.clang-tidy", | ||
// Extensions for Galois. | ||
"raczzalan.webgl-glsl-editor", | ||
"arcanis.vscode-zipfs", | ||
"ms-python.python", | ||
"bazelbuild.vscode-bazel", | ||
"rust-lang.rust-analyzer" | ||
] | ||
} | ||
}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available | ||
// locally. | ||
"forwardPorts": [ | ||
3000, // The main app web port. | ||
3010, // The sync server port. | ||
9229 // The Chrome Inspector debugger port. | ||
], | ||
"runArgs": [ | ||
// The following three flags enable ptrace-based debuggers (like gdb for | ||
// C++) to work in the container. | ||
"--cap-add=SYS_PTRACE", | ||
"--security-opt", | ||
"seccomp=unconfined", | ||
], | ||
// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-in-docker. | ||
"mounts": [ | ||
// Persist our installed vscode extensions across sessions. | ||
"source=biomes-vscode-extensions,target=/home/docker-user/.vscode-server/extensions,type=volume", | ||
// Persist our bash history across sessions. | ||
"source=biomes-bashhistory,target=/home/docker-user/commandhistory,type=volume", | ||
// Persist the node_modules diretory so that we don't have to re-install | ||
// everything each time we open the workspace. | ||
"source=biomes-node_modules,target=${containerWorkspaceFolder}/node_modules,type=volume", | ||
// Make sure Next.js caches are persisted across sessions. | ||
"source=biomes-nextjs,target=${containerWorkspaceFolder}/.next,type=volume", | ||
// This is the directory the build_wasm.sh script uses to put its | ||
// C++/emscripten intermediate output. | ||
"source=biomes-build-js,target=${containerWorkspaceFolder}/voxeloo/build_js,type=volume", | ||
// gcloud stores credential information in .local, so persist that. | ||
"source=biomes-home-local,target=/home/docker-user/.local,type=volume", | ||
// A few different processes store data in ~/.cache, such as `pip install`, so it's | ||
// useful for this to persist. | ||
"source=biomes-home-local,target=/home/docker-user/.cache,type=volume", | ||
// Remember application config options, and in particular the | ||
// gcloud CLI settings/credential tokens. | ||
"source=biomes-home-local,target=/home/docker-user/.config,type=volume", | ||
], | ||
// Since some of the volumes specified above need to be accessed by the | ||
// remoteUser (as opposed to root), we assign ownership of them after the | ||
// docker image is created. | ||
"postCreateCommand": "sudo chown docker-user node_modules && sudo chown docker-user .next && sudo chown docker-user ${HOME}/commandhistory && sudo chown docker-user voxeloo/build_js && sudo chown docker-user ${HOME}/.local && sudo chown docker-user ${HOME}/.config && git lfs pull", | ||
// Ensure node_modules is up-to-date each time we load up this workspace. | ||
"postAttachCommand": "yarn install && pip install -r requirements.txt", | ||
// This matches up with the user created in the Dockerfile. For some reason | ||
// the node binary complains with weird permission denied errors when run | ||
// as root. | ||
"remoteUser": "docker-user", | ||
} |
Oops, something went wrong.