This commit is contained in:
Jiuyue Ma 2025-04-22 10:01:49 +08:00 committed by GitHub
commit 70f302d74c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 110 additions and 2 deletions

3
.gitignore vendored
View File

@ -321,6 +321,9 @@ src_managed/
project/boot/
project/plugins/project/
# mill specific
.mill-jvm-opts
# Scala-IDE specific
.scala_dependencies
.worksheet

57
Dockerfile Normal file
View File

@ -0,0 +1,57 @@
#***************************************************************************************
# Copyright (c) 2025 Beijing Institute of Open Source Chip (BOSC)
#
# XiangShan is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
# http://license.coscl.org.cn/MulanPSL2
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
#
# See the Mulan PSL v2 for more details.
#***************************************************************************************
FROM verilator/verilator:latest
# override ENTRYPOINT in verilator image
ENTRYPOINT [ "/bin/bash" ]
#
# Prepare envrionments for chisel/mill
#
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive \
&& apt-get install --no-install-recommends -y \
default-jdk \
python3 \
curl \
make \
time \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
#
# Mill
#
RUN curl -L https://github.com/com-lihaoyi/mill/releases/download/0.12.3/0.12.3 -o /usr/bin/mill \
&& chmod +x /usr/bin/mill \
&& mill --version
#
# XiangShan workspace
#
WORKDIR /work
VOLUME /work/out
VOLUME /work/build
#
# download IvyDeps
#
RUN --mount=type=bind,source=.,target=/work,readonly \
--mount=type=tmpfs,destination=/work/out,rw <<EOF
mill -i _.resolvedIvyDeps
mill -i utility.compile
EOF

View File

@ -316,3 +316,51 @@ include Makefile.test
include src/main/scala/device/standalone/standalone_device.mk
.PHONY: verilog sim-verilog emu clean help init bump bsp $(REF_SO)
#
# Docker Support
#
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g")
XSDEV_IMAGE := OpenXiangShan/xsdev$(if $(GIT_BRANCH_CLEAN),:$(GIT_BRANCH_CLEAN))
HAVE_XSDEV_IMAGE := $(shell docker image inspect --format '{{.ID}}' $(XSDEV_IMAGE) 2> /dev/null)
DOCKER_RUN = docker run -it --rm -e IN_XSDEV_DOCKER=y -e NOOP_HOME=/work \
-v .:/work:ro \
-v ./out:/work/out:rw \
-v ./build:/work/build:rw \
$(XSDEV_IMAGE) $(1) || exit 1
# run all targets in docker
check_docker_env:
@mkdir -p out build;
@if [ -z "$(IN_XSDEV_DOCKER)" ]; then \
echo "Switching to Docker environment..."; \
$(call DOCKER_RUN, -c "make $(MAKECMDGOALS)"); \
exit 0; \
else \
echo; \
fi
$(filter-out image sh,$(MAKECMDGOALS)): $(if $(HAVE_XSDEV_IMAGE),check_docker_env)
@$(MAKE) $(MAKECMDGOALS)
# build docker image
HTTP_PROXY ?= http://172.28.9.101:1091
PROXY_HOST := $(shell echo $(HTTP_PROXY) | sed -e 's|http://\(.*\):\(.*\)|\1|')
PROXY_PORT := $(shell echo $(HTTP_PROXY) | sed -e 's|http://\(.*\):\(.*\)|\2|')
.mill-jvm-opts:
@{ echo -Dhttp.proxyHost=$(PROXY_HOST); \
echo -Dhttp.proxyPort=$(PROXY_PORT); \
echo -Dhttps.proxyHost=$(PROXY_HOST); \
echo -Dhttps.proxyPort=$(PROXY_PORT); } > $@
__prep_proxy: .mill-jvm-opts
image: $(if $(HTTP_PROXY),__prep_proxy) init
@mkdir -p out
docker build -t $(XSDEV_IMAGE) \
$(if $(HTTP_PROXY),--build-arg HTTP_PROXY=$(HTTP_PROXY) \
--build-arg HTTPS_PROXY=$(HTTP_PROXY)) .
# run interactive shell
sh:
$(if $(HAVE_XSDEV_IMAGE),,\
$(error Docker unavailable or "$(XSDEV_IMAGE)" image not exist))
@$(call DOCKER_RUN)
.PHONY: image __prep_proxy sh

View File

@ -100,7 +100,7 @@ make idea
* Set environment variable `NEMU_HOME` to the **absolute path** of the [NEMU project](https://github.com/OpenXiangShan/NEMU).
* Set environment variable `NOOP_HOME` to the **absolute path** of the XiangShan project.
* Set environment variable `AM_HOME` to the **absolute path** of the [AM project](https://github.com/OpenXiangShan/nexus-am).
* Install `mill`. Refer to [the Manual section in this guide](https://mill-build.org/mill/0.11.11/Scala_Installation_IDE_Support.html#_bootstrap_scripts).
* Install `mill`. Refer to [the Manual section in this guide](https://mill-build.org/mill/cli/installation-ide.html#_bootstrap_scripts).
* Clone this project and run `make init` to initialize submodules.
### Run with simulator

View File

@ -58,7 +58,7 @@ trait HasChisel extends SbtModule {
override def scalacOptions = super.scalacOptions() ++
Agg("-language:reflectiveCalls", "-Ymacro-annotations", "-Ytasty-reader")
override def ivyDeps = super.ivyDeps() ++ Agg(chiselIvy.get)
override def ivyDeps = super.ivyDeps() ++ Agg(chiselIvy.get) ++ Agg(ivy"org.chipsalliance:llvm-firtool:1.62.1")
override def scalacPluginIvyDeps = super.scalacPluginIvyDeps() ++ Agg(chiselPluginIvy.get)
}