然后从安装步骤的【第9步】开始测试scala和chisel是否能正常使用即可
然后给Ubuntu换个镜像,方便下载
注意换源后使用apt-get update更新下
安装vim(可以不做)
这里安装Vim是我感觉Ubuntu自带的vi编辑器似乎有问题,因为我按i进入【插入模式】并没有提示,所以安装vim进行替代。
只关心Chisel安装的可以跳过这一步。
apt install vim
sudo vim /etc/vim/vimrc
#在vimrc文件结尾处添加
#显示行数
set number
#自动缩进
set autoindent
#光标高亮
set cursorline
set ruler
#Tab默认4格
set tabstop=4
如果在apt换源时报错:
The following signatures couldn’t be verified because the public key
is not available
执行
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys [报错最后给出的key]
例如:5523BAEEB01FA116
sudo apt-get install default-jdk
安装完成后使用java -version
测试结果为:
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee /etc/apt/sources.list.d/sbt_old.list
#curl依赖libcurl4
apt-get purge libcurl4
apt-get install curl
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo apt-key add
sudo apt-get update
sudo apt-get install sbt
安装完成后使用sbt --version
查看版本:
#进入用户目录
cd ~
#下面有一个.sbt目录
cd .sbt
在.sbt目录下创建一个名为repositories的文件,不用后缀
[repositories]
local
aliyun: https://maven.aliyun.com/repository/central/
sbt-plugin-repo: https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
然后在/usr/share/sbt/conf/sbtopts
文件的最后添加-Dsbt.override.build.repos=true
安装VS Code并配置插件
首先在软件商店中安装VS Code,打开VS Code,在View->extensions中安装Scala(Syntax)和Scala(Metals)
安装make
apt install make
object HelloScala{
def main(args:Array[String]):Unit={
println("helloscala")
}
}
使用sbt run进行构建,会输出helloworld
git clone https://github.com/schoeberl/chisel-examples.git
cd chisel-examples/hello-world
make
sbt test
测试成功:
该脚本完成了更改Ubuntu下载源、java11安装、更改sbt下载源、下载sbt
#备份sources.list
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
#apt换源
echo "deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse" > /etc/apt/sources.list
sudo apt-get -qq update
#安装jdk
sudo apt-get install -yqq default-jdk
java -version
#安装sbt构建工具
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee /etc/apt/sources.list.d/sbt_old.list
sudo apt-get -qq purge libcurl4
sudo apt-get -qq install curl
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo apt-key add
sudo apt-get -qq update
sudo apt-get -qq install sbt
#sbt换源
mkdir ~/.sbt
cd ~/.sbt
echo "[repositories]
local
aliyun: https://maven.aliyun.com/repository/central/
sbt-plugin-repo: https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]" > repositories
echo "-Dsbt.override.build.repos=true" >> /usr/share/sbt/conf/sbtopts
#安装make
sudo apt install -yqq make
##sbt版本测试
sbt --version