Anki/build/configure/src/main.rs
antecrescent 58ce29f461
Refactor offline build process and add offline generation of Sphinx docs (#3082)
* Simplify the offline build

The two environment variables OFFLINE_BUILD and NO_VENV jointly provide
the ability to build Anki fully offline. This commit boils them down
into just one, namely OFFLINE_BUILD.

The rationale being that first, OFFLINE_BUILD implies the use of
a custom non-networked Python environment.
Second, building Anki with a custom Python environment in a networked
setting is a use case, that we currently do not support.
Developers in need of such a solution may want to give containerized
development environments a try. Users could also look into building
Anki fully offline instead.

* Add documentation for offline builds.

* Add support for offline generation of Sphinx documentation.

Control installation of Sphinx dependencies via the network through the
OFFLINE_BUILD environment variable.

* Add documentation for offline generation of Sphinx documentation.
2024-03-27 13:51:09 +00:00

77 lines
1.6 KiB
Rust

// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
mod aqt;
mod bundle;
mod platform;
mod pylib;
mod python;
mod rust;
mod web;
use std::env;
use anyhow::Result;
use aqt::build_and_check_aqt;
use bundle::build_bundle;
use ninja_gen::glob;
use ninja_gen::inputs;
use ninja_gen::protobuf::check_proto;
use ninja_gen::protobuf::setup_protoc;
use ninja_gen::python::setup_python;
use ninja_gen::Build;
use pylib::build_pylib;
use pylib::check_pylib;
use python::check_python;
use python::setup_venv;
use rust::build_rust;
use rust::check_minilints;
use rust::check_rust;
use web::build_and_check_web;
use web::check_sql;
use crate::python::setup_sphinx;
fn anki_version() -> String {
std::fs::read_to_string(".version")
.unwrap()
.trim()
.to_string()
}
fn main() -> Result<()> {
let mut build = Build::new()?;
let build = &mut build;
setup_protoc(build)?;
check_proto(build, inputs![glob!["proto/**/*.proto"]])?;
if env::var("OFFLINE_BUILD").is_err() {
setup_python(build)?;
}
setup_venv(build)?;
build_rust(build)?;
build_pylib(build)?;
build_and_check_web(build)?;
build_and_check_aqt(build)?;
if env::var("OFFLINE_BUILD").is_err() {
build_bundle(build)?;
}
setup_sphinx(build)?;
check_rust(build)?;
check_pylib(build)?;
check_python(build)?;
check_sql(build)?;
check_minilints(build)?;
build.trailing_text = "default pylib qt\n".into();
build.write_build_file()?;
Ok(())
}