mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
Make it so that you don't need to run xtask through cargo
This commit is contained in:
parent
9b1fd52231
commit
54c979d9e6
5 changed files with 11 additions and 10 deletions
|
@ -50,7 +50,7 @@ file(GLOB generated_headers_dependencies
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
generated_headers_target
|
generated_headers_target
|
||||||
COMMAND
|
COMMAND
|
||||||
${CMAKE_COMMAND} -E env CARGO_MANIFEST_DIR="${CMAKE_CURRENT_SOURCE_DIR}/../../xtask}" $<TARGET_FILE:xtask> cbindgen --output-dir "${CMAKE_CURRENT_BINARY_DIR}/generated_include/"
|
xtask cbindgen --output-dir "${CMAKE_CURRENT_BINARY_DIR}/generated_include/"
|
||||||
BYPRODUCTS ${generated_headers}
|
BYPRODUCTS ${generated_headers}
|
||||||
DEPENDS ${generated_headers_dependencies}
|
DEPENDS ${generated_headers_dependencies}
|
||||||
)
|
)
|
||||||
|
|
|
@ -60,7 +60,7 @@ fn symlink_files_in_dir<S: AsRef<Path>, T: AsRef<Path>, TS: AsRef<Path>>(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn generate() -> Result<(), Box<dyn std::error::Error>> {
|
pub fn generate() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let root = super::root_dir()?;
|
let root = super::root_dir();
|
||||||
|
|
||||||
let docs_source_dir = root.join("api/sixtyfps-cpp");
|
let docs_source_dir = root.join("api/sixtyfps-cpp");
|
||||||
let docs_build_dir = root.join("target/cppdocs");
|
let docs_build_dir = root.join("target/cppdocs");
|
||||||
|
|
|
@ -273,7 +273,7 @@ const EXPECTED_HOMEPAGE: &str = "https://sixtyfps.io";
|
||||||
const EXPECTED_REPOSITORY: &str = "https://github.com/sixtyfpsui/sixtyfps";
|
const EXPECTED_REPOSITORY: &str = "https://github.com/sixtyfpsui/sixtyfps";
|
||||||
|
|
||||||
fn collect_files() -> Result<Vec<PathBuf>> {
|
fn collect_files() -> Result<Vec<PathBuf>> {
|
||||||
let root = super::root_dir()?;
|
let root = super::root_dir();
|
||||||
let ls_files_output = super::run_command(
|
let ls_files_output = super::run_command(
|
||||||
"git",
|
"git",
|
||||||
&["ls-files", "-z"],
|
&["ls-files", "-z"],
|
||||||
|
@ -552,7 +552,7 @@ impl LicenseHeaderCheck {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_file(&self, path: &Path) -> Result<()> {
|
fn check_file(&self, path: &Path) -> Result<()> {
|
||||||
let repo_relative_path = path.strip_prefix(super::root_dir()?)?;
|
let repo_relative_path = path.strip_prefix(super::root_dir())?;
|
||||||
let path_str = repo_relative_path.to_str().unwrap();
|
let path_str = repo_relative_path.to_str().unwrap();
|
||||||
let location = LICENSE_LOCATION_FOR_FILE
|
let location = LICENSE_LOCATION_FOR_FILE
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -42,10 +42,11 @@ pub struct CbindgenCommand {
|
||||||
output_dir: String,
|
output_dir: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn root_dir() -> anyhow::Result<PathBuf> {
|
/// The root dir of the git repository
|
||||||
let mut root = PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").ok_or_else(|| anyhow::anyhow!("Cannot determine root directory - CARGO_MANIFEST_DIR is not set -- you can only run xtask via cargo"))?);
|
fn root_dir() -> PathBuf {
|
||||||
|
let mut root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||||
root.pop(); // $root/xtask -> $root
|
root.pop(); // $root/xtask -> $root
|
||||||
Ok(root)
|
root
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_command<I, K, V>(program: &str, args: &[&str], env: I) -> anyhow::Result<Vec<u8>>
|
fn run_command<I, K, V>(program: &str, args: &[&str], env: I) -> anyhow::Result<Vec<u8>>
|
||||||
|
@ -57,7 +58,7 @@ where
|
||||||
let cmdline = || format!("{} {}", program, args.join(" "));
|
let cmdline = || format!("{} {}", program, args.join(" "));
|
||||||
let output = std::process::Command::new(program)
|
let output = std::process::Command::new(program)
|
||||||
.args(args)
|
.args(args)
|
||||||
.current_dir(root_dir()?)
|
.current_dir(root_dir())
|
||||||
.envs(env)
|
.envs(env)
|
||||||
.output()
|
.output()
|
||||||
.with_context(|| format!("Error launching {}", cmdline()))?;
|
.with_context(|| format!("Error launching {}", cmdline()))?;
|
||||||
|
@ -82,7 +83,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
match ApplicationArguments::from_args().command {
|
match ApplicationArguments::from_args().command {
|
||||||
TaskCommand::CheckLicenseHeaders(cmd) => cmd.check_license_headers()?,
|
TaskCommand::CheckLicenseHeaders(cmd) => cmd.check_license_headers()?,
|
||||||
TaskCommand::CppDocs => cppdocs::generate()?,
|
TaskCommand::CppDocs => cppdocs::generate()?,
|
||||||
TaskCommand::Cbindgen(cmd) => cbindgen::gen_all(&root_dir()?, Path::new(&cmd.output_dir))?,
|
TaskCommand::Cbindgen(cmd) => cbindgen::gen_all(&root_dir(), Path::new(&cmd.output_dir))?,
|
||||||
TaskCommand::NodePackage => nodepackage::generate()?,
|
TaskCommand::NodePackage => nodepackage::generate()?,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ use anyhow::Context;
|
||||||
use xshell::{cmd, cp, pushd, read_file, rm_rf, write_file};
|
use xshell::{cmd, cp, pushd, read_file, rm_rf, write_file};
|
||||||
|
|
||||||
pub fn generate() -> Result<(), Box<dyn std::error::Error>> {
|
pub fn generate() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let root = super::root_dir().context("error determining root directory")?;
|
let root = super::root_dir();
|
||||||
let node_dir = root.join("api").join("sixtyfps-node");
|
let node_dir = root.join("api").join("sixtyfps-node");
|
||||||
|
|
||||||
let cargo_toml_path = node_dir.join("native").join("Cargo.toml");
|
let cargo_toml_path = node_dir.join("native").join("Cargo.toml");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue