mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-29 13:24:48 +00:00
C++: Make it possible to split up the C++ code generated for a .slint file
Add a COMPILATION_UNITS argument to slint_target_sources that defines into how many .cpp files to split up a .slint file. The new default is now one.
This commit is contained in:
parent
12f5343cd8
commit
c25a03d6f7
6 changed files with 160 additions and 31 deletions
|
@ -70,6 +70,10 @@ struct Cli {
|
|||
/// C++ namespace
|
||||
#[arg(long = "cpp-namespace", name = "C++ namespace")]
|
||||
cpp_namespace: Option<String>,
|
||||
|
||||
/// C++ files to generate (0 for header-only output)
|
||||
#[arg(long = "cpp-file", name = "C++ file to generate", number_of_values = 1, action)]
|
||||
cpp_files: Vec<std::path::PathBuf>,
|
||||
}
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
|
@ -89,8 +93,28 @@ fn main() -> std::io::Result<()> {
|
|||
if !matches!(format, generator::OutputFormat::Cpp(..)) {
|
||||
eprintln!("C++ namespace option was set. Output format will be C++.");
|
||||
}
|
||||
format =
|
||||
generator::OutputFormat::Cpp(generator::cpp::Config { namespace: args.cpp_namespace });
|
||||
format = generator::OutputFormat::Cpp(generator::cpp::Config {
|
||||
namespace: args.cpp_namespace,
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
|
||||
if !args.cpp_files.is_empty() {
|
||||
match &mut format {
|
||||
generator::OutputFormat::Cpp(ref mut config) => {
|
||||
config.cpp_files = args.cpp_files;
|
||||
|
||||
if args.output == std::path::Path::new("-") {
|
||||
eprintln!("--cpp-file can only be used together with -o");
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
config.header_include = args.output.to_string_lossy().to_string();
|
||||
}
|
||||
_ => {
|
||||
eprintln!("C++ files option was set but the output format is not C++ - ignorning");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut compiler_config = CompilerConfiguration::new(format.clone());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue