aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Fan <alex.fan.q@gmail.com>2022-06-09 23:54:47 +1000
committerYixun Lan <dlan@gentoo.org>2022-07-09 17:49:01 +0800
commit7a3751af7b4c0043ad4e5ef675d5e72c00217d59 (patch)
tree6701d9d12d7e37c2044f4dfb0ff1bec783371ec7
parentsys-apps/kexec-tools: keyword 2.0.24 for ~riscv (diff)
downloadriscv-7a3751af7b4c0043ad4e5ef675d5e72c00217d59.tar.gz
riscv-7a3751af7b4c0043ad4e5ef675d5e72c00217d59.tar.bz2
riscv-7a3751af7b4c0043ad4e5ef675d5e72c00217d59.zip
app-emulation/nemu-xiangshan: initial import
scripts/gcpt_restore requires cross-compilation, not built by ebuild for now Signed-off-by: Alex Fan <alex.fan.q@gmail.com> Signed-off-by: Yixun Lan <dlan@gentoo.org>
-rw-r--r--app-emulation/nemu-xiangshan/files/nemu-xiangshan-add-syncconfig.patch14
-rw-r--r--app-emulation/nemu-xiangshan/files/nemu-xiangshan-disable-git-tracking.patch13
-rw-r--r--app-emulation/nemu-xiangshan/metadata.xml8
-rw-r--r--app-emulation/nemu-xiangshan/nemu-xiangshan-9999.ebuild124
4 files changed, 159 insertions, 0 deletions
diff --git a/app-emulation/nemu-xiangshan/files/nemu-xiangshan-add-syncconfig.patch b/app-emulation/nemu-xiangshan/files/nemu-xiangshan-add-syncconfig.patch
new file mode 100644
index 0000000..537c3de
--- /dev/null
+++ b/app-emulation/nemu-xiangshan/files/nemu-xiangshan-add-syncconfig.patch
@@ -0,0 +1,14 @@
+diff --git a/scripts/config.mk b/scripts/config.mk
+index 7b85f49..f8d994e 100644
+--- a/scripts/config.mk
++++ b/scripts/config.mk
+@@ -26,6 +26,9 @@ $(MCONF):
+ $(FIXDEP):
+ $(Q)$(MAKE) $(silent) -C $(FIXDEP_PATH)
+
++syncconfig: $(CONF) $(FIXDEP)
++ $(Q)$(CONF) $(silent) --syncconfig $(Kconfig)
++
+ menuconfig: $(MCONF) $(CONF) $(FIXDEP)
+ $(Q)$(MCONF) $(Kconfig)
+ $(Q)$(CONF) $(silent) --syncconfig $(Kconfig)
diff --git a/app-emulation/nemu-xiangshan/files/nemu-xiangshan-disable-git-tracking.patch b/app-emulation/nemu-xiangshan/files/nemu-xiangshan-disable-git-tracking.patch
new file mode 100644
index 0000000..80ff5c5
--- /dev/null
+++ b/app-emulation/nemu-xiangshan/files/nemu-xiangshan-disable-git-tracking.patch
@@ -0,0 +1,13 @@
+diff --git a/scripts/git.mk b/scripts/git.mk
+index 5400e61..8e0a353 100644
+--- a/scripts/git.mk
++++ b/scripts/git.mk
+@@ -7,8 +7,4 @@ GITFLAGS = -q --author='tracer-ics2021 <tracer@njuics.org>' --no-verify --allow-
+
+ # prototype: git_commit(msg)
+ define git_commit
+- -@git add $(NEMU_HOME)/.. -A --ignore-errors
+- -@while (test -e .git/index.lock); do sleep 0.1; done
+- -@(echo "> $(1)" && echo $(STUID) && hostnamectl && uptime) | git commit -F - $(GITFLAGS)
+- -@sync
+ endef
diff --git a/app-emulation/nemu-xiangshan/metadata.xml b/app-emulation/nemu-xiangshan/metadata.xml
new file mode 100644
index 0000000..decc6f6
--- /dev/null
+++ b/app-emulation/nemu-xiangshan/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <!-- maintainer-needed -->
+ <upstream>
+ <remote-id type="github">OpenXiangShan/NEMU</remote-id>
+ </upstream>
+</pkgmetadata>
diff --git a/app-emulation/nemu-xiangshan/nemu-xiangshan-9999.ebuild b/app-emulation/nemu-xiangshan/nemu-xiangshan-9999.ebuild
new file mode 100644
index 0000000..fb8c93e
--- /dev/null
+++ b/app-emulation/nemu-xiangshan/nemu-xiangshan-9999.ebuild
@@ -0,0 +1,124 @@
+# Copyright 2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+DISABLE_AUTOFORMATTING="true"
+DOC_CONTENTS='
+ nemu-xiangshan mini config HOWTO
+
+Note: nemu-xiangshan is configurable via mconf, like the linux kernel.
+Without user config, this ebuild will target minimum riscv64
+You are encouraged to configure it on your own. Here are a couple of ways:
+
+1) USE="-savedconfig" and set/unset the remaining flags to obtain the features
+you want, and possibly a lot more.
+
+2) You can create your own configuration file by doing:
+
+FEATURES="keepwork" USE="savedconfig -*" emerge nemu-xiangshan
+cd /var/tmp/portage/app-emulation/nemu-xiangshan*/work/nemu-xiangshan*
+make menuconfig
+
+Now configure nemu-xiangshan as you want. Finally save your config file:
+
+cp config/.config /etc/portage/savedconfig/app-emulation/nemu-xiangshan-${PV}
+
+where ${PV} is the current version. You can then run emerge again with
+your configuration by doing:
+
+USE="savedconfig" emerge nemu-xiangshan
+'
+
+inherit savedconfig readme.gentoo-r1
+
+DESCRIPTION="NJU EMUlator, a full system x86/mips32/riscv32/riscv64 emulator for teaching"
+HOMEPAGE="https://github.com/OpenXiangShan/NEMU"
+
+# no license specified in upstream
+LICENSE="GPL-2"
+SLOT="0"
+IUSE="savedconfig"
+
+EGIT_REPO_URI="https://github.com/OpenXiangShan/NEMU.git"
+EGIT_SUBMODULES=(
+ ready-to-run
+)
+inherit git-r3
+
+DEPEND="
+ sys-apps/dtc
+ media-libs/libsdl2
+ sys-libs/zlib
+ sys-libs/readline:=
+"
+RDEPEND="${DEPEND}"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-disable-git-tracking.patch
+ "${FILESDIR}"/${PN}-add-syncconfig.patch
+)
+
+QA_PREBUILT="
+ usr/share/${PN}/ready-to-run/coremark-2-iteration.bin
+ usr/share/${PN}/ready-to-run/linux.bin
+ usr/share/${PN}/ready-to-run/riscv64-nemu-interpreter-dual-so
+ usr/share/${PN}/ready-to-run/linux-0xa0000.bin
+ usr/share/${PN}/ready-to-run/microbench.bin
+ usr/share/${PN}/ready-to-run/riscv64-nemu-interpreter-so
+"
+
+src_prepare() {
+ default
+ sed -i -e "/^CCACHE/d" scripts/build.mk || die
+}
+
+src_configure() {
+ export NEMU_HOME="${PWD}"
+ if use savedconfig; then
+ restore_config .config
+ if [[ -f .config ]]; then
+ ewarn "Using saved config"
+ else
+ die "No saved config, please consider generate one with 'make menuconfig'"
+ fi
+ else
+ elog "No saved config, seeding minimum riscv64"
+ cp configs/riscv64-xs_defconfig .config || die
+ fi
+
+ emake -j1 syncconfig < <(yes '') > /dev/null
+}
+
+src_compile() {
+ export NEMU_HOME="${PWD}"
+ emake
+ # TODO: require cross-compilation
+ # cd resource/gcpt_restore || die
+ # emake
+}
+
+src_install() {
+ dodoc README.md
+ dodoc -r resource/debian
+ dodoc -r resource/sdcard
+ readme.gentoo_create_doc
+
+ insinto "/usr/share/${PN}/"
+ rm -r ready-to-run/.git || die
+ doins -r ready-to-run
+ # Disallow stripping of prebuilt images
+ dostrip -x ${QA_PREBUILT}
+
+ cd build || die
+ for binary in $(ls -1 2>/dev/null); do
+ IFS='-' read -a name <<<"${binary}" || die
+ if [[ "${name[1]}" == 'nemu' ]]; then
+ newbin "${binary}" "${name[0]}-nemu-xiangshan-${name[@]:2}"
+ fi
+ done
+}
+
+pkg_postinst() {
+ readme.gentoo_print_elog
+}