Skip to content

Commit

Permalink
Revert name change of udl files
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniusnaumann committed Oct 20, 2023
1 parent 32bb24a commit 73e7c8c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 31 deletions.
34 changes: 21 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 3 additions & 11 deletions src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,14 @@ fn create_project(
lib_type: lib_type.identifier(),
macro_only,
};
let lib_rs_content = templating::LibRs {
plain,
namespace: &namespace,
macro_only,
};
let lib_rs_content = templating::LibRs { plain, macro_only };
let (udl_content, build_rs_content) = if !macro_only {
(
Some(templating::LibUdl {
namespace: &namespace,
plain,
}),
Some(templating::BuildRs {
namespace: &namespace,
}),
Some(templating::BuildRs {}),
)
} else {
(None, None)
Expand All @@ -86,7 +80,6 @@ fn create_project(
lib_rs_content,
udl_content,
crate_name,
&namespace,
)?;

Ok(())
Expand All @@ -98,7 +91,6 @@ fn write_project_files(
lib_rs: templating::LibRs,
lib_udl: Option<templating::LibUdl>,
crate_name: &str,
namespace: &str,
) -> Result<()> {
create_dir(crate_name).map_err(|_| "Could not create directory for crate!")?;

Expand All @@ -125,7 +117,7 @@ fn write_project_files(

if let Some(lib_udl) = lib_udl {
write(
format!("{}/src/{}.udl", crate_name, namespace),
format!("{}/src/lib.udl", crate_name),
lib_udl.render().unwrap(),
)
.map_err(|_| "Could not write src/lib.udl!")?;
Expand Down
7 changes: 2 additions & 5 deletions src/templating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ pub(crate) struct CargoToml<'a> {

#[derive(Template)]
#[template(path = "build.rs", escape = "none")]
pub(crate) struct BuildRs<'a> {
pub(crate) namespace: &'a str,
}
pub(crate) struct BuildRs {}

#[derive(Template)]
#[template(path = "lib.rs", escape = "none")]
pub(crate) struct LibRs<'a> {
pub(crate) namespace: &'a str,
pub(crate) struct LibRs {
pub(crate) plain: bool,
pub(crate) macro_only: bool,
}
Expand Down
2 changes: 1 addition & 1 deletion templates/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fn main() {
uniffi::generate_scaffolding("./src/{{ namespace }}.udl").unwrap();
uniffi::generate_scaffolding("./src/lib.udl").unwrap();
}
2 changes: 1 addition & 1 deletion templates/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% if macro_only %}
uniffi::setup_scaffolding!();
{% else %}
uniffi::include_scaffolding!("{{ namespace }}");
uniffi::include_scaffolding!("lib");
{%- endif %}

{% if !plain %}
Expand Down

0 comments on commit 73e7c8c

Please sign in to comment.