Skip to content

Commit 70b384c

Browse files
committed
Add --enable-cpython flag
1 parent bb4c39e commit 70b384c

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

src/bin/lpython.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,11 @@ int link_executable(const std::vector<std::string> &infiles,
12461246
cmd += " -I " + rtlib_header_dir;
12471247
cmd += " -L" + base_path
12481248
+ " -Wl,-rpath," + base_path + " -l" + runtime_lib + " -lm";
1249+
if (compiler_options.enable_cpython) {
1250+
std::string py_version = "3.10";
1251+
std::string py_flags = R"(-I $CONDA_PREFIX/include/python)" + py_version + R"( -L$CONDA_PREFIX/lib -Wl,-rpath -Wl,$CONDA_PREFIX/lib -lpython)" + py_version + R"()";
1252+
cmd += " " + py_flags;
1253+
}
12491254
int err = system(cmd.c_str());
12501255
if (err) {
12511256
std::cout << "The command '" + cmd + "' failed." << std::endl;
@@ -1556,6 +1561,7 @@ int main(int argc, char *argv[])
15561561
app.add_flag("--get-rtl-header-dir", print_rtl_header_dir, "Print the path to the runtime library header file");
15571562
app.add_flag("--get-rtl-dir", print_rtl_dir, "Print the path to the runtime library file");
15581563
app.add_flag("--verbose", compiler_options.verbose, "Print debugging statements");
1564+
app.add_flag("--enable-cpython", compiler_options.enable_cpython, "Enable CPython runtime");
15591565

15601566
// LSP specific options
15611567
app.add_flag("--show-errors", show_errors, "Show errors when LSP is running in the background");

src/libasr/utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct CompilerOptions {
5656
bool emit_debug_line_column = false;
5757
bool verbose = false;
5858
bool pass_cumulative = false;
59+
bool enable_cpython = false;
5960
std::vector<std::string> import_paths;
6061
Platform platform;
6162

0 commit comments

Comments
 (0)