convert repo to cargo workspace

This should make it easier to add new crates to the repo (e.g. no need
to add CI jobs for each one), and just generally makes more sense than
stuffing everything that is not quiche itself under tools/.

Pretty much all the changes are related to build scripts and related
things. All the actual code is just moved around.
This commit is contained in:
Alessandro Ghedini 2021-11-29 15:33:27 +00:00
parent 2649457a56
commit bbe6e2ab22
83 changed files with 133 additions and 247 deletions

View File

@ -32,20 +32,25 @@ jobs:
command: fmt
args: -- --check
- name: Install dependencies
run: sudo apt-get install libev-dev uthash-dev
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --tests --examples --verbose --features qlog
args: --verbose --all-targets --features=ffi,qlog
# Need to run doc tests separately.
# (https://github.com/rust-lang/cargo/issues/6669)
- name: Run cargo doc test
uses: actions-rs/cargo@v1
with:
command: test
args: --verbose --doc --features=ffi,qlog
- name: Run cargo package
uses: actions-rs/cargo@v1
with:
command: package
args: --verbose --allow-dirty
args: --verbose --workspace --exclude=quiche_apps --allow-dirty
- name: Run cargo doc
uses: actions-rs/cargo@v1
@ -54,38 +59,9 @@ jobs:
args: --no-deps
- name: Build C examples
run: make -C examples
apps:
runs-on: ubuntu-latest
# Only run on "pull_request" event for external PRs. This is to avoid
# duplicate builds for PRs created from internal branches.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.TOOLCHAIN }}
components: rustfmt
override: true
- name: Run cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --verbose --manifest-path=tools/apps/Cargo.toml
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --manifest-path=tools/apps/Cargo.toml -- --check
run: |
sudo apt-get install libev-dev uthash-dev
make -C quiche/examples
fuzz:
runs-on: ubuntu-latest
@ -133,37 +109,6 @@ jobs:
command: fmt
args: --manifest-path=fuzz/Cargo.toml -- --check
qlog:
runs-on: ubuntu-latest
# Only run on "pull_request" event for external PRs. This is to avoid
# duplicate builds for PRs created from internal branches.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.TOOLCHAIN }}
components: rustfmt
override: true
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --verbose --manifest-path=tools/qlog/Cargo.toml
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --manifest-path=tools/qlog/Cargo.toml -- --check
http3_test:
runs-on: ubuntu-latest
# Only run on "pull_request" event for external PRs. This is to avoid

View File

@ -26,20 +26,25 @@ jobs:
components: clippy
override: true
- name: Install dependencies
run: sudo apt-get install libev-dev uthash-dev
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --tests --examples --verbose --features ffi,qlog
args: --verbose --all-targets --features=ffi,qlog
# Need to run doc tests separately.
# (https://github.com/rust-lang/cargo/issues/6669)
- name: Run cargo doc test
uses: actions-rs/cargo@v1
with:
command: test
args: --verbose --doc --features=ffi,qlog
- name: Run cargo package
uses: actions-rs/cargo@v1
with:
command: package
args: --verbose --allow-dirty
args: --verbose --workspace --exclude=quiche_apps --allow-dirty
- name: Run cargo clippy
uses: actions-rs/cargo@v1
@ -54,7 +59,9 @@ jobs:
args: --no-deps
- name: Build C examples
run: make -C examples
run: |
sudo apt-get install libev-dev uthash-dev
make -C quiche/examples
quiche_macos:
runs-on: macos-latest
@ -78,16 +85,13 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --tests --examples --verbose --features ffi,qlog
- name: Install libev
run: brew install libev
- name: Install uthash
run: curl -o examples/uthash.h https://raw.githubusercontent.com/troydhanson/uthash/master/src/uthash.h
args: --verbose --all-targets --features ffi,qlog
- name: Build C examples
run: make -C examples
run: |
brew install libev
curl -o quiche/examples/uthash.h https://raw.githubusercontent.com/troydhanson/uthash/master/src/uthash.h
make -C quiche/examples
quiche_ios:
runs-on: macos-latest
@ -148,7 +152,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --target=${{ matrix.target }} --tests --examples --verbose --features ffi,qlog
args: --target=${{ matrix.target }} --verbose --all-targets --features=ffi,qlog
quiche_multiarch:
runs-on: ubuntu-latest
@ -176,69 +180,9 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --target=${{ matrix.target }} --tests --examples --verbose --features ffi,qlog
args: --target=${{ matrix.target }} --verbose --all-targets --features=ffi,qlog
use-cross: true
apps:
runs-on: ubuntu-latest
# Only run on "pull_request" event for external PRs. This is to avoid
# duplicate builds for PRs created from internal branches.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.TOOLCHAIN }}
override: true
- name: Run cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --verbose --manifest-path=tools/apps/Cargo.toml
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --manifest-path=tools/apps/Cargo.toml -- -D warnings
qlog:
runs-on: ubuntu-latest
# Only run on "pull_request" event for external PRs. This is to avoid
# duplicate builds for PRs created from internal branches.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.TOOLCHAIN }}
override: true
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --verbose --manifest-path=tools/qlog/Cargo.toml
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --manifest-path=tools/qlog/Cargo.toml -- -D warnings
http3_test:
runs-on: ubuntu-latest
# Only run on "pull_request" event for external PRs. This is to avoid
@ -302,8 +246,8 @@ jobs:
- name: Build NGINX
run: |
cd nginx-${{ matrix.version }} &&
patch -p01 < ../extras/nginx/nginx-1.16.patch &&
./configure --with-http_ssl_module --with-http_v2_module --with-http_v3_module --with-openssl="../deps/boringssl" --with-quiche=".." --with-debug &&
patch -p01 < ../nginx/nginx-1.16.patch &&
./configure --with-http_ssl_module --with-http_v2_module --with-http_v3_module --with-openssl="${{ github.workspace }}/quiche/deps/boringssl" --with-quiche="${{ github.workspace }}" --with-debug &&
make -j`nproc` &&
objs/nginx -V

2
.gitmodules vendored
View File

@ -1,4 +1,4 @@
[submodule "boringssl"]
path = deps/boringssl
path = quiche/deps/boringssl
url = https://github.com/google/boringssl.git
ignore = dirty

View File

@ -1,75 +1,9 @@
[package]
name = "quiche"
version = "0.10.0"
authors = ["Alessandro Ghedini <alessandro@ghedini.me>"]
edition = "2018"
build = "src/build.rs"
description = "🥧 Savoury implementation of the QUIC transport protocol and HTTP/3"
repository = "https://github.com/cloudflare/quiche"
readme = "README.md"
keywords = ["quic", "http3"]
categories = ["network-programming"]
license = "BSD-2-Clause"
include = [
"/*.md",
"/*.toml",
"/CODEOWNERS",
"/COPYING",
"/benches",
"/deps/boringssl/**/*.[chS]",
"/deps/boringssl/**/*.asm",
"/deps/boringssl/src/**/*.cc",
"/deps/boringssl/**/CMakeLists.txt",
"/deps/boringssl/**/sources.cmake",
"/deps/boringssl/LICENSE",
"/examples",
"/include",
"/quiche.svg",
"/src",
]
[features]
default = ["boringssl-vendored"]
# Build vendored BoringSSL library.
boringssl-vendored = []
# Generate pkg-config metadata file for libquiche.
pkg-config-meta = []
# Equivalent to "--cfg fuzzing", but can also be checked in build.rs.
fuzzing = []
# Expose the FFI API.
ffi = []
[package.metadata.docs.rs]
no-default-features = true
[build-dependencies]
cmake = "0.1"
[dependencies]
log = { version = "0.4", features = ["std"] }
libc = "0.2"
libm = "0.2"
ring = "0.16"
lazy_static = "1"
boring-sys = { version = "1.0.2", optional = true }
qlog = { version = "0.5", path = "tools/qlog", optional = true }
[target."cfg(windows)".dependencies]
winapi = { version = "0.3", features = ["wincrypt"] }
[dev-dependencies]
mio = "0.6"
url = "1"
[workspace]
members = [ "quiche", "qlog", "apps" ]
exclude = [ "fuzz", "tools/http3_test" ]
[profile.bench]
debug = true
[profile.release]
debug = true
[lib]
crate-type = ["lib", "staticlib", "cdylib"]

View File

@ -2,15 +2,14 @@ FROM rust:1.53 as build
WORKDIR /build
COPY deps/ ./deps/
COPY src/ ./src/
COPY tools/ ./tools/
COPY Cargo.toml .
COPY quiche/ ./quiche/
COPY qlog/ ./qlog/
COPY apps/ ./apps/
RUN apt-get update && apt-get install -y cmake && \
rm -rf /var/lib/apt/lists/*
RUN cargo build --manifest-path tools/apps/Cargo.toml
RUN cargo build --manifest-path apps/Cargo.toml
##
## quiche-base: quiche image for apps
@ -21,8 +20,8 @@ RUN apt-get update && apt-get install -y ca-certificates && \
rm -rf /var/lib/apt/lists/*
COPY --from=build \
/build/tools/apps/target/debug/quiche-client \
/build/tools/apps/target/debug/quiche-server \
/build/apps/target/debug/quiche-client \
/build/apps/target/debug/quiche-server \
/usr/local/bin/
ENV PATH="/usr/local/bin/:${PATH}"
@ -38,9 +37,9 @@ FROM martenseemann/quic-network-simulator-endpoint:latest as quiche-qns
WORKDIR /quiche
COPY --from=build \
/build/tools/apps/target/debug/quiche-client \
/build/tools/apps/target/debug/quiche-server \
/build/tools/qns/run_endpoint.sh \
/build/apps/target/debug/quiche-client \
/build/apps/target/debug/quiche-server \
/build/apps/run_endpoint.sh \
./
ENV RUST_LOG=trace

View File

@ -14,7 +14,7 @@ docker-build: docker-base docker-qns
# build quiche-apps only
.PHONY: build-apps
build-apps:
cargo build --manifest-path tools/apps/Cargo.toml
cargo build --package=quiche_apps
# build base image
.PHONY: docker-base
@ -23,7 +23,7 @@ docker-base: Dockerfile
# build qns image
.PHONY: docker-qns
docker-qns: Dockerfile tools/qns/run_endpoint.sh
docker-qns: Dockerfile apps/run_endpoint.sh
$(DOCKER) build --target quiche-qns -t $(QNS_REPO):$(QNS_TAG) .
.PHONY: docker-publish

View File

@ -32,12 +32,11 @@ quiche can be [integrated into curl][curl-http3] to provide support for HTTP/3.
### NGINX (unofficial)
quiche can be [integrated into NGINX][nginx-http3] using an unofficial patch to
quiche can be [integrated into NGINX](nginx/) using an unofficial patch to
provide support for HTTP/3.
[cloudflare-http3]: https://blog.cloudflare.com/http3-the-past-present-and-future/
[curl-http3]: https://github.com/curl/curl/blob/master/docs/HTTP3.md#quiche-version
[nginx-http3]: https://github.com/cloudflare/quiche/tree/master/extras/nginx
Getting Started
---------------
@ -45,20 +44,18 @@ Getting Started
### Command-line apps
Before diving into the quiche API, here are a few examples on how to use the
quiche tools provided as part of the [quiche-apps](tools/apps/) crate.
quiche tools provided as part of the [quiche-apps](apps/) crate.
After cloning the project according to the command mentioned in the [building](#building) section, the client can be run as follows:
```bash
$ cargo run --manifest-path=tools/apps/Cargo.toml --bin quiche-client -- https://cloudflare-quic.com/
$ cargo run --bin quiche-client -- https://cloudflare-quic.com/
```
while the server can be run as follows:
```bash
$ cargo run --manifest-path=tools/apps/Cargo.toml --bin quiche-server -- \
--cert tools/apps/src/bin/cert.crt \
--key tools/apps/src/bin/cert.key
$ cargo run --bin quiche-server -- --cert tools/apps/src/bin/cert.crt --key tools/apps/src/bin/cert.key
```
(note that the certificate provided is self-signed and should not be used in

View File

@ -24,10 +24,7 @@ mio = "0.6"
url = "1"
log = "0.4"
ring = "0.16"
quiche = { path = "../../" }
[profile.release]
debug = true
quiche = { path = "../quiche" }
[lib]
crate-type = ["lib"]

View File

@ -12,7 +12,7 @@ cargo-fuzz = true
opt-level = 3
[dependencies]
quiche = { path = "..", features = ["fuzzing"] }
quiche = { path = "../quiche", features = ["fuzzing"] }
lazy_static = "1"
libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" }

View File

@ -13,9 +13,9 @@ use std::sync::Mutex;
lazy_static! {
static ref CONFIG: Mutex<quiche::Config> = {
let crt_path = std::env::var("QUICHE_FUZZ_CRT")
.unwrap_or_else(|_| "examples/cert.crt".to_string());
.unwrap_or_else(|_| "fuzz/cert.crt".to_string());
let key_path = std::env::var("QUICHE_FUZZ_KEY")
.unwrap_or_else(|_| "examples/cert.key".to_string());
.unwrap_or_else(|_| "fuzz/cert.key".to_string());
let mut config = quiche::Config::new(quiche::PROTOCOL_VERSION).unwrap();
config.load_cert_chain_from_pem_file(&crt_path).unwrap();

View File

@ -32,7 +32,7 @@ As well as quiche, the underlying implementation of HTTP/3 and QUIC:
Next youll need to apply the patch to NGINX:
```
% cd nginx-1.16.1
% patch -p01 < ../quiche/extras/nginx/nginx-1.16.patch
% patch -p01 < ../quiche/nginx/nginx-1.16.patch
```
And finally build NGINX with HTTP/3 support enabled:
@ -43,7 +43,7 @@ And finally build NGINX with HTTP/3 support enabled:
--with-http_ssl_module \
--with-http_v2_module \
--with-http_v3_module \
--with-openssl=../quiche/deps/boringssl \
--with-openssl=../quiche/quiche/deps/boringssl \
--with-quiche=../quiche
% make
```

View File

@ -116,7 +116,7 @@ index 000000000..23219d92a
+ QUICHE_BUILD_TARGET="debug"
+ fi
+
+ CORE_INCS="$CORE_INCS $QUICHE/include"
+ CORE_INCS="$CORE_INCS $QUICHE/quiche/include"
+ CORE_DEPS="$CORE_DEPS $QUICHE/target/$QUICHE_BUILD_TARGET/libquiche.a"
+ CORE_LIBS="$CORE_LIBS $QUICHE/target/$QUICHE_BUILD_TARGET/libquiche.a $NGX_LIBPTHREAD -lm"
+
@ -134,7 +134,7 @@ index 000000000..6e5ede5bc
+
+# Copyright (C) Cloudflare, Inc.
+
+QUICHE_COMMON_FLAGS="--verbose --no-default-features --features ffi"
+QUICHE_COMMON_FLAGS="--package quiche --verbose --no-default-features --features ffi"
+
+# Default is release build
+QUICHE_BUILD_FLAGS="$QUICHE_COMMON_FLAGS --release"

1
qlog/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
foo.qlog

69
quiche/Cargo.toml Normal file
View File

@ -0,0 +1,69 @@
[package]
name = "quiche"
version = "0.10.0"
authors = ["Alessandro Ghedini <alessandro@ghedini.me>"]
edition = "2018"
build = "src/build.rs"
description = "🥧 Savoury implementation of the QUIC transport protocol and HTTP/3"
repository = "https://github.com/cloudflare/quiche"
readme = "README.md"
keywords = ["quic", "http3"]
categories = ["network-programming"]
license = "BSD-2-Clause"
include = [
"/*.md",
"/*.toml",
"/CODEOWNERS",
"/COPYING",
"/benches",
"/deps/boringssl/**/*.[chS]",
"/deps/boringssl/**/*.asm",
"/deps/boringssl/src/**/*.cc",
"/deps/boringssl/**/CMakeLists.txt",
"/deps/boringssl/**/sources.cmake",
"/deps/boringssl/LICENSE",
"/examples",
"/include",
"/quiche.svg",
"/src",
]
[features]
default = ["boringssl-vendored"]
# Build vendored BoringSSL library.
boringssl-vendored = []
# Generate pkg-config metadata file for libquiche.
pkg-config-meta = []
# Equivalent to "--cfg fuzzing", but can also be checked in build.rs.
fuzzing = []
# Expose the FFI API.
ffi = []
[package.metadata.docs.rs]
no-default-features = true
[build-dependencies]
cmake = "0.1"
[dependencies]
log = { version = "0.4", features = ["std"] }
libc = "0.2"
libm = "0.2"
ring = "0.16"
lazy_static = "1"
boring-sys = { version = "1.0.2", optional = true }
qlog = { version = "0.5", path = "../qlog", optional = true }
[target."cfg(windows)".dependencies]
winapi = { version = "0.3", features = ["wincrypt"] }
[dev-dependencies]
mio = "0.6"
url = "1"
[lib]
crate-type = ["lib", "staticlib", "cdylib"]

View File

@ -15,4 +15,4 @@ ring = "0.16"
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
quiche = { path = "../../"}
quiche = { path = "../../quiche"}