Merge pull request #20 from olofk/config_gen
Update FuseSoC SweRV config generator
This commit is contained in:
commit
9260b5567c
|
@ -1,55 +1,39 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from fusesoc.capi2.generator import Generator
|
from fusesoc.capi2.generator import Generator
|
||||||
import os
|
import os
|
||||||
import shutil
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
|
||||||
if sys.version[0] == '2':
|
|
||||||
devnull = open(os.devnull, 'w')
|
|
||||||
else:
|
|
||||||
from subprocess import DEVNULL as devnull
|
|
||||||
|
|
||||||
class SwervConfigGenerator(Generator):
|
class SwervConfigGenerator(Generator):
|
||||||
def run(self):
|
def run(self):
|
||||||
script_root = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..'))
|
script_root = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..'))
|
||||||
files = [
|
files = [
|
||||||
{"configs/snapshots/default/common_defines.vh" : {
|
{"common_defines.vh" : {
|
||||||
"copyto" : "config/common_defines.vh",
|
"copyto" : "config/common_defines.vh",
|
||||||
"file_type" : "systemVerilogSource"}},
|
"file_type" : "systemVerilogSource"}},
|
||||||
{"configs/snapshots/default/el2_pdef.vh" : {
|
{"el2_pdef.vh" : {
|
||||||
"copyto" : "config/el2_pdef.vh",
|
"copyto" : "config/el2_pdef.vh",
|
||||||
"file_type" : "systemVerilogSource"}},
|
"file_type" : "systemVerilogSource"}},
|
||||||
{"configs/snapshots/default/el2_param.vh" : {
|
{"el2_param.vh" : {
|
||||||
"is_include_file" : True,
|
"is_include_file" : True,
|
||||||
"file_type" : "systemVerilogSource"}},
|
"file_type" : "systemVerilogSource"}},
|
||||||
{"configs/snapshots/default/pic_map_auto.h" : {
|
{"pic_map_auto.h" : {
|
||||||
"is_include_file" : True,
|
"is_include_file" : True,
|
||||||
"file_type" : "systemVerilogSource"}}]
|
"file_type" : "systemVerilogSource"}}]
|
||||||
|
|
||||||
tmp_dir = os.path.join(tempfile.mkdtemp(), 'core')
|
|
||||||
shutil.copytree(script_root, tmp_dir)
|
|
||||||
|
|
||||||
cwd = tmp_dir
|
|
||||||
|
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env['RV_ROOT'] = tmp_dir
|
env['RV_ROOT'] = script_root
|
||||||
|
env['BUILD_PATH'] = os.getcwd()
|
||||||
args = ['configs/swerv.config'] + self.config.get('args', [])
|
args = ['configs/swerv.config'] + self.config.get('args', [])
|
||||||
rc = subprocess.call(args, cwd=cwd, env=env, stdout=devnull)
|
|
||||||
|
rc = subprocess.call(args, cwd=script_root, env=env, stdout=subprocess.DEVNULL)
|
||||||
if rc:
|
if rc:
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
filenames = []
|
filenames = []
|
||||||
for f in files:
|
for f in files:
|
||||||
for k in f:
|
for k in f:
|
||||||
filenames.append(k)
|
filenames.append(k)
|
||||||
|
|
||||||
for f in filenames:
|
|
||||||
d = os.path.dirname(f)
|
|
||||||
if d and not os.path.exists(d):
|
|
||||||
os.makedirs(d)
|
|
||||||
shutil.copy2(os.path.join(cwd, f),f)
|
|
||||||
|
|
||||||
self.add_files(files)
|
self.add_files(files)
|
||||||
|
|
||||||
g = SwervConfigGenerator()
|
g = SwervConfigGenerator()
|
||||||
|
|
Loading…
Reference in New Issue