Fix linux build [wip]

pull/11/head
Ibrahim Numanagić 2022-01-25 13:17:37 -08:00
parent 6f4e24fb00
commit fd06afaa61
9 changed files with 37 additions and 35 deletions
codon
compiler
parser
visitors
stdlib/internal

View File

@ -334,7 +334,7 @@ llvm_map_components_to_libnames(LLVM_LIBS
if(APPLE)
target_link_libraries(codonc PRIVATE ${LLVM_LIBS} dl codonrt)
else()
target_link_libraries(codonc PRIVATE ${STATIC_LIBCPP} ${LLVM_LIBS} dl codonrt)
target_link_libraries(codonc PRIVATE ${STATIC_LIBCPP} ${LLVM_LIBS} dl codonrt stdc++fs)
endif()
# Gather headers

View File

@ -144,16 +144,17 @@ if(CODON_JUPYTER)
CPMAddPackage(
NAME json
GITHUB_REPOSITORY "nlohmann/json"
VERSION 3.10.4)
VERSION 3.10.1)
CPMAddPackage(
NAME xeus
GITHUB_REPOSITORY "jupyter-xeus/xeus"
VERSION 2.2.0
GIT_TAG 2.2.0
PATCH_COMMAND sed -i bak "s/-Wunused-parameter -Wextra -Wreorder//g" CMakeLists.txt
PATCH_COMMAND sed -ibak "s/-Wunused-parameter -Wextra -Wreorder//g" CMakeLists.txt
OPTIONS "BUILD_EXAMPLES OFF"
"XEUS_BUILD_SHARED_LIBS OFF"
"XEUS_STATIC_DEPENDENCIES ON")
"XEUS_STATIC_DEPENDENCIES ON"
"CMAKE_POSITION_INDEPENDENT_CODE ON")
if (xeus_ADDED)
install(TARGETS nlohmann_json EXPORT xeus-targets)
endif()

View File

@ -1,7 +1,5 @@
#include "compiler.h"
#include <filesystem>
#include "codon/parser/cache.h"
#include "codon/parser/peg/peg.h"
#include "codon/parser/visitors/doc/doc.h"
@ -67,7 +65,7 @@ Compiler::parse(bool isCode, const std::string &file, const std::string &code,
const std::unordered_map<std::string, std::string> &defines) {
input = file;
std::string abspath =
(file != "-") ? std::filesystem::absolute(std::filesystem::path(file)).string()
(file != "-") ? std::experimental::filesystem::absolute(std::experimental::filesystem::path(file)).string()
: file;
try {
Timer t1("parse");

View File

@ -1,7 +1,7 @@
#include "plugins.h"
#include <cstdlib>
#include <filesystem>
#include <experimental/filesystem>
#include "codon/parser/common.h"
#include "codon/util/common.h"
@ -17,7 +17,7 @@ llvm::Expected<Plugin *> pluginError(const std::string &msg) {
typedef std::unique_ptr<DSL> LoadFunc();
} // namespace
namespace fs = std::filesystem;
namespace fs = std::experimental::filesystem;
llvm::Expected<Plugin *> PluginManager::load(const std::string &path) {
#if __APPLE__

View File

@ -1,6 +1,5 @@
#include "common.h"
#include <filesystem>
#include <string>
#include <vector>
@ -195,7 +194,7 @@ std::string executable_path(const char *argv0) {
std::string executable_path(const char *argv0) { return std::string(argv0); }
#endif
namespace fs = std::filesystem;
namespace fs = std::experimental::filesystem;
namespace {
void addPath(std::vector<fs::path> &paths, const fs::path &path) {

View File

@ -1,6 +1,6 @@
#include "doc.h"
#include <filesystem>
#include <experimental/filesystem>
#include <memory>
#include <string>
#include <tuple>
@ -116,7 +116,7 @@ std::shared_ptr<json> DocVisitor::apply(const std::string &argv0,
auto ctx = std::make_shared<DocContext>(shared);
for (auto &f : files) {
auto path = std::filesystem::canonical(std::filesystem::path(f)).string();
auto path = std::experimental::filesystem::canonical(std::experimental::filesystem::path(f)).string();
ctx->setFilename(path);
ast = ast::parseFile(shared->cache, path);
// LOG("parsing {}", f);

View File

@ -1,6 +1,5 @@
#include "translate.h"
#include <filesystem>
#include <memory>
#include <sstream>
#include <string>
@ -36,7 +35,7 @@ ir::Func *TranslateVisitor::apply(Cache *cache, StmtPtr stmts) {
} else {
main = cast<ir::BodiedFunc>(cache->module->getMainFunc());
auto path =
std::filesystem::canonical(std::filesystem::path(cache->module0)).string();
std::experimental::filesystem::canonical(std::experimental::filesystem::path(cache->module0)).string();
main->setSrcInfo({path, 0, 0, 0});
}

View File

@ -1,7 +1,7 @@
#pragma once
#include <chrono>
#include <filesystem>
#include <experimental/filesystem>
#include <iostream>
#include <ostream>
@ -123,7 +123,7 @@ struct SrcInfo {
SrcInfo() : SrcInfo("", 0, 0, 0) {}
friend std::ostream &operator<<(std::ostream &out, const codon::SrcInfo &src) {
out << std::filesystem::path(src.file).filename() << ":" << src.line << ":"
out << std::experimental::filesystem::path(src.file).filename() << ":" << src.line << ":"
<< src.col;
return out;
}

View File

@ -43,28 +43,33 @@ _PY_MODULE_CACHE = Dict[str, pyobj]()
_PY_INIT = """
import io
cls = None
cls2 = None
clsf = None
clsa = None
plt = None
try:
import matplotlib.figure
cls = matplotlib.figure.Figure
cls2 = matplotlib.lines.Line2D
import matplotlib.figure
import matplotlib.pyplot
plt = matplotlib.pyplot
clsf = matplotlib.figure.Figure
clsa = matplotlib.artist.Artist
except ModuleNotFoundError:
pass
pass
def __codon_repr__(fig):
if cls and isinstance(fig, cls):
stream = io.StringIO()
fig.savefig(stream, format="svg")
return 'image/svg+xml', stream.getvalue()
elif cls2 and isinstance(fig, cls2):
stream = io.StringIO()
fig.savefig(stream, format="svg")
return 'image/svg+xml', stream.getvalue()
elif hasattr(fig, "_repr_html_"):
return 'text/html', fig._repr_html_()
else:
return 'text/plain', fig.__repr__()
if clsf and isinstance(fig, clsf):
stream = io.StringIO()
fig.savefig(stream, format="svg")
return 'image/svg+xml', stream.getvalue()
elif clsa and isinstance(fig, list) and all(
isinstance(i, clsa) for i in fig
):
stream = io.StringIO()
plt.gcf().savefig(stream, format="svg")
return 'image/svg+xml', stream.getvalue()
elif hasattr(fig, "_repr_html_"):
return 'text/html', fig._repr_html_()
else:
return 'text/plain', fig.__repr__()
"""
_PY_INITIALIZED = False