mirror of
https://github.com/YosysHQ/yosys
synced 2025-10-10 09:48:06 +00:00
Merge e8829762f6
into 47ca09a016
This commit is contained in:
commit
cf766acb23
7 changed files with 28 additions and 30 deletions
4
.github/workflows/extra-builds.yml
vendored
4
.github/workflows/extra-builds.yml
vendored
|
@ -73,8 +73,8 @@ jobs:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
WASI_SDK=wasi-sdk-19.0
|
WASI_SDK=wasi-sdk-27.0-x86_64-linux
|
||||||
WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz
|
WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-27/wasi-sdk-27.0-x86_64-linux.tar.gz
|
||||||
if ! [ -d ${WASI_SDK} ]; then curl -L ${WASI_SDK_URL} | tar xzf -; fi
|
if ! [ -d ${WASI_SDK} ]; then curl -L ${WASI_SDK_URL} | tar xzf -; fi
|
||||||
|
|
||||||
FLEX_VER=2.6.4
|
FLEX_VER=2.6.4
|
||||||
|
|
3
Makefile
3
Makefile
|
@ -286,12 +286,11 @@ ifeq ($(WASI_SDK),)
|
||||||
CXX = clang++
|
CXX = clang++
|
||||||
AR = llvm-ar
|
AR = llvm-ar
|
||||||
RANLIB = llvm-ranlib
|
RANLIB = llvm-ranlib
|
||||||
WASIFLAGS := -target wasm32-wasi --sysroot $(WASI_SYSROOT) $(WASIFLAGS)
|
WASIFLAGS := -target wasm32-wasi $(WASIFLAGS)
|
||||||
else
|
else
|
||||||
CXX = $(WASI_SDK)/bin/clang++
|
CXX = $(WASI_SDK)/bin/clang++
|
||||||
AR = $(WASI_SDK)/bin/ar
|
AR = $(WASI_SDK)/bin/ar
|
||||||
RANLIB = $(WASI_SDK)/bin/ranlib
|
RANLIB = $(WASI_SDK)/bin/ranlib
|
||||||
WASIFLAGS := --sysroot $(WASI_SDK)/share/wasi-sysroot $(WASIFLAGS)
|
|
||||||
endif
|
endif
|
||||||
CXXFLAGS := $(WASIFLAGS) -std=$(CXXSTD) $(OPT_LEVEL) -D_WASI_EMULATED_PROCESS_CLOCKS $(filter-out -fPIC,$(CXXFLAGS))
|
CXXFLAGS := $(WASIFLAGS) -std=$(CXXSTD) $(OPT_LEVEL) -D_WASI_EMULATED_PROCESS_CLOCKS $(filter-out -fPIC,$(CXXFLAGS))
|
||||||
LINKFLAGS := $(WASIFLAGS) -Wl,-z,stack-size=1048576 $(filter-out -rdynamic,$(LINKFLAGS))
|
LINKFLAGS := $(WASIFLAGS) -Wl,-z,stack-size=1048576 $(filter-out -rdynamic,$(LINKFLAGS))
|
||||||
|
|
|
@ -637,20 +637,6 @@ std::string escape_cxx_string(const std::string &input)
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string basename(const std::string &filepath)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
const std::string dir_seps = "\\/";
|
|
||||||
#else
|
|
||||||
const std::string dir_seps = "/";
|
|
||||||
#endif
|
|
||||||
size_t sep_pos = filepath.find_last_of(dir_seps);
|
|
||||||
if (sep_pos != std::string::npos)
|
|
||||||
return filepath.substr(sep_pos + 1);
|
|
||||||
else
|
|
||||||
return filepath;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
std::string get_hdl_name(T *object)
|
std::string get_hdl_name(T *object)
|
||||||
{
|
{
|
||||||
|
@ -2858,7 +2844,7 @@ struct CxxrtlWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (split_intf)
|
if (split_intf)
|
||||||
f << "#include \"" << basename(intf_filename) << "\"\n";
|
f << "#include \"" << name_from_file_path(intf_filename) << "\"\n";
|
||||||
else
|
else
|
||||||
f << "#include <cxxrtl/cxxrtl.h>\n";
|
f << "#include <cxxrtl/cxxrtl.h>\n";
|
||||||
f << "\n";
|
f << "\n";
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "libs/sha1/sha1.h"
|
#include "libs/sha1/sha1.h"
|
||||||
#include "frontends/verilog/verilog_frontend.h"
|
#include "frontends/verilog/verilog_frontend.h"
|
||||||
#include "ast.h"
|
#include "ast.h"
|
||||||
|
#include "kernel/io.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -4474,12 +4475,7 @@ std::unique_ptr<AstNode> AstNode::readmem(bool is_readmemh, std::string mem_file
|
||||||
std::ifstream f;
|
std::ifstream f;
|
||||||
f.open(mem_filename.c_str());
|
f.open(mem_filename.c_str());
|
||||||
if (f.fail()) {
|
if (f.fail()) {
|
||||||
#ifdef _WIN32
|
std::string path = parent_from_file_path(*location.begin.filename);
|
||||||
char slash = '\\';
|
|
||||||
#else
|
|
||||||
char slash = '/';
|
|
||||||
#endif
|
|
||||||
std::string path = location.begin.filename->substr(0, location.begin.filename->find_last_of(slash)+1);
|
|
||||||
f.open(path + mem_filename.c_str());
|
f.open(path + mem_filename.c_str());
|
||||||
yosys_input_files.insert(path + mem_filename);
|
yosys_input_files.insert(path + mem_filename);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -895,11 +895,7 @@ frontend_verilog_preproc(std::istream &f,
|
||||||
// if the include file was not found, it is not given with an absolute path, and the
|
// if the include file was not found, it is not given with an absolute path, and the
|
||||||
// currently read file is given with a path, then try again relative to its directory
|
// currently read file is given with a path, then try again relative to its directory
|
||||||
ff.clear();
|
ff.clear();
|
||||||
#ifdef _WIN32
|
fixed_fn = parent_from_file_path(filename) + fn;
|
||||||
fixed_fn = filename.substr(0, filename.find_last_of("/\\")+1) + fn;
|
|
||||||
#else
|
|
||||||
fixed_fn = filename.substr(0, filename.rfind('/')+1) + fn;
|
|
||||||
#endif
|
|
||||||
ff.open(fixed_fn);
|
ff.open(fixed_fn);
|
||||||
}
|
}
|
||||||
if (ff.fail() && fn.size() > 0 && fn_relative) {
|
if (ff.fail() && fn.size() > 0 && fn_relative) {
|
||||||
|
|
19
kernel/io.cc
19
kernel/io.cc
|
@ -2,6 +2,7 @@
|
||||||
#include "kernel/log.h"
|
#include "kernel/log.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#if !defined(WIN32)
|
#if !defined(WIN32)
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
@ -384,6 +385,24 @@ std::string escape_filename_spaces(const std::string& filename)
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string name_from_file_path(std::string path) {
|
||||||
|
return std::filesystem::path(path).filename().string();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Includes OS_PATH_SEP at the end if present
|
||||||
|
std::string parent_from_file_path(std::string path) {
|
||||||
|
auto parent = std::filesystem::path(path).parent_path();
|
||||||
|
if (parent.empty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
// Add trailing separator to match original behavior
|
||||||
|
std::string result = parent.string();
|
||||||
|
if (!result.empty() && result.back() != std::filesystem::path::preferred_separator) {
|
||||||
|
result += std::filesystem::path::preferred_separator;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void format_emit_unescaped(std::string &result, std::string_view fmt)
|
void format_emit_unescaped(std::string &result, std::string_view fmt)
|
||||||
{
|
{
|
||||||
result.reserve(result.size() + fmt.size());
|
result.reserve(result.size() + fmt.size());
|
||||||
|
|
|
@ -469,6 +469,8 @@ bool is_absolute_path(std::string filename);
|
||||||
void remove_directory(std::string dirname);
|
void remove_directory(std::string dirname);
|
||||||
bool create_directory(const std::string& dirname);
|
bool create_directory(const std::string& dirname);
|
||||||
std::string escape_filename_spaces(const std::string& filename);
|
std::string escape_filename_spaces(const std::string& filename);
|
||||||
|
std::string name_from_file_path(std::string path);
|
||||||
|
std::string parent_from_file_path(std::string path);
|
||||||
|
|
||||||
YOSYS_NAMESPACE_END
|
YOSYS_NAMESPACE_END
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue