diff --git a/crates/cxx-qt-lib/build.rs b/crates/cxx-qt-lib/build.rs index b7008e0f1..8a1cb2253 100644 --- a/crates/cxx-qt-lib/build.rs +++ b/crates/cxx-qt-lib/build.rs @@ -6,6 +6,10 @@ 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 emscripten_targeted = match std::env::var("CARGO_CFG_TARGET_OS") { + Ok(val) => val == "emscripten", + Err(_) => false, + }; let mut qt_modules = vec!["Core".to_owned()]; if feature_qt_gui_enabled { @@ -31,7 +35,6 @@ fn main() { "core/qbytearray", "core/qcoreapplication", "core/qdate", - "core/qdatetime", "core/qhash/qhash_i32_qbytearray", "core/qhash/qhash_qstring_qvariant", "core/qlist/qlist_bool", @@ -43,7 +46,6 @@ fn main() { "core/qlist/qlist_i64", "core/qlist/qlist_qbytearray", "core/qlist/qlist_qdate", - "core/qlist/qlist_qdatetime", "core/qlist/qlist_qmargins", "core/qlist/qlist_qmarginsf", "core/qlist/qlist_qpersistentmodelindex", @@ -80,7 +82,6 @@ fn main() { "core/qset/qset_i64", "core/qset/qset_qbytearray", "core/qset/qset_qdate", - "core/qset/qset_qdatetime", "core/qset/qset_qpersistentmodelindex", "core/qset/qset_qstring", "core/qset/qset_qtime", @@ -95,7 +96,6 @@ fn main() { "core/qstringlist", "core/qt", "core/qtime", - "core/qtimezone", "core/qurl", "core/qvariant/mod", "core/qvariant/qvariant_bool", @@ -107,7 +107,6 @@ fn main() { "core/qvariant/qvariant_i64", "core/qvariant/qvariant_qbytearray", "core/qvariant/qvariant_qdate", - "core/qvariant/qvariant_qdatetime", "core/qvariant/qvariant_qmodelindex", "core/qvariant/qvariant_qpersistentmodelindex", "core/qvariant/qvariant_qpoint", @@ -133,7 +132,6 @@ fn main() { "core/qvector/qvector_i64", "core/qvector/qvector_qbytearray", "core/qvector/qvector_qdate", - "core/qvector/qvector_qdatetime", "core/qvector/qvector_qmargins", "core/qvector/qvector_qmarginsf", "core/qvector/qvector_qpersistentmodelindex", @@ -170,6 +168,17 @@ fn main() { rust_bridges.extend(["qml/qqmlapplicationengine", "qml/qqmlengine"]); } + if !emscripten_targeted { + rust_bridges.extend([ + "core/qdatetime", + "core/qtimezone", + "core/qlist/qlist_qdatetime", + "core/qset/qset_qdatetime", + "core/qvariant/qvariant_qdatetime", + "core/qvector/qvector_qdatetime", + ]); + } + for bridge in &rust_bridges { println!("cargo:rerun-if-changed=src/{bridge}.rs"); } @@ -187,7 +196,6 @@ fn main() { "core/qbytearray", "core/qcoreapplication", "core/qdate", - "core/qdatetime", "core/qhash/qhash", "core/qlist/qlist", "core/qmap/qmap", @@ -206,7 +214,6 @@ fn main() { "core/qstring", "core/qstringlist", "core/qtime", - "core/qtimezone", "core/qurl", "core/qvariant/qvariant", "core/qvector/qvector", @@ -226,6 +233,10 @@ fn main() { cpp_files.extend(["qml/qqmlapplicationengine", "qml/qqmlengine"]); } + if !emscripten_targeted { + cpp_files.extend(["core/qdatetime", "core/qtimezone"]); + } + for cpp_file in &cpp_files { builder.file(format!("src/{cpp_file}.cpp")); println!("cargo:rerun-if-changed=src/{cpp_file}.cpp"); diff --git a/crates/cxx-qt-lib/src/core/mod.rs b/crates/cxx-qt-lib/src/core/mod.rs index 903d7140f..c4349c8b2 100644 --- a/crates/cxx-qt-lib/src/core/mod.rs +++ b/crates/cxx-qt-lib/src/core/mod.rs @@ -12,7 +12,9 @@ pub use qcoreapplication::QCoreApplication; mod qdate; pub use qdate::QDate; +#[cfg(not(target_os = "emscripten"))] mod qdatetime; +#[cfg(not(target_os = "emscripten"))] pub use qdatetime::QDateTime; mod qhash; @@ -68,7 +70,9 @@ pub use qt::{ mod qtime; pub use qtime::QTime; +#[cfg(not(target_os = "emscripten"))] mod qtimezone; +#[cfg(not(target_os = "emscripten"))] pub use qtimezone::QTimeZone; mod qpoint; diff --git a/crates/cxx-qt-lib/src/core/qlist/mod.rs b/crates/cxx-qt-lib/src/core/qlist/mod.rs index 6acf18186..4beb19da6 100644 --- a/crates/cxx-qt-lib/src/core/qlist/mod.rs +++ b/crates/cxx-qt-lib/src/core/qlist/mod.rs @@ -5,9 +5,11 @@ #[cfg(feature = "qt_gui")] use crate::QColor; +#[cfg(not(target_os = "emscripten"))] +use crate::QDateTime; use crate::{ - QByteArray, QDate, QDateTime, QMargins, QMarginsF, QPersistentModelIndex, QPoint, QPointF, - QRect, QRectF, QSize, QSizeF, QString, QTime, QUrl, QVariant, + QByteArray, QDate, QMargins, QMarginsF, QPersistentModelIndex, QPoint, QPointF, QRect, QRectF, + QSize, QSizeF, QString, QTime, QUrl, QVariant, }; use core::{marker::PhantomData, mem::MaybeUninit}; use cxx::{type_id, ExternType}; @@ -351,6 +353,7 @@ impl_qlist_element!(QByteArray, qlist_qbytearray, "QList_QByteArray"); #[cfg(feature = "qt_gui")] impl_qlist_element!(QColor, qlist_qcolor, "QList_QColor"); impl_qlist_element!(QDate, qlist_qdate, "QList_QDate"); +#[cfg(not(target_os = "emscripten"))] impl_qlist_element!(QDateTime, qlist_qdatetime, "QList_QDateTime"); impl_qlist_element!(QMargins, qlist_qmargins, "QList_QMargins"); impl_qlist_element!(QMarginsF, qlist_qmarginsf, "QList_QMarginsF"); diff --git a/crates/cxx-qt-lib/src/core/qset/mod.rs b/crates/cxx-qt-lib/src/core/qset/mod.rs index 0c51694c2..45e44ced0 100644 --- a/crates/cxx-qt-lib/src/core/qset/mod.rs +++ b/crates/cxx-qt-lib/src/core/qset/mod.rs @@ -2,7 +2,9 @@ // SPDX-FileContributor: Andrew Hayzen // // SPDX-License-Identifier: MIT OR Apache-2.0 -use crate::{QByteArray, QDate, QDateTime, QPersistentModelIndex, QString, QTime, QUrl}; +#[cfg(not(target_os = "emscripten"))] +use crate::QDateTime; +use crate::{QByteArray, QDate, QPersistentModelIndex, QString, QTime, QUrl}; use core::{marker::PhantomData, mem::MaybeUninit}; use cxx::{type_id, ExternType}; @@ -250,6 +252,7 @@ impl_qset_element!(i32, qset_i32, "QSet_i32"); impl_qset_element!(i64, qset_i64, "QSet_i64"); impl_qset_element!(QByteArray, qset_qbytearray, "QSet_QByteArray"); impl_qset_element!(QDate, qset_qdate, "QSet_QDate"); +#[cfg(not(target_os = "emscripten"))] impl_qset_element!(QDateTime, qset_qdatetime, "QSet_QDateTime"); impl_qset_element!( QPersistentModelIndex, diff --git a/crates/cxx-qt-lib/src/core/qvariant/mod.rs b/crates/cxx-qt-lib/src/core/qvariant/mod.rs index 0d10528a3..32a508b82 100644 --- a/crates/cxx-qt-lib/src/core/qvariant/mod.rs +++ b/crates/cxx-qt-lib/src/core/qvariant/mod.rs @@ -167,6 +167,7 @@ impl_qvariant_value!(crate::QByteArray, qvariant_qbytearray); #[cfg(feature = "qt_gui")] impl_qvariant_value!(crate::QColor, qvariant_qcolor); impl_qvariant_value!(crate::QDate, qvariant_qdate); +#[cfg(not(target_os = "emscripten"))] impl_qvariant_value!(crate::QDateTime, qvariant_qdatetime); impl_qvariant_value!(crate::QModelIndex, qvariant_qmodelindex); impl_qvariant_value!(crate::QPersistentModelIndex, qvariant_qpersistentmodelindex); diff --git a/crates/cxx-qt-lib/src/core/qvector/mod.rs b/crates/cxx-qt-lib/src/core/qvector/mod.rs index ca903a9bd..24011f7f8 100644 --- a/crates/cxx-qt-lib/src/core/qvector/mod.rs +++ b/crates/cxx-qt-lib/src/core/qvector/mod.rs @@ -5,9 +5,11 @@ #[cfg(feature = "qt_gui")] use crate::QColor; +#[cfg(not(target_os = "emscripten"))] +use crate::QDateTime; use crate::{ - QByteArray, QDate, QDateTime, QMargins, QMarginsF, QPersistentModelIndex, QPoint, QPointF, - QRect, QRectF, QSize, QSizeF, QString, QTime, QUrl, QVariant, + QByteArray, QDate, QMargins, QMarginsF, QPersistentModelIndex, QPoint, QPointF, QRect, QRectF, + QSize, QSizeF, QString, QTime, QUrl, QVariant, }; use core::{marker::PhantomData, mem::MaybeUninit}; use cxx::{type_id, ExternType}; @@ -351,6 +353,7 @@ impl_qvector_element!(QByteArray, qvector_qbytearray, "QVector_QByteArray"); #[cfg(feature = "qt_gui")] impl_qvector_element!(QColor, qvector_qcolor, "QVector_QColor"); impl_qvector_element!(QDate, qvector_qdate, "QVector_QDate"); +#[cfg(not(target_os = "emscripten"))] impl_qvector_element!(QDateTime, qvector_qdatetime, "QVector_QDateTime"); impl_qvector_element!(QMargins, qvector_qmargins, "QVector_QMargins"); impl_qvector_element!(QMarginsF, qvector_qmarginsf, "QVector_QMarginsF");