Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions arbitrator/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions arbitrator/brotli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ lazy_static = { workspace = true }
num_enum = { workspace = true }
wasmer = { workspace = true, optional = true }

[build-dependencies]
cc = { version = "1.0", optional = true }

[lib]
crate-type = ["lib"]

[features]
wasmer_traits = ["dep:wasmer"]
cc_brotli = ["dep:cc"]
56 changes: 53 additions & 3 deletions arbitrator/brotli/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright 2021-2024, Offchain Labs, Inc.
// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE.md

use std::env;

#[cfg(not(feature = "cc_brotli"))]
fn main() {
use std::env;

let target_arch = env::var("TARGET").unwrap();

if target_arch.contains("wasm32") {
Expand All @@ -16,3 +16,53 @@ fn main() {
println!("cargo:rustc-link-lib=static=brotlidec-static");
println!("cargo:rustc-link-lib=static=brotlicommon-static");
}

#[cfg(feature = "cc_brotli")]
fn main() {
use std::env;
use std::path::PathBuf;
let manifest_dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
let include_dir = manifest_dir.join("../../brotli/c/include");
cc::Build::new()
.files(&[
"../../brotli/c/common/constants.c",
"../../brotli/c/common/context.c",
"../../brotli/c/common/dictionary.c",
"../../brotli/c/common/platform.c",
"../../brotli/c/common/shared_dictionary.c",
"../../brotli/c/common/transform.c",
"../../brotli/c/dec/bit_reader.c",
"../../brotli/c/dec/decode.c",
"../../brotli/c/dec/huffman.c",
"../../brotli/c/dec/state.c",
"../../brotli/c/enc/backward_references.c",
"../../brotli/c/enc/backward_references_hq.c",
"../../brotli/c/enc/bit_cost.c",
"../../brotli/c/enc/block_splitter.c",
"../../brotli/c/enc/brotli_bit_stream.c",
"../../brotli/c/enc/cluster.c",
"../../brotli/c/enc/command.c",
"../../brotli/c/enc/compound_dictionary.c",
"../../brotli/c/enc/compress_fragment.c",
"../../brotli/c/enc/compress_fragment_two_pass.c",
"../../brotli/c/enc/dictionary_hash.c",
"../../brotli/c/enc/encode.c",
"../../brotli/c/enc/encoder_dict.c",
"../../brotli/c/enc/entropy_encode.c",
"../../brotli/c/enc/fast_log.c",
"../../brotli/c/enc/histogram.c",
"../../brotli/c/enc/literal_cost.c",
"../../brotli/c/enc/memory.c",
"../../brotli/c/enc/metablock.c",
"../../brotli/c/enc/static_dict.c",
"../../brotli/c/enc/utf8_util.c",
])
.includes(["../../brotli/c/include"])
.define("BROTLI_BUILD_ENC_EXTRA_API", None)
.define("BROTLI_HAVE_LOG2", "1")
.warnings(false)
.compile("brotli");

println!("cargo:include={}", include_dir.display());
println!("cargo:rerun-if-changed=brotli/c");
}
1 change: 1 addition & 0 deletions arbitrator/caller-env/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ default = ["brotli"]
brotli = ["dep:brotli"]
static_caller = []
wasmer_traits = ["dep:wasmer", "brotli?/wasmer_traits"]
cc_brotli = ["brotli?/cc_brotli"]
1 change: 1 addition & 0 deletions arbitrator/jit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ wasmer-compiler-llvm = { workspace = true, optional = true }

[features]
llvm = ["dep:wasmer-compiler-llvm"]
cc_brotli = ["brotli/cc_brotli"]
1 change: 1 addition & 0 deletions arbitrator/prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ counters = []
native = ["dep:wasmer", "dep:wasmer-compiler-singlepass", "brotli/wasmer_traits", "dep:c-kzg"]
singlepass_rayon = ["wasmer-compiler-singlepass?/rayon"]
rayon = ["dep:rayon"]
cc_brotli = ["brotli/cc_brotli"]
1 change: 1 addition & 0 deletions arbitrator/stylus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ benchmark = []
timings = []
singlepass_rayon = ["prover/singlepass_rayon", "wasmer-compiler-singlepass/rayon"]
rayon = ["prover/rayon"]
cc_brotli = ["brotli/cc_brotli"]

[lib]
crate-type = ["lib", "staticlib"]
Loading