mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Use a ninja variable for Protoc binary (#2345)
* Use a ninja variable for Protoc binary * fix whitespace
This commit is contained in:
parent
ff59b33c54
commit
da7d4dd2fc
8 changed files with 38 additions and 19 deletions
|
@ -1,7 +1,7 @@
|
||||||
[env]
|
[env]
|
||||||
STRINGS_JSON = { value = "out/rslib/i18n/strings.json", relative = true }
|
STRINGS_JSON = { value = "out/rslib/i18n/strings.json", relative = true }
|
||||||
# build script will append .exe if necessary
|
# 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"
|
PYO3_NO_PYTHON = "1"
|
||||||
MACOSX_DEPLOYMENT_TARGET = "10.13.4"
|
MACOSX_DEPLOYMENT_TARGET = "10.13.4"
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,7 @@ Zoom <zoomrmc+git@gmail.com>
|
||||||
TRIAEIOU <github.com/TRIAEIOU>
|
TRIAEIOU <github.com/TRIAEIOU>
|
||||||
Stefan Kangas <stefankangas@gmail.com>
|
Stefan Kangas <stefankangas@gmail.com>
|
||||||
Fabricio Duarte <fabricio.duarte.jr@gmail.com>
|
Fabricio Duarte <fabricio.duarte.jr@gmail.com>
|
||||||
|
Mani <github.com/krmanik>
|
||||||
|
|
||||||
********************
|
********************
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// Copyright: Ankitects Pty Ltd and contributors
|
// Copyright: Ankitects Pty Ltd and contributors
|
||||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
// 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::download_and_extract;
|
||||||
use ninja_gen::archives::with_exe;
|
use ninja_gen::archives::with_exe;
|
||||||
use ninja_gen::glob;
|
use ninja_gen::glob;
|
||||||
|
@ -10,16 +12,31 @@ use ninja_gen::protobuf::protoc_archive;
|
||||||
use ninja_gen::protobuf::ClangFormat;
|
use ninja_gen::protobuf::ClangFormat;
|
||||||
use ninja_gen::Build;
|
use ninja_gen::Build;
|
||||||
use ninja_gen::Result;
|
use ninja_gen::Result;
|
||||||
|
use ninja_gen::Utf8Path;
|
||||||
|
|
||||||
pub fn download_protoc(build: &mut Build) -> Result<()> {
|
pub fn setup_protoc(build: &mut Build) -> Result<()> {
|
||||||
download_and_extract(
|
let protoc_binary = match env::var("PROTOC_BINARY") {
|
||||||
build,
|
Ok(path) => {
|
||||||
"protoc",
|
assert!(
|
||||||
protoc_archive(build.host_platform),
|
Utf8Path::new(&path).is_absolute(),
|
||||||
hashmap! {
|
"PROTOC_BINARY must be absolute"
|
||||||
"bin" => [with_exe("bin/protoc")]
|
);
|
||||||
},
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ impl BuildAction for GenPythonProto {
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
build.add_inputs("in", &self.proto_files);
|
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_inputs("protoc-gen-mypy", inputs![":pyenv:protoc-gen-mypy"]);
|
||||||
build.add_outputs("", python_outputs);
|
build.add_outputs("", python_outputs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,11 @@ use ninja_gen::Build;
|
||||||
use ninja_gen::Result;
|
use ninja_gen::Result;
|
||||||
|
|
||||||
use crate::platform::overriden_rust_target_triple;
|
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<()> {
|
pub fn build_rust(build: &mut Build) -> Result<()> {
|
||||||
prepare_translations(build)?;
|
prepare_translations(build)?;
|
||||||
download_protoc(build)?;
|
setup_protoc(build)?;
|
||||||
build_rsbridge(build)
|
build_rsbridge(build)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ fn build_rsbridge(build: &mut Build) -> Result<()> {
|
||||||
CargoBuild {
|
CargoBuild {
|
||||||
inputs: inputs![
|
inputs: inputs![
|
||||||
glob!["{pylib/rsbridge/**,rslib/**,proto/**}"],
|
glob!["{pylib/rsbridge/**,rslib/**,proto/**}"],
|
||||||
":extract:protoc:bin",
|
"$protoc_binary",
|
||||||
// declare a dependency on i18n so it gets built first, allowing
|
// declare a dependency on i18n so it gets built first, allowing
|
||||||
// things depending on strings.json to build faster, and ensuring
|
// things depending on strings.json to build faster, and ensuring
|
||||||
// changes to the ftl files trigger a rebuild
|
// changes to the ftl files trigger a rebuild
|
||||||
|
|
|
@ -76,9 +76,9 @@ There are a few things to be aware of:
|
||||||
|
|
||||||
## Packaging considerations
|
## Packaging considerations
|
||||||
|
|
||||||
Python and node are downloaded as part of the build. You can optionally define
|
Python, node and protoc 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
|
PYTHON_BINARY and PROTOC_BINARY as the full path to a Python binary and Protoc binary respectively,
|
||||||
version. A similar approach could be done with node in the future; a PR would be
|
to use it instead of the downloaded version. A similar approach could be done with node in the future; a PR would be
|
||||||
welcome.
|
welcome.
|
||||||
|
|
||||||
If rust-toolchain.toml is removed, newer Rust versions can be used. Older versions
|
If rust-toolchain.toml is removed, newer Rust versions can be used. Older versions
|
||||||
|
|
|
@ -125,7 +125,8 @@ pub fn write_backend_proto_rs() {
|
||||||
/// If PROTOC is not defined, and protoc is not on path, use the protoc
|
/// If PROTOC is not defined, and protoc is not on path, use the protoc
|
||||||
/// fetched by Bazel so that Rust Analyzer does not fail.
|
/// fetched by Bazel so that Rust Analyzer does not fail.
|
||||||
fn maybe_add_protobuf_to_path() {
|
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") {
|
if cfg!(windows) && !protoc.ends_with(".exe") {
|
||||||
env::set_var("PROTOC", format!("{protoc}.exe"));
|
env::set_var("PROTOC", format!("{protoc}.exe"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
export let disabled = false;
|
export let disabled = false;
|
||||||
export let tabbable = false;
|
export let tabbable = false;
|
||||||
export let ellipsis = false;
|
export let ellipsis = false;
|
||||||
|
|
||||||
let buttonRef: HTMLButtonElement;
|
let buttonRef: HTMLButtonElement;
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
Loading…
Reference in a new issue