gdext_gen/gdext/mod.rs
1//! Module for the definition of the structs to be serialized to build the `.gdextension` file, and the functions to generate the file.
2
3pub mod config;
4#[cfg(feature = "dependencies")]
5pub mod deps;
6#[cfg(feature = "icons")]
7pub mod icons;
8pub mod libs;
9
10use serde::{Deserialize, Serialize};
11use toml::Table;
12
13use self::config::Configuration;
14
15/// `.gdextension` file representation.
16#[derive(Default, Deserialize, Serialize, Debug)]
17pub struct GDExtension {
18 /// Configuration section of the `.gdextension` file.
19 configuration: Configuration,
20 /// Libraries section of the `.gdextension` file. Links the `godot` target to the compiled [`GDExtension`] libraries. It contains relationships of `godot_target: GDExtensionCdylibPath`.
21 libraries: Table,
22 /// Icons section of the `.gdextension` file. Links the [`GDExtension`] classes to the files to use as their editor icons. It contains relationships of `ClassName: IconPath`. Available with feature "icons".
23 #[cfg(feature = "icons")]
24 icons: Option<Table>,
25 // The dependencies section is not needed anymore since it's parsed through toml_edit.
26 /*
27 /// Dependencies section of the `.gdextension` file. It contains tables with key `running_system.build_mode`, whose entries are `GDExtensionCdylibPath: dependency`.
28 dependencies: Option<Table>,
29 */
30}
31
32impl GDExtension {
33 /// Creates a new instance of [`GDExtension`], with libraries, icons and dependencies empty and with the assigned [`Configuration`].
34 ///
35 /// # Parameters
36 ///
37 /// * `configuration` - [`Configuration`] to be assigned to the [`GDExtension`].
38 ///
39 /// # Returns
40 ///
41 /// The [`GDExtension`] with the [`Configuration`] assigned.
42 pub fn from_config(configuration: Configuration) -> Self {
43 Self {
44 configuration,
45 libraries: Table::new(),
46 #[cfg(feature = "icons")]
47 icons: None,
48 //dependencies: None,
49 }
50 }
51}