diff --git a/CMakeLists.txt b/CMakeLists.txt index b12194bb8..de6569498 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,7 @@ set(VERSION_MINOR 0) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/spdlog/include ${CMAKE_CURRENT_SOURCE_DIR}/third_party/exprtk) -set(VERSION_PATCH 235) +set(VERSION_PATCH 236) option( WITH_LIBCXX diff --git a/src/Compiler/Compiler.cpp b/src/Compiler/Compiler.cpp index c874543a0..1fe3e98d2 100644 --- a/src/Compiler/Compiler.cpp +++ b/src/Compiler/Compiler.cpp @@ -3033,3 +3033,7 @@ int Compiler::add_files(Compiler* compiler, Tcl_Interp* interp, int argc, } return TCL_OK; } + +std::filesystem::path Compiler::GetBinPath() const { + return GlobalSession->Context()->BinaryPath(); +} \ No newline at end of file diff --git a/src/Compiler/Compiler.h b/src/Compiler/Compiler.h index 5e7fa42da..fc204f0c0 100644 --- a/src/Compiler/Compiler.h +++ b/src/Compiler/Compiler.h @@ -304,6 +304,8 @@ class Compiler { return m_configFileSearchDir; } + std::filesystem::path GetBinPath() const; + std::string Name() const { return m_name; } static constexpr SynthesisOpt SYNTH_OPT_DEFAULT{SynthesisOpt::Mixed}; diff --git a/src/Configuration/CFGCommon/CFGCommon.cpp b/src/Configuration/CFGCommon/CFGCommon.cpp index 9e59354ef..7ae3282ac 100644 --- a/src/Configuration/CFGCommon/CFGCommon.cpp +++ b/src/Configuration/CFGCommon/CFGCommon.cpp @@ -65,8 +65,8 @@ std::string CFG_print(const char* format_string, ...) { void CFG_assertion(const char* file, const char* func, size_t line, std::string msg) { - std::string filepath = change_directory_to_linux_format(file); - filepath = get_configuration_relative_path(filepath); + std::string filepath = CFG_change_directory_to_linux_format(file); + filepath = CFG_get_configuration_relative_path(filepath); std::string err = func != nullptr ? CFG_print("Assertion at %s (func: %s, line: %d)", filepath.c_str(), func, (uint32_t)(line)) @@ -110,9 +110,9 @@ float CFG_time_elapse(CFG_TIME begin) { return float(CFG_nano_time_elapse(begin) * 1e-9); } -void set_callback_message_function(cfg_callback_post_msg_function msg, - cfg_callback_post_err_function err, - cfg_callback_execute_command exec) { +void CFG_set_callback_message_function(cfg_callback_post_msg_function msg, + cfg_callback_post_err_function err, + cfg_callback_execute_command exec) { CFG_ASSERT(msg != nullptr); CFG_ASSERT(err != nullptr); CFG_ASSERT(exec != nullptr); @@ -121,7 +121,7 @@ void set_callback_message_function(cfg_callback_post_msg_function msg, m_execute_cmd_function = exec; } -void unset_callback_message_function() { +void CFG_unset_callback_message_function() { m_msg_function = nullptr; m_err_function = nullptr; m_execute_cmd_function = nullptr; @@ -150,7 +150,7 @@ void CFG_post_err(const std::string& message, bool append) { } } -std::string change_directory_to_linux_format(std::string path) { +std::string CFG_change_directory_to_linux_format(std::string path) { std::replace(path.begin(), path.end(), '\\', '/'); size_t index = path.find("//"); while (index != std::string::npos) { @@ -160,8 +160,9 @@ std::string change_directory_to_linux_format(std::string path) { return path; } -std::string get_configuration_relative_path(std::string path) { - size_t index = path.find("/src/Configuration"); +std::string CFG_get_configuration_relative_path(std::string path) { + path = CFG_change_directory_to_linux_format(path); + size_t index = path.rfind("/src/Configuration"); if (index != std::string::npos) { path.erase(0, index + 5); } diff --git a/src/Configuration/CFGCommon/CFGCommon.h b/src/Configuration/CFGCommon/CFGCommon.h index 14f083c7f..ea7965144 100644 --- a/src/Configuration/CFGCommon/CFGCommon.h +++ b/src/Configuration/CFGCommon/CFGCommon.h @@ -38,6 +38,9 @@ struct CFGCommon_ARG { std::string projectName; std::string projectPath; std::string taskPath; + std::string analyzePath; + std::string synthesisPath; + std::string binPath; std::string compilerName; std::filesystem::path toolPath; // for any tool path std::filesystem::path searchPath; // for any search path @@ -87,11 +90,11 @@ uint64_t CFG_nano_time_elapse(CFG_TIME begin); float CFG_time_elapse(CFG_TIME begin); -void set_callback_message_function(cfg_callback_post_msg_function msg, - cfg_callback_post_err_function err, - cfg_callback_execute_command exec); +void CFG_set_callback_message_function(cfg_callback_post_msg_function msg, + cfg_callback_post_err_function err, + cfg_callback_execute_command exec); -void unset_callback_message_function(); +void CFG_unset_callback_message_function(); void CFG_post_msg(const std::string& message, const std::string pre_msg = "INFO: ", @@ -105,9 +108,9 @@ int CFG_execute_and_monitor_system_command( const std::string& command, const std::string logFile = std::string{}, bool appendLog = false); -std::string change_directory_to_linux_format(std::string path); +std::string CFG_change_directory_to_linux_format(std::string path); -std::string get_configuration_relative_path(std::string path); +std::string CFG_get_configuration_relative_path(std::string path); void CFG_get_rid_trailing_whitespace(std::string& string, const std::vector whitespaces = { diff --git a/src/Configuration/CFGCompiler/CFGCompiler.cpp b/src/Configuration/CFGCompiler/CFGCompiler.cpp index 100300099..8b528f199 100644 --- a/src/Configuration/CFGCompiler/CFGCompiler.cpp +++ b/src/Configuration/CFGCompiler/CFGCompiler.cpp @@ -54,8 +54,8 @@ static bool programmer_flow(CFGCompiler* cfgcompiler, int argc, CFGCompiler::CFGCompiler(Compiler* compiler) : m_compiler(compiler) { m_CFGCompiler = this; - set_callback_message_function(Message, ErrorMessage, - ExecuteAndMonitorSystemCommand); + CFG_set_callback_message_function(Message, ErrorMessage, + ExecuteAndMonitorSystemCommand); } Compiler* CFGCompiler::GetCompiler() const { return m_compiler; } @@ -111,7 +111,12 @@ int CFGCompiler::Compile(CFGCompiler* cfgcompiler, bool batchMode) { cfgcompiler->m_cmdarg.projectPath = compiler->ProjManager()->projectPath(); cfgcompiler->m_cmdarg.taskPath = compiler->FilePath(Compiler::Action::Bitstream).string(); + cfgcompiler->m_cmdarg.analyzePath = + compiler->FilePath(Compiler::Action::Analyze).string(); + cfgcompiler->m_cmdarg.synthesisPath = + compiler->FilePath(Compiler::Action::Synthesis).string(); cfgcompiler->m_cmdarg.searchPath = compiler->GetConfigFileSearchDirectory(); + cfgcompiler->m_cmdarg.binPath = compiler->GetBinPath().string(); // Call Compile() if (batchMode) { diff --git a/tests/unittest/CFGCommon/CFGArg_test.cpp b/tests/unittest/CFGCommon/CFGArg_test.cpp index 25f30d4c3..d04634a3f 100644 --- a/tests/unittest/CFGCommon/CFGArg_test.cpp +++ b/tests/unittest/CFGCommon/CFGArg_test.cpp @@ -24,7 +24,7 @@ along with this program. If not, see . #include "gtest/gtest.h" TEST(CFGArg, test_arg) { - unset_callback_message_function(); + CFG_unset_callback_message_function(); CFGArg_UTST arg; CFGArg_UTST_SUB0 sub0arg; EXPECT_EQ(sub0arg.debug, true); diff --git a/tests/unittest/CFGCommon/CFGCommon_test.cpp b/tests/unittest/CFGCommon/CFGCommon_test.cpp index cf9cc522c..c2d3ee4cd 100644 --- a/tests/unittest/CFGCommon/CFGCommon_test.cpp +++ b/tests/unittest/CFGCommon/CFGCommon_test.cpp @@ -22,6 +22,16 @@ along with this program. If not, see . #include "Configuration/CFGCommon/CFGCommon.h" #include "gtest/gtest.h" +TEST(CFGCommon, test_change_directory_to_linux_format) { + std::string linux_format = CFG_change_directory_to_linux_format("c:\\\\\\ abc \\ efg /////xyz //123"); + EXPECT_EQ(linux_format, "c:/ abc / efg /xyz /123"); +} + +TEST(CFGCommon, test_configuration_relative_path) { + std::string path = CFG_get_configuration_relative_path("/usr/src/ConfigurationRS/abc"); + EXPECT_EQ(path, "ConfigurationRS/abc"); +} + TEST(CFGCommon, test_get_rid_whitespace) { std::string str = "\t \t \r \n \tThis is Love\t \r \n \n"; CFG_get_rid_trailing_whitespace(str, {'\t'}); @@ -118,7 +128,7 @@ TEST(CFGCommon, test_string_split) { } TEST(CFGCommon, test_exception) { - unset_callback_message_function(); + CFG_unset_callback_message_function(); int a = 10; int exception_count = 0; try { diff --git a/tests/unittest/CFGCompiler/CFGCompiler_test.cpp b/tests/unittest/CFGCompiler/CFGCompiler_test.cpp index 1ed25d759..3d59e81a3 100644 --- a/tests/unittest/CFGCompiler/CFGCompiler_test.cpp +++ b/tests/unittest/CFGCompiler/CFGCompiler_test.cpp @@ -48,7 +48,7 @@ void test_callback_bad_function(const CFGCommon_ARG* cmdarg) { } TEST(CFGCompiler, test_CallbackFunction) { - unset_callback_message_function(); + CFG_unset_callback_message_function(); // New registration - OK EXPECT_EQ(cfgcompiler.RegisterCallbackFunction("good_testing", test_callback_good_function), true); EXPECT_EQ(cfgcompiler.RegisterCallbackFunction("bad_testing", test_callback_bad_function), true);