diff --git a/Cargo.toml b/Cargo.toml index 7197a5984..ae34f3637 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,9 +9,7 @@ members = [ "crates/cxx-qt-build", "crates/cxx-qt-gen", "crates/cxx-qt-lib", - "crates/cxx-qt-lib-headers", "crates/qt-build-utils", - "crates/cxx-qt-lib-extras-headers", "crates/cxx-qt-lib-extras", "examples/cargo_without_cmake", @@ -39,9 +37,7 @@ cxx-qt-macro = { path = "crates/cxx-qt-macro", version = "0.6.1" } cxx-qt-build = { path = "crates/cxx-qt-build", version = "0.6.1" } cxx-qt-gen = { path = "crates/cxx-qt-gen", version = "0.6.1" } cxx-qt-lib = { path = "crates/cxx-qt-lib", version = "0.6.1" } -cxx-qt-lib-headers = { path = "crates/cxx-qt-lib-headers", version = "0.6.1" } qt-build-utils = { path = "crates/qt-build-utils", version = "0.6.1" } -cxx-qt-lib-extras-headers = { path = "crates/cxx-qt-lib-extras-headers", version = "0.6.1" } cxx-qt-lib-extras = { path = "crates/cxx-qt-lib-extras", version = "0.6.1" } cc = { version = "1.0.89", features = ["parallel"] } diff --git a/cmake/CxxQt.cmake b/cmake/CxxQt.cmake index fa244cad4..006a72145 100644 --- a/cmake/CxxQt.cmake +++ b/cmake/CxxQt.cmake @@ -43,8 +43,8 @@ function(cxxqt_import_crate) "QMAKE=${IMPORT_CRATE_QMAKE}" $<$:RUSTC_WRAPPER=${CMAKE_RUSTC_WRAPPER}>) - file(MAKE_DIRECTORY "${IMPORT_CRATE_CXXQT_EXPORT_DIR}/include/${CRATE}") - target_include_directories(${CRATE} INTERFACE "${IMPORT_CRATE_CXXQT_EXPORT_DIR}/include/${CRATE}") + file(MAKE_DIRECTORY "${IMPORT_CRATE_CXXQT_EXPORT_DIR}/crates/${CRATE}/include/") + target_include_directories(${CRATE} INTERFACE "${IMPORT_CRATE_CXXQT_EXPORT_DIR}/crates/${CRATE}/include/") set_target_properties(${CRATE} PROPERTIES @@ -53,7 +53,7 @@ function(cxxqt_import_crate) # cxx-qt-build generates object files that need to be linked to the final target. # These are the static initializers that would be removed as an optimization if they're not referenced. # So add them to an object library instead. - file(MAKE_DIRECTORY "${IMPORT_CRATE_CXXQT_EXPORT_DIR}/initializers/") + file(MAKE_DIRECTORY "${IMPORT_CRATE_CXXQT_EXPORT_DIR}/crates/${CRATE}/") # When using the Ninja generator, we need to provide **some** way to generate the object file # Unfortunately I'm not able to tell corrosion that this obj file is indeed a byproduct, so # create a fake target for it. @@ -61,19 +61,17 @@ function(cxxqt_import_crate) add_custom_target(${CRATE}_mock_initializers COMMAND ${CMAKE_COMMAND} -E true DEPENDS ${CRATE} - BYPRODUCTS "${IMPORT_CRATE_CXXQT_EXPORT_DIR}/initializers/${CRATE}.o") + BYPRODUCTS "${IMPORT_CRATE_CXXQT_EXPORT_DIR}/crates/${CRATE}/initializers.o") add_library(${CRATE}_initializers OBJECT IMPORTED) set_target_properties(${CRATE}_initializers PROPERTIES - IMPORTED_OBJECTS "${IMPORT_CRATE_CXXQT_EXPORT_DIR}/initializers/${CRATE}.o") + IMPORTED_OBJECTS "${IMPORT_CRATE_CXXQT_EXPORT_DIR}/crates/${CRATE}/initializers.o") # Note that we need to link using TARGET_OBJECTS, so that the object files are included **transitively**, otherwise # Only the linker flags from the object library would be included, but not the actual object files. # See also the "Linking Object Libraries" and "Linking Object Libraries via $" sections: # https://cmake.org/cmake/help/latest/command/target_link_libraries.html target_link_libraries(${CRATE} INTERFACE ${CRATE}_initializers $) - - message(VERBOSE "CXX-Qt Expects QML plugin: ${QML_MODULE_URI} in directory: ${QML_MODULE_PLUGIN_DIR}") endforeach() endfunction() @@ -98,9 +96,9 @@ function(cxxqt_import_qml_module target) endif() # Note: This needs to match the URI conversion in cxx-qt-build - string(REPLACE "." "_" plugin_name ${QML_MODULE_URI}) - set(QML_MODULE_PLUGIN_DIR "${QML_MODULE_EXPORT_DIR}/plugins/${plugin_name}") - file(MAKE_DIRECTORY ${QML_MODULE_PLUGIN_DIR}) + string(REPLACE "." "_" module_name ${QML_MODULE_URI}) + set(QML_MODULE_DIR "${QML_MODULE_EXPORT_DIR}/qml_modules/${module_name}") + file(MAKE_DIRECTORY ${QML_MODULE_DIR}) # QML plugin - init target # When using the Ninja generator, we need to provide **some** way to generate the object file @@ -110,13 +108,13 @@ function(cxxqt_import_qml_module target) add_custom_target(${target}_mock_obj_output COMMAND ${CMAKE_COMMAND} -E true DEPENDS ${QML_MODULE_SOURCE_CRATE} - BYPRODUCTS "${QML_MODULE_PLUGIN_DIR}/plugin_init.o") + BYPRODUCTS "${QML_MODULE_DIR}/plugin_init.o") add_library(${target} OBJECT IMPORTED) set_target_properties(${target} PROPERTIES - IMPORTED_OBJECTS "${QML_MODULE_PLUGIN_DIR}/plugin_init.o") + IMPORTED_OBJECTS "${QML_MODULE_DIR}/plugin_init.o") target_link_libraries(${target} INTERFACE ${QML_MODULE_SOURCE_CRATE}) - message(VERBOSE "CXX-Qt Expects QML plugin: ${QML_MODULE_URI} in directory: ${QML_MODULE_PLUGIN_DIR}") + message(VERBOSE "CXX-Qt Expects QML plugin: ${QML_MODULE_URI} in directory: ${QML_MODULE_DIR}") endfunction() diff --git a/crates/cxx-qt-build/Cargo.toml b/crates/cxx-qt-build/Cargo.toml index b676e8280..c808a6495 100644 --- a/crates/cxx-qt-build/Cargo.toml +++ b/crates/cxx-qt-build/Cargo.toml @@ -22,6 +22,9 @@ quote.workspace = true qt-build-utils.workspace = true codespan-reporting = "0.11" version_check = "0.9" +scratch = "1.0" +serde = { version = "1.0", features = ["default", "derive"] } +serde_json = "1.0" [features] link_qt_object_files = ["qt-build-utils/link_qt_object_files"] diff --git a/crates/cxx-qt-build/src/dependencies.rs b/crates/cxx-qt-build/src/dependencies.rs new file mode 100644 index 000000000..a829b137c --- /dev/null +++ b/crates/cxx-qt-build/src/dependencies.rs @@ -0,0 +1,299 @@ +// SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company +// SPDX-FileContributor: Leon Matthes +// +// SPDX-License-Identifier: MIT OR Apache-2.0 + +//! This modules contains utilities for specifying dependencies with cxx-qt-build. + +use serde::{Deserialize, Serialize}; + +use std::collections::{HashMap, HashSet}; +use std::path::{Path, PathBuf}; + +/// When generating a library with cxx-qt-build, the library may need to export certain flags or headers. +/// These are all specified by this Interface struct, which should be passed to the [crate::CxxQtBuilder::library] function. +pub struct Interface { + pub(crate) compile_definitions: HashMap>, + pub(crate) initializers: Vec, + // The name of the links keys, whose CXX-Qt dependencies to reexport + pub(crate) reexport_links: HashSet, + pub(crate) exported_include_prefixes: Vec, + pub(crate) exported_include_directories: Vec<(PathBuf, String)>, + // TODO: In future, we want to also set up the include paths so that you can include anything + // from the crates source directory. + // Once this is done, this flag should indicate whether or not to export our own crates source + // directory to downstream dependencies? + // export_crate_directory: bool, +} + +impl Default for Interface { + fn default() -> Self { + Self { + compile_definitions: HashMap::new(), + initializers: Vec::new(), + reexport_links: HashSet::new(), + exported_include_prefixes: vec![super::crate_name()], + exported_include_directories: Vec::new(), + } + } +} + +impl Interface { + /// Add a compile-time-definition for the C++ code built by this crate and all downstream + /// dependencies + /// + /// This function will panic if the variable has already been defined with a different value. + /// + /// Also please note that any definitions added here will only be exported throughout the cargo + /// build. Due to technical limitations, they can not be imported into CMake with the + /// cxxqt_import_crate function. + pub fn define(mut self, variable: &str, value: Option<&str>) -> Self { + use std::collections::hash_map::Entry::*; + + let entry = self.compile_definitions.entry(variable.to_owned()); + match entry { + Vacant(entry) => entry.insert(value.map(String::from)), + Occupied(entry) => { + if entry.get().as_deref() == value { + println!("Warning: Silently ignoring duplicate compiler definition for {variable} with {value:?}."); + } + panic!( + "Cxx-Qt-build - Error: Interface::define - Duplicate compile-time definition for variable {variable} with value {value:?}!" + ); + } + }; + self + } + + /// Add a C++ file path that will be exported as an initializer to downstream dependencies. + /// + /// Initializer files will be built into object files, instead of linked into the static + /// library. + /// This way, the static variables and their constructors in this code will not be optimized + /// out by the linker. + pub fn initializer(mut self, path: impl AsRef) -> Self { + let path = PathBuf::from(path.as_ref()); + let path = path + .canonicalize() + .expect("Failed to canonicalize path to initializer! Does the path exist?"); + self.initializers.push(path); + self + } + + /// Export all headers with the given prefix to downstream dependencies + /// + /// Note: This will overwrite any previously specified header_prefixes, including the default + /// header_prefix of this crate. + /// + /// This function will panic if any of the given prefixes are already exported through the + /// [Self::export_include_directory] function. + pub fn export_include_prefixes<'a>( + mut self, + prefixes: impl IntoIterator, + ) -> Self { + let prefixes = prefixes.into_iter().map(|item| item.to_string()).collect(); + + let mut exported_prefixes = self + .exported_include_directories + .iter() + .map(|(_path, prefix)| prefix); + for prefix in &prefixes { + if let Some(duplicate) = + exported_prefixes.find(|exported_prefix| exported_prefix.starts_with(prefix)) + { + panic!("Duplicate export_prefix! Cannot export `{prefix}`, as `{duplicate}` is already exported as an export_include_directory!"); + } + } + + self.exported_include_prefixes = prefixes; + self + } + + /// Add a directory that will be added as an include directory under the given prefix. + /// + /// The prefix will automatically be exported (see also: [Self::export_include_prefixes]) + /// + /// This function will panic if the given prefix is already exported. + pub fn export_include_directory(mut self, directory: impl AsRef, prefix: &str) -> Self { + let mut exported_prefixes = self.exported_include_prefixes.iter().chain( + self.exported_include_directories + .iter() + .map(|(_path, prefix)| prefix), + ); + if let Some(duplicate) = + exported_prefixes.find(|exported_prefix| exported_prefix.starts_with(prefix)) + { + panic!("Duplicate export_prefix! Cannot export `{prefix}`, as `{duplicate}` is already exported!"); + } + + self.exported_include_directories + .push((directory.as_ref().into(), prefix.to_owned())); + self + } + + /// Reexport the dependency with the given link name. + /// This will make the dependency available to downstream dependencies. + /// + /// Specifically it will reexport all include_prefixes of the given dependency + /// as well as any definitions made by that dependency. + /// + /// Note that the link name may differ from the crate name. + /// Check your dependencies manifest file for the correct link name. + pub fn reexport_dependency(mut self, link_name: &str) -> Self { + self.reexport_links.insert(link_name.to_owned()); + self + } +} + +#[derive(Clone, Serialize, Deserialize)] +/// This struct is used by cxx-qt-build internally to propagate data through to downstream +/// dependencies +pub(crate) struct Manifest { + pub(crate) name: String, + pub(crate) link_name: String, + pub(crate) qt_modules: Vec, + pub(crate) defines: Vec<(String, Option)>, + pub(crate) initializers: Vec, + pub(crate) exported_include_prefixes: Vec, +} + +#[derive(Clone)] +/// A dependency that has been set up with [crate::CxxQtBuilder::library] and is available to +/// the crate that is currently being built. +pub(crate) struct Dependency { + /// The path of the dependencies export directory + pub(crate) path: PathBuf, + /// The deserialized manifest of the dependency + pub(crate) manifest: Manifest, +} + +impl Dependency { + /// This function will search the environment for all dependencies that have been set up with + /// CxxQtBuilder::library. + /// They export their manifest paths as metadata, which will be exposed to us as an environment + /// variable. + /// We extract those paths here, parse the manifest and make sure to set it up correctly as a + /// dependency. + /// + /// See also the internals "build system" section of our book. + pub(crate) fn find_all() -> Vec { + std::env::vars_os() + .map(|(var, value)| (var.to_string_lossy().to_string(), value)) + .filter(|(var, _)| var.starts_with("DEP_") && var.ends_with("_CXX_QT_MANIFEST_PATH")) + .map(|(_, manifest_path)| { + let manifest_path = PathBuf::from(manifest_path); + let manifest: Manifest = serde_json::from_str( + &std::fs::read_to_string(&manifest_path) + .expect("Could not read dependency manifest file!"), + ) + .expect("Could not deserialize dependency manifest file!"); + + println!( + "cxx-qt-build: Discovered dependency `{}` at: {}", + manifest.name, + manifest_path.to_string_lossy() + ); + Dependency { + path: manifest_path.parent().unwrap().to_owned(), + manifest, + } + }) + .collect() + } +} + +pub(crate) fn initializer_paths( + interface: Option<&Interface>, + dependencies: &[Dependency], +) -> HashSet { + dependencies + .iter() + .flat_map(|dep| dep.manifest.initializers.iter().cloned()) + .chain( + interface + .iter() + .flat_map(|interface| interface.initializers.iter().cloned()), + ) + .collect() +} + +pub(crate) fn all_include_prefixes( + interface: &Interface, + dependencies: &[Dependency], +) -> Vec { + interface + .exported_include_prefixes + .iter() + .cloned() + .chain( + interface + .exported_include_directories + .iter() + .map(|(_path, prefix)| prefix.clone()), + ) + .chain( + dependencies + .iter() + .flat_map(|dep| &dep.manifest.exported_include_prefixes) + .cloned(), + ) + .collect() +} + +pub(crate) fn reexported_dependencies( + interface: &Interface, + dependencies: &[Dependency], +) -> Vec { + let mut exported_dependencies = Vec::new(); + for link_name in &interface.reexport_links { + if let Some(dependency) = dependencies + .iter() + .find(|dep| &dep.manifest.link_name == link_name) + { + exported_dependencies.push(dependency.clone()); + } else { + panic!("Could not find dependency with link name `{link_name}` to reexport!"); + } + } + exported_dependencies +} + +pub(crate) fn all_compile_definitions( + interface: Option<&Interface>, + dependencies: &[Dependency], +) -> Vec<(String, Option)> { + // For each definition, store the name of the crate that defines it so we can generate a + // nicer error message + let mut definitions: HashMap, String)> = interface + .iter() + .flat_map(|interface| &interface.compile_definitions) + .map(|(key, value)| (key.clone(), (value.clone(), crate::crate_name()))) + .collect(); + + for dependency in dependencies { + for (variable, value) in &dependency.manifest.defines { + use std::collections::hash_map::Entry::*; + let entry = definitions.entry(variable.to_owned()); + + match entry { + Vacant(entry) => { + entry.insert((value.to_owned(), dependency.manifest.name.clone())); + } + Occupied(entry) => { + let existing_value = &entry.get().0; + // Only allow duplicate definitions with the same value + if existing_value != value { + panic!("Conflicting compiler definitions requested!\nCrate {existing} exports {variable}={existing_value:?}, and crate {conflicting} exports {variable}={value:?}", + existing=entry.get().1, + conflicting = dependency.manifest.name); + } + } + } + } + } + + definitions + .into_iter() + .map(|(key, (value, _crate_name))| (key, value)) + .collect() +} diff --git a/crates/cxx-qt-build/src/dir.rs b/crates/cxx-qt-build/src/dir.rs new file mode 100644 index 000000000..9d8083828 --- /dev/null +++ b/crates/cxx-qt-build/src/dir.rs @@ -0,0 +1,80 @@ +// SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company +// SPDX-FileContributor: Leon Matthes +// +// SPDX-License-Identifier: MIT OR Apache-2.0 + +//! This modules contains information about the paths where artifacts are placed by cxx-qt-build. + +use crate::{crate_name, module_name_from_uri}; +use std::io::Result; +use std::{ + env, + path::{Path, PathBuf}, +}; + +// Clean a directory by removing it and recreating it. +pub(crate) fn clean(path: impl AsRef) -> Result<()> { + let result = std::fs::remove_dir_all(&path); + if let Err(err) = result { + // If the path doesn't exist that's fine, otherwise we want to panic + if err.kind() != std::io::ErrorKind::NotFound { + return Err(err); + } + } + + std::fs::create_dir_all(path)?; + Ok(()) +} + +/// The target directory, namespaced by crate +pub(crate) fn crate_target() -> PathBuf { + target().join("crates").join(crate_name()) +} + +/// The target directory, namespaced by plugin +pub(crate) fn module_target(module_uri: &str) -> PathBuf { + target() + .join("qml_modules") + .join(module_name_from_uri(module_uri)) +} + +/// The target directory or another directory where we can write files that will be shared +/// between crates. +pub(crate) fn target() -> PathBuf { + if let Some(export) = export() { + return export; + } + + // The CARGO_TARGET_DIR is only set by users that want to configure cargo. + // So it's unlikely that it is indeed set. + // However, if it is, it's the easiest way to get the target dir. + let cargo_target_dir = env::var("CARGO_TARGET_DIR").ok().map(PathBuf::from); + if let Some(cargo_target_dir) = cargo_target_dir { + if cargo_target_dir.exists() && cargo_target_dir.is_absolute() { + return cargo_target_dir.join("cxxqtbridge"); + } + } + + scratch::path("cxxqtbridge") +} + +/// The export directory, if one was specified through the environment. +/// Note that this is not namspaced by crate. +pub(crate) fn export() -> Option { + env::var("CXXQT_EXPORT_DIR").ok().map(PathBuf::from) +} + +/// The include directory is namespaced by crate name when exporting for a C++ build system, +/// but for using cargo build without a C++ build system, OUT_DIR is already namespaced by crate name. +pub(crate) fn header_root() -> PathBuf { + crate_target().join("include") +} + +/// The OUT_DIR, converted into a PathBuf +pub(crate) fn out() -> PathBuf { + env::var("OUT_DIR").unwrap().into() +} + +pub(crate) fn is_exporting() -> bool { + export().is_some() +} diff --git a/crates/cxx-qt-build/src/lib.rs b/crates/cxx-qt-build/src/lib.rs index 5afefceec..4db4a727b 100644 --- a/crates/cxx-qt-build/src/lib.rs +++ b/crates/cxx-qt-build/src/lib.rs @@ -16,6 +16,12 @@ mod cfg_evaluator; mod diagnostics; use diagnostics::{Diagnostic, GeneratedError}; +pub mod dir; + +mod dependencies; +pub use dependencies::Interface; +use dependencies::{Dependency, Manifest}; + mod opts; pub use opts::CxxQtBuildersOpts; pub use opts::QObjectHeaderOpts; @@ -234,12 +240,18 @@ impl GeneratedCpp { fn generate_cxxqt_cpp_files( rs_source: &[impl AsRef], header_dir: impl AsRef, + include_prefix: &str, ) -> Vec { + let cxx_qt_dir = dir::out().join("cxx-qt-gen"); + std::fs::create_dir_all(&cxx_qt_dir).expect("Failed to create cxx-qt-gen directory!"); + std::fs::write(cxx_qt_dir.join("include-prefix.txt"), include_prefix).expect(""); + + let header_dir = header_dir.as_ref().join(include_prefix); let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); let mut generated_file_paths: Vec = Vec::with_capacity(rs_source.len()); for rs_path in rs_source { - let cpp_directory = out_dir().join("cxx-qt-gen/src"); + let cpp_directory = cxx_qt_dir.join("src"); let path = manifest_dir.join(rs_path); println!("cargo:rerun-if-changed={}", path.to_string_lossy()); @@ -256,31 +268,17 @@ fn generate_cxxqt_cpp_files( generated_file_paths } -/// The export directory, if one was specified through the environment. -/// Note that this is not namspaced by crate. -fn export_dir() -> Option { - env::var("CXXQT_EXPORT_DIR").ok().map(PathBuf::from) -} - -fn out_dir() -> PathBuf { - env::var("OUT_DIR").unwrap().into() +pub(crate) fn module_name_from_uri(module_uri: &str) -> String { + // Note: We need to make sure this matches the conversion done in CMake! + module_uri.replace('.', "_") } -fn plugin_name_from_uri(plugin_uri: &str) -> String { - plugin_uri.replace('.', "_") +pub(crate) fn crate_name() -> String { + env::var("CARGO_PKG_NAME").unwrap() } -/// The include directory needs to be namespaced by crate name when exporting for a C++ build system, -/// but for using cargo build without a C++ build system, OUT_DIR is already namespaced by crate name. -fn header_root() -> PathBuf { - export_dir() - .unwrap_or_else(|| PathBuf::from(env::var("OUT_DIR").unwrap())) - .join("include") - .join(crate_name()) -} - -fn crate_name() -> String { - env::var("CARGO_PKG_NAME").unwrap() +pub(crate) fn link_name() -> Option { + env::var("CARGO_MANIFEST_LINKS").ok() } fn static_lib_name() -> String { @@ -336,7 +334,8 @@ pub struct CxxQtBuilder { qt_modules: HashSet, qml_modules: Vec, cc_builder: cc::Build, - extra_defines: HashSet, + public_interface: Option, + include_prefix: String, initializers: Vec, } @@ -352,9 +351,25 @@ impl CxxQtBuilder { qt_modules, qml_modules: vec![], cc_builder: cc::Build::new(), - extra_defines: HashSet::new(), - initializers: Vec::new(), + initializers: vec![], + public_interface: None, + include_prefix: crate_name(), + } + } + + /// Create a new builder that is set up to create a library crate that is meant to be + /// included by later dependencies. + /// + /// The headers generated for this crate will be specified + pub fn library(interface_definition: Interface) -> Self { + let mut this = Self::new(); + this.public_interface = Some(interface_definition); + + if link_name().is_none() { + panic!("Building a Cxx-Qt based library requires setting a `links` field in the Cargo.toml file.\nConsider adding:\n\tlinks = \"{}\"\nto your Cargo.toml\n", crate_name()); } + + this } /// Specify rust file paths to parse through the cxx-qt marco @@ -398,12 +413,23 @@ impl CxxQtBuilder { /// Link additional [Qt modules](https://doc.qt.io/qt-6/qtmodules.html). /// Specify their names without the `Qt` prefix, for example `"Widgets"`. - /// The `Core` module and any modules from [CxxQtBuildersOpts] are linked automatically; there is no need to specify them. + /// The `Core` module and any modules from dependencies are linked automatically; there is no need to specify them. + /// + /// Note that any qt_module you specify here will be enabled for all downstream + /// dependencies as well if this crate is built as a library with [CxxQtBuilder::library]. + /// It is therefore best practice to specify features on your crate that allow downstream users + /// to disable any qt modules that are optional. pub fn qt_module(mut self, module: &str) -> Self { self.qt_modules.insert(module.to_owned()); self } + /// Instead of generating files under the crate name, generate files under the given prefix. + pub fn include_prefix(mut self, prefix: &str) -> Self { + prefix.clone_into(&mut self.include_prefix); + self + } + /// Register a QML module at build time. The `rust_files` of the [QmlModule] struct /// should contain `#[cxx_qt::bridge]` modules with QObject types annotated with `#[qml_element]`. /// @@ -475,38 +501,6 @@ impl CxxQtBuilder { self } - /// Build with the given extra options - pub fn with_opts(mut self, opts: CxxQtBuildersOpts) -> Self { - let header_root = header_root(); - for (file_contents, dir_name, file_name) in opts.headers { - let directory = if dir_name.is_empty() { - header_root.clone() - } else { - header_root.join(dir_name) - }; - std::fs::create_dir_all(directory.clone()) - .expect("Could not create {directory} header directory"); - - let h_path = directory.join(file_name); - std::fs::write(&h_path, file_contents).unwrap_or_else(|_| { - panic!( - "Could not write header: {h_path}", - h_path = h_path.to_string_lossy() - ) - }); - } - - // Add any of the defines - self.extra_defines.extend(opts.defines); - - self.initializers.extend(opts.initializers); - - // Add any of the Qt modules - self.qt_modules.extend(opts.qt_modules); - - self - } - fn define_cfg_variable(key: String, value: Option<&str>) { if let Some(value) = value { println!("cargo:rustc-cfg={key}=\"{value}\""); @@ -573,7 +567,7 @@ impl CxxQtBuilder { } fn write_common_headers() { - let header_root = header_root(); + let header_root = dir::header_root(); // Write cxx-qt and cxx headers cxx_qt::write_headers(header_root.join("cxx-qt")); std::fs::create_dir_all(header_root.join("rust")) @@ -586,10 +580,57 @@ impl CxxQtBuilder { } } - fn setup_cc_builder<'a>( + fn symlink_directory(target: impl AsRef, link: impl AsRef) -> std::io::Result<()> { + #[cfg(unix)] + let result = std::os::unix::fs::symlink(target, link); + + #[cfg(windows)] + let result = std::os::windows::fs::symlink_dir(target, link); + + // TODO: If it's neither unix nor windows, we should probably just deep-copy the + // dependency headers into our own include directory. + #[cfg(not(any(unix, windows)))] + panic!("Cxx-Qt-build: Unsupported platform! Only unix and windows are currently supported! Please file a bug report in the CXX-Qt repository."); + + result + } + + // A dependency can specify which of its own include paths it wants to export. + // Set up each of these exported include paths as symlinks in our own include directory. + fn include_dependency(&mut self, dependency: &Dependency) { + for include_prefix in &dependency.manifest.exported_include_prefixes { + // setup include directory + let target = dependency.path.join("include").join(include_prefix); + + let symlink = dir::header_root().join(include_prefix); + if symlink.exists() { + // Two dependencies may be reexporting the same shared dependency, which will + // result in conflicting symlinks. + // Try detecting this by resolving the symlinks and checking whether this leads us + // to the same paths. If so, it's the same include path for the same prefix, which + // is fine. + let symlink = + std::fs::canonicalize(symlink).expect("Failed to canonicalize symlink!"); + let target = + std::fs::canonicalize(target).expect("Failed to canonicalize symlink target!"); + if symlink != target { + panic!( + "Conflicting include_prefixes for {include_prefix}!\nDependency {dep_name} conflicts with existing include path", + dep_name = dependency.manifest.name, + ); + } + } else { + Self::symlink_directory(target, symlink).unwrap_or_else(|_| { + panic!("Could not create symlink for include_prefix {include_prefix}!") + }); + } + } + } + + fn setup_cc_builder( builder: &mut cc::Build, include_paths: &[impl AsRef], - defines: impl Iterator, + defines: &[(String, Option)], ) { // Note, ensure our settings stay in sync across cxx-qt, cxx-qt-build, and cxx-qt-lib builder.cpp(true); @@ -602,8 +643,8 @@ impl CxxQtBuilder { builder.flag_if_supported("-Wa,-mbig-obj"); // Enable any extra defines - for define in defines { - builder.define(define, None); + for (variable, value) in defines { + builder.define(variable, value.as_deref()); } for include_path in include_paths { @@ -622,8 +663,12 @@ impl CxxQtBuilder { } } - fn generate_cpp_files_from_cxxqt_bridges(&mut self, header_dir: impl AsRef) { - for files in generate_cxxqt_cpp_files(&self.rust_sources, &header_dir) { + fn generate_cpp_files_from_cxxqt_bridges( + &mut self, + header_dir: impl AsRef, + include_prefix: &str, + ) { + for files in generate_cxxqt_cpp_files(&self.rust_sources, &header_dir, include_prefix) { self.cc_builder.file(files.plain_cpp); if let (Some(qobject), Some(qobject_header)) = (files.qobject, files.qobject_header) { self.cc_builder.file(&qobject); @@ -632,11 +677,7 @@ impl CxxQtBuilder { } } - fn build_object_file( - builder: &cc::Build, - file_path: impl AsRef, - export_path: Option<(&str, &str)>, - ) { + fn build_object_file(builder: &cc::Build, file_path: impl AsRef, object_path: PathBuf) { let mut obj_builder = builder.clone(); obj_builder.file(file_path); let obj_files = obj_builder.compile_intermediates(); @@ -645,23 +686,21 @@ impl CxxQtBuilder { // If there's 0 or > 1 file, we panic in the `else` branch, because then the builder is // probably not correctly configured. if let [obj_file] = &obj_files[..] { - if let Some(export_dir) = export_dir() { - if let Some((out_directory, out_file_name)) = export_path { - let obj_dir = export_dir.join(out_directory); - std::fs::create_dir_all(&obj_dir).unwrap_or_else(|_| { + if dir::is_exporting() { + if let Some(directory) = object_path.parent() { + std::fs::create_dir_all(directory).unwrap_or_else(|_| { panic!( "Could not create directory for object file: {}", - obj_dir.to_string_lossy() - ) - }); - let obj_path = obj_dir.join(out_file_name); - std::fs::copy(obj_file, &obj_path).unwrap_or_else(|_| { - panic!( - "Failed to move object file to {obj_path}!", - obj_path = obj_path.to_string_lossy() + object_path.to_string_lossy() ) }); } + std::fs::copy(obj_file, &object_path).unwrap_or_else(|_| { + panic!( + "Failed to move object file to {}!", + object_path.to_string_lossy() + ) + }); } else { println!("cargo::rustc-link-arg={}", obj_file.to_string_lossy()); // The linker argument order matters! @@ -683,11 +722,19 @@ impl CxxQtBuilder { init_builder: &cc::Build, qtbuild: &mut qt_build_utils::QtBuild, generated_header_dir: impl AsRef, + header_prefix: &str, ) { for qml_module in &self.qml_modules { + dir::clean(dir::module_target(&qml_module.uri)) + .expect("Failed to clean qml module export directory!"); + let mut qml_metatypes_json = Vec::new(); - for files in generate_cxxqt_cpp_files(&qml_module.rust_files, &generated_header_dir) { + for files in generate_cxxqt_cpp_files( + &qml_module.rust_files, + &generated_header_dir, + header_prefix, + ) { self.cc_builder.file(files.plain_cpp); if let (Some(qobject), Some(qobject_header)) = (files.qobject, files.qobject_header) { @@ -709,7 +756,7 @@ impl CxxQtBuilder { // TODO: This will be passed to the `optional plugin ...` part of the qmldir // We don't load any shared libraries, so the name shouldn't matter // But make sure it still works - &plugin_name_from_uri(&qml_module.uri), + &module_name_from_uri(&qml_module.uri), &qml_module.qml_files, &qml_module.qrc_files, ); @@ -749,10 +796,7 @@ impl CxxQtBuilder { Self::build_object_file( init_builder, &qml_module_registration_files.plugin_init, - Some(( - &format!("plugins/{}", plugin_name_from_uri(&qml_module.uri)), - "plugin_init.o", - )), + dir::module_target(&qml_module.uri).join("plugin_init.o"), ); } } @@ -779,29 +823,105 @@ impl CxxQtBuilder { } } - fn build_initializers(&mut self, init_builder: &cc::Build) { - let initializers_path = out_dir().join("cxx-qt-build").join("initializers"); + fn generate_init_code(&self, initializers: &HashSet) -> String { + initializers + .iter() + .map(|path| std::fs::read_to_string(path).expect("Could not read initializer file!")) + .chain(self.initializers.iter().cloned()) + .collect::>() + .join("\n") + } + + fn build_initializers(&mut self, init_builder: &cc::Build, initializers: &HashSet) { + let initializers_path = dir::out().join("cxx-qt-build").join("initializers"); std::fs::create_dir_all(&initializers_path).expect("Failed to create initializers path!"); let initializers_path = initializers_path.join(format!("{}.cpp", crate_name())); - std::fs::write(&initializers_path, self.initializers.join("\n")) + std::fs::write(&initializers_path, self.generate_init_code(initializers)) .expect("Could not write initializers file"); Self::build_object_file( init_builder, initializers_path, - Some(("initializers", &format!("{}.o", crate_name()))), + dir::crate_target().join("initializers.o"), ); } - fn build_qrc_files(&mut self, init_builder: &cc::Build, qtbuild: &mut qt_build_utils::QtBuild) { - for qrc_file in &self.qrc_files { - // We need to link this using an obect file or +whole-achive, the static initializer of - // the qrc file isn't lost. - Self::build_object_file(init_builder, qtbuild.qrc(&qrc_file), None); + fn generate_cpp_from_qrc_files( + &mut self, + qtbuild: &mut qt_build_utils::QtBuild, + ) -> HashSet { + self.qrc_files + .iter() + .map(|qrc_file| { + // Also ensure that each of the files in the qrc can cause a change + for qrc_inner_file in qtbuild.qrc_list(&qrc_file) { + println!("cargo:rerun-if-changed={}", qrc_inner_file.display()); + } + // We need to link this using an object file or +whole-achive, the static initializer of + // the qrc file isn't lost. + qtbuild.qrc(&qrc_file) + }) + .collect() + } + + fn write_manifest( + &self, + dependencies: &[Dependency], + qt_modules: HashSet, + initializers: HashSet, + ) { + if let Some(interface) = &self.public_interface { + // We automatically reexport all qt_modules and initializers from downstream dependencies + // as they will always need to be enabled in the final binary. + // However, we only reexport the headers and compile-time definitions of libraries that + // are marked as re-export. + let dependencies = dependencies::reexported_dependencies(interface, dependencies); + + let initializers = initializers.into_iter().collect(); + let exported_include_prefixes = + dependencies::all_include_prefixes(interface, &dependencies); + let defines = dependencies::all_compile_definitions(Some(interface), &dependencies); + + let manifest = Manifest { + name: crate_name(), + link_name: link_name() + .expect("The links key must be set when creating a library with CXX-Qt-build!"), + defines, + initializers, + qt_modules: qt_modules.into_iter().collect(), + exported_include_prefixes, + }; + + let manifest_path = dir::crate_target().join("manifest.json"); + let manifest_json = serde_json::to_string_pretty(&manifest) + .expect("Failed to convert Manifest to JSON!"); + std::fs::write(&manifest_path, manifest_json).expect("Failed to write manifest.json!"); + println!( + "cargo::metadata=CXX_QT_MANIFEST_PATH={}", + manifest_path.to_string_lossy() + ); + } + } + + fn qt_modules(&self, dependencies: &[Dependency]) -> HashSet { + let mut qt_modules = self.qt_modules.clone(); + for dependency in dependencies { + qt_modules.extend(dependency.manifest.qt_modules.iter().cloned()); + } + qt_modules + } - // Also ensure that each of the files in the qrc can cause a change - for qrc_inner_file in qtbuild.qrc_list(&qrc_file) { - println!("cargo:rerun-if-changed={}", qrc_inner_file.display()); + fn write_interface_include_dirs(&self) { + if let Some(interface) = &self.public_interface { + for (header_dir, symlink) in &interface.exported_include_directories { + Self::symlink_directory(header_dir, dir::header_root().join(symlink)) + .unwrap_or_else(|_| { + panic!( + "Failed to create symlink `{}` for export_include_directory: {}", + symlink, + header_dir.to_string_lossy() + ) + }); } } } @@ -809,19 +929,30 @@ impl CxxQtBuilder { /// Generate and compile cxx-qt C++ code, as well as compile any additional files from /// [CxxQtBuilder::qobject_header] and [CxxQtBuilder::cc_builder]. pub fn build(mut self) { + dir::clean(dir::crate_target()).expect("Failed to clean crate export directory!"); + + // We will do these two steps first, as setting up the dependencies can modify flags we + // need further down the line + // Also write the common headers first, to make sure they don't conflict with any + // dependencies + Self::write_common_headers(); + self.write_interface_include_dirs(); + let dependencies = Dependency::find_all(); + for dependency in &dependencies { + self.include_dependency(dependency); + } + let qt_modules = self.qt_modules(&dependencies); + // Ensure that the linker is setup correctly for Cargo builds qt_build_utils::setup_linker(); - let header_root = header_root(); - let generated_header_dir = header_root.join("cxx-qt-gen/"); + let header_root = dir::header_root(); - let mut qtbuild = qt_build_utils::QtBuild::new(self.qt_modules.drain().collect()) + let mut qtbuild = qt_build_utils::QtBuild::new(qt_modules.iter().cloned().collect()) .expect("Could not find Qt installation"); qtbuild.cargo_link_libraries(&mut self.cc_builder); Self::define_qt_version_cfg_variables(qtbuild.version()); - Self::write_common_headers(); - // Setup compilers // Static QML plugin and Qt resource initializers need to be linked as their own separate // object files because they use static variables which need to be initialized before main @@ -830,18 +961,19 @@ impl CxxQtBuilder { // Use a separate cc::Build for the little amount of code that needs to be built & linked this way. let mut init_builder = cc::Build::new(); let mut include_paths = qtbuild.include_paths(); - include_paths.extend([header_root.clone(), generated_header_dir.clone()]); - - Self::setup_cc_builder( - &mut self.cc_builder, - &include_paths, - self.extra_defines.iter().map(String::as_str), - ); - Self::setup_cc_builder( - &mut init_builder, - &include_paths, - self.extra_defines.iter().map(String::as_str), - ); + include_paths.push(header_root.clone()); + // TODO: Some of the code generated by qmltyperegistrar doesn't add the include_prefix to + // the #include directives. + // We therefore need to push the full header directory including the prefix as an include path. + // This is not ideal and should be removed in future as it allows user code direct access + // to the generated files without any namespacing. + include_paths.push(header_root.join(&self.include_prefix)); + + let compile_definitions = + dependencies::all_compile_definitions(self.public_interface.as_ref(), &dependencies); + Self::setup_cc_builder(&mut self.cc_builder, &include_paths, &compile_definitions); + + Self::setup_cc_builder(&mut init_builder, &include_paths, &compile_definitions); // Note: From now on the init_builder is correctly configured. // When building object files with this builder, we always need to copy it first. // So remove `mut` to ensure that we can't accidentally change the configuration or add @@ -849,24 +981,35 @@ impl CxxQtBuilder { let init_builder = init_builder; // Generate files - self.generate_cpp_files_from_cxxqt_bridges(&generated_header_dir); + self.generate_cpp_files_from_cxxqt_bridges(&header_root, &self.include_prefix.clone()); self.moc_qobject_headers(&mut qtbuild); // Bridges for QML modules are handled separately because // the metatypes_json generated by moc needs to be passed to qmltyperegistrar - self.build_qml_modules(&init_builder, &mut qtbuild, &generated_header_dir); + self.build_qml_modules( + &init_builder, + &mut qtbuild, + &header_root, + &self.include_prefix.clone(), + ); - self.build_qrc_files(&init_builder, &mut qtbuild); + let mut initializers = self.generate_cpp_from_qrc_files(&mut qtbuild); + initializers.extend(dependencies::initializer_paths( + self.public_interface.as_ref(), + &dependencies, + )); self.setup_qt5_compatibility(&qtbuild); - self.build_initializers(&init_builder); + self.build_initializers(&init_builder, &initializers); // Only compile if we have added files to the builder // otherwise we end up with no static library but ask cargo to link to it which causes an error if self.cc_builder.get_files().count() > 0 { self.cc_builder.compile(&static_lib_name()); } + + self.write_manifest(&dependencies, qt_modules, initializers); } } diff --git a/crates/cxx-qt-gen/src/generator/rust/mod.rs b/crates/cxx-qt-gen/src/generator/rust/mod.rs index c6c50cc0a..ee0b4cd14 100644 --- a/crates/cxx-qt-gen/src/generator/rust/mod.rs +++ b/crates/cxx-qt-gen/src/generator/rust/mod.rs @@ -17,6 +17,7 @@ pub mod threading; use crate::generator::rust::fragment::GeneratedRustFragment; use crate::parser::Parser; +use crate::writer; use quote::quote; use syn::{Item, ItemMod, Result}; @@ -79,7 +80,11 @@ impl GeneratedRustBlocks { /// Generate the include line for this parsed block fn generate_include(parser: &Parser) -> Result { - let import_path = format!("cxx-qt-gen/{}.cxxqt.h", parser.cxx_file_stem); + let import_path = format!( + "{header_prefix}/{}.cxxqt.h", + parser.cxx_file_stem, + header_prefix = writer::get_header_prefix() + ); syn::parse2(quote! { unsafe extern "C++" { diff --git a/crates/cxx-qt-gen/src/writer/cpp/header.rs b/crates/cxx-qt-gen/src/writer/cpp/header.rs index 2f632fd87..a55504397 100644 --- a/crates/cxx-qt-gen/src/writer/cpp/header.rs +++ b/crates/cxx-qt-gen/src/writer/cpp/header.rs @@ -6,7 +6,7 @@ use std::collections::BTreeSet; use crate::generator::cpp::{fragment::CppFragment, GeneratedCppBlocks}; -use crate::writer::cpp::namespaced; +use crate::writer::{self, cpp::namespaced}; use indoc::formatdoc; /// Extract the header from a given CppFragment @@ -181,7 +181,7 @@ pub fn write_cpp_header(generated: &GeneratedCppBlocks) -> String { {includes} {forward_declare} - #include "cxx-qt-gen/{cxx_file_stem}.cxx.h" + #include "{header_prefix}/{cxx_file_stem}.cxx.h" {extern_cxx_qt} {qobjects} @@ -189,6 +189,7 @@ pub fn write_cpp_header(generated: &GeneratedCppBlocks) -> String { cxx_file_stem = generated.cxx_file_stem, forward_declare = forward_declare(generated).join("\n"), qobjects = qobjects_header(generated).join("\n"), + header_prefix = writer::get_header_prefix() } } diff --git a/crates/cxx-qt-gen/src/writer/cpp/source.rs b/crates/cxx-qt-gen/src/writer/cpp/source.rs index 4632032a7..85f5a58d3 100644 --- a/crates/cxx-qt-gen/src/writer/cpp/source.rs +++ b/crates/cxx-qt-gen/src/writer/cpp/source.rs @@ -4,7 +4,7 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 use crate::generator::cpp::{fragment::CppFragment, GeneratedCppBlocks}; -use crate::writer::cpp::namespaced; +use crate::writer::{self, cpp::namespaced}; use indoc::formatdoc; /// Extract the source from a given CppFragment @@ -60,13 +60,14 @@ pub fn write_cpp_source(generated: &GeneratedCppBlocks) -> String { .join("\n"); formatdoc! {r#" - #include "cxx-qt-gen/{cxx_file_stem}.cxxqt.h" + #include "{header_prefix}/{cxx_file_stem}.cxxqt.h" {extern_cxx_qt} {qobjects} "#, cxx_file_stem = generated.cxx_file_stem, qobjects = qobjects_source(generated).join("\n"), + header_prefix = writer::get_header_prefix(), } } diff --git a/crates/cxx-qt-gen/src/writer/mod.rs b/crates/cxx-qt-gen/src/writer/mod.rs index 486ef1423..768cabac0 100644 --- a/crates/cxx-qt-gen/src/writer/mod.rs +++ b/crates/cxx-qt-gen/src/writer/mod.rs @@ -5,3 +5,17 @@ pub mod cpp; pub mod rust; + +use std::{error::Error, path::PathBuf}; + +fn header_prefix_from_out_dir() -> Result> { + // This file should be written by cxx-qt-build + let header_prefix_path = PathBuf::from(std::env::var("OUT_DIR")?) + .join("cxx-qt-gen") + .join("include-prefix.txt"); + Ok(std::fs::read_to_string(header_prefix_path)?) +} + +pub(crate) fn get_header_prefix() -> String { + header_prefix_from_out_dir().unwrap_or_else(|_err| "cxx-qt-gen".to_owned()) +} diff --git a/crates/cxx-qt-lib-extras-headers/Cargo.toml b/crates/cxx-qt-lib-extras-headers/Cargo.toml deleted file mode 100644 index 131deaf35..000000000 --- a/crates/cxx-qt-lib-extras-headers/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company -# SPDX-FileContributor: Laurent Montel -# -# SPDX-License-Identifier: MIT OR Apache-2.0 -[package] -name = "cxx-qt-lib-extras-headers" -version.workspace = true -authors = ["Laurent Montel "] -edition.workspace = true -license.workspace = true -description = "A small crate for cxx-qt-lib-extras to share cxx-qt-lib's C++ headers" -repository.workspace = true - -[dependencies] -cxx-qt-build.workspace = true diff --git a/crates/cxx-qt-lib-extras-headers/src/lib.rs b/crates/cxx-qt-lib-extras-headers/src/lib.rs deleted file mode 100644 index 45214b91a..000000000 --- a/crates/cxx-qt-lib-extras-headers/src/lib.rs +++ /dev/null @@ -1,34 +0,0 @@ -// SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company -// SPDX-FileContributor: Laurent Montel -// -// SPDX-License-Identifier: MIT OR Apache-2.0 - -/// Retrieves the headers for cxx-qt-lib-extras -/// -/// These can be passed into [cxx_qt_build::CxxQtBuilder]. -pub fn build_opts() -> cxx_qt_build::CxxQtBuildersOpts { - let mut opts = cxx_qt_build::CxxQtBuildersOpts::default(); - - for (file_contents, file_name) in [ - ( - include_str!("../include/core/qelapsedtimer.h"), - "qelapsedtimer.h", - ), - ( - include_str!("../include/core/qcommandlineparser.h"), - "qcommandlineparser.h", - ), - ( - include_str!("../include/core/qcommandlineoption.h"), - "qcommandlineoption.h", - ), - ( - include_str!("../include/gui/qapplication.h"), - "qapplication.h", - ), - ] { - opts = opts.header(file_contents, "cxx-qt-lib-extras", file_name); - } - - opts.qt_module("Gui").qt_module("Widgets") -} diff --git a/crates/cxx-qt-lib-extras/Cargo.toml b/crates/cxx-qt-lib-extras/Cargo.toml index db37f892a..17da5ceb6 100644 --- a/crates/cxx-qt-lib-extras/Cargo.toml +++ b/crates/cxx-qt-lib-extras/Cargo.toml @@ -11,6 +11,8 @@ license.workspace = true description = "Extra Qt types for integrating `cxx-qt` crate with `cxx` that are not available in `cxx-qt-lib`" repository.workspace = true +links = "cxx-qt-lib-extras" + [dependencies] cxx.workspace = true cxx-qt.workspace = true @@ -18,8 +20,6 @@ cxx-qt-lib.workspace = true [build-dependencies] cxx-qt-build.workspace = true -cxx-qt-lib-headers.workspace = true -cxx-qt-lib-extras-headers.workspace = true [features] default = [] diff --git a/crates/cxx-qt-lib-extras/build.rs b/crates/cxx-qt-lib-extras/build.rs index 7e6b9c6aa..7900a3c81 100644 --- a/crates/cxx-qt-lib-extras/build.rs +++ b/crates/cxx-qt-lib-extras/build.rs @@ -4,9 +4,53 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 use cxx_qt_build::CxxQtBuilder; +use std::path::PathBuf; + +fn header_dir() -> PathBuf { + PathBuf::from(std::env::var("OUT_DIR").unwrap()) + .join("include") + .join("cxx-qt-lib-extras") +} + +fn write_headers_in(subfolder: &str) { + println!("cargo::rerun-if-changed=include/{subfolder}"); + + for entry in + std::fs::read_dir(format!("include/{subfolder}")).expect("Failed to read include directory") + { + let entry = entry.expect("Failed to read header file!"); + let header_name = entry.file_name(); + println!( + "cargo::rerun-if-changed=include/{subfolder}/{header_name}", + header_name = header_name.to_string_lossy() + ); + + // TODO: Do we want to add the headers into a subdirectory? + std::fs::copy(entry.path(), header_dir().join(header_name)) + .expect("Failed to copy header file!"); + } +} + +fn write_headers() { + println!("cargo::rerun-if-changed=include/"); + std::fs::create_dir_all(header_dir()).expect("Failed to create include directory"); + + write_headers_in("core"); + write_headers_in("gui"); +} fn main() { - let mut builder = CxxQtBuilder::new(); + write_headers(); + + let interface = cxx_qt_build::Interface::default() + // Disable exporting the standard include directory, as we are exporting custom headers + .export_include_prefixes([]) + .export_include_directory(header_dir(), "cxx-qt-lib-extras") + .reexport_dependency("cxx-qt-lib"); + + let mut builder = CxxQtBuilder::library(interface) + .qt_module("Gui") + .qt_module("Widgets"); let rust_bridges = vec![ "core/qelapsedtimer", @@ -37,7 +81,6 @@ fn main() { println!("cargo:rerun-if-changed=src/assertion_utils.h"); builder - .with_opts(cxx_qt_lib_headers::build_opts()) - .with_opts(cxx_qt_lib_extras_headers::build_opts()) + .include_prefix("cxx-qt-lib-extras-internals") .build(); } diff --git a/crates/cxx-qt-lib-extras-headers/include/core/qcommandlineoption.h b/crates/cxx-qt-lib-extras/include/core/qcommandlineoption.h similarity index 100% rename from crates/cxx-qt-lib-extras-headers/include/core/qcommandlineoption.h rename to crates/cxx-qt-lib-extras/include/core/qcommandlineoption.h diff --git a/crates/cxx-qt-lib-extras-headers/include/core/qcommandlineparser.h b/crates/cxx-qt-lib-extras/include/core/qcommandlineparser.h similarity index 100% rename from crates/cxx-qt-lib-extras-headers/include/core/qcommandlineparser.h rename to crates/cxx-qt-lib-extras/include/core/qcommandlineparser.h diff --git a/crates/cxx-qt-lib-extras-headers/include/core/qelapsedtimer.h b/crates/cxx-qt-lib-extras/include/core/qelapsedtimer.h similarity index 100% rename from crates/cxx-qt-lib-extras-headers/include/core/qelapsedtimer.h rename to crates/cxx-qt-lib-extras/include/core/qelapsedtimer.h diff --git a/crates/cxx-qt-lib-extras-headers/include/gui/qapplication.h b/crates/cxx-qt-lib-extras/include/gui/qapplication.h similarity index 100% rename from crates/cxx-qt-lib-extras-headers/include/gui/qapplication.h rename to crates/cxx-qt-lib-extras/include/gui/qapplication.h diff --git a/crates/cxx-qt-lib-headers/Cargo.toml b/crates/cxx-qt-lib-headers/Cargo.toml deleted file mode 100644 index 68468cc2a..000000000 --- a/crates/cxx-qt-lib-headers/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -# SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB, a KDAB Group company -# SPDX-FileContributor: Be Wilson -# -# SPDX-License-Identifier: MIT OR Apache-2.0 -[package] -name = "cxx-qt-lib-headers" -version.workspace = true -authors = ["Andrew Hayzen ", "Be Wilson "] -edition.workspace = true -license.workspace = true -description = "A small crate for cxx-qt-lib and cxx-qt-build to share cxx-qt-lib's C++ headers" -repository.workspace = true - -[features] -default = [] -qt_gui = [] -qt_qml = [] -qt_quickcontrols = [] - -[dependencies] -cxx-qt-build.workspace = true diff --git a/crates/cxx-qt-lib-headers/src/lib.rs b/crates/cxx-qt-lib-headers/src/lib.rs deleted file mode 100644 index 9640bf6d3..000000000 --- a/crates/cxx-qt-lib-headers/src/lib.rs +++ /dev/null @@ -1,136 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB, a KDAB Group company -// SPDX-FileContributor: Be Wilson -// -// SPDX-License-Identifier: MIT OR Apache-2.0 - -#![deny(missing_docs)] - -//! The headers for cxx-qt-lib, when combined into cxx-qt-lib crate this fails to build on Windows. -//! The issue occurs when cxx-qt-lib is a build-dependency of an example - -/// Retrieves the headers for cxx-qt-lib -/// -/// These can be passed into [cxx_qt_build::CxxQtBuilder]. -pub fn build_opts() -> cxx_qt_build::CxxQtBuildersOpts { - let mut opts = cxx_qt_build::CxxQtBuildersOpts::default(); - - for (file_contents, file_name) in [ - (include_str!("../include/core/qbytearray.h"), "qbytearray.h"), - ( - include_str!("../include/core/qcoreapplication.h"), - "qcoreapplication.h", - ), - (include_str!("../include/core/qdate.h"), "qdate.h"), - (include_str!("../include/core/qdatetime.h"), "qdatetime.h"), - (include_str!("../include/core/qhash.h"), "qhash.h"), - (include_str!("../include/core/qline.h"), "qline.h"), - (include_str!("../include/core/qlinef.h"), "qlinef.h"), - (include_str!("../include/core/qlist.h"), "qlist.h"), - ( - include_str!("../include/core/qlist_qvector.h"), - "qlist_qvector.h", - ), - (include_str!("../include/core/qmap.h"), "qmap.h"), - (include_str!("../include/core/qmargins.h"), "qmargins.h"), - (include_str!("../include/core/qmarginsf.h"), "qmarginsf.h"), - ( - include_str!("../include/core/qmetaobjectconnection.h"), - "qmetaobjectconnection.h", - ), - ( - include_str!("../include/core/qmodelindex.h"), - "qmodelindex.h", - ), - #[cfg(feature = "qt_gui")] - (include_str!("../include/gui/qpen.h"), "qpen.h"), - ( - include_str!("../include/core/qpersistentmodelindex.h"), - "qpersistentmodelindex.h", - ), - (include_str!("../include/core/qpoint.h"), "qpoint.h"), - (include_str!("../include/core/qpointf.h"), "qpointf.h"), - (include_str!("../include/core/qrect.h"), "qrect.h"), - (include_str!("../include/core/qrectf.h"), "qrectf.h"), - (include_str!("../include/core/qset.h"), "qset.h"), - (include_str!("../include/core/qsize.h"), "qsize.h"), - (include_str!("../include/core/qsizef.h"), "qsizef.h"), - (include_str!("../include/core/qstring.h"), "qstring.h"), - ( - include_str!("../include/core/qstringlist.h"), - "qstringlist.h", - ), - (include_str!("../include/core/qt.h"), "qt.h"), - (include_str!("../include/core/qtime.h"), "qtime.h"), - (include_str!("../include/core/qtimezone.h"), "qtimezone.h"), - (include_str!("../include/core/qurl.h"), "qurl.h"), - (include_str!("../include/core/qvariant.h"), "qvariant.h"), - (include_str!("../include/core/qvector.h"), "qvector.h"), - #[cfg(feature = "qt_gui")] - (include_str!("../include/gui/qcolor.h"), "qcolor.h"), - #[cfg(feature = "qt_gui")] - (include_str!("../include/gui/qfont.h"), "qfont.h"), - #[cfg(feature = "qt_gui")] - ( - include_str!("../include/gui/qguiapplication.h"), - "qguiapplication.h", - ), - #[cfg(feature = "qt_gui")] - (include_str!("../include/gui/qimage.h"), "qimage.h"), - #[cfg(feature = "qt_gui")] - (include_str!("../include/gui/qpolygon.h"), "qpolygon.h"), - (include_str!("../include/gui/qpolygonf.h"), "qpolygonf.h"), - ( - include_str!("../include/gui/qpainterpath.h"), - "qpainterpath.h", - ), - #[cfg(feature = "qt_gui")] - (include_str!("../include/gui/qpainter.h"), "qpainter.h"), - #[cfg(feature = "qt_gui")] - (include_str!("../include/gui/qregion.h"), "qregion.h"), - #[cfg(feature = "qt_gui")] - (include_str!("../include/gui/qvector2d.h"), "qvector2d.h"), - #[cfg(feature = "qt_gui")] - (include_str!("../include/gui/qvector3d.h"), "qvector3d.h"), - #[cfg(feature = "qt_gui")] - (include_str!("../include/gui/qvector4d.h"), "qvector4d.h"), - #[cfg(feature = "qt_qml")] - ( - include_str!("../include/qml/qqmlapplicationengine.h"), - "qqmlapplicationengine.h", - ), - #[cfg(feature = "qt_qml")] - (include_str!("../include/qml/qqmlengine.h"), "qqmlengine.h"), - #[cfg(feature = "qt_quickcontrols")] - ( - include_str!("../include/quickcontrols/qquickstyle.h"), - "qquickstyle.h", - ), - (include_str!("../include/common.h"), "common.h"), - ] { - opts = opts.header(file_contents, "cxx-qt-lib", file_name); - } - - opts = opts.initializer(include_str!("../include/core/init.cpp")); - - #[cfg(feature = "qt_gui")] - { - opts = opts - .define("CXX_QT_GUI_FEATURE") - .qt_module("Gui") - .initializer(include_str!("../include/gui/init.cpp")); - } - - #[cfg(feature = "qt_qml")] - { - opts = opts.define("CXX_QT_QML_FEATURE").qt_module("Qml"); - } - - #[cfg(feature = "qt_quickcontrols")] - { - opts = opts - .define("CXX_QT_QUICKCONTROLS_FEATURE") - .qt_module("QuickControls2"); - } - - opts -} diff --git a/crates/cxx-qt-lib/Cargo.toml b/crates/cxx-qt-lib/Cargo.toml index a6a3ffb49..8ef36925c 100644 --- a/crates/cxx-qt-lib/Cargo.toml +++ b/crates/cxx-qt-lib/Cargo.toml @@ -13,6 +13,12 @@ description = "Qt types for integrating `cxx-qt` crate with `cxx`" repository.workspace = true exclude = [ "**/generate.sh" ] +# When creating a library with cxx-qt-build, we need to set a fake "links" key +# to make sure the build scripts are run in the correct order and the build scripts +# can pass metadata from library to dependent. +# See also: https://doc.rust-lang.org/cargo/reference/build-scripts.html#the-links-manifest-key +links = "cxx-qt-lib" + [dependencies] cxx.workspace = true cxx-qt.workspace = true @@ -26,17 +32,18 @@ serde = { version = "1", features=["derive"], optional = true } [build-dependencies] cxx-qt-build.workspace = true -cxx-qt-lib-headers.workspace = true [features] default = ["qt_gui", "qt_qml", "qt_quickcontrols"] + +qt_gui = [] +qt_qml = [] +qt_quickcontrols = [] + bytes = ["dep:bytes"] chrono = ["dep:chrono"] http = ["dep:http"] rgb = ["dep:rgb"] -qt_gui = ["cxx-qt-lib-headers/qt_gui"] -qt_qml = ["cxx-qt-lib-headers/qt_qml"] -qt_quickcontrols = ["cxx-qt-lib-headers/qt_quickcontrols"] time = ["dep:time"] url = ["dep:url"] serde = ["dep:serde"] diff --git a/crates/cxx-qt-lib/build.rs b/crates/cxx-qt-lib/build.rs index 0ff576591..93d3fbbb9 100644 --- a/crates/cxx-qt-lib/build.rs +++ b/crates/cxx-qt-lib/build.rs @@ -4,11 +4,67 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 use cxx_qt_build::CxxQtBuilder; +use std::path::PathBuf; + +fn qt_gui_enabled() -> bool { + std::env::var("CARGO_FEATURE_QT_GUI").is_ok() +} + +fn qt_qml_enabled() -> bool { + std::env::var("CARGO_FEATURE_QT_QML").is_ok() +} + +fn qt_quickcontrols_enabled() -> bool { + std::env::var("CARGO_FEATURE_QT_QUICKCONTROLS").is_ok() +} + +fn header_dir() -> PathBuf { + PathBuf::from(std::env::var("OUT_DIR").unwrap()) + .join("include") + .join("cxx-qt-lib") +} + +fn write_headers_in(subfolder: &str) { + println!("cargo::rerun-if-changed=include/{subfolder}"); + + for entry in + std::fs::read_dir(format!("include/{subfolder}")).expect("Failed to read include directory") + { + let entry = entry.expect("Failed to read header file!"); + let header_name = entry.file_name(); + println!( + "cargo::rerun-if-changed=include/{subfolder}/{header_name}", + header_name = header_name.to_string_lossy() + ); + + // TODO: Do we want to add the headers into a subdirectory? + std::fs::copy(entry.path(), header_dir().join(header_name)) + .expect("Failed to copy header file!"); + } +} + +fn write_headers() { + println!("cargo::rerun-if-changed=include/"); + std::fs::create_dir_all(header_dir()).expect("Failed to create include directory"); + println!("cargo::rerun-if-changed=include/common.h"); + std::fs::copy("include/common.h", header_dir().join("common.h")) + .expect("Failed to copy header file!"); + + write_headers_in("core"); + if qt_gui_enabled() { + write_headers_in("gui"); + } + if qt_qml_enabled() { + write_headers_in("qml"); + } + if qt_quickcontrols_enabled() { + write_headers_in("quickcontrols"); + } +} fn main() { - let feature_qt_gui_enabled = std::env::var("CARGO_FEATURE_QT_GUI").is_ok(); - let feature_qt_qml_enabled = std::env::var("CARGO_FEATURE_QT_QML").is_ok(); - let feature_qt_quickcontrols_enabled = std::env::var("CARGO_FEATURE_QT_QUICKCONTROLS").is_ok(); + write_headers(); + let emscripten_targeted = match std::env::var("CARGO_CFG_TARGET_OS") { Ok(val) => val == "emscripten", Err(_) => false, @@ -135,7 +191,7 @@ fn main() { "core/qvector/qvector_u64", ]; - if feature_qt_gui_enabled { + if qt_gui_enabled() { rust_bridges.extend([ "core/qlist/qlist_qcolor", "core/qvariant/qvariant_qcolor", @@ -156,11 +212,11 @@ fn main() { ]); } - if feature_qt_qml_enabled { + if qt_qml_enabled() { rust_bridges.extend(["qml/qqmlapplicationengine", "qml/qqmlengine"]); } - if feature_qt_quickcontrols_enabled { + if qt_quickcontrols_enabled() { rust_bridges.extend(["quickcontrols/qquickstyle"]); } @@ -203,7 +259,7 @@ fn main() { "core/qvector/qvector", ]; - if feature_qt_gui_enabled { + if qt_gui_enabled() { cpp_files.extend([ "gui/qcolor", "gui/qfont", @@ -221,11 +277,11 @@ fn main() { ]); } - if feature_qt_qml_enabled { + if qt_qml_enabled() { cpp_files.extend(["qml/qqmlapplicationengine", "qml/qqmlengine"]); } - if feature_qt_quickcontrols_enabled { + if qt_quickcontrols_enabled() { cpp_files.extend(["quickcontrols/qquickstyle"]); } @@ -233,7 +289,38 @@ fn main() { cpp_files.extend(["core/qdatetime", "core/qtimezone"]); } - let mut builder = CxxQtBuilder::new(); + let mut interface = cxx_qt_build::Interface::default() + .initializer("src/core/init.cpp") + .export_include_prefixes([]) + .export_include_directory(header_dir(), "cxx-qt-lib"); + + if qt_gui_enabled() { + interface = interface + .define("CXX_QT_GUI_FEATURE", None) + .initializer("src/gui/init.cpp"); + } + + if qt_qml_enabled() { + interface = interface.define("CXX_QT_QML_FEATURE", None); + } + + if qt_quickcontrols_enabled() { + interface = interface.define("CXX_QT_QUICKCONTROLS_FEATURE", None); + } + + let mut builder = CxxQtBuilder::library(interface).include_prefix("cxx-qt-lib-internals"); + + if qt_gui_enabled() { + builder = builder.qt_module("Gui"); + } + + if qt_qml_enabled() { + builder = builder.qt_module("Qml"); + } + + if qt_quickcontrols_enabled() { + builder = builder.qt_module("QuickControls2"); + } for rust_source in &rust_bridges { builder = builder.file(format!("src/{rust_source}.rs")); @@ -249,5 +336,5 @@ fn main() { }); println!("cargo:rerun-if-changed=src/assertion_utils.h"); - builder.with_opts(cxx_qt_lib_headers::build_opts()).build(); + builder.build(); } diff --git a/crates/cxx-qt-lib-headers/include/common.h b/crates/cxx-qt-lib/include/common.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/common.h rename to crates/cxx-qt-lib/include/common.h diff --git a/crates/cxx-qt-lib-headers/include/core/qbytearray.h b/crates/cxx-qt-lib/include/core/qbytearray.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qbytearray.h rename to crates/cxx-qt-lib/include/core/qbytearray.h diff --git a/crates/cxx-qt-lib-headers/include/core/qcoreapplication.h b/crates/cxx-qt-lib/include/core/qcoreapplication.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qcoreapplication.h rename to crates/cxx-qt-lib/include/core/qcoreapplication.h diff --git a/crates/cxx-qt-lib-headers/include/core/qdate.h b/crates/cxx-qt-lib/include/core/qdate.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qdate.h rename to crates/cxx-qt-lib/include/core/qdate.h diff --git a/crates/cxx-qt-lib-headers/include/core/qdatetime.h b/crates/cxx-qt-lib/include/core/qdatetime.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qdatetime.h rename to crates/cxx-qt-lib/include/core/qdatetime.h diff --git a/crates/cxx-qt-lib-headers/include/core/qhash.h b/crates/cxx-qt-lib/include/core/qhash.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qhash.h rename to crates/cxx-qt-lib/include/core/qhash.h diff --git a/crates/cxx-qt-lib-headers/include/core/qline.h b/crates/cxx-qt-lib/include/core/qline.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qline.h rename to crates/cxx-qt-lib/include/core/qline.h diff --git a/crates/cxx-qt-lib-headers/include/core/qlinef.h b/crates/cxx-qt-lib/include/core/qlinef.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qlinef.h rename to crates/cxx-qt-lib/include/core/qlinef.h diff --git a/crates/cxx-qt-lib-headers/include/core/qlist.h b/crates/cxx-qt-lib/include/core/qlist.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qlist.h rename to crates/cxx-qt-lib/include/core/qlist.h diff --git a/crates/cxx-qt-lib-headers/include/core/qlist_qvector.h b/crates/cxx-qt-lib/include/core/qlist_qvector.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qlist_qvector.h rename to crates/cxx-qt-lib/include/core/qlist_qvector.h diff --git a/crates/cxx-qt-lib-headers/include/core/qmap.h b/crates/cxx-qt-lib/include/core/qmap.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qmap.h rename to crates/cxx-qt-lib/include/core/qmap.h diff --git a/crates/cxx-qt-lib-headers/include/core/qmargins.h b/crates/cxx-qt-lib/include/core/qmargins.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qmargins.h rename to crates/cxx-qt-lib/include/core/qmargins.h diff --git a/crates/cxx-qt-lib-headers/include/core/qmarginsf.h b/crates/cxx-qt-lib/include/core/qmarginsf.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qmarginsf.h rename to crates/cxx-qt-lib/include/core/qmarginsf.h diff --git a/crates/cxx-qt-lib-headers/include/core/qmetaobjectconnection.h b/crates/cxx-qt-lib/include/core/qmetaobjectconnection.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qmetaobjectconnection.h rename to crates/cxx-qt-lib/include/core/qmetaobjectconnection.h diff --git a/crates/cxx-qt-lib-headers/include/core/qmodelindex.h b/crates/cxx-qt-lib/include/core/qmodelindex.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qmodelindex.h rename to crates/cxx-qt-lib/include/core/qmodelindex.h diff --git a/crates/cxx-qt-lib-headers/include/core/qpersistentmodelindex.h b/crates/cxx-qt-lib/include/core/qpersistentmodelindex.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qpersistentmodelindex.h rename to crates/cxx-qt-lib/include/core/qpersistentmodelindex.h diff --git a/crates/cxx-qt-lib-headers/include/core/qpoint.h b/crates/cxx-qt-lib/include/core/qpoint.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qpoint.h rename to crates/cxx-qt-lib/include/core/qpoint.h diff --git a/crates/cxx-qt-lib-headers/include/core/qpointf.h b/crates/cxx-qt-lib/include/core/qpointf.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qpointf.h rename to crates/cxx-qt-lib/include/core/qpointf.h diff --git a/crates/cxx-qt-lib-headers/include/core/qrect.h b/crates/cxx-qt-lib/include/core/qrect.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qrect.h rename to crates/cxx-qt-lib/include/core/qrect.h diff --git a/crates/cxx-qt-lib-headers/include/core/qrectf.h b/crates/cxx-qt-lib/include/core/qrectf.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qrectf.h rename to crates/cxx-qt-lib/include/core/qrectf.h diff --git a/crates/cxx-qt-lib-headers/include/core/qset.h b/crates/cxx-qt-lib/include/core/qset.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qset.h rename to crates/cxx-qt-lib/include/core/qset.h diff --git a/crates/cxx-qt-lib-headers/include/core/qsize.h b/crates/cxx-qt-lib/include/core/qsize.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qsize.h rename to crates/cxx-qt-lib/include/core/qsize.h diff --git a/crates/cxx-qt-lib-headers/include/core/qsizef.h b/crates/cxx-qt-lib/include/core/qsizef.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qsizef.h rename to crates/cxx-qt-lib/include/core/qsizef.h diff --git a/crates/cxx-qt-lib-headers/include/core/qstring.h b/crates/cxx-qt-lib/include/core/qstring.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qstring.h rename to crates/cxx-qt-lib/include/core/qstring.h diff --git a/crates/cxx-qt-lib-headers/include/core/qstringlist.h b/crates/cxx-qt-lib/include/core/qstringlist.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qstringlist.h rename to crates/cxx-qt-lib/include/core/qstringlist.h diff --git a/crates/cxx-qt-lib-headers/include/core/qt.h b/crates/cxx-qt-lib/include/core/qt.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qt.h rename to crates/cxx-qt-lib/include/core/qt.h diff --git a/crates/cxx-qt-lib-headers/include/core/qtime.h b/crates/cxx-qt-lib/include/core/qtime.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qtime.h rename to crates/cxx-qt-lib/include/core/qtime.h diff --git a/crates/cxx-qt-lib-headers/include/core/qtimezone.h b/crates/cxx-qt-lib/include/core/qtimezone.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qtimezone.h rename to crates/cxx-qt-lib/include/core/qtimezone.h diff --git a/crates/cxx-qt-lib-headers/include/core/qurl.h b/crates/cxx-qt-lib/include/core/qurl.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qurl.h rename to crates/cxx-qt-lib/include/core/qurl.h diff --git a/crates/cxx-qt-lib-headers/include/core/qvariant.h b/crates/cxx-qt-lib/include/core/qvariant.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qvariant.h rename to crates/cxx-qt-lib/include/core/qvariant.h diff --git a/crates/cxx-qt-lib-headers/include/core/qvector.h b/crates/cxx-qt-lib/include/core/qvector.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/qvector.h rename to crates/cxx-qt-lib/include/core/qvector.h diff --git a/crates/cxx-qt-lib-headers/include/gui/qcolor.h b/crates/cxx-qt-lib/include/gui/qcolor.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/gui/qcolor.h rename to crates/cxx-qt-lib/include/gui/qcolor.h diff --git a/crates/cxx-qt-lib-headers/include/gui/qfont.h b/crates/cxx-qt-lib/include/gui/qfont.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/gui/qfont.h rename to crates/cxx-qt-lib/include/gui/qfont.h diff --git a/crates/cxx-qt-lib-headers/include/gui/qguiapplication.h b/crates/cxx-qt-lib/include/gui/qguiapplication.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/gui/qguiapplication.h rename to crates/cxx-qt-lib/include/gui/qguiapplication.h diff --git a/crates/cxx-qt-lib-headers/include/gui/qimage.h b/crates/cxx-qt-lib/include/gui/qimage.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/gui/qimage.h rename to crates/cxx-qt-lib/include/gui/qimage.h diff --git a/crates/cxx-qt-lib-headers/include/gui/qpainter.h b/crates/cxx-qt-lib/include/gui/qpainter.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/gui/qpainter.h rename to crates/cxx-qt-lib/include/gui/qpainter.h diff --git a/crates/cxx-qt-lib-headers/include/gui/qpainterpath.h b/crates/cxx-qt-lib/include/gui/qpainterpath.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/gui/qpainterpath.h rename to crates/cxx-qt-lib/include/gui/qpainterpath.h diff --git a/crates/cxx-qt-lib-headers/include/gui/qpen.h b/crates/cxx-qt-lib/include/gui/qpen.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/gui/qpen.h rename to crates/cxx-qt-lib/include/gui/qpen.h diff --git a/crates/cxx-qt-lib-headers/include/gui/qpolygon.h b/crates/cxx-qt-lib/include/gui/qpolygon.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/gui/qpolygon.h rename to crates/cxx-qt-lib/include/gui/qpolygon.h diff --git a/crates/cxx-qt-lib-headers/include/gui/qpolygonf.h b/crates/cxx-qt-lib/include/gui/qpolygonf.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/gui/qpolygonf.h rename to crates/cxx-qt-lib/include/gui/qpolygonf.h diff --git a/crates/cxx-qt-lib-headers/include/gui/qregion.h b/crates/cxx-qt-lib/include/gui/qregion.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/gui/qregion.h rename to crates/cxx-qt-lib/include/gui/qregion.h diff --git a/crates/cxx-qt-lib-headers/include/gui/qvector2d.h b/crates/cxx-qt-lib/include/gui/qvector2d.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/gui/qvector2d.h rename to crates/cxx-qt-lib/include/gui/qvector2d.h diff --git a/crates/cxx-qt-lib-headers/include/gui/qvector3d.h b/crates/cxx-qt-lib/include/gui/qvector3d.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/gui/qvector3d.h rename to crates/cxx-qt-lib/include/gui/qvector3d.h diff --git a/crates/cxx-qt-lib-headers/include/gui/qvector4d.h b/crates/cxx-qt-lib/include/gui/qvector4d.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/gui/qvector4d.h rename to crates/cxx-qt-lib/include/gui/qvector4d.h diff --git a/crates/cxx-qt-lib-headers/include/qml/qqmlapplicationengine.h b/crates/cxx-qt-lib/include/qml/qqmlapplicationengine.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/qml/qqmlapplicationengine.h rename to crates/cxx-qt-lib/include/qml/qqmlapplicationengine.h diff --git a/crates/cxx-qt-lib-headers/include/qml/qqmlengine.h b/crates/cxx-qt-lib/include/qml/qqmlengine.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/qml/qqmlengine.h rename to crates/cxx-qt-lib/include/qml/qqmlengine.h diff --git a/crates/cxx-qt-lib-headers/include/quickcontrols/qquickstyle.h b/crates/cxx-qt-lib/include/quickcontrols/qquickstyle.h similarity index 100% rename from crates/cxx-qt-lib-headers/include/quickcontrols/qquickstyle.h rename to crates/cxx-qt-lib/include/quickcontrols/qquickstyle.h diff --git a/crates/cxx-qt-lib-headers/include/core/init.cpp b/crates/cxx-qt-lib/src/core/init.cpp similarity index 100% rename from crates/cxx-qt-lib-headers/include/core/init.cpp rename to crates/cxx-qt-lib/src/core/init.cpp diff --git a/crates/cxx-qt-lib-headers/include/gui/init.cpp b/crates/cxx-qt-lib/src/gui/init.cpp similarity index 100% rename from crates/cxx-qt-lib-headers/include/gui/init.cpp rename to crates/cxx-qt-lib/src/gui/init.cpp diff --git a/examples/cargo_without_cmake/Cargo.toml b/examples/cargo_without_cmake/Cargo.toml index 68e1b3e91..a6aba9388 100644 --- a/examples/cargo_without_cmake/Cargo.toml +++ b/examples/cargo_without_cmake/Cargo.toml @@ -31,5 +31,3 @@ cxx-qt-lib.workspace = true # Use `cxx-qt-build = "0.6"` here instead! # The link_qt_object_files feature is required for statically linking Qt 6. cxx-qt-build = { workspace = true, features = [ "link_qt_object_files" ] } -# Use `cxx-qt-lib-headers = "0.6"` here instead! -cxx-qt-lib-headers.workspace = true diff --git a/examples/cargo_without_cmake/build.rs b/examples/cargo_without_cmake/build.rs index 04123e23a..79a91b6ad 100644 --- a/examples/cargo_without_cmake/build.rs +++ b/examples/cargo_without_cmake/build.rs @@ -20,7 +20,6 @@ fn main() { qml_files: &["qml/main.qml"], ..Default::default() }) - .with_opts(cxx_qt_lib_headers::build_opts()) .build(); } // ANCHOR_END: book_cargo_executable_build_rs diff --git a/examples/demo_threading/cpp/helpers/energyusageproxymodel.h b/examples/demo_threading/cpp/helpers/energyusageproxymodel.h index 322a1ebce..6af092a00 100644 --- a/examples/demo_threading/cpp/helpers/energyusageproxymodel.h +++ b/examples/demo_threading/cpp/helpers/energyusageproxymodel.h @@ -12,7 +12,7 @@ #include #include -#include "cxx-qt-gen/energy_usage.cxxqt.h" +#include "cxx_qt_demo_threading/energy_usage.cxxqt.h" class EnergyUsageProxyModel : public QAbstractListModel { diff --git a/examples/demo_threading/rust/Cargo.toml b/examples/demo_threading/rust/Cargo.toml index 1af9ee454..299505efd 100644 --- a/examples/demo_threading/rust/Cargo.toml +++ b/examples/demo_threading/rust/Cargo.toml @@ -25,7 +25,6 @@ uuid = { version = "1.2", features = ["serde"] } [build-dependencies] cxx-qt-build.workspace = true -cxx-qt-lib-headers.workspace = true [features] link_qt_object_files = [ "cxx-qt-build/link_qt_object_files" ] diff --git a/examples/demo_threading/rust/build.rs b/examples/demo_threading/rust/build.rs index 2b4b6a0af..7a23cd1f7 100644 --- a/examples/demo_threading/rust/build.rs +++ b/examples/demo_threading/rust/build.rs @@ -46,6 +46,5 @@ fn main() { ], ..Default::default() }) - .with_opts(cxx_qt_lib_headers::build_opts()) .build(); } diff --git a/examples/qml_features/rust/Cargo.toml b/examples/qml_features/rust/Cargo.toml index cc7b95028..b67b391a7 100644 --- a/examples/qml_features/rust/Cargo.toml +++ b/examples/qml_features/rust/Cargo.toml @@ -22,7 +22,6 @@ serde_json.workspace = true [build-dependencies] cxx-qt-build.workspace = true -cxx-qt-lib-headers.workspace = true [features] link_qt_object_files = [ "cxx-qt-build/link_qt_object_files" ] diff --git a/examples/qml_features/rust/build.rs b/examples/qml_features/rust/build.rs index 2772bb0dc..3d534d775 100644 --- a/examples/qml_features/rust/build.rs +++ b/examples/qml_features/rust/build.rs @@ -59,7 +59,6 @@ fn main() { .qt_module("Quick") // Import a Qt resource file .qrc("../qml/images/images.qrc") - .with_opts(cxx_qt_lib_headers::build_opts()) .build(); } // ANCHOR_END: book_build_rs diff --git a/examples/qml_features/tests/tst_qrc.qml b/examples/qml_features/tests/tst_qrc.qml index c9f703579..d7a778820 100644 --- a/examples/qml_features/tests/tst_qrc.qml +++ b/examples/qml_features/tests/tst_qrc.qml @@ -28,6 +28,8 @@ TestCase { return [ { tag: "valid", source: "qrc:/images/red.png", status: Image.Ready, + }, + { tag: "invalid", source: "qrc:/images/invalid.png", status: Image.Error, } ] diff --git a/examples/qml_minimal/rust/Cargo.toml b/examples/qml_minimal/rust/Cargo.toml index 300bd7d59..c2f108432 100644 --- a/examples/qml_minimal/rust/Cargo.toml +++ b/examples/qml_minimal/rust/Cargo.toml @@ -38,8 +38,6 @@ cxx-qt-lib.workspace = true [build-dependencies] # Use `cxx-qt-build = "0.6"` here instead! cxx-qt-build.workspace = true -# Use `cxx-qt-lib-headers = "0.6"` here instead! -cxx-qt-lib-headers.workspace = true [features] # This feature must be enabled for `cargo test` when linking Qt 6 statically. diff --git a/examples/qml_minimal/rust/build.rs b/examples/qml_minimal/rust/build.rs index 92ae1e2d9..cbccb39aa 100644 --- a/examples/qml_minimal/rust/build.rs +++ b/examples/qml_minimal/rust/build.rs @@ -17,7 +17,6 @@ fn main() { ..Default::default() }) // ANCHOR_END: book_qml_module - .with_opts(cxx_qt_lib_headers::build_opts()) .build(); } // ANCHOR_END: book_build_rs diff --git a/scripts/release_crates.sh b/scripts/release_crates.sh index e77bfd32b..4dbf26c58 100755 --- a/scripts/release_crates.sh +++ b/scripts/release_crates.sh @@ -61,14 +61,11 @@ release_crate "cxx-qt" # Requires cxx-qt, cxx-qt-gen, and qt-build-utils release_crate "cxx-qt-build" -# Requires cxx-qt-build -release_crate "cxx-qt-lib-headers" - -# Requires cxx-qt, cxx-qt-build, cxx-qt-lib-headers +# Requires cxx-qt, cxx-qt-build release_crate "cxx-qt-lib" # Requires cxx-qt-build release_crate "cxx-qt-lib-extras-headers" -# Requires cxx-qt, cxx-qt-build, cxx-qt-lib, cxx-qt-lib-headers, cxx-qt-lib-extras-headers +# Requires cxx-qt, cxx-qt-build, cxx-qt-lib, cxx-qt-lib-extras-headers release_crate "cxx-qt-lib-extras" diff --git a/tests/basic_cxx_only/cpp/main.cpp b/tests/basic_cxx_only/cpp/main.cpp index 358fd5bf6..331b94319 100644 --- a/tests/basic_cxx_only/cpp/main.cpp +++ b/tests/basic_cxx_only/cpp/main.cpp @@ -7,7 +7,7 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 #include -#include "cxx-qt-gen/lib.cxx.h" +#include "basic_cxx_only/lib.cxx.h" #include "cxx_test.h" class CxxTest : public QObject diff --git a/tests/basic_cxx_qt/cpp/main.cpp b/tests/basic_cxx_qt/cpp/main.cpp index 4b08c4c77..85b41f4a1 100644 --- a/tests/basic_cxx_qt/cpp/main.cpp +++ b/tests/basic_cxx_qt/cpp/main.cpp @@ -10,11 +10,11 @@ #include #include -#include "cxx-qt-gen/empty.cxxqt.h" -#include "cxx-qt-gen/locking.cxxqt.h" -#include "cxx-qt-gen/my_data.cxxqt.h" -#include "cxx-qt-gen/my_object.cxxqt.h" -#include "cxx-qt-gen/my_types.cxxqt.h" +#include "basic_cxx_qt/empty.cxxqt.h" +#include "basic_cxx_qt/locking.cxxqt.h" +#include "basic_cxx_qt/my_data.cxxqt.h" +#include "basic_cxx_qt/my_object.cxxqt.h" +#include "basic_cxx_qt/my_types.cxxqt.h" class LockingWorkerThread : public QThread { diff --git a/tests/basic_cxx_qt/rust/Cargo.toml b/tests/basic_cxx_qt/rust/Cargo.toml index 78551fd36..e2307bb17 100644 --- a/tests/basic_cxx_qt/rust/Cargo.toml +++ b/tests/basic_cxx_qt/rust/Cargo.toml @@ -22,4 +22,3 @@ serde_json = "1.0" [build-dependencies] cxx-qt-build.workspace = true -cxx-qt-lib-headers.workspace = true diff --git a/tests/basic_cxx_qt/rust/build.rs b/tests/basic_cxx_qt/rust/build.rs index b7c5e9411..74764048e 100644 --- a/tests/basic_cxx_qt/rust/build.rs +++ b/tests/basic_cxx_qt/rust/build.rs @@ -12,6 +12,5 @@ fn main() { .file("src/lib.rs") .file("src/locking.rs") .file("src/types.rs") - .with_opts(cxx_qt_lib_headers::build_opts()) .build(); } diff --git a/tests/qt_types_standalone/cpp/qbytearray.h b/tests/qt_types_standalone/cpp/qbytearray.h index bb3b1dc74..17374d107 100644 --- a/tests/qt_types_standalone/cpp/qbytearray.h +++ b/tests/qt_types_standalone/cpp/qbytearray.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qbytearray.cxx.h" +#include "qt_types_standalone/qbytearray.cxx.h" class QByteArrayTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qcolor.h b/tests/qt_types_standalone/cpp/qcolor.h index 80789b6d9..b6d951fb0 100644 --- a/tests/qt_types_standalone/cpp/qcolor.h +++ b/tests/qt_types_standalone/cpp/qcolor.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qcolor.cxx.h" +#include "qt_types_standalone/qcolor.cxx.h" class QColorTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qcoreapplication.h b/tests/qt_types_standalone/cpp/qcoreapplication.h index b4a21e651..cad2cd882 100644 --- a/tests/qt_types_standalone/cpp/qcoreapplication.h +++ b/tests/qt_types_standalone/cpp/qcoreapplication.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qcoreapplication.cxx.h" +#include "qt_types_standalone/qcoreapplication.cxx.h" class QCoreApplicationTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qdate.h b/tests/qt_types_standalone/cpp/qdate.h index 8a1bbe7f0..c23912409 100644 --- a/tests/qt_types_standalone/cpp/qdate.h +++ b/tests/qt_types_standalone/cpp/qdate.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qdate.cxx.h" +#include "qt_types_standalone/qdate.cxx.h" class QDateTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qdatetime.h b/tests/qt_types_standalone/cpp/qdatetime.h index 7e21cfc9c..e8c59de60 100644 --- a/tests/qt_types_standalone/cpp/qdatetime.h +++ b/tests/qt_types_standalone/cpp/qdatetime.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qdatetime.cxx.h" +#include "qt_types_standalone/qdatetime.cxx.h" class QDateTimeTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qguiapplication.h b/tests/qt_types_standalone/cpp/qguiapplication.h index c0c889c02..4857878ff 100644 --- a/tests/qt_types_standalone/cpp/qguiapplication.h +++ b/tests/qt_types_standalone/cpp/qguiapplication.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qguiapplication.cxx.h" +#include "qt_types_standalone/qguiapplication.cxx.h" class QGuiApplicationTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qhash.h b/tests/qt_types_standalone/cpp/qhash.h index d41a03cfb..bf1834f82 100644 --- a/tests/qt_types_standalone/cpp/qhash.h +++ b/tests/qt_types_standalone/cpp/qhash.h @@ -10,7 +10,7 @@ #include #include -#include "cxx-qt-gen/qhash.cxx.h" +#include "qt_types_standalone/qhash.cxx.h" class QHashTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qline.h b/tests/qt_types_standalone/cpp/qline.h index a92af021a..e9d6a458a 100644 --- a/tests/qt_types_standalone/cpp/qline.h +++ b/tests/qt_types_standalone/cpp/qline.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qline.cxx.h" +#include "qt_types_standalone/qline.cxx.h" class QLineTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qlinef.h b/tests/qt_types_standalone/cpp/qlinef.h index 5d2556fe1..53a2fd25e 100644 --- a/tests/qt_types_standalone/cpp/qlinef.h +++ b/tests/qt_types_standalone/cpp/qlinef.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qlinef.cxx.h" +#include "qt_types_standalone/qlinef.cxx.h" class QLineFTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qlist.h b/tests/qt_types_standalone/cpp/qlist.h index ac7bcbc3d..ed1c0d436 100644 --- a/tests/qt_types_standalone/cpp/qlist.h +++ b/tests/qt_types_standalone/cpp/qlist.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qlist.cxx.h" +#include "qt_types_standalone/qlist.cxx.h" class QListTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qmap.h b/tests/qt_types_standalone/cpp/qmap.h index a60ec9e8b..ef6884b84 100644 --- a/tests/qt_types_standalone/cpp/qmap.h +++ b/tests/qt_types_standalone/cpp/qmap.h @@ -10,7 +10,7 @@ #include #include -#include "cxx-qt-gen/qmap.cxx.h" +#include "qt_types_standalone/qmap.cxx.h" class QMapTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qmargins.h b/tests/qt_types_standalone/cpp/qmargins.h index 60937806d..1612d1592 100644 --- a/tests/qt_types_standalone/cpp/qmargins.h +++ b/tests/qt_types_standalone/cpp/qmargins.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qmargins.cxx.h" +#include "qt_types_standalone/qmargins.cxx.h" class QMarginsTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qmarginsf.h b/tests/qt_types_standalone/cpp/qmarginsf.h index c90277dc4..ec9c3b6d2 100644 --- a/tests/qt_types_standalone/cpp/qmarginsf.h +++ b/tests/qt_types_standalone/cpp/qmarginsf.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qmarginsf.cxx.h" +#include "qt_types_standalone/qmarginsf.cxx.h" class QMarginsFTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qmetaobjectconnection.h b/tests/qt_types_standalone/cpp/qmetaobjectconnection.h index ef6a28b5b..79eeba56c 100644 --- a/tests/qt_types_standalone/cpp/qmetaobjectconnection.h +++ b/tests/qt_types_standalone/cpp/qmetaobjectconnection.h @@ -11,7 +11,7 @@ #include #include -#include "cxx-qt-gen/qmetaobjectconnection.cxx.h" +#include "qt_types_standalone/qmetaobjectconnection.cxx.h" class MyObject : public QObject { diff --git a/tests/qt_types_standalone/cpp/qmodelindex.h b/tests/qt_types_standalone/cpp/qmodelindex.h index a29bc6c97..4855e4486 100644 --- a/tests/qt_types_standalone/cpp/qmodelindex.h +++ b/tests/qt_types_standalone/cpp/qmodelindex.h @@ -11,7 +11,7 @@ #include #include -#include "cxx-qt-gen/qmodelindex.cxx.h" +#include "qt_types_standalone/qmodelindex.cxx.h" // We subclass from QAbstractListModel to have a valid model to use for // access to createIndex(); diff --git a/tests/qt_types_standalone/cpp/qpen.h b/tests/qt_types_standalone/cpp/qpen.h index b493f7207..3850ea394 100644 --- a/tests/qt_types_standalone/cpp/qpen.h +++ b/tests/qt_types_standalone/cpp/qpen.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qpen.cxx.h" +#include "qt_types_standalone/qpen.cxx.h" class QPenTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qpersistentmodelindex.h b/tests/qt_types_standalone/cpp/qpersistentmodelindex.h index f9bbe3cdb..a3f3deda4 100644 --- a/tests/qt_types_standalone/cpp/qpersistentmodelindex.h +++ b/tests/qt_types_standalone/cpp/qpersistentmodelindex.h @@ -11,7 +11,7 @@ #include #include -#include "cxx-qt-gen/qpersistentmodelindex.cxx.h" +#include "qt_types_standalone/qpersistentmodelindex.cxx.h" class QPersistentModelIndexTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qpoint.h b/tests/qt_types_standalone/cpp/qpoint.h index db380b33f..cc3a52029 100644 --- a/tests/qt_types_standalone/cpp/qpoint.h +++ b/tests/qt_types_standalone/cpp/qpoint.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qpoint.cxx.h" +#include "qt_types_standalone/qpoint.cxx.h" class QPointTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qpointf.h b/tests/qt_types_standalone/cpp/qpointf.h index f945f0b79..1e0042fcc 100644 --- a/tests/qt_types_standalone/cpp/qpointf.h +++ b/tests/qt_types_standalone/cpp/qpointf.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qpointf.cxx.h" +#include "qt_types_standalone/qpointf.cxx.h" class QPointFTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qpolygon.h b/tests/qt_types_standalone/cpp/qpolygon.h index 6fa66a913..951024816 100644 --- a/tests/qt_types_standalone/cpp/qpolygon.h +++ b/tests/qt_types_standalone/cpp/qpolygon.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qpolygon.cxx.h" +#include "qt_types_standalone/qpolygon.cxx.h" class QPolygonTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qpolygonf.h b/tests/qt_types_standalone/cpp/qpolygonf.h index 7f0df2eca..1af4007c8 100644 --- a/tests/qt_types_standalone/cpp/qpolygonf.h +++ b/tests/qt_types_standalone/cpp/qpolygonf.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qpolygonf.cxx.h" +#include "qt_types_standalone/qpolygonf.cxx.h" class QPolygonFTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qqmlapplicationengine.h b/tests/qt_types_standalone/cpp/qqmlapplicationengine.h index e32e9d2e9..b07c40f42 100644 --- a/tests/qt_types_standalone/cpp/qqmlapplicationengine.h +++ b/tests/qt_types_standalone/cpp/qqmlapplicationengine.h @@ -10,7 +10,7 @@ #include #include -#include "cxx-qt-gen/qqmlapplicationengine.cxx.h" +#include "qt_types_standalone/qqmlapplicationengine.cxx.h" class QQmlApplicationEngineTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qqmlengine.h b/tests/qt_types_standalone/cpp/qqmlengine.h index a4290c2db..7b95f172c 100644 --- a/tests/qt_types_standalone/cpp/qqmlengine.h +++ b/tests/qt_types_standalone/cpp/qqmlengine.h @@ -10,7 +10,7 @@ #include #include -#include "cxx-qt-gen/qqmlengine.cxx.h" +#include "qt_types_standalone/qqmlengine.cxx.h" class QQmlEngineTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qrect.h b/tests/qt_types_standalone/cpp/qrect.h index 6ebc646df..167c113a7 100644 --- a/tests/qt_types_standalone/cpp/qrect.h +++ b/tests/qt_types_standalone/cpp/qrect.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qrect.cxx.h" +#include "qt_types_standalone/qrect.cxx.h" class QRectTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qrectf.h b/tests/qt_types_standalone/cpp/qrectf.h index 28182d3d6..272629b16 100644 --- a/tests/qt_types_standalone/cpp/qrectf.h +++ b/tests/qt_types_standalone/cpp/qrectf.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qrectf.cxx.h" +#include "qt_types_standalone/qrectf.cxx.h" class QRectFTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qregion.h b/tests/qt_types_standalone/cpp/qregion.h index 3d02acb37..614f1348d 100644 --- a/tests/qt_types_standalone/cpp/qregion.h +++ b/tests/qt_types_standalone/cpp/qregion.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qregion.cxx.h" +#include "qt_types_standalone/qregion.cxx.h" class QRegionTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qset.h b/tests/qt_types_standalone/cpp/qset.h index 272067733..1eeb0fa4b 100644 --- a/tests/qt_types_standalone/cpp/qset.h +++ b/tests/qt_types_standalone/cpp/qset.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qset.cxx.h" +#include "qt_types_standalone/qset.cxx.h" class QSetTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qsize.h b/tests/qt_types_standalone/cpp/qsize.h index 1d67ce88a..c753ad4ff 100644 --- a/tests/qt_types_standalone/cpp/qsize.h +++ b/tests/qt_types_standalone/cpp/qsize.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qsize.cxx.h" +#include "qt_types_standalone/qsize.cxx.h" class QSizeTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qsizef.h b/tests/qt_types_standalone/cpp/qsizef.h index 91d419b6d..fabb6d5a9 100644 --- a/tests/qt_types_standalone/cpp/qsizef.h +++ b/tests/qt_types_standalone/cpp/qsizef.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qsizef.cxx.h" +#include "qt_types_standalone/qsizef.cxx.h" class QSizeFTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qstring.h b/tests/qt_types_standalone/cpp/qstring.h index 7b73aa310..98be871d9 100644 --- a/tests/qt_types_standalone/cpp/qstring.h +++ b/tests/qt_types_standalone/cpp/qstring.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qstring.cxx.h" +#include "qt_types_standalone/qstring.cxx.h" class QStringTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qstringlist.h b/tests/qt_types_standalone/cpp/qstringlist.h index 93152423d..2bfd5334e 100644 --- a/tests/qt_types_standalone/cpp/qstringlist.h +++ b/tests/qt_types_standalone/cpp/qstringlist.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qstringlist.cxx.h" +#include "qt_types_standalone/qstringlist.cxx.h" class QStringListTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qtime.h b/tests/qt_types_standalone/cpp/qtime.h index 34c220a05..1a70c8f3b 100644 --- a/tests/qt_types_standalone/cpp/qtime.h +++ b/tests/qt_types_standalone/cpp/qtime.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qtime.cxx.h" +#include "qt_types_standalone/qtime.cxx.h" class QTimeTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qtimezone.h b/tests/qt_types_standalone/cpp/qtimezone.h index b15df5675..34575e9a0 100644 --- a/tests/qt_types_standalone/cpp/qtimezone.h +++ b/tests/qt_types_standalone/cpp/qtimezone.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qtimezone.cxx.h" +#include "qt_types_standalone/qtimezone.cxx.h" class QTimeZoneTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qurl.h b/tests/qt_types_standalone/cpp/qurl.h index 2cc49f5fa..327cb71f5 100644 --- a/tests/qt_types_standalone/cpp/qurl.h +++ b/tests/qt_types_standalone/cpp/qurl.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qurl.cxx.h" +#include "qt_types_standalone/qurl.cxx.h" class QUrlTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qvariant.h b/tests/qt_types_standalone/cpp/qvariant.h index 6d34585cc..5db3e9c33 100644 --- a/tests/qt_types_standalone/cpp/qvariant.h +++ b/tests/qt_types_standalone/cpp/qvariant.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qvariant.cxx.h" +#include "qt_types_standalone/qvariant.cxx.h" // We use VariantTest in data driven tests, so register to Qt metatype system Q_DECLARE_METATYPE(VariantTest) diff --git a/tests/qt_types_standalone/cpp/qvector.h b/tests/qt_types_standalone/cpp/qvector.h index 58b74cc55..cb9003d7e 100644 --- a/tests/qt_types_standalone/cpp/qvector.h +++ b/tests/qt_types_standalone/cpp/qvector.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qvector.cxx.h" +#include "qt_types_standalone/qvector.cxx.h" class QVectorTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qvector2d.h b/tests/qt_types_standalone/cpp/qvector2d.h index 81ee65e2b..77c8c86bc 100644 --- a/tests/qt_types_standalone/cpp/qvector2d.h +++ b/tests/qt_types_standalone/cpp/qvector2d.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qvector2d.cxx.h" +#include "qt_types_standalone/qvector2d.cxx.h" class QVector2DTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qvector3d.h b/tests/qt_types_standalone/cpp/qvector3d.h index b640f9039..7cbeb672d 100644 --- a/tests/qt_types_standalone/cpp/qvector3d.h +++ b/tests/qt_types_standalone/cpp/qvector3d.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qvector3d.cxx.h" +#include "qt_types_standalone/qvector3d.cxx.h" class QVector3DTest : public QObject { diff --git a/tests/qt_types_standalone/cpp/qvector4d.h b/tests/qt_types_standalone/cpp/qvector4d.h index 76e3caed7..f480f7638 100644 --- a/tests/qt_types_standalone/cpp/qvector4d.h +++ b/tests/qt_types_standalone/cpp/qvector4d.h @@ -9,7 +9,7 @@ #include #include -#include "cxx-qt-gen/qvector4d.cxx.h" +#include "qt_types_standalone/qvector4d.cxx.h" class QVector4DTest : public QObject { diff --git a/tests/qt_types_standalone/rust/Cargo.toml b/tests/qt_types_standalone/rust/Cargo.toml index f6d70338f..b389624ae 100644 --- a/tests/qt_types_standalone/rust/Cargo.toml +++ b/tests/qt_types_standalone/rust/Cargo.toml @@ -20,4 +20,3 @@ cxx-qt-lib.workspace = true [build-dependencies] cxx-qt-build.workspace = true -cxx-qt-lib-headers.workspace = true diff --git a/tests/qt_types_standalone/rust/build.rs b/tests/qt_types_standalone/rust/build.rs index 4f14a782f..7b748f1d2 100644 --- a/tests/qt_types_standalone/rust/build.rs +++ b/tests/qt_types_standalone/rust/build.rs @@ -46,6 +46,5 @@ fn main() { .file("src/qvector2d.rs") .file("src/qvector3d.rs") .file("src/qvector4d.rs") - .with_opts(cxx_qt_lib_headers::build_opts()) .build(); }