add new feat: appimage (#43)

* [fix] performance analysis and internal signal config

* add dockerfile and ci builder

* [feat] add appimage building process, basic cpp support

* [fix] appimage multi-language support, appimage mode detection

* [feat] integrate verible-verilog-syntax in appiamge, fix dynamic lib search priority

* try ci appimages

* [fix] cmake CMP0171 for codegen keyword

* [fix] cmake CMP0171 for codegen keyword

* [fix] cmake CMP0171 for codegen keyword

* [fix] cmake CMP0171 for codegen keyword

* [fix] cmake CMP0171 for codegen keyword

* [fix] arm64 autobuild

* [fix] arm64 autobuild

* [fix] tag right release

* [fix] format and typos

* [fix] typo explaination should be corrected to 'explanation'

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Makiras 2025-07-08 16:04:14 +08:00 committed by GitHub
parent b3da72f4d4
commit ba5127bd4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
35 changed files with 598 additions and 61 deletions

95
.github/workflows/AppImage.yaml vendored Normal file
View File

@ -0,0 +1,95 @@
name: Basic Env Docker Build and Publish
on:
push:
# master or any *appimage* branch
branches:
- master
- '*appimage*'
jobs:
build:
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-22.04-arm]
runs-on: ${{ matrix.os }}
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Initialize AppImage environment
run: |
ARCH=$(uname -m)
if [ "$ARCH" = "arm64" ]; then
ARCH="aarch64"
fi
wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-${ARCH}.AppImage
wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-${ARCH}.AppImage
chmod +x appimagetool-${ARCH}.AppImage
sudo mv appimagetool-${ARCH}.AppImage /usr/bin/appimagetool
chmod +x linuxdeploy-${ARCH}.AppImage
sudo mv linuxdeploy-${ARCH}.AppImage /usr/bin/linuxdeploy
wget https://zenlayer.dl.sourceforge.net/project/swig/swig/swig-4.3.1/swig-4.3.1.tar.gz
tar -xzf swig-4.3.1.tar.gz
cd swig-4.3.1
./configure --prefix=/usr
make -j$(nproc)
sudo make install
cd ..
- name: Build AppImage
run: |
# Build the AppImage
make init
make appimage
- name: Upload AppImage for next jobs
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-appimage
path: '*.AppImage'
publish:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
# Only run this job for pushes to master or any branch starting with 'appimage'
if: |
contains(github.ref, 'appimage') || contains(github.ref, 'master')
steps:
- name: Download AppImage
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: appimages
- name: Generate release tag
id: tag_vars
run: |
DATE=$(date +'%Y%m%d')
SHORT_SHA=${GITHUB_SHA::6}
echo "TAG_NAME=$DATE-$SHORT_SHA" >> $GITHUB_OUTPUT
- name: Create AppImage release
uses: softprops/action-gh-release@v2
with:
files: |
appimages/*.AppImage
tag_name: ${{ steps.tag_vars.outputs.TAG_NAME }}
name: Picker AppImage ${{ steps.tag_vars.outputs.TAG_NAME }}
body: |
This is the AppImage release for Picker.
It includes the latest changes and features.
target_commitish: ${{ github.sha }}
draft: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

48
.github/workflows/docker_images.yaml vendored Normal file
View File

@ -0,0 +1,48 @@
name: Basic Env Docker Build and Publish
on:
push:
branches: [ "master" ]
workflow_run:
workflows: [ "docker_images" ]
branches: [ "master" ]
types: [ "completed" ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: xs-mlvp/picker
IMAGE_TAG: ${{ github.sha }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

4
.gitignore vendored
View File

@ -43,6 +43,7 @@ log
*.exe
*.out
*.app
*.AppImage
build/
dist/
@ -52,3 +53,6 @@ logs/
temp/
picker_out*
dependence/xcomm
AppDir/
app_image_build/

View File

@ -42,9 +42,7 @@ add_subdirectory(test)
# install
set(CMAKE_INSTALL_LOCAL_ONLY TRUE)
install(
TARGETS picker DESTINATION bin
)
install(
DIRECTORY template DESTINATION share/picker
)

122
Dockerfile Normal file
View File

@ -0,0 +1,122 @@
# Use Ubuntu 22.04 as the base image
FROM ubuntu:22.04
# Set non-interactive installation
ENV DEBIAN_FRONTEND=noninteractive
# Set the locale
ENV LANG=C.UTF-8
ENV LANGUAGE=C.UTF-8
ENV LC_ALL=C.UTF-8
# Use https for apt repositories
RUN apt update && \
apt install -y --no-install-recommends apt-transport-https ca-certificates && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN sed -i 's|http|https|g' /etc/apt/sources.list
# Set the timezone to France
ENV TZ=Europe/Paris
RUN apt-get update && \
apt-get install -y --no-install-recommends tzdata && \
ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && \
dpkg-reconfigure --frontend noninteractive tzdata && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
build-essential \
git \
sudo \
wget \
curl \
vim \
software-properties-common \
python3 \
python3-pip \
python3-dev \
libpcre3-dev \
pkg-config \
libfl-dev \
bison \
flex \
gperf \
clang \
g++ \
zlib1g-dev \
openssh-server \
gnupg \
autoconf \
automake \
libtool \
openjdk-17-jdk \
libpcre2-dev \
help2man && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install SWIG (4.2.1)d
RUN git clone https://github.com/swig/swig.git -b v4.2.1 --depth=1 /tmp/swig && \
cd /tmp/swig && \
./autogen.sh && \
./configure --prefix=/usr/local && \
make -j$(nproc) && \
make install && \
rm -rf /tmp/swig
# Set up Kitware repository and install the latest CMake
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | \
gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null && \
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' | \
tee /etc/apt/sources.list.d/kitware.list >/dev/null && \
apt-get update && \
apt-get install -y --no-install-recommends cmake && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install Verilator (5.0 series latest version, e.g. v5.018)
RUN git clone https://github.com/verilator/verilator -b v5.018 --depth=1 /tmp/verilator && \
cd /tmp/verilator && \
autoconf && \
./configure --prefix=/usr/local && \
make -j$(nproc) && make test && \
make install && \
rm -rf /tmp/verilator
# Verify Dependency installations
RUN swig -version && \
cmake --version && \
verilator --version && \
java --version && \
python3 --version
# Install Picker
ENV BUILD_XSPCOMM_SWIG=python,java
RUN mkdir /workspace && \
cd /workspace && \
git clone https://github.com/XS-MLVP/picker.git --depth=1 && \
wget https://github.com/chipsalliance/verible/releases/download/v0.0-3979-g786edf03/verible-v0.0-3979-g786edf03-linux-static-x86_64.tar.gz && \
tar -xzf verible-v0.0-3979-g786edf03-linux-static-x86_64.tar.gz -C /usr/local/ --strip-components=1 && \
rm verible-v0.0-3979-g786edf03-linux-static-x86_64.tar.gz && \
cd picker && make init && \
make -j$(nproc) && \
make install && \
make clean && \
chmod 755 /usr/local/bin -R
# set user and password
RUN useradd -m -s /bin/bash user && \
echo "user:user" | chpasswd && \
adduser user sudo && \
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
chown user:user -R /workspace && \
chmod 755 /workspace
# Switch to the new user
USER user
# Set the default shell to bash
SHELL ["/bin/bash", "-c"]
# Set working directory
WORKDIR /workspace

View File

@ -1,6 +1,10 @@
export BUILD_XSPCOMM_SWIG?=python
verible_arch := $(shell uname -m)
ifneq ($(verible_arch),x86_64)
verible_arch := $(shell echo $(verible_arch) | sed 's/aarch64/arm64/')
endif
all: clean build
all: clean init build
init:
rm -rf dependence/xcomm
@ -10,9 +14,13 @@ init:
build:
@if ! command -v verible-verilog-format ; then \
echo "verible-verilog-format could not be found"; \
echo "install verible-verilog-format"; \
echo "https://github.com/chipsalliance/verible/releases/tag/v0.0-3428-gcfcbb82b"; \
echo "verible-verilog-format could not be found, please install verible first"; \
echo "you can install verible by following command:"; \
echo "\t$$ wget \"https://github.com/chipsalliance/verible/releases/download/v0.0-4007-g98bdb38a/verible-v0.0-4007-g98bdb38a-linux-static-${verible_arch}.tar.gz\""; \
echo "\t$$ tar -xzf verible-v0.0-4007-g98bdb38a-linux-static-${verible_arch}.tar.gz"; \
echo "\t$$ mv verible-v0.0-4007-g98bdb38a/bin/verible-verilog-format /usr/local/bin/"; \
echo "or you can install in user local directory, remember to add ~/.local/bin to your PATH"; \
echo "\t$$ mv verible-v0.0-4007-g98bdb38a/bin/verible-verilog-format ~/.local/bin/"; \
exit 1; \
fi
cmake . -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_PARALLEL=`nproc` $(ARGS)
@ -21,6 +29,19 @@ build:
install: build
cd build && make install
appimage:
rm -rf AppDir app_image_build
# Build Picker Binary and XSPCOMM library
cmake -DCMAKE_INSTALL_PREFIX=/usr . -Bapp_image_build -DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_PARALLEL=`nproc` $(ARGS)
cd app_image_build && make -j`nproc` && make install DESTDIR=`pwd`/../AppDir
# Intergrate verible
wget "https://github.com/chipsalliance/verible/releases/download/v0.0-4007-g98bdb38a/verible-v0.0-4007-g98bdb38a-linux-static-${verible_arch}.tar.gz" \
-O app_image_build/verible.tar.gz
tar -xzf app_image_build/verible.tar.gz -C app_image_build/
mv app_image_build/verible-v0.0-4007-g98bdb38a/bin/verible-verilog-syntax AppDir/usr/bin/verible-verilog-syntax
# Packing Final AppImage
linuxdeploy --appdir AppDir/ --output appimage --desktop-file src/appimage/picker.desktop --icon-file src/appimage/logo256.png
test: build
./build/bin/picker -h
./build/bin/picker pack -h
@ -64,7 +85,7 @@ test_all_scala:
bash example/CacheSignalCFG/release-verilator.sh --lang scala
clean:
rm -rf temp build dist picker_out*
rm -rf temp build dist picker_out* app_image_build AppDir dependence/xcomm
wheel: clean
cd dependence/xcomm && make wheel

View File

@ -0,0 +1,20 @@
#ifndef PICKER_APPIMAGE_CONFIGURATION_HPP
#define PICKER_APPIMAGE_CONFIGURATION_HPP
#include <string>
namespace picker::appimage {
bool is_running_as_appimage();
void initialize();
std::string get_temporary_path();
std::string get_template_path();
std::string get_picker_lib(const std::string &lib_lang);
} // namespace picker::appimage
#endif // PICKER_APPIMAGE_CONFIGURATION_HPP

View File

@ -14,6 +14,7 @@
#include "inja.hpp"
#include "CLI11.hpp"
#include "version.hpp"
#include "appimage/configuration.hpp"
#include "codegen/cpp.hpp"
#include "codegen/python.hpp"
#include "codegen/java.hpp"
@ -26,6 +27,9 @@
#include "parser/internalcfg.hpp"
#include "parser/verilator_root.hpp"
extern std::map<std::string, std::string> lang_lib_map;
extern std::map<std::string, std::string> display_names;
namespace picker {
extern bool is_debug;
@ -442,6 +446,10 @@ inline std::string get_target_path_from(std::string base, std::initializer_list<
inline std::string get_xcomm_location()
{
if (appimage::is_running_as_appimage()) {
// If running as AppImage, use the appimage configuration to get the xcomm location
return appimage::get_picker_lib("");
}
auto path = get_executable_path();
return get_target_path_from(path, {"../../dependence/xcomm", // 1. search in bulid dir (for dev)
"./picker", // 2. search in current dir
@ -466,6 +474,10 @@ inline std::string get_xcomm_lib(std::string lib_name, std::string &message)
inline std::string get_template_path()
{
if (appimage::is_running_as_appimage()) {
// If running as AppImage, use the appimage configuration to get the template path
return appimage::get_template_path();
}
auto path = get_executable_path();
auto tmp = get_target_path_from(path, {"../../../template", // 1. search in source dir (for dev)
"./template", // 2. search in current dir

View File

@ -1,14 +1,21 @@
include_directories(../include)
set(source_file
picker.cpp
)
add_subdirectory(./codegen)
add_subdirectory(./parser)
add_subdirectory(./appimage)
# executable
set(source_file
picker.cpp
)
message(STATUS "PROJECT_NAME: ${PROJECT_NAME}")
add_executable(${PROJECT_NAME} ${source_file})
target_link_libraries(${PROJECT_NAME} codegen parser)
target_link_libraries(${PROJECT_NAME} codegen_ parser appimage)
install(
TARGETS ${PROJECT_NAME} DESTINATION bin
)
search_libs(ALL_FOUND LIBS libm.a libc.a)
if (ALL_FOUND)
@ -16,3 +23,8 @@ if (ALL_FOUND)
else()
message(WARNING "picker cannot be built statically")
endif()
# # Add AppImage target
# add_custom_target(appimage

View File

@ -0,0 +1,8 @@
include_directories(../../include)
include_directories(../../include/codegen)
include_directories(../../include/parse)
set(source_file
configuration.cpp
)
add_library(appimage ${source_file})

View File

@ -0,0 +1,153 @@
#include <bits/stdc++.h>
#include <bits/fs_fwd.h>
#include "picker.hpp"
namespace picker::appimage {
/*
* AppImage support explanation:
* This file contains functions to initialize the application image configuration, extract the template and library
* directories from the application image.
* The application image configuration is used to store the template and library directories, allowing for easy
access
* and management of these resources.
* How it works:
* 1. The `initialize()` function is called at the start of the application to extract the necessary template and
library
* paths.
* 2. It checks if the template and library directories exist in the file system.
* 3. If they do not exist, it extracts them from the application image.
* 4. The `get_template_path()` function returns the path to the template directory based on the XDG Base Directory
* Specification, which is typically located at "$HOME/.config/picker/$version/template".
* 5. The `get_picker_lib()` function returns the path to the picker library, which is typically located at
* "$HOME/.local/share/picker/lib/$version/lib".
* 6. The `extract_template()` and `extract_library()` functions copy the template and library directories from the
* application image to the user's home directory if they do not already exist.
* 7. The paths are constructed using the environment variable `HOME`
*
* Note:
* - The `GIT_HASH` is a placeholder for the version of the application, which should be replaced with the actual
version
* during the build process.
* - The rendered project structure will use LD_LIBRARY_PATH to find the libraries in the specified path, which is
typically
* located at "$HOME/.local/share/picker/lib/$version/lib".
* - The rendered project structure will use the template path to find the templates, which is typically located at
* "$HOME/.config/picker/$version/template" and defined in the Makefile.
* - Picker will check /proc/self/exe symlink to check whether it is running as an AppImage or not.
*/
bool is_running_as_appimage()
{
// AppImage set APPIMAGE environment variable
const char *appimage_env = getenv("APPIMAGE");
if (appimage_env != nullptr) {
PK_DEBUG("Running as AppImage, APPIMAGE environment variable is set.\n");
return true;
}
return false;
}
std::string get_temporary_path()
{
// Return the path to the fuse temporary directory
// picker -> bin -> usr -> .mount
std::string temp_path = std::filesystem::read_symlink("/proc/self/exe").parent_path().parent_path().parent_path().string();
PK_DEBUG("AppImage extracts files to temporary path: %s\n", temp_path.c_str());
return temp_path;
}
// Extract the template directory from the application image
void extract_template()
{
// get the directory of the picker binary
std::string picker_dir = get_temporary_path() + "/usr/share/picker/";
// copy template directory from the picker binary directory to the user's home directory
std::string user_home = getenv("HOME") ? getenv("HOME") : ".";
std::string template_path = user_home + "/.config/picker/" + GIT_HASH + "/template";
if (!std::filesystem::exists(template_path)) { std::filesystem::create_directories(template_path); }
// copy the template directory from the picker binary directory to the user's home directory
std::filesystem::copy(picker_dir + "template", template_path,
std::filesystem::copy_options::recursive | std::filesystem::copy_options::overwrite_existing);
PK_DEBUG("Template directory extracted to: %s\n", template_path.c_str());
}
// Extract the library directory from the application image
void extract_library()
{
// get self binary path from /proc/self/exe symlink
std::string picker_path = std::filesystem::read_symlink("/proc/self/exe").string();
// get the directory of the picker binary
std::string picker_dir = std::filesystem::path(picker_path).parent_path().parent_path().string() + "/share/picker/";
// copy library directory from the picker binary directory to the user's home directory
std::string user_home = getenv("HOME") ? getenv("HOME") : ".";
// iterate std::map lang_lib_map to process each language library
for (const auto &lang_lib : lang_lib_map) {
std::string lang = lang_lib.first;
std::string lib = lang_lib.second;
std::string lib_path = user_home + "/.local/share/picker/lib/" + GIT_HASH + "/" + lib;
if (!std::filesystem::exists(lib_path) && std::filesystem::exists(picker_dir + lib)) {
std::filesystem::create_directories(lib_path);
// copy the library directory from the picker binary directory to the user's home directory
std::filesystem::copy(picker_dir + lib, lib_path,
std::filesystem::copy_options::recursive
| std::filesystem::copy_options::overwrite_existing);
PK_DEBUG("Library directory for %s extracted to: %s\n", lang.c_str(), lib_path.c_str());
}
}
}
void initialize()
{
// Initialize the application image configuration
// This function is called at the start of the application to extract the necessary template and library paths
// Check if the template directory is exist in file system
std::string template_path = get_template_path();
if (std::filesystem::exists(template_path)) {
PK_DEBUG("Template path: %s\n", template_path.c_str());
} else {
PK_MESSAGE("Template path %s is not found", template_path.c_str());
PK_MESSAGE("Extract the template directory from the application image");
extract_template();
}
// Check if the library directory is exist in file system
std::string lib_path = get_picker_lib("lib");
if (std::filesystem::exists(lib_path)) {
PK_DEBUG("Library path: %s\n", lib_path.c_str());
} else {
PK_MESSAGE("Library path %s is not found", lib_path.c_str());
PK_MESSAGE("Extract the library directory from the application image");
extract_library();
}
PK_DEBUG("Application image configuration initialized.\n");
return;
}
std::string get_template_path()
{
// Return the path to the template directory
// It's extracted from the application image follow XDG Base Directory Specification such as
// "$HOME/.config/picker/$version/template". For now, it returns a hardcoded path, but it can be modified to search
// in specific directories
std::string user_home = getenv("HOME") ? getenv("HOME") : ".";
std::string template_path = user_home + "/.config/picker/" + GIT_HASH + "/template";
return template_path;
}
std::string get_picker_lib(const std::string &lib_lang)
{
// This function should return the path to the picker library, default should be in xspcomm.
// For now, it returns a hardcoded path, but it can be modified to search in specific directories
std::string user_home = getenv("HOME") ? getenv("HOME") : ".";
std::string lib_path = user_home + "/.local/share/picker/lib/" + GIT_HASH + "/" + lib_lang;
return lib_path;
}
} // namespace picker::appimage

BIN
src/appimage/logo256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -0,0 +1,8 @@
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=picker
Icon=logo256
Terminal=true
Exec=picker
Categories=Development

View File

@ -14,4 +14,4 @@ set(source_file
mem_direct.cpp
)
add_library(codegen ${source_file})
add_library(codegen_ STATIC ${source_file})

View File

@ -152,18 +152,20 @@ namespace picker { namespace codegen {
// Render lib filelist
gen_filelist(files, ifilelists, ofilelist);
data["__VCS_CLOCK_PERIOD_HIGH__"] = vcs_clock_period_h;
data["__VCS_CLOCK_PERIOD_LOW__"] = vcs_clock_period_l;
data["__VERBOSE__"] = opts.verbose ? "ON" : "OFF";
data["__EXAMPLE__"] = opts.example ? "ON" : "OFF";
data["__COVERAGE__"] = opts.coverage ? "ON" : "OFF";
data["__CHECKPOINTS__"] = opts.checkpoints ? "ON" : "OFF";
data["__VPI__"] = opts.vpi ? "ON" : "OFF";
data["__RW_TYPE__"] = opts.rw_type == picker::SignalAccessType::MEM_DIRECT ? "MEM_DIRECT" : "DPI";
data["__TARGET_LANGUAGE__"] = opts.language;
data["__FILELIST__"] = ofilelist;
data["__VCS_CLOCK_PERIOD_HIGH__"] = vcs_clock_period_h;
data["__VCS_CLOCK_PERIOD_LOW__"] = vcs_clock_period_l;
data["__VERBOSE__"] = opts.verbose ? "ON" : "OFF";
data["__EXAMPLE__"] = opts.example ? "ON" : "OFF";
data["__COVERAGE__"] = opts.coverage ? "ON" : "OFF";
data["__CHECKPOINTS__"] = opts.checkpoints ? "ON" : "OFF";
data["__VPI__"] = opts.vpi ? "ON" : "OFF";
data["__RW_TYPE__"] = opts.rw_type == picker::SignalAccessType::MEM_DIRECT ? "MEM_DIRECT" : "DPI";
data["__TARGET_LANGUAGE__"] = opts.language;
data["__FILELIST__"] = ofilelist;
data["__LIB_DPI_FUNC_NAME_HASH__"] = std::string(lib_random_hash);
data["__GENERATOR_PICKER_PATH__"] = std::filesystem::read_symlink("/proc/self/exe").string();
data["__GENERATOR_PICKER_PATH__"] = appimage::is_running_as_appimage() ?
std::filesystem::read_symlink("/proc/self/exe").string() :
std::string(getenv("APPIMAGE"));
data["__GENERATOR_TEMPLATE_PATH__"] = std::filesystem::path(opts.source_dir).string();
// Render lib files

View File

@ -20,7 +20,9 @@ namespace picker { namespace parser {
std::vector<std::string> tokens;
std::string token;
std::istringstream tokenStream(value);
while (std::getline(tokenStream, token, ' ')) { tokens.push_back(token); }
while (tokenStream >> token) {
tokens.push_back(token);
}
if (tokens.size() == 2) {
pin.logic_pin = prefix + "." + tokens[1];
pin.logic_pin_type = tokens[0];
@ -31,7 +33,6 @@ namespace picker { namespace parser {
int pos = tokens[1].find(":");
pin.logic_pin_hb = std::stoi(tokens[1].substr(1, pos - 1));
pin.logic_pin_lb = std::stoi(tokens[1].substr(pos + 1, tokens[1].length() - pos - 2));
} else {
PK_MESSAGE("error: unknown node type");
}
@ -39,6 +40,7 @@ namespace picker { namespace parser {
} else {
PK_MESSAGE("error: unknown node type");
}
return;
}
std::vector<picker::sv_signal_define> internal(std::string internal_pin_filename)

View File

@ -135,7 +135,9 @@ namespace picker { namespace parser {
for (auto f : files) {
std::string fpath = "/tmp/" + std::filesystem::path(f).filename().string() + std::string(lib_random_hash)
+ picker::get_node_uuid() + ".json";
std::string syntax_cmd = "verible-verilog-syntax --export_json --printtokens " + f + "> " + fpath;
std::string syntax_cmd =
std::string(appimage::is_running_as_appimage() ? appimage::get_temporary_path() + "/usr/bin/" : "")
+ "verible-verilog-syntax --export_json --printtokens " + f + "> " + fpath;
exec(syntax_cmd.c_str());
auto mjson = nlohmann::json::parse(read_file(fpath));
std::vector<std::string> module_list;

View File

@ -8,6 +8,14 @@ picker::main_opts main_opts;
picker::export_opts export_opts;
picker::pack_opts pack_opts;
char *picker::lib_random_hash;
std::map<std::string, std::string> lang_lib_map = {{"cpp", "lib"},
{"java", "java/xspcomm-java.jar"},
{"scala", "scala/xspcomm-scala.jar"},
{"python", "python"},
{"golang", "golang"},
{"lua", "lua/luaxspcomm.so"}};
std::map<std::string, std::string> display_names = {{"cpp", "Cpp"}, {"java", "Java"}, {"scala", "Scala"},
{"python", "Python"}, {"golang", "Golang"}, {"lua", "Lua"}};
namespace picker {
bool is_debug = false;
@ -212,14 +220,6 @@ int show_xcom_lib_location()
int check_picker_support()
{
std::map<std::string, std::string> lang_lib_map = {{"cpp", "lib"},
{"java", "java/xspcomm-java.jar"},
{"scala", "scala/xspcomm-scala.jar"},
{"python", "python"},
{"golang", "golang"},
{"lua", "lua/luaxspcomm.so"}};
std::map<std::string, std::string> display_names = {{"cpp", "Cpp"}, {"java", "Java"}, {"scala", "Scala"},
{"python", "Python"}, {"golang", "Golang"}, {"lua", "Lua"}};
std::string err_message;
// check if the xspcomm lib is available
@ -274,6 +274,12 @@ int check_picker_support()
int main(int argc, char **argv)
{
check_debug();
if(picker::appimage::is_running_as_appimage()) {
PK_MESSAGE("Running as AppImage");
picker::appimage::initialize();
} else {
PK_MESSAGE("Running as normal executable");
}
CLI::App app{"XDut Generate. \n"
"Convert DUT(*.v/*.sv) to C++ DUT libs.\n"};
set_options_main(app);
@ -334,8 +340,8 @@ int main(int argc, char **argv)
exit(0);
}
std::vector<picker::sv_module_define> sv_module_result;
std::vector<picker::sv_signal_define> internal_sginal_result;
std::vector<picker::sv_module_define> sv_module_result; // sv signal pins
std::vector<picker::sv_signal_define> internal_sginal_result; // configuration signal pings
nlohmann::json signal_tree_json;
picker::parser::sv(export_opts, sv_module_result);

View File

@ -23,8 +23,10 @@ copy_xspcomm:
endif
compile: copy_xspcomm
@echo "start build wrapper at $(shell date)"
@cmake . -Bbuild
@cmake --build build --config Release --parallel `nproc`
@echo "end build wrapper at $(shell date)"
clean:
@rm -rf *.fst *.vcd *.fsdb *.log *.key *.dat build

View File

@ -91,9 +91,9 @@ function(XSPTarget)
PRIVATE
-L./
-L${VCS_HOME}/linux64/lib
-Wl,-rpath={{__XSPCOMM_LIB__}}
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
-Wl,-rpath={{__XSPCOMM_LIB__}}
-Wl,-rpath=${VCS_HOME}/linux64/lib
-no-pie
-Wl,--no-as-needed

View File

@ -44,9 +44,9 @@ function(XSPTarget)
add_executable(${ExecutableName} UT_${RTLModuleName}.cpp)
target_link_libraries(${ExecutableName} UT${RTLModuleName} xspcomm ${CustomLibs} ${CMAKE_DL_LIBS})
target_link_options(${ExecutableName} PRIVATE
-Wl,-rpath={{__XSPCOMM_LIB__}}
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
-Wl,-rpath={{__XSPCOMM_LIB__}}
${CustomLinkOptions})
endfunction()

View File

@ -90,9 +90,9 @@ function(XSGolangTarget)
PRIVATE
-L./
-L${VCS_HOME}/linux64/lib
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
-Wl,-rpath={{__XSPCOMM_LIB__}}
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
-Wl,-rpath=${VCS_HOME}/linux64/lib
-no-pie
-Wl,--no-as-needed

View File

@ -42,9 +42,9 @@ function(XSGolangTarget)
target_link_libraries(UT_${PROJECT_NAME} PRIVATE UT${RTLModuleName} xspcomm ${CustomLibs} ${CMAKE_DL_LIBS})
target_link_options(UT_${PROJECT_NAME} PRIVATE
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
-Wl,-rpath={{__XSPCOMM_LIB__}}
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
${CustomLinkOptions})
set_property(TARGET UT_${PROJECT_NAME} PROPERTY SWIG_COMPILE_OPTIONS -module UT_${PROJECT_NAME})

View File

@ -83,7 +83,7 @@ function(XSJavaTarget)
swig_add_library(UT_${PROJECT_NAME} LANGUAGE java SOURCES dut.i)
set_target_properties(UT_${PROJECT_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${JAR_SOURCE_DIR})
target_link_libraries(UT_${PROJECT_NAME} PRIVATE UT${RTLModuleName} DPI${RTLModuleName} xspcomm ${CustomLibs} ${CMAKE_DL_LIBS})
search_libs(ALL_FOUND LIBS zerosoft_rt_stubs m c pthread numa dl)
target_link_options(
@ -91,9 +91,9 @@ function(XSJavaTarget)
PRIVATE
-L./
-L${VCS_HOME}/linux64/lib
-Wl,-rpath={{__XSPCOMM_LIB__}}
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
-Wl,-rpath={{__XSPCOMM_LIB__}}
-Wl,-rpath=${VCS_HOME}/linux64/lib
-no-pie
-Wl,--no-as-needed

View File

@ -45,9 +45,9 @@ function(XSJavaTarget)
target_link_libraries(UT_${PROJECT_NAME} PRIVATE UT${RTLModuleName} xspcomm ${CustomLibs} ${CMAKE_DL_LIBS})
target_link_options(UT_${PROJECT_NAME} PRIVATE
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
-Wl,-rpath={{__XSPCOMM_LIB__}}
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
${CustomLinkOptions})
set_property(TARGET UT_${PROJECT_NAME} PROPERTY SWIG_COMPILE_OPTIONS -package com.ut.{{__TOP_MODULE_NAME__}})

View File

@ -45,6 +45,17 @@ set_target_properties(
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS ON
OUTPUT_NAME "UT${ModuleName}")
add_custom_command(
TARGET ${ModuleName}
PRE_BUILD
COMMAND bash -c "date '+start +%s'"
)
add_custom_command(
TARGET ${ModuleName}
POST_BUILD
COMMAND bash -c "date '+end +%s'"
)
# Create release directory and Copy output files
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/UT_${ModuleName})

View File

@ -20,21 +20,28 @@ all: release
compile:
mkdir -p build
cp pli.tab build/pli.tab
cmake . -Bbuild -DSIMULATOR=$(SIMULATOR) -DTRACE=$(TRACE) -DPROJECT=$(PROJECT) -DCMAKE_BUILD_PARALLEL=$(NPROC) -DRW_TYPE=$(RW_TYPE)
cmake --build build --config release --parallel $(NPROC)
@echo -n "[TIME LOG] verilator generate START: " && date +%s.%3N
/usr/bin/time cmake . -Bbuild -DSIMULATOR=$(SIMULATOR) -DTRACE=$(TRACE) -DPROJECT=$(PROJECT) -DCMAKE_BUILD_PARALLEL=$(NPROC) -DRW_TYPE=$(RW_TYPE)
@echo -n "[TIME LOG] verilator generate END: " && date +%s.%3N
/usr/bin/time cmake --build build --config release --parallel $(NPROC)
@echo -n "[TIME LOG] verilator build END: " && date +%s.%3N
ifeq ($(RW_TYPE), MEM_DIRECT)
ifeq ($(SIMULATOR), verilator)
# file exsit check with Makefile
ifeq ($(wildcard build/DPI{{__TOP_MODULE_NAME__}}/V{{__TOP_MODULE_NAME__}}___024root.h),)
@echo -n "[TIME LOG] mem_direct export START: " && date +%s.%3N
@rm -rf mem_direct
@{{__GENERATOR_PICKER_PATH__}} export build/DPI{{__TOP_MODULE_NAME__}}/V{{__TOP_MODULE_NAME__}}___024root.h \
--source_dir {{__GENERATOR_TEMPLATE_PATH__}}/mem_direct --target_dir ./mem_direct \
--source_module_name {{__TOP_MODULE_NAME__}}
@echo -n "[TIME LOG] mem_direct export END: " && date +%s.%3N
endif
@echo -n "[TIME LOG] mem_direct gen START: " && date +%s.%3N
@cd mem_direct && make -j$(NPROC) TOP_NAME={{__TOP_MODULE_NAME__}}
@./mem_direct/export.bin > mem_direct/{{__TOP_MODULE_NAME__}}_offset.yaml
@rm -rf mem_direct_tmp
@echo -n "[TIME LOG] mem_direct gen END: " && date +%s.%3N
endif
endif
@ -43,6 +50,7 @@ release: compile
@cp dut_base.hpp ${TARGET}/dut_base.hpp
@cp mem_direct/{{__TOP_MODULE_NAME__}}_offset.yaml ${TARGET}/{{__TOP_MODULE_NAME__}}_offset.yaml 2>/dev/null|| true
@make -f mk/${TLANG}.mk
ifeq ($(VERBOSE), OFF) # if VERBOSE is OFF
@rm -rf build cmake cpp mk python java scala golang lua CMakeLists.txt dut_base.* 2>/dev/null|| true

View File

@ -53,6 +53,7 @@ if(SIMULATOR STREQUAL "verilator")
set(VERILATE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/DPI${ModuleName})
include_directories(${VERILATE_DIRECTORY})
add_library(DPI${ModuleName} STATIC)
verilate(
DPI${ModuleName}

View File

@ -90,9 +90,9 @@ function(XSPyTarget)
PRIVATE
-L./
-L${VCS_HOME}/linux64/lib
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
-Wl,-rpath={{__XSPCOMM_LIB__}}
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
-Wl,-rpath=${VCS_HOME}/linux64/lib
-no-pie
-Wl,--no-as-needed

View File

@ -42,9 +42,9 @@ function(XSPyTarget)
target_link_libraries(_UT_${PROJECT_NAME} PRIVATE UT${RTLModuleName} xspcomm ${CustomLibs} ${CMAKE_DL_LIBS})
target_link_options(_UT_${PROJECT_NAME} PRIVATE
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
-Wl,-rpath={{__XSPCOMM_LIB__}}
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
${CustomLinkOptions})

View File

@ -21,11 +21,13 @@ copy_xspcomm:
endif
compile: copy_xspcomm
@echo "start build wrapper at" && date
cmake . -Bbuild
cmake --build build --config Debug --parallel `nproc`
@cp build/_${TARGET}.so .
@cp build/lib${TARGET}.py .
@touch ../__init__.py
@echo "end build wrapper at" && date
clean:
@rm -rf *.fst *.vcd *.fsdb *.log *.key build

View File

@ -90,9 +90,9 @@ function(XSPyTarget)
PRIVATE
-L./
-L${VCS_HOME}/linux64/lib
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
-Wl,-rpath={{__XSPCOMM_LIB__}}
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
-Wl,-rpath=${VCS_HOME}/linux64/lib
-no-pie
-Wl,--no-as-needed

View File

@ -42,9 +42,9 @@ function(XSPyTarget)
target_link_libraries(UT_${PROJECT_NAME} PRIVATE UT${RTLModuleName} xspcomm ${CustomLibs} ${CMAKE_DL_LIBS})
target_link_options(UT_${PROJECT_NAME} PRIVATE
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
-Wl,-rpath={{__XSPCOMM_LIB__}}
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
${CustomLinkOptions})

View File

@ -93,9 +93,9 @@ function(XSScalaTarget)
PRIVATE
-L./
-L${VCS_HOME}/linux64/lib
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
-Wl,-rpath={{__XSPCOMM_LIB__}}
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
-Wl,-rpath=${VCS_HOME}/linux64/lib
-no-pie
-Wl,--no-as-needed

View File

@ -45,9 +45,9 @@ function(XSScalaTarget)
target_link_libraries(UT_${PROJECT_NAME} PRIVATE UT${RTLModuleName} xspcomm ${CustomLibs} ${CMAKE_DL_LIBS})
target_link_options(UT_${PROJECT_NAME} PRIVATE
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
-Wl,-rpath={{__XSPCOMM_LIB__}}
-Wl,-rpath=~/.local/lib
-Wl,-rpath=/usr/local/lib
${CustomLinkOptions})
set_property(TARGET UT_${PROJECT_NAME} PROPERTY SWIG_COMPILE_OPTIONS -package com.ut.{{__TOP_MODULE_NAME__}})