Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Allow multiple -I flags #1741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bin/lpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ int main(int argc, char *argv[])
// app.add_flag("-E", arg_E, "Preprocess only; do not compile, assemble or link");
// app.add_option("-l", arg_l, "Link library option");
// app.add_option("-L", arg_L, "Library path option");
app.add_option("-I", compiler_options.import_path, "Specify the path"
app.add_option("-I", compiler_options.import_paths, "Specify the paths"
"to look for the module")->allow_extra_args(false);
// app.add_option("-J", arg_J, "Where to save mod files");
app.add_flag("-g", compiler_options.emit_debug_info, "Compile with debugging information");
Expand Down
2 changes: 1 addition & 1 deletion src/libasr/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct CompilerOptions {
bool emit_debug_line_column = false;
bool verbose = false;
bool pass_cumulative = false;
std::string import_path = "";
std::vector<std::string> import_paths;
Platform platform;

CompilerOptions () : platform{get_platform()} {};
Expand Down
22 changes: 11 additions & 11 deletions src/lpython/semantics/python_ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
IntrinsicNodeHandler intrinsic_node_handler;
std::map<int, ASR::symbol_t*> &ast_overload;
std::string parent_dir;
std::string import_path;
std::vector<std::string> import_paths;
Vec<ASR::stmt_t*> *current_body;
ASR::ttype_t* ann_assign_target_type;
AST::expr_t* assign_ast_target;
Expand All @@ -573,9 +573,9 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
CommonVisitor(Allocator &al, LocationManager &lm, SymbolTable *symbol_table,
diag::Diagnostics &diagnostics, bool main_module,
std::map<int, ASR::symbol_t*> &ast_overload, std::string parent_dir,
std::string import_path, bool allow_implicit_casting_)
std::vector<std::string> import_paths, bool allow_implicit_casting_)
: diag{diagnostics}, al{al}, lm{lm}, current_scope{symbol_table}, main_module{main_module},
ast_overload{ast_overload}, parent_dir{parent_dir}, import_path{import_path},
ast_overload{ast_overload}, parent_dir{parent_dir}, import_paths{import_paths},
current_body{nullptr}, ann_assign_target_type{nullptr},
assign_ast_target{nullptr}, is_c_p_pointer_call{false}, allow_implicit_casting{allow_implicit_casting_} {
current_module_dependencies.reserve(al, 4);
Expand Down Expand Up @@ -3320,9 +3320,9 @@ class SymbolTableVisitor : public CommonVisitor<SymbolTableVisitor> {
SymbolTableVisitor(Allocator &al, LocationManager &lm, SymbolTable *symbol_table,
diag::Diagnostics &diagnostics, bool main_module,
std::map<int, ASR::symbol_t*> &ast_overload, std::string parent_dir,
std::string import_path, bool allow_implicit_casting_)
std::vector<std::string> import_paths, bool allow_implicit_casting_)
: CommonVisitor(al, lm, symbol_table, diagnostics, main_module, ast_overload,
parent_dir, import_path, allow_implicit_casting_), is_derived_type{false} {}
parent_dir, import_paths, allow_implicit_casting_), is_derived_type{false} {}


ASR::symbol_t* resolve_symbol(const Location &loc, const std::string &sub_name) {
Expand Down Expand Up @@ -3636,8 +3636,8 @@ class SymbolTableVisitor : public CommonVisitor<SymbolTableVisitor> {
in the second priority. Top priority path
is runtime library path.
*/
if( import_path != "" ) {
paths.insert(paths.begin() + 1, import_path);
for( auto& path: import_paths ) {
paths.push_back(path);
}

/*
Expand Down Expand Up @@ -3870,10 +3870,10 @@ class SymbolTableVisitor : public CommonVisitor<SymbolTableVisitor> {
Result<ASR::asr_t*> symbol_table_visitor(Allocator &al, LocationManager &lm, const AST::Module_t &ast,
diag::Diagnostics &diagnostics, bool main_module,
std::map<int, ASR::symbol_t*> &ast_overload, std::string parent_dir,
std::string import_path, bool allow_implicit_casting)
std::vector<std::string> import_paths, bool allow_implicit_casting)
{
SymbolTableVisitor v(al, lm, nullptr, diagnostics, main_module, ast_overload,
parent_dir, import_path, allow_implicit_casting);
parent_dir, import_paths, allow_implicit_casting);
try {
v.visit_Module(ast);
} catch (const SemanticError &e) {
Expand Down Expand Up @@ -3901,7 +3901,7 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
BodyVisitor(Allocator &al, LocationManager &lm, ASR::asr_t *unit, diag::Diagnostics &diagnostics,
bool main_module, std::map<int, ASR::symbol_t*> &ast_overload,
bool allow_implicit_casting_)
: CommonVisitor(al, lm, nullptr, diagnostics, main_module, ast_overload, "", "", allow_implicit_casting_),
: CommonVisitor(al, lm, nullptr, diagnostics, main_module, ast_overload, "", {}, allow_implicit_casting_),
asr{unit}, gotoids{0}
{}

Expand Down Expand Up @@ -6693,7 +6693,7 @@ Result<ASR::TranslationUnit_t*> python_ast_to_asr(Allocator &al, LocationManager

ASR::asr_t *unit;
auto res = symbol_table_visitor(al, lm, *ast_m, diagnostics, main_module,
ast_overload, parent_dir, compiler_options.import_path, allow_implicit_casting);
ast_overload, parent_dir, compiler_options.import_paths, allow_implicit_casting);
if (res.ok) {
unit = res.result;
} else {
Expand Down