Skip to content

Commit b927c0a

Browse files
committed
openflow: simplified/imrpoved configure
1 parent 1f67e74 commit b927c0a

File tree

6 files changed

+35
-28
lines changed

6 files changed

+35
-28
lines changed

examples/configure/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
EXAMPLES=$(wildcard *.py)
2+
3+
.PHONY: $(EXAMPLES)
4+
5+
all: $(EXAMPLES)
6+
7+
$(EXAMPLES):
8+
python3 $@

examples/configure/file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from openflow.configure import ConfigureTools
44

5-
cfg = ConfigureTools('../openflow.yml')
5+
cfg = ConfigureTools('file.yml')
66

77
for tool in cfg.get_tools():
88
print(cfg.get_command(tool))

examples/configure/file.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
engine: example
2+
volumes:
3+
- "path1:path2"
4+
- "path3:path4"
5+
work: .
6+
containers:
7+
example1: hdlc/example1
8+
example2: extra-oci-options hdlc/example2
9+
names:
10+
example1: alt-example1
11+
example2: alt-example2

openflow/configure.py

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,40 +22,26 @@
2222
"""
2323

2424

25+
import os
2526
from yaml import safe_load, dump
2627

2728

28-
_DEFAULTS = {
29-
'ecppack': 'hdlc/prjtrellis',
30-
'ghdl': 'hdlc/ghdl:yosys',
31-
'icepack': 'hdlc/icestorm',
32-
'iceprog': '--device /dev/bus/usb hdlc/icestorm',
33-
'icetime': 'hdlc/icestorm',
34-
'nextpnr-ecp5': 'hdlc/nextpnr:ecp5',
35-
'nextpnr-ice40': 'hdlc/nextpnr:ice40',
36-
'openocd': '--device /dev/bus/usb hdlc/prog',
37-
'yosys': 'hdlc/ghdl:yosys',
38-
}
39-
40-
4129
class ConfigureTools:
4230
"""Configure Tools."""
4331

44-
def __init__(self, filename=None):
32+
def __init__(self, filename='.openflow.yml'):
4533
"""Class constructor."""
46-
self.configs = {}
47-
if filename is not None:
48-
with open(filename, 'r') as file:
49-
self.configs = safe_load(file)
34+
usrfile = os.path.join(os.path.expanduser('~'), filename)
35+
prjfile = os.path.join(os.path.dirname(__file__), 'configure.yml')
36+
if os.path.exists(filename):
37+
filepath = filename
38+
elif os.path.exists(usrfile):
39+
filepath = usrfile
5040
else:
51-
self.configs['engine'] = 'docker'
52-
self.configs['volumes'] = ['$HOME:$HOME']
53-
self.configs['work'] = '$PWD'
54-
self.configs['containers'] = {}
55-
self.configs['names'] = {}
56-
for key, value in _DEFAULTS.items():
57-
self.configs['containers'][key] = value
58-
self.configs['names'][key] = key
41+
filepath = prjfile
42+
self.configs = {}
43+
with open(filepath, 'r') as file:
44+
self.configs = safe_load(file)
5945

6046
def get_command(self, tool):
6147
"""Get the command-line needed to run a tool."""
File renamed without changes.

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
license='GPLv3',
1717
url='https://github.com/PyFPGA/openflow',
1818
packages=find_packages(),
19+
package_data={'': ['configure.yml']},
1920
entry_points={
2021
'console_scripts': [
2122
'openflow_syn = openflow.helpers.synthesis:main',
@@ -38,5 +39,6 @@
3839
'Topic :: Software Development :: Build Tools',
3940
"Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)"
4041
],
41-
install_requires=['pyyaml']
42+
install_requires=['pyyaml'],
43+
python_requires=">=3.5, <4"
4244
)

0 commit comments

Comments
 (0)