Fix comments and naming found in review in #355

This commit is contained in:
Olivier Goffart 2021-07-28 15:53:30 +02:00 committed by Olivier Goffart
parent 7821926002
commit 43e07320a5
3 changed files with 5 additions and 4 deletions

View file

@ -203,6 +203,7 @@ pub fn compile_with_config(
};
if std::env::var_os("SIXTYFPS_STYLE").is_none() && compiler_config.style.is_none() {
compiler_config.style = std::env::var_os("OUT_DIR").and_then(|path| {
// Same logic as in sixtyfps-rendering-backend-default's build script to get the path
let path = Path::new(&path).parent()?.parent()?.join("SIXTYFPS_DEFAULT_STYLE.txt");
let style = std::fs::read_to_string(path).ok()?;
Some(style.trim().into())

View file

@ -17,10 +17,10 @@ fn main() {
// The way this work is this
// 1. `qttypes`' crate's build script already detects Qt and set the DEP_QT_VERSION
// 2. The qt rendering backend's build script will check if the qttype crates found Qt and
// look at the SIXTYFPS_NO_QT env variable, and sets the DEP_SIXTYFPS_RENDERING_BACKEND_QT_HAS_NATIVE_STYLE
// look at the SIXTYFPS_NO_QT env variable, and sets the DEP_SIXTYFPS_RENDERING_BACKEND_QT_SUPPORTS_NATIVE_STYLE
// env variable so that the default rendering backend can know if Qt was there.
// 3. here, in the default rendering backend, we know if we depends on the qt backend and if it
// has set the DEP_SIXTYFPS_RENDERING_BACKEND_QT_HAS_NATIVE_STYLE env variable.
// has set the DEP_SIXTYFPS_RENDERING_BACKEND_QT_SUPPORTS_NATIVE_STYLE env variable.
// We then write a file in the build directory with the default style that depends on the
// Qt availability
// 4a. When using the sixtyfps-build crate from a build script, it will be able to read this file
@ -29,7 +29,7 @@ fn main() {
// the location of that file, the build script of sixtyfps-macros had to save the path in an env
// variable
let has_native_style = std::env::var("DEP_SIXTYFPS_RENDERING_BACKEND_QT_HAS_NATIVE_STYLE")
let has_native_style = std::env::var("DEP_SIXTYFPS_RENDERING_BACKEND_QT_SUPPORTS_NATIVE_STYLE")
.unwrap_or_default()
== "1";

View file

@ -49,5 +49,5 @@ fn main() {
println!("cargo:rerun-if-changed=qt_window.rs");
println!("cargo:rerun-if-changed=widgets.rs");
println!("cargo:rerun-if-changed=lib.rs");
println!("cargo:HAS_NATIVE_STYLE=1");
println!("cargo:SUPPORTS_NATIVE_STYLE=1");
}