Make the yowasp hook smarter

This commit is contained in:
Peder Bergebakken Sundt 2020-08-08 01:48:05 +02:00
parent 7f6b133241
commit e3da4a696a
1 changed files with 9 additions and 7 deletions

View File

@ -6,16 +6,18 @@ __version__ = '0.1.0'
def populate_environ():
import os, shutil
for env_name, program in [
("YOSYS", "yowasp-yosys"),
("NEXTPNR_ICE40", "yowasp-nextpnr-ice40"),
("NEXTPNR_ECP5", "yowasp-nextpnr-ecp5"),
for nmigen_envvar, expected_path, alternative_path in [
("YOSYS", "yosys", "yowasp-yosys"), # nmigen-yosys is handled by nmigen
("NEXTPNR_ICE40", "nextpnr-ice40", "yowasp-nextpnr-ice40"),
("NEXTPNR_ECP5", "nextpnr-ecp5", "yowasp-nextpnr-ecp5"),
]:
if shutil.which(program):
os.environ[env_name] = program
if nmigen_envvar in os.environ: continue
if shutil.which(expected_path): continue
if not shutil.which(alternative_path): continue
os.environ[nmigen_envvar] = alternative_path
populate_environ()
del populate_environ
# dogelang: Slow. Stupid. Absolutely adorable.
import dg # install import hook
import dg # setup the dg import hook