diff --git a/.cargo/config.toml b/.cargo/config.toml index 838b8d683..ce666a159 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,7 +1,7 @@ [env] STRINGS_JSON = { value = "out/rslib/i18n/strings.json", relative = true } # build script will append .exe if necessary -PROTOC = { value = "out/extracted/protoc/bin/protoc", relative = true } +PROTOC_BINARY = { value = "out/extracted/protoc/bin/protoc", relative = true } PYO3_NO_PYTHON = "1" MACOSX_DEPLOYMENT_TARGET = "10.13.4" diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 7a2f6c419..1b1dc3e25 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -109,6 +109,7 @@ Zoom TRIAEIOU Stefan Kangas Fabricio Duarte +Mani ******************** diff --git a/build/configure/src/proto.rs b/build/configure/src/proto.rs index 47590af32..263de30b1 100644 --- a/build/configure/src/proto.rs +++ b/build/configure/src/proto.rs @@ -1,6 +1,8 @@ // Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html +use std::env; + use ninja_gen::archives::download_and_extract; use ninja_gen::archives::with_exe; use ninja_gen::glob; @@ -10,16 +12,31 @@ use ninja_gen::protobuf::protoc_archive; use ninja_gen::protobuf::ClangFormat; use ninja_gen::Build; use ninja_gen::Result; +use ninja_gen::Utf8Path; -pub fn download_protoc(build: &mut Build) -> Result<()> { - download_and_extract( - build, - "protoc", - protoc_archive(build.host_platform), - hashmap! { - "bin" => [with_exe("bin/protoc")] - }, - )?; +pub fn setup_protoc(build: &mut Build) -> Result<()> { + let protoc_binary = match env::var("PROTOC_BINARY") { + Ok(path) => { + assert!( + Utf8Path::new(&path).is_absolute(), + "PROTOC_BINARY must be absolute" + ); + path.into() + } + Err(_) => { + download_and_extract( + build, + "protoc", + protoc_archive(build.host_platform), + hashmap! { + "bin" => [with_exe("bin/protoc")] + }, + )?; + inputs![":extract:protoc:bin"] + } + }; + let protoc_binary = build.expand_inputs(protoc_binary); + build.variable("protoc_binary", &protoc_binary[0]); Ok(()) } diff --git a/build/configure/src/python.rs b/build/configure/src/python.rs index a4acbfac1..b8ac8debd 100644 --- a/build/configure/src/python.rs +++ b/build/configure/src/python.rs @@ -178,7 +178,7 @@ impl BuildAction for GenPythonProto { }) .collect(); build.add_inputs("in", &self.proto_files); - build.add_inputs("protoc", inputs![":extract:protoc:bin"]); + build.add_inputs("protoc", inputs!["$protoc_binary"]); build.add_inputs("protoc-gen-mypy", inputs![":pyenv:protoc-gen-mypy"]); build.add_outputs("", python_outputs); } diff --git a/build/configure/src/rust.rs b/build/configure/src/rust.rs index b51d99445..e137b00c5 100644 --- a/build/configure/src/rust.rs +++ b/build/configure/src/rust.rs @@ -14,11 +14,11 @@ use ninja_gen::Build; use ninja_gen::Result; use crate::platform::overriden_rust_target_triple; -use crate::proto::download_protoc; +use crate::proto::setup_protoc; pub fn build_rust(build: &mut Build) -> Result<()> { prepare_translations(build)?; - download_protoc(build)?; + setup_protoc(build)?; build_rsbridge(build) } @@ -79,7 +79,7 @@ fn build_rsbridge(build: &mut Build) -> Result<()> { CargoBuild { inputs: inputs![ glob!["{pylib/rsbridge/**,rslib/**,proto/**}"], - ":extract:protoc:bin", + "$protoc_binary", // declare a dependency on i18n so it gets built first, allowing // things depending on strings.json to build faster, and ensuring // changes to the ftl files trigger a rebuild diff --git a/docs/linux.md b/docs/linux.md index 2c0e85cb1..6b0e3afd7 100644 --- a/docs/linux.md +++ b/docs/linux.md @@ -76,9 +76,9 @@ There are a few things to be aware of: ## Packaging considerations -Python and node are downloaded as part of the build. You can optionally define -PYTHON_BINARY as the full path to a Python binary, to use it instead of the downloaded -version. A similar approach could be done with node in the future; a PR would be +Python, node and protoc are downloaded as part of the build. You can optionally define +PYTHON_BINARY and PROTOC_BINARY as the full path to a Python binary and Protoc binary respectively, +to use it instead of the downloaded version. A similar approach could be done with node in the future; a PR would be welcome. If rust-toolchain.toml is removed, newer Rust versions can be used. Older versions diff --git a/rslib/build/protobuf.rs b/rslib/build/protobuf.rs index 2d92940f3..2e4affa5b 100644 --- a/rslib/build/protobuf.rs +++ b/rslib/build/protobuf.rs @@ -125,7 +125,8 @@ pub fn write_backend_proto_rs() { /// If PROTOC is not defined, and protoc is not on path, use the protoc /// fetched by Bazel so that Rust Analyzer does not fail. fn maybe_add_protobuf_to_path() { - if let Ok(protoc) = env::var("PROTOC") { + if let Ok(protoc) = env::var("PROTOC_BINARY") { + env::set_var("PROTOC", &protoc); if cfg!(windows) && !protoc.ends_with(".exe") { env::set_var("PROTOC", format!("{protoc}.exe")); } diff --git a/ts/components/LabelButton.svelte b/ts/components/LabelButton.svelte index b79e5d64b..46598fd5e 100644 --- a/ts/components/LabelButton.svelte +++ b/ts/components/LabelButton.svelte @@ -15,7 +15,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html export let disabled = false; export let tabbable = false; export let ellipsis = false; - + let buttonRef: HTMLButtonElement; const dispatch = createEventDispatcher();