Skip to content

Commit

Permalink
Generate the modulemap file (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlabelle authored Mar 14, 2024
1 parent acd4048 commit 4332d52
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
12 changes: 12 additions & 0 deletions swiftwinrt/abi_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,16 @@ namespace swiftwinrt
w.save_header();

}

inline void write_modulemap()
{
writer w;
write_preamble(w, /* swift_code: */ false);
w.write(R"^_^(module % {
header "%.h"
export *
}
)^_^", settings.get_c_module_name(), settings.get_c_module_name());
w.save_modulemap();
}
}
1 change: 1 addition & 0 deletions swiftwinrt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ Where <spec> is one or more of:
}

write_include_all(c.namespaces());
write_modulemap();
if (settings.verbose)
{
w.write(" time: %ms\n", get_elapsed_time(start));
Expand Down
5 changes: 5 additions & 0 deletions swiftwinrt/type_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,11 @@ namespace swiftwinrt
flush_to_file(root_directory() / "CWinRT" / "include" / (type_namespace + ".h"));
}

void save_modulemap()
{
flush_to_file(root_directory() / "CWinRT" / "include" / "module.modulemap");
}

void save_cmake()
{
flush_to_file(project_directory() / "CMakeLists.txt");
Expand Down
10 changes: 6 additions & 4 deletions tests/test_component/Sources/CWinRT/include/module.modulemap
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module Ctest_component {
header "Ctest_component.h"
export *
}
// WARNING: Please don't edit this file. It was generated by Swift/WinRT v0.0.1

module Ctest_component {
header "Ctest_component.h"
export *
}

0 comments on commit 4332d52

Please sign in to comment.