|
| 1 | +// SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]> |
| 2 | +// SPDX-FileContributor: Andrew Hayzen <[email protected]> |
| 3 | +// |
| 4 | +// SPDX-License-Identifier: MIT OR Apache-2.0 |
| 5 | + |
| 6 | +use std::collections::HashSet; |
| 7 | + |
| 8 | +/// Options for external crates to use |
| 9 | +#[derive(Default)] |
| 10 | +pub struct CxxQtBuildersOpts { |
| 11 | + /// Any extra definitions |
| 12 | + pub(crate) defines: HashSet<String>, |
| 13 | + /// Contents, directory, file name |
| 14 | + pub(crate) headers: Vec<(String, String, String)>, |
| 15 | + /// Qt modules that are required |
| 16 | + pub(crate) qt_modules: HashSet<String>, |
| 17 | +} |
| 18 | + |
| 19 | +impl CxxQtBuildersOpts { |
| 20 | + /// Any additional defines that are required from this opt |
| 21 | + pub fn define(mut self, define: &str) -> Self { |
| 22 | + self.defines.insert(define.to_owned()); |
| 23 | + self |
| 24 | + } |
| 25 | + |
| 26 | + /// Any additional headers that are required from this opt |
| 27 | + /// |
| 28 | + /// These are placed in the given sub directory with the given file name |
| 29 | + pub fn header(mut self, contents: &str, directory: &str, file_name: &str) -> Self { |
| 30 | + self.headers.push(( |
| 31 | + contents.to_owned(), |
| 32 | + directory.to_owned(), |
| 33 | + file_name.to_owned(), |
| 34 | + )); |
| 35 | + self |
| 36 | + } |
| 37 | + |
| 38 | + /// Link additional [Qt modules](https://doc.qt.io/qt-6/qtmodules.html) for this opt. |
| 39 | + /// Specify their names without the `Qt` prefix, for example `"Widgets"`. |
| 40 | + pub fn qt_module(mut self, module: &str) -> Self { |
| 41 | + self.qt_modules.insert(module.to_owned()); |
| 42 | + self |
| 43 | + } |
| 44 | +} |
0 commit comments