Implement --file-names-only (#8788)

* flatc builds and seems to work, some of the extra targets are having linker errors

* fix build system

* pipeline failures

* un-rename files

* refactor to use unique_ptr

* typo

* rm make_unique, add comments

* fix cmake

---------

Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
This commit is contained in:
Justin Davis
2025-12-02 23:37:06 -05:00
committed by GitHub
parent 0b60686e3d
commit a1e125af11
34 changed files with 207 additions and 210 deletions

View File

@@ -336,8 +336,8 @@ static bool GenerateRustModuleRootFile(const Parser& parser,
"Do not modify.";
code += "// @generated";
root_module.GenerateImports(code);
const bool success =
SaveFile((output_dir + "mod.rs").c_str(), code.ToString(), false);
const bool success = parser.opts.file_saver->SaveFile(
(output_dir + "mod.rs").c_str(), code.ToString(), false);
code.Clear();
return success;
}
@@ -394,8 +394,8 @@ class RustGenerator : public BaseGenerator {
namer_.Directories(*symbol.defined_namespace);
EnsureDirExists(directories);
const std::string file_path = directories + namer_.File(symbol);
const bool save_success =
SaveFile(file_path.c_str(), code_.ToString(), /*binary=*/false);
const bool save_success = parser_.opts.file_saver->SaveFile(
file_path.c_str(), code_.ToString(), /*binary=*/false);
if (!save_success) return false;
}
return true;
@@ -496,7 +496,8 @@ class RustGenerator : public BaseGenerator {
const auto file_path = GeneratedFileName(path_, file_name_, parser_.opts);
const auto final_code = code_.ToString();
return SaveFile(file_path.c_str(), final_code, false);
return parser_.opts.file_saver->SaveFile(file_path.c_str(), final_code,
false);
}
private: