bfgroup / b2

B2 makes it easy to build C++ projects, everywhere.
https://www.bfgroup.xyz/b2/
Boost Software License 1.0
76 stars 228 forks source link

command-databasse has not pass the true filename to prop_db->write_file(filename, ... #415

Open CyanCloverFern opened 1 week ago

CyanCloverFern commented 1 week ago

when i use --command-databasse i find the error report : "...writing to command database 'compile_commands.jsonE:\hello\compile_commands.json' FAILED...\n" i think the problem is the filename string has pass twice. so i modifiy the file "engine\mod_command_db.cpp", i insert a line in function exit_main(int status)

old void exit_main(int status) { if (status == EXIT_FAIL) return; std::string filename = output_filename; if (!b2::paths::is_rooted(output_filename)) { if (!b2::paths::is_rooted(output_directory)) filename = b2::cwd_str() + "/"; filename += output_directory + "/" + output_filename; filename = b2::paths::normalize(filename); } if (prop_db->write_file(filename, output_format)) out_printf("...wrote command database '%s'...\n", filename.c_str()); else err_printf("...writing to command database '%s' FAILED...\n", filename.c_str()); } new void exit_main(int status) { if (status == EXIT_FAIL) return; std::string filename = output_filename; if (!b2::paths::is_rooted(output_filename)) { filename = {} if (!b2::paths::is_rooted(output_directory)) filename = b2::cwd_str() + "/"; filename += output_directory + "/" + output_filename; filename = b2::paths::normalize(filename); } if (prop_db->write_file(filename, output_format)) out_printf("...wrote command database '%s'...\n", filename.c_str()); else err_printf("...writing to command database '%s' FAILED...\n", filename.c_str()); }

then i generate compile_command ok.

os: windows

CyanCloverFern commented 1 week ago

i think my modifiy is not a true change. when i use b2 --command-database=json in b2-main project, it report : ...writing to command database 'E:/b2-5.2.1/.build/compile_commands.json' FAILED...