Skip to content

Commit

Permalink
initial public import (#1)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Klein <[email protected]>
  • Loading branch information
mattklein123 authored Aug 23, 2024
1 parent 90980fb commit d85adfd
Show file tree
Hide file tree
Showing 659 changed files with 70,173 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .bazelproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import examples/android/.bazelproject

android_sdk_platform: android-33
150 changes: 150 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
common --experimental_allow_tags_propagation

mobile-install --config=android

build --enable_platform_specific_config
# https://github.com/bazelbuild/bazel/issues/18958
build --noenable_bzlmod
build:macos --apple_crosstool_top=@local_config_apple_cc//:toolchain
build:macos --crosstool_top=@local_config_apple_cc//:toolchain
build:macos --host_crosstool_top=@local_config_apple_cc//:toolchain

# We need access to ld in order to build libunwind on Linux
build:libunwind --action_env=PATH=/usr/bin

build --action_env=CC --host_action_env=CC
build --action_env=CXX --host_action_env=CXX
build --action_env=LLVM_CONFIG --host_action_env=LLVM_CONFIG
build --action_env=PATH --host_action_env=PATH

build --features=debug_prefix_map_pwd_is_dot
build --features=oso_prefix_is_pwd
build --features=relative_ast_path
build --features=remap_xcode_path
build --features=swift.cacheable_swiftmodules
build --features=swift.coverage_prefix_map
build --features=swift.opt_uses_osize
build --features=swift.opt_uses_wmo
build --features=swift.remap_xcode_path
build --features=swift.use_global_module_cache

# Gate the references to androidndk behind a flag to support building on arm linux.
build:android --android_crosstool_top=@androidndk//:toolchain
build:android --extra_toolchains=@androidndk//...
build --platform_mappings=bazel/platform_mappings

build --@rules_rust//:rustfmt.toml=//:rustfmt.toml
build --@rules_rust//:clippy.toml=//:.clippy.toml

build --macos_minimum_os=12.5
build --host_macos_minimum_os=12.5

build --ios_minimum_os=12.0
build --ios_simulator_device="iPhone 13"
build --ios_simulator_version=17.5
build --xcode_version=15.4

build:clippy --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect
build:clippy --output_groups=+clippy_checks

build:compdb --build_tag_filters=-nocompdb,-clippy_checks,-macos_only
build:compdb --config=noclippy

build:noclippy --output_groups=-clippy_checks

test --test_env=RUST_BACKTRACE=full

# Shared configuration for all CI tasks.
build:ci --config=clippy
build:ci --swiftcopt=-warnings-as-errors

# Common debug configuration for iOS/Android. Used when building examples apps.
build:dbg-common --compilation_mode=opt
build:dbg-common --config=abort-panic

build:dbg-ios --config=dbg-common

# Ensure that the output of the `ios_static_framework` rule is a zip as opposed to an unzipped
# framework. Without this, the output of `ios_static_framework` is a zip when invoked with the use of
# command line tool and an unzipped framework when invoked with the use of Xcode UI.
# Ideally we should allow for an unzipped output of `ios_static_framework` so that we can avoid having
# to zip/unzip framework when building it but for simplicity purposes, we force the output to be always
# zipped.
build:rules_xcodeproj --config=dbg-ios
build:rules_xcodeproj --define=apple.experimental.tree_artifact_outputs=0

# Common release configuration for iOS/Android
# TODO(mattklein123): Should we be compiling the rust code size optimized?
build:release-common --compilation_mode=opt
# TODO(mattklein123): This doesn't work for whatever reason when building tests, but we should be
# running tests with release settings.
build:release-common --config=abort-panic

# Size optimizations, codegen-units=1 go along side LTO, which accounts for
# about 10% reduction; -z has a non-zero smaller impact (a few pp).
build:release-common --@rules_rust//:extra_rustc_flag='-Ccodegen-units=1'
build:release-common --@rules_rust//:extra_rustc_flag='-Clto=fat'
build:release-common --@rules_rust//:extra_rustc_flag='-Copt-level=s'

build:release-android --define android_strip_symbols=true
build:release-android --fat_apk_cpu=x86,x86_64,armeabi-v7a,arm64-v8a
build:release-android --config=release-common
build:release-android --copt=-flto=thin --linkopt=-flto=thin
build:release-android --config=android
# TODO(snowp): Enable relr once we no longer need to support Android 8. The system linker is not
# able to understand RELR relocations, see https://bugs.chromium.org/p/chromium/issues/detail?id=900049.
# Enabling relr provides a small binary size decrease.
# build:release-android --linkopt=-Wl,--pack-dyn-relocs=relr
# build:release-android --linkopt=-Wl,--use-android-relr-tags

# Custom iOS release configuration
build:release-ios --config=release-common

# Allows disabling the cache for cases where the cache might be slow, e.g. slow networks.
build:nocache --remote_accept_cached=false
build:nocache --noremote_upload_local_results
build:nocache --bes_results_url=
build:nocache --bes_backend=
build:nocache --remote_cache=

# Convenience config for disabling targets that build on macos only (e.g. iOS targets).
build:nomacos --test_tag_filters=-macos_only --build_tag_filters=-macos_only

# We run this with release-common to be as indicative of production as possible, and add in as much debug information we
# can to allow using perf to generate flamegraphs.
build:benchmark --config=release-common
build:benchmark-profile --config=benchmark --@rules_rust//:extra_rustc_flag='-Cdebuginfo=2' --force_pic

# Specifies that panics should automatically be treated as a panic.
build:abort-panic --@rules_rust//:extra_rustc_flag=-C
build:abort-panic --@rules_rust//:extra_rustc_flag=panic=abort

# This attempts to match what cargo-fuzz does, but it's likely a moving target with many options.
# Occasionally check back to see if anything has changed over there.
# https://github.com/rust-fuzz/cargo-fuzz/blob/fa18f0d77aef036302d9f948e80aa12c6b95d57b/src/project.rs#L163
build:fuzz --config=release-common
build:fuzz --@rules_rust//:extra_rustc_flag=-Cpasses=sancov-module
build:fuzz --@rules_rust//:extra_rustc_flag=-Cllvm-args=-sanitizer-coverage-level=4
build:fuzz --@rules_rust//:extra_rustc_flag=-Cllvm-args=-sanitizer-coverage-inline-8bit-counters
build:fuzz --@rules_rust//:extra_rustc_flag=-Cllvm-args=-sanitizer-coverage-pc-table
build:fuzz --@rules_rust//:extra_rustc_flag=-Cllvm-args=-sanitizer-coverage-trace-compares
build:fuzz --@rules_rust//:extra_rustc_flag=-Cllvm-args=-sanitizer-coverage-stack-depth
build:fuzz --@rules_rust//:extra_rustc_flag=-Zsanitizer=address
build:fuzz --@rules_rust//:extra_rustc_flag=--cfg=fuzzing
build:fuzz --@rules_rust//rust/toolchain/channel=nightly

build:fake-nightly --action_env=RUSTC_BOOTSTRAP=1

# Enables TSAN for all targets. This does not currently work when targeting platforms where TSAN is not enabled in the Rust toolchain (e.g. ios-sim).
build:tsan --config=fake-nightly
build:tsan --features=tsan
build:tsan --@rules_rust//:extra_rustc_flag=-Zsanitizer=thread

# Enables using TSAN with iOS tests. This does not enable tsan in Rust and may therefore result in false positivies.
build:ios-tsan --features=tsan

build:asan --config=fake-nightly
build:asan --features=address
build:tsan --@rules_rust//:extra_rustc_flag=-Zsanitizer=address

try-import %workspace%/tmp/ci-bazelrc
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.0.0-pre.20231018.3
66 changes: 66 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
########################################
# Optimization / Compile Configuration #
########################################

[target.'cfg(target_vendor="apple")']
rustflags = ["-Csplit-debuginfo=unpacked"]

[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "link-arg=-fuse-ld=lld"]

#####################################
# Warnings and Linter Configuration #
#####################################
# This is a hack to work around the fact that neither rustc, cargo, nor clippy
# allows globally configuring lints. To avoid having to copy a massive block of
# allow/warn/deny statements to the top of every file, we configure them as
# all-profile compiler flags here.
[target.'cfg(all())']
rustflags = [
"-Dwarnings",
"-Dfuture-incompatible",
"-Dnonstandard-style",
"-Drust-2018-compatibility",
"-Drust-2018-idioms",
"-Drust-2021-compatibility",
"-Dunused",
"-Dclippy::all",
"-Dclippy::correctness",
"-Dclippy::suspicious",
"-Dclippy::style",
"-Dclippy::complexity",
"-Dclippy::perf",
"-Dclippy::pedantic",
"-Dclippy::nursery",

# The following produces very annoying error lines over entire async functions when there
# are compile errors. Trying enabling this again later.
"-Arust_2021_incompatible_closure_captures",

"-Aclippy::future-not-send",
"-Aclippy::missing-errors-doc",
"-Aclippy::missing-panics-doc",
"-Aclippy::similar-names",
"-Aclippy::too-many-arguments",
"-Aclippy::too-many-lines",
"-Aclippy::unnecessary-wraps",
"-Aclippy::unused-async",

# Appears spurious on 1.62. Try to remove later.
"-Aclippy::redundant-pub-crate",
"-Aclippy::significant_drop_tightening",
"-Aclippy::significant_drop_in_scrutinee",

# ProtoHashWrapper causes this to trigger due to the mutable cached size within the message.
# The cache sized field is correctly handled but there doesn't seem to be a way to turn this
# off for a type.
"-Aclippy::mutable-key-type",
]

# Fetch internal repos via git
[net]
git-fetch-with-cli = true

# Make sure we don't compile protoc
[env]
PROTOC_NO_VENDOR = "true"
38 changes: 38 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
Language: Cpp
AccessModifierOffset: -2
ColumnLimit: 100
DerivePointerAlignment: false
PointerAlignment: Left
SortIncludes: false
...

---
Language: Java
AccessModifierOffset: -2
ColumnLimit: 100
DerivePointerAlignment: false
IndentWidth: 2
PointerAlignment: Left
SortIncludes: false
...

---
Language: ObjC
AccessModifierOffset: -2
ColumnLimit: 100
DerivePointerAlignment: false
IndentWidth: 2
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Right
SortIncludes: false
...

---
Language: Proto
ColumnLimit: 100
SpacesInContainerLiterals: false
AllowShortFunctionsOnASingleLine: false
...
1 change: 1 addition & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
doc-valid-idents = ["gRPC", ".."]
9 changes: 9 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.234.0/containers/rust/.devcontainer/base.Dockerfile

# [Choice] Debian OS version (use bullseye on local arm64/Apple Silicon): buster, bullseye
ARG VARIANT="buster"
FROM mcr.microsoft.com/vscode/devcontainers/rust:0-${VARIANT}

# [Optional] Uncomment this section to install additional packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends clang
51 changes: 51 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.234.0/containers/rust
{
"name": "loop-sdk-dev",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Use the VARIANT arg to pick a Debian OS version: buster, bullseye
// Use bullseye when on local on arm64/Apple Silicon.
// We use buster since the tooling situation for aarch64 linux is not so great.
"VARIANT": "buster"
}
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
"remoteEnv": {
"CC": "/usr/bin/clang",
"CXX": "/usr/bin/clang++"
},

// Set *default* container specific settings.json values on container create.
"settings": {
"lldb.executable": "/usr/bin/lldb",
// VS Code don't watch files under ./target
"files.watcherExclude": {
"**/target/**": true
},
"rust-analyzer.checkOnSave.command": "clippy"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"vadimcn.vscode-lldb",
"mutantdino.resourcemonitor",
"matklad.rust-analyzer",
"tamasfe.even-better-toml",
"serayuzgur.crates"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "rustc --version",

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
9 changes: 9 additions & 0 deletions .drstring.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
align-after-colon = ["throws", "returns", "parameters"]
column-limit = 110
empty-patterns = true
first-letter = "lowercase"
ignore-throws = true
include = ["platform/swift/**.swift", "test/platform/swift/**.swift", "examples/swift/**.swift"]
needs-separation = ["description", "parameters"]
parameter-style = "separate"
vertical-align = true
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Cargo.lock linguist-generated=true merge=binary
Cargo.Bazel.lock linguist-generated=true merge=binary
cargo-bazel-lock.json linguist-generated=true merge=binary

Loading

0 comments on commit d85adfd

Please sign in to comment.