MCPcopy Create free account
hub / github.com/chipsalliance/Surelog / parseCommandLine

Method parseCommandLine

src/CommandLine/CommandLineParser.cpp:778–1476  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

776}
777
778bool CommandLineParser::parseCommandLine(int32_t argc, const char** argv) {
779 FileSystem* const fileSystem = FileSystem::getInstance();
780 std::string pname = argv[0];
781 if (pname == "read_systemverilog") {
782 // When surelog is embedded as a plugin in yosys, the program name is
783 // "read_systemverilog", which breaks the -lowmem option
784 pname = "surelog";
785 std::filesystem::path programPath = FileSystem::getProgramPath();
786 programPath = programPath.parent_path();
787 programPath = programPath / pname;
788 m_programId = fileSystem->toPathId(programPath.string(), m_symbolTable);
789 } else {
790 m_programId = fileSystem->getProgramFile(pname, m_symbolTable);
791 }
792 std::vector<std::string> cmd_line;
793 for (int32_t i = 1; i < argc; i++) {
794 cmd_line.emplace_back(undecorateArg(argv[i]));
795 const std::string& arg = cmd_line.back();
796
797 if (arg.empty() || (arg[0] != '-')) {
798 continue;
799 } else if (arg == "-help" || arg == "-h" || arg == "--help") {
800 m_help = true;
801 std::string help = printStringArray(helpText);
802 m_errors->init();
803 logBanner(argc, argv);
804 std::cout << help;
805 return true;
806 } else if (arg == "--version") {
807 std::cout << BuildIdentifier() << std::flush;
808 m_help = true;
809 return true;
810 } else if (arg == "-builtin") {
811 ++i; // Deprecated and ignored!
812 } else if (arg.find("-D") == 0) {
813 std::string def;
814 std::string value;
815 const size_t loc = arg.find('=');
816 if (loc == std::string::npos) {
817 def = arg.substr(2);
818 } else {
819 def = arg.substr(2, loc - 2);
820 value = arg.substr(loc + 1);
821 }
822 if (!def.empty()) {
823 StringUtils::registerEnvVar(def, value);
824 SymbolId id = m_symbolTable->registerSymbol(def);
825 m_defineList.emplace(id, value);
826 }
827 }
828 }
829
830 std::vector<std::string> all_arguments;
831 processOutputDirectory_(cmd_line);
832
833 // Setup a few dependent input & output directories
834 if (!m_outputDirId) {
835 m_outputDirId =

Callers 8

mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
executeCompilationFunction · 0.80
mainFunction · 0.80
TESTFunction · 0.80
TESTFunction · 0.80
TESTFunction · 0.80

Calls 15

undecorateArgFunction · 0.85
printStringArrayFunction · 0.85
BuildIdentifierFunction · 0.85
is_numberFunction · 0.85
StrCatFunction · 0.85
is_c_fileFunction · 0.85
toPathIdMethod · 0.80
getOutputDirMethod · 0.80
getPrecompiledDirMethod · 0.80
getCompileDirMethod · 0.80
toPathMethod · 0.80
addMappingMethod · 0.80

Tested by 3

TESTFunction · 0.64
TESTFunction · 0.64
TESTFunction · 0.64