Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Since release 2.1.55, upstream has changed the build system to a homebrew solution written in Rust, which generates the files for ninja(1) and then uses the latter also for building. As a result, quite a number of patches, that revolved around the Bazel build system, can now be removed and the Makefile can also be slimmed down considerably. By environment variables recognized by the build system, some required binaries (e.g. Python, Node.js, etc.) for the build can be directly defined instead downloading the binary tarballs from the official repositories, which saving quite a bit of patches at the end. In order to be able to build Anki successfully on FreeBSD, a few more environment variables have been introduced via custom patches. With this it's possible to use an offline cache for Node.js as well as a native Python environment instead of a venv. * Belatedly add devel/py-orjson as a fixed runtime dependency and although it's still optional in the code, the question is how long this will be the case. Thus update NOT_FOR_ARCH_REASON accordingly and keep ONLY_FOR_ARCH unchanged for now. Changelogs since 2.1.54: https://changes.ankiweb.net/changes/2.1.60-69.html https://changes.ankiweb.net/changes/2.1.50-59.html MFH: No (feature release)
- Loading branch information
Showing
46 changed files
with
1,986 additions
and
2,682 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
Check for NO_BUNDLE and NO_VENV environment variables. | ||
|
||
--- build/configure/src/main.rs.orig 2023-03-31 02:32:25 UTC | ||
+++ build/configure/src/main.rs | ||
@@ -10,6 +10,8 @@ mod web; | ||
mod rust; | ||
mod web; | ||
|
||
+use std::env; | ||
+ | ||
use aqt::build_and_check_aqt; | ||
use bundle::build_bundle; | ||
use ninja_gen::python::setup_python; | ||
@@ -20,6 +22,7 @@ use python::setup_venv; | ||
use python::check_copyright; | ||
use python::check_python; | ||
use python::setup_venv; | ||
+use python::setup_venv_stub; | ||
use rust::build_rust; | ||
use rust::check_rust; | ||
use web::build_and_check_web; | ||
@@ -39,13 +42,24 @@ fn main() -> Result<()> { | ||
let build = &mut build; | ||
|
||
setup_python(build)?; | ||
- setup_venv(build)?; | ||
|
||
+ if env::var("NO_VENV").is_ok() { | ||
+ println!("NO_VENV is set, using Python system environment."); | ||
+ setup_venv_stub(build)?; | ||
+ } else { | ||
+ setup_venv(build)?; | ||
+ } | ||
+ | ||
build_rust(build)?; | ||
build_pylib(build)?; | ||
build_and_check_web(build)?; | ||
build_and_check_aqt(build)?; | ||
- build_bundle(build)?; | ||
+ | ||
+ if env::var("NO_BUNDLE").is_ok() { | ||
+ println!("NO_BUNDLE is set, skipping build of bundles."); | ||
+ } else { | ||
+ build_bundle(build)?; | ||
+ } | ||
|
||
check_rust(build)?; | ||
check_pylib(build)?; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Use the "PythonEnvironmentStub" function to use a native Python environment | ||
instead of Python venv. | ||
|
||
--- build/configure/src/python.rs.orig 2023-05-01 01:47:30 UTC | ||
+++ build/configure/src/python.rs | ||
@@ -11,6 +11,7 @@ use ninja_gen::python::PythonEnvironment; | ||
use ninja_gen::inputs; | ||
use ninja_gen::python::python_format; | ||
use ninja_gen::python::PythonEnvironment; | ||
+use ninja_gen::python::PythonEnvironmentStub; | ||
use ninja_gen::python::PythonLint; | ||
use ninja_gen::python::PythonTypecheck; | ||
use ninja_gen::rsync::RsyncFiles; | ||
@@ -73,6 +74,25 @@ pub fn setup_venv(build: &mut Build) -> Result<()> { | ||
base_requirements_txt: inputs!["python/requirements.base.txt"], | ||
requirements_txt: inputs![reqs_qt5, "python/requirements.qt5_14.txt"], | ||
extra_binary_exports: &[], | ||
+ }, | ||
+ )?; | ||
+ | ||
+ Ok(()) | ||
+} | ||
+ | ||
+pub fn setup_venv_stub(build: &mut Build) -> Result<()> { | ||
+ build.add( | ||
+ "pyenv", | ||
+ PythonEnvironmentStub { | ||
+ folder: "pyenv", | ||
+ extra_binary_exports: &[ | ||
+ "mypy", | ||
+ "black", // Required in some parts of the code, but not for build | ||
+ "isort", // dito | ||
+ "pylint", // dito | ||
+ "pytest", // dito | ||
+ "protoc-gen-mypy", | ||
+ ], | ||
}, | ||
)?; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
Check for the OFFLINE_BUILD environment variable to prevent issuing the repo | ||
sync that requires git and an internet connection. | ||
|
||
--- build/configure/src/rust.rs.orig 2023-03-31 02:32:25 UTC | ||
+++ build/configure/src/rust.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::cargo::CargoBuild; | ||
use ninja_gen::cargo::CargoClippy; | ||
use ninja_gen::cargo::CargoFormat; | ||
@@ -8,6 +10,7 @@ use ninja_gen::git::SyncSubmodule; | ||
use ninja_gen::cargo::CargoTest; | ||
use ninja_gen::cargo::RustOutput; | ||
use ninja_gen::git::SyncSubmodule; | ||
+use ninja_gen::git::SyncSubmoduleOffline; | ||
use ninja_gen::glob; | ||
use ninja_gen::inputs; | ||
use ninja_gen::Build; | ||
@@ -24,18 +27,34 @@ fn prepare_translations(build: &mut Build) -> Result<( | ||
|
||
fn prepare_translations(build: &mut Build) -> Result<()> { | ||
// ensure repos are checked out | ||
- build.add( | ||
- "ftl:repo:core", | ||
- SyncSubmodule { | ||
- path: "ftl/core-repo", | ||
- }, | ||
- )?; | ||
- build.add( | ||
- "ftl:repo:qt", | ||
- SyncSubmodule { | ||
- path: "ftl/qt-repo", | ||
- }, | ||
- )?; | ||
+ if env::var("OFFLINE_BUILD").is_ok() { | ||
+ println!("OFFLINE_BUILD set, skipping git repository sync for translation files."); | ||
+ build.add( | ||
+ "ftl:repo:core", | ||
+ SyncSubmoduleOffline { | ||
+ path: "ftl/core-repo", | ||
+ }, | ||
+ )?; | ||
+ build.add( | ||
+ "ftl:repo:qt", | ||
+ SyncSubmoduleOffline { | ||
+ path: "ftl/qt-repo", | ||
+ }, | ||
+ )?; | ||
+ } else { | ||
+ build.add( | ||
+ "ftl:repo:core", | ||
+ SyncSubmodule { | ||
+ path: "ftl/core-repo", | ||
+ }, | ||
+ )?; | ||
+ build.add( | ||
+ "ftl:repo:qt", | ||
+ SyncSubmodule { | ||
+ path: "ftl/qt-repo", | ||
+ }, | ||
+ )?; | ||
+ } | ||
// build anki_i18n and spit out strings.json | ||
build.add( | ||
"rslib/i18n", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Enable the build for FreeBSD. Technically it would make sense to define | ||
corresponding variables, e.g. "FreeBSDX64" for FreeBSD amd64, instead of | ||
using the already defined variables. | ||
|
||
The problem here is that new variables have to be defined in other places | ||
(= "configure/src/python.rs", "ninja_gen/src/{node,python,protobuf}.rs") | ||
and are actually mostly needed to obtain the corresponding binary | ||
distributions for Node, Protobuf, and Python. | ||
|
||
Since the latter is already bypassed by setting the environment variables | ||
"{NODE,PROTOC,PYTHON,YARN}_BINARY", it makes little sense to patch the | ||
other parts of the code for now. | ||
|
||
It probably makes sense to have a generic variable (e.g. "Self::FreeBSD") | ||
for all FreeBSD architectures that is used in conjunction with NO_BUNDLE, | ||
NO_VENV, OFFLINE_BUILD and OFFLINE_YARNCACHE to allow building on FreeBSD | ||
(and preferably other BSDs) persistently. | ||
|
||
--- build/ninja_gen/src/archives.rs.orig 2023-03-31 02:32:25 UTC | ||
+++ build/ninja_gen/src/archives.rs | ||
@@ -39,6 +39,8 @@ impl Platform { | ||
let os = std::env::consts::OS; | ||
let arch = std::env::consts::ARCH; | ||
match (os, arch) { | ||
+ ("freebsd", "x86_64") => Self::LinuxX64, | ||
+ ("freebsd", "aarch64") => Self::LinuxArm, | ||
("linux", "x86_64") => Self::LinuxX64, | ||
("linux", "aarch64") => Self::LinuxArm, | ||
("macos", "x86_64") => Self::MacX64, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Make the cargo build for the rust library more verbose | ||
|
||
--- build/ninja_gen/src/cargo.rs.orig 2023-04-09 12:58:05 UTC | ||
+++ build/ninja_gen/src/cargo.rs | ||
@@ -74,7 +74,7 @@ impl BuildAction for CargoBuild<'_> { | ||
|
||
impl BuildAction for CargoBuild<'_> { | ||
fn command(&self) -> &str { | ||
- "cargo build $release_arg $target_arg $cargo_flags $extra_args" | ||
+ "cargo build $release_arg $target_arg $cargo_flags $extra_args --verbose --verbose" | ||
} | ||
|
||
fn files(&mut self, build: &mut impl FilesHandle) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
Add "SyncSubmoduleOffline" stub function that is used if the OFFLINE_BUILD | ||
environment variable is set. | ||
|
||
--- build/ninja_gen/src/git.rs.orig 2023-03-31 02:32:25 UTC | ||
+++ build/ninja_gen/src/git.rs | ||
@@ -11,6 +11,10 @@ pub struct SyncSubmodule { | ||
pub path: &'static str, | ||
} | ||
|
||
+pub struct SyncSubmoduleOffline { | ||
+ pub path: &'static str, | ||
+} | ||
+ | ||
impl BuildAction for SyncSubmodule { | ||
fn command(&self) -> &str { | ||
"git -c protocol.file.allow=always submodule update --init $path" | ||
@@ -33,6 +37,17 @@ impl BuildAction for SyncSubmodule { | ||
|
||
fn concurrency_pool(&self) -> Option<&'static str> { | ||
Some("git") | ||
+ } | ||
+} | ||
+ | ||
+impl BuildAction for SyncSubmoduleOffline { | ||
+ fn command(&self) -> &str { | ||
+ "echo Runnung SyncSubmoduleOffline stub function for $path" | ||
+ } | ||
+ | ||
+ fn files(&mut self, build: &mut impl build::FilesHandle) { | ||
+ build.add_variable("path", self.path); | ||
+ build.add_output_stamp(format!("git/{}", self.path)); | ||
} | ||
} | ||
|
Oops, something went wrong.