From 654ae5b8a4fa4b8f7be1dade607e392ea363877d Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Fri, 20 Mar 2020 15:07:41 +0100 Subject: [PATCH] Added compile script for Yosys in docker (for Debian 10). --- .../docker/debian-10/Dockerfile.coriolis | 2 +- bootstrap/docker/debian-10/Dockerfile.system | 5 +- .../docker/debian-10/root/socInstaller.py | 111 ++++++++++-------- bootstrap/socInstaller.py | 111 ++++++++++-------- bootstrap/yosysInstaller.sh | 12 ++ 5 files changed, 147 insertions(+), 94 deletions(-) create mode 100755 bootstrap/yosysInstaller.sh diff --git a/bootstrap/docker/debian-10/Dockerfile.coriolis b/bootstrap/docker/debian-10/Dockerfile.coriolis index 23f52b5c..86fdf229 100644 --- a/bootstrap/docker/debian-10/Dockerfile.coriolis +++ b/bootstrap/docker/debian-10/Dockerfile.coriolis @@ -6,5 +6,5 @@ RUN mkdir -p coriolis-2.x/src \ && git clone https://github.com/m-labs/nmigen.git \ && cd nmigen \ && python3 setup.py develop \ - && /root/socInstaller.py --docker --profile=Debian10 --do-alliance --do-coriolis --benchs + && /root/socInstaller.py --docker --profile=Debian10 --do-yosys --do-alliance --do-coriolis --benchs diff --git a/bootstrap/docker/debian-10/Dockerfile.system b/bootstrap/docker/debian-10/Dockerfile.system index 22571c5e..83d6caf8 100644 --- a/bootstrap/docker/debian-10/Dockerfile.system +++ b/bootstrap/docker/debian-10/Dockerfile.system @@ -14,7 +14,7 @@ RUN apt-get update \ autotools-dev automake \ libxt-dev libxpm-dev libmotif-dev \ \ - yosys \ + tcl tcl-dev libffi6 libffi-dev libreadline7 \ \ vim \ && apt-get clean @@ -24,3 +24,6 @@ RUN apt-get update \ # transfig texlive texlive-latex-extra # texlive-plain-generic texlive-pictures # imagemagick +# +# The packaged yosys 0.8 is too old to work with nMigen, must be 0.9. +# yosys diff --git a/bootstrap/docker/debian-10/root/socInstaller.py b/bootstrap/docker/debian-10/root/socInstaller.py index 36d9c840..c80a658c 100755 --- a/bootstrap/docker/debian-10/root/socInstaller.py +++ b/bootstrap/docker/debian-10/root/socInstaller.py @@ -203,6 +203,13 @@ class CommandArg ( object ): return +class YosysCommand ( CommandArg ): + + def __init__ ( self, yosysBin, fdLog=None ): + CommandArg.__init__ ( self, [ yosysBin ], fdLog=fdLog ) + return + + class AllianceCommand ( CommandArg ): def __init__ ( self, alcBin, fdLog=None ): @@ -286,7 +293,7 @@ class Configuration ( object ): , 'success' , 'rcode' ] SecondaryNames = \ - [ 'rootDir', 'srcDir', 'logDir', 'logs', 'fds', 'alcBin', 'ccbBin', 'benchsDir' + [ 'rootDir', 'srcDir', 'logDir', 'logs', 'fds', 'yosysBin', 'alcBin', 'ccbBin', 'benchsDir' ] def __init__ ( self ): @@ -301,8 +308,9 @@ class Configuration ( object ): self._rmSource = False self._rmBuild = False self._doGit = True - self._doCoriolis = False + self._doYosys = False self._doAlliance = False + self._doCoriolis = False self._doBenchs = False self._doSendReport = False self._nightlyMode = False @@ -355,6 +363,7 @@ class Configuration ( object ): self._rootDir = self._homeDir + '/coriolis-2.x' self._srcDir = self._rootDir + '/src' self._logDir = self._srcDir + '/logs' + self._yosysBin = self._srcDir + '/' + GitRepository.getLocalRepository(self._coriolisRepo) + '/bootstrap/yosysInstaller.sh' self._alcBin = self._srcDir + '/' + GitRepository.getLocalRepository(self._coriolisRepo) + '/bootstrap/allianceInstaller.sh' self._ccbBin = self._srcDir + '/' + GitRepository.getLocalRepository(self._coriolisRepo) + '/bootstrap/ccb.py' self._benchsDir = self._srcDir + '/' + GitRepository.getLocalRepository(self._benchsRepo ) + '/benchs' @@ -415,6 +424,13 @@ class Configuration ( object ): def getCommands ( self, target ): commands = [] + if self.doYosys: + if not os.path.isfile( self.yosysBin ): + raise ErrorMessage( 1, [ 'Cannot find , should be here:' + , ' <%s>' % self.yosysBin + ] ) + commands.append( YosysCommand( self.yosysBin, fdLog=self.fds['yosys'] ) ) + if self.doAlliance: if not os.path.isfile( self.alcBin ): raise ErrorMessage( 1, [ 'Cannot find , should be here:' @@ -524,6 +540,7 @@ class Report ( object ): parser = optparse.OptionParser () parser.add_option ( "--debug" , action="store_true" , dest="debug" , help="Build a aka (-g) version." ) parser.add_option ( "--no-git" , action="store_true" , dest="noGit" , help="Do not pull/update Git repositories before building." ) +parser.add_option ( "--do-yosys" , action="store_true" , dest="doYosys" , help="Rebuild Yosys." ) parser.add_option ( "--do-alliance" , action="store_true" , dest="doAlliance" , help="Rebuild the Alliance tools." ) parser.add_option ( "--do-coriolis" , action="store_true" , dest="doCoriolis" , help="Rebuild the Coriolis tools." ) parser.add_option ( "--do-report" , action="store_true" , dest="doReport" , help="Send a final report." ) @@ -547,14 +564,16 @@ try: if options.docker: conf.dockerMode = True if options.chroot: conf.chrootMode = True if options.noGit: conf.doGit = False - if options.doCoriolis: conf.doCoriolis = True + if options.doYosys: conf.doYosys = True if options.doAlliance: conf.doAlliance = True + if options.doCoriolis: conf.doCoriolis = True if options.benchs: conf.doBenchs = True if options.doReport: conf.doSendReport = True if options.rmSource or options.rmAll: conf.rmSource = True if options.rmBuild or options.rmAll: conf.rmBuild = True + if conf.doYosys: conf.openLog( 'yosys' ) if conf.doAlliance: conf.openLog( 'alliance' ) if conf.doCoriolis: conf.openLog( 'coriolis' ) if conf.doBenchs: conf.openLog( 'benchs' ) @@ -563,68 +582,68 @@ try: gitSupports = [] for supportRepo in conf.supportRepos: - gitSupports.append( GitRepository( supportRepo, conf.srcDir+'/support' ) ) + gitSupports.append( GitRepository( supportRepo, conf.srcDir+'/support' ) ) gitCoriolis = GitRepository( conf.coriolisRepo, conf.srcDir, conf.fds['coriolis'] ) gitBenchs = GitRepository( conf.benchsRepo , conf.srcDir, conf.fds['coriolis'] ) if conf.doAlliance: - gitAlliance = GitRepository( conf.allianceRepo, conf.srcDir, conf.fds['alliance'] ) + gitAlliance = GitRepository( conf.allianceRepo, conf.srcDir, conf.fds['alliance'] ) if conf.doGit: - for gitSupport in gitSupports: - if conf.rmSource: gitSupport.removeLocalRepo() - gitSupport.clone() - #if gitSupport.url.endswith('rapidjson'): - # gitSupport.checkout( 'a1c4f32' ) - - if conf.doCoriolis: - if conf.rmSource: gitCoriolis.removeLocalRepo() - gitCoriolis.clone () - gitCoriolis.checkout( 'devel' ) - - if conf.doAlliance: - if conf.rmSource: gitAlliance.removeLocalRepo() - gitAlliance.clone () - #gitAlliance.checkout( 'devel' ) - - if conf.rmSource: gitBenchs.removeLocalRepo() - gitBenchs.clone() + for gitSupport in gitSupports: + if conf.rmSource: gitSupport.removeLocalRepo() + gitSupport.clone() + #if gitSupport.url.endswith('rapidjson'): + # gitSupport.checkout( 'a1c4f32' ) + + if conf.doAlliance: + if conf.rmSource: gitAlliance.removeLocalRepo() + gitAlliance.clone () + #gitAlliance.checkout( 'devel' ) + + if conf.doCoriolis: + if conf.rmSource: gitCoriolis.removeLocalRepo() + gitCoriolis.clone () + gitCoriolis.checkout( 'devel' ) + + if conf.rmSource: gitBenchs.removeLocalRepo() + gitBenchs.clone() if conf.rmBuild: - for entry in os.listdir(conf.rootDir): - if entry.startswith('Linux.'): - buildDir = conf.rootDir+'/'+entry - print 'Removing OS build directory: <%s>' % buildDir - shutil.rmtree( buildDir ) + for entry in os.listdir(conf.rootDir): + if entry.startswith('Linux.'): + buildDir = conf.rootDir+'/'+entry + print 'Removing OS build directory: <%s>' % buildDir + shutil.rmtree( buildDir ) commands = conf.getCommands( options.profile ) for command in commands: - if command.host: - print 'Executing command on remote host <%s>:' % host - else: - print 'Executing command on *local* host:' - print ' %s' % str(command) - command.execute() + if command.host: + print 'Executing command on remote host <%s>:' % host + else: + print 'Executing command on *local* host:' + print ' %s' % str(command) + command.execute() conf.closeLogs() conf.success = True except ErrorMessage, e: - print e - conf.closeLogs() - conf.success = False - - if showTrace: - print '\nPython stack trace:' - traceback.print_tb( sys.exc_info()[2] ) - conf.rcode = e.code + print e + conf.closeLogs() + conf.success = False + + if showTrace: + print '\nPython stack trace:' + traceback.print_tb( sys.exc_info()[2] ) + conf.rcode = e.code if conf.doSendReport: - report = Report( conf ) - report.attachLog( conf.logs['coriolis' ] ) - report.attachLog( conf.logs['benchs' ] ) - report.send() + report = Report( conf ) + report.attachLog( conf.logs['coriolis' ] ) + report.attachLog( conf.logs['benchs' ] ) + report.send() conf.compressLogs() diff --git a/bootstrap/socInstaller.py b/bootstrap/socInstaller.py index 36d9c840..c80a658c 100755 --- a/bootstrap/socInstaller.py +++ b/bootstrap/socInstaller.py @@ -203,6 +203,13 @@ class CommandArg ( object ): return +class YosysCommand ( CommandArg ): + + def __init__ ( self, yosysBin, fdLog=None ): + CommandArg.__init__ ( self, [ yosysBin ], fdLog=fdLog ) + return + + class AllianceCommand ( CommandArg ): def __init__ ( self, alcBin, fdLog=None ): @@ -286,7 +293,7 @@ class Configuration ( object ): , 'success' , 'rcode' ] SecondaryNames = \ - [ 'rootDir', 'srcDir', 'logDir', 'logs', 'fds', 'alcBin', 'ccbBin', 'benchsDir' + [ 'rootDir', 'srcDir', 'logDir', 'logs', 'fds', 'yosysBin', 'alcBin', 'ccbBin', 'benchsDir' ] def __init__ ( self ): @@ -301,8 +308,9 @@ class Configuration ( object ): self._rmSource = False self._rmBuild = False self._doGit = True - self._doCoriolis = False + self._doYosys = False self._doAlliance = False + self._doCoriolis = False self._doBenchs = False self._doSendReport = False self._nightlyMode = False @@ -355,6 +363,7 @@ class Configuration ( object ): self._rootDir = self._homeDir + '/coriolis-2.x' self._srcDir = self._rootDir + '/src' self._logDir = self._srcDir + '/logs' + self._yosysBin = self._srcDir + '/' + GitRepository.getLocalRepository(self._coriolisRepo) + '/bootstrap/yosysInstaller.sh' self._alcBin = self._srcDir + '/' + GitRepository.getLocalRepository(self._coriolisRepo) + '/bootstrap/allianceInstaller.sh' self._ccbBin = self._srcDir + '/' + GitRepository.getLocalRepository(self._coriolisRepo) + '/bootstrap/ccb.py' self._benchsDir = self._srcDir + '/' + GitRepository.getLocalRepository(self._benchsRepo ) + '/benchs' @@ -415,6 +424,13 @@ class Configuration ( object ): def getCommands ( self, target ): commands = [] + if self.doYosys: + if not os.path.isfile( self.yosysBin ): + raise ErrorMessage( 1, [ 'Cannot find , should be here:' + , ' <%s>' % self.yosysBin + ] ) + commands.append( YosysCommand( self.yosysBin, fdLog=self.fds['yosys'] ) ) + if self.doAlliance: if not os.path.isfile( self.alcBin ): raise ErrorMessage( 1, [ 'Cannot find , should be here:' @@ -524,6 +540,7 @@ class Report ( object ): parser = optparse.OptionParser () parser.add_option ( "--debug" , action="store_true" , dest="debug" , help="Build a aka (-g) version." ) parser.add_option ( "--no-git" , action="store_true" , dest="noGit" , help="Do not pull/update Git repositories before building." ) +parser.add_option ( "--do-yosys" , action="store_true" , dest="doYosys" , help="Rebuild Yosys." ) parser.add_option ( "--do-alliance" , action="store_true" , dest="doAlliance" , help="Rebuild the Alliance tools." ) parser.add_option ( "--do-coriolis" , action="store_true" , dest="doCoriolis" , help="Rebuild the Coriolis tools." ) parser.add_option ( "--do-report" , action="store_true" , dest="doReport" , help="Send a final report." ) @@ -547,14 +564,16 @@ try: if options.docker: conf.dockerMode = True if options.chroot: conf.chrootMode = True if options.noGit: conf.doGit = False - if options.doCoriolis: conf.doCoriolis = True + if options.doYosys: conf.doYosys = True if options.doAlliance: conf.doAlliance = True + if options.doCoriolis: conf.doCoriolis = True if options.benchs: conf.doBenchs = True if options.doReport: conf.doSendReport = True if options.rmSource or options.rmAll: conf.rmSource = True if options.rmBuild or options.rmAll: conf.rmBuild = True + if conf.doYosys: conf.openLog( 'yosys' ) if conf.doAlliance: conf.openLog( 'alliance' ) if conf.doCoriolis: conf.openLog( 'coriolis' ) if conf.doBenchs: conf.openLog( 'benchs' ) @@ -563,68 +582,68 @@ try: gitSupports = [] for supportRepo in conf.supportRepos: - gitSupports.append( GitRepository( supportRepo, conf.srcDir+'/support' ) ) + gitSupports.append( GitRepository( supportRepo, conf.srcDir+'/support' ) ) gitCoriolis = GitRepository( conf.coriolisRepo, conf.srcDir, conf.fds['coriolis'] ) gitBenchs = GitRepository( conf.benchsRepo , conf.srcDir, conf.fds['coriolis'] ) if conf.doAlliance: - gitAlliance = GitRepository( conf.allianceRepo, conf.srcDir, conf.fds['alliance'] ) + gitAlliance = GitRepository( conf.allianceRepo, conf.srcDir, conf.fds['alliance'] ) if conf.doGit: - for gitSupport in gitSupports: - if conf.rmSource: gitSupport.removeLocalRepo() - gitSupport.clone() - #if gitSupport.url.endswith('rapidjson'): - # gitSupport.checkout( 'a1c4f32' ) - - if conf.doCoriolis: - if conf.rmSource: gitCoriolis.removeLocalRepo() - gitCoriolis.clone () - gitCoriolis.checkout( 'devel' ) - - if conf.doAlliance: - if conf.rmSource: gitAlliance.removeLocalRepo() - gitAlliance.clone () - #gitAlliance.checkout( 'devel' ) - - if conf.rmSource: gitBenchs.removeLocalRepo() - gitBenchs.clone() + for gitSupport in gitSupports: + if conf.rmSource: gitSupport.removeLocalRepo() + gitSupport.clone() + #if gitSupport.url.endswith('rapidjson'): + # gitSupport.checkout( 'a1c4f32' ) + + if conf.doAlliance: + if conf.rmSource: gitAlliance.removeLocalRepo() + gitAlliance.clone () + #gitAlliance.checkout( 'devel' ) + + if conf.doCoriolis: + if conf.rmSource: gitCoriolis.removeLocalRepo() + gitCoriolis.clone () + gitCoriolis.checkout( 'devel' ) + + if conf.rmSource: gitBenchs.removeLocalRepo() + gitBenchs.clone() if conf.rmBuild: - for entry in os.listdir(conf.rootDir): - if entry.startswith('Linux.'): - buildDir = conf.rootDir+'/'+entry - print 'Removing OS build directory: <%s>' % buildDir - shutil.rmtree( buildDir ) + for entry in os.listdir(conf.rootDir): + if entry.startswith('Linux.'): + buildDir = conf.rootDir+'/'+entry + print 'Removing OS build directory: <%s>' % buildDir + shutil.rmtree( buildDir ) commands = conf.getCommands( options.profile ) for command in commands: - if command.host: - print 'Executing command on remote host <%s>:' % host - else: - print 'Executing command on *local* host:' - print ' %s' % str(command) - command.execute() + if command.host: + print 'Executing command on remote host <%s>:' % host + else: + print 'Executing command on *local* host:' + print ' %s' % str(command) + command.execute() conf.closeLogs() conf.success = True except ErrorMessage, e: - print e - conf.closeLogs() - conf.success = False - - if showTrace: - print '\nPython stack trace:' - traceback.print_tb( sys.exc_info()[2] ) - conf.rcode = e.code + print e + conf.closeLogs() + conf.success = False + + if showTrace: + print '\nPython stack trace:' + traceback.print_tb( sys.exc_info()[2] ) + conf.rcode = e.code if conf.doSendReport: - report = Report( conf ) - report.attachLog( conf.logs['coriolis' ] ) - report.attachLog( conf.logs['benchs' ] ) - report.send() + report = Report( conf ) + report.attachLog( conf.logs['coriolis' ] ) + report.attachLog( conf.logs['benchs' ] ) + report.send() conf.compressLogs() diff --git a/bootstrap/yosysInstaller.sh b/bootstrap/yosysInstaller.sh new file mode 100755 index 00000000..e58e6e19 --- /dev/null +++ b/bootstrap/yosysInstaller.sh @@ -0,0 +1,12 @@ +#!/bin/bash + + srcDir=${HOME} + gitHash="6edca05" + + cd ${srcDir} + git clone https://github.com/cliffordwolf/yosys.git + cd yosys + git checkout ${gitHash} + make config-gcc + make GIT_REV=${gitHash} -j4 + make GIT_REV=${gitHash} install