Skip to content

Commit

Permalink
Disable WebEngine example for Windows non-MSVC targets (namely, MinGW)
Browse files Browse the repository at this point in the history
This is getting ridiculous.

Fixes woboq#167
  • Loading branch information
ratijas committed Jul 10, 2021
1 parent 48aac9b commit f0136d4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions examples/webengine/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,21 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
use semver::Version;

fn main() {
let cargo_target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
let cargo_target_env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap();

if (cargo_target_os == "windows") && (cargo_target_env != "msvc") {
println!("cargo:warning=On Windows, WebEngine module is only available under MSVC 2017 or MSVC2019.");
println!("cargo:rustc-cfg=no_qt");
}

let qt_version = std::env::var("DEP_QT_VERSION")
.unwrap()
.parse::<Version>()
.expect("Parsing Qt version failed");

if qt_version >= Version::new(6, 0, 0) && qt_version < Version::new(6, 2, 0) {
println!("cargo:warning=WebEngine is not supported on Qt {} yet. It is planned for Qt 6.2 LTS.", qt_version);
println!("cargo:rustc-cfg=no_qt");
}
}
4 changes: 3 additions & 1 deletion qmetaobject/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ pub mod qtdeclarative;
pub mod qtquickcontrols2;
pub mod scenegraph;
pub mod tablemodel;
#[cfg(all(feature = "webengine", not(any(qt_6_0, qt_6_1))))]
#[cfg(feature = "webengine")]
#[cfg(not(any(qt_6_0, qt_6_1)))]
#[cfg(not(all(target_os = "windows", not(target_env = "msvc"))))]
pub mod webengine;

/// Module intended for glob import.
Expand Down
4 changes: 4 additions & 0 deletions qmetaobject/src/webengine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ use cpp::cpp;

cpp! {{
#if !(QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 2, 0))
# if !(_WIN32 && ! defined(_MSC_VER))
#include <QtWebEngine/QtWebEngine>
# endif
#endif
}}

/// Refer to the Qt documentation of QtWebEngine::initialize()
pub fn initialize() {
cpp!(unsafe [] {
#if !(QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 2, 0))
# if !(_WIN32 && ! defined(_MSC_VER))
QtWebEngine::initialize();
# endif
#endif
});
}
2 changes: 2 additions & 0 deletions qttypes/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ fn main() {
#[cfg(feature = "qtwebengine")]
if qt_version >= Version::new(6, 0, 0) && qt_version < Version::new(6, 2, 0) {
println!("cargo:warning=WebEngine is not supported on Qt {} yet. It is planned for Qt 6.2 LTS.", qt_version);
} else if (cargo_target_os == "windows") && (cargo_target_env != "msvc") {
println!("cargo:warning=On Windows, WebEngine module is only available under MSVC 2017 or MSVC2019.");
} else {
link_lib("WebEngine");
}
Expand Down

0 comments on commit f0136d4

Please sign in to comment.