Skip to content

Commit

Permalink
[cpp] on successful link, remove intermediate object files generated …
Browse files Browse the repository at this point in the history
…during codegen
  • Loading branch information
harrand committed Apr 18, 2024
1 parent 3af971a commit 8f2c84e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cpp/src/link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ namespace link
#endif
}

void post_link(std::vector<std::filesystem::path> object_files)
{
for(auto file : object_files)
{
std::filesystem::remove(file);
}
}

void executable(std::vector<std::filesystem::path> object_files, std::filesystem::path output_path, std::string output_name, std::string linker)
{
if(linker.empty())
Expand Down Expand Up @@ -106,6 +114,7 @@ namespace link

int ret = std::system(cmd.c_str());
diag::assert_that(ret == 0, "detected that linker failed. unlucky, dickface!");
post_link(object_files);
}

void library(std::vector<std::filesystem::path> object_files, std::filesystem::path output_path, std::string output_name, std::string linker)
Expand Down Expand Up @@ -140,5 +149,6 @@ namespace link

int ret = std::system(cmd.c_str());
diag::assert_that(ret == 0, "detected that archiver failed. unlucky, dickface!");
post_link(object_files);
}
}

0 comments on commit 8f2c84e

Please sign in to comment.