mirror of
https://github.com/TinyTapeout/tt-support-tools.git
synced 2026-11-03 04:36:09 +01:00
Merge branch 'tt03' of github.com:tinytapeout/tt-support-tools into tt03
This commit is contained in:
+1
-5
@@ -99,11 +99,6 @@ class Projects():
|
|||||||
project.post_clone_setup()
|
project.post_clone_setup()
|
||||||
logging.debug(project)
|
logging.debug(project)
|
||||||
|
|
||||||
# fetch the wokwi source
|
|
||||||
if args.clone_all:
|
|
||||||
if not project.is_fill() and project.is_wokwi():
|
|
||||||
project.fetch_wokwi_files()
|
|
||||||
|
|
||||||
if args.harden:
|
if args.harden:
|
||||||
if filler is False:
|
if filler is False:
|
||||||
project.create_user_config()
|
project.create_user_config()
|
||||||
@@ -223,6 +218,7 @@ class Projects():
|
|||||||
logging.info("top 10 tags")
|
logging.info("top 10 tags")
|
||||||
count_items(tags)
|
count_items(tags)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser(description="TinyTapeout configuration and docs")
|
parser = argparse.ArgumentParser(description="TinyTapeout configuration and docs")
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -3,7 +3,9 @@ from urllib.parse import urlparse
|
|||||||
import logging
|
import logging
|
||||||
import requests
|
import requests
|
||||||
import os
|
import os
|
||||||
import zipfile, io
|
import zipfile
|
||||||
|
import io
|
||||||
|
import errno
|
||||||
|
|
||||||
|
|
||||||
def unique(duplist):
|
def unique(duplist):
|
||||||
@@ -21,7 +23,7 @@ def fetch_file(url, filename):
|
|||||||
r = requests.get(url)
|
r = requests.get(url)
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
logging.warning("couldn't download {}".format(url))
|
logging.warning("couldn't download {}".format(url))
|
||||||
exit(1)
|
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), filename)
|
||||||
|
|
||||||
with open(filename, 'wb') as fh:
|
with open(filename, 'wb') as fh:
|
||||||
logging.info("written to {}".format(filename))
|
logging.info("written to {}".format(filename))
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
flake8 --ignore E203,E123,E501,E221,E401,W605 configure.py project.py tt_tool.py orders.py documentation.py caravel.py
|
flake8 --ignore E203,E123,E501,E221,E401,W605 configure.py project.py tt_tool.py orders.py documentation.py caravel.py git_utils.py
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class Orders():
|
|||||||
try:
|
try:
|
||||||
with open(self.config['extra_projects']) as fh:
|
with open(self.config['extra_projects']) as fh:
|
||||||
config = yaml.safe_load(fh)
|
config = yaml.safe_load(fh)
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError:
|
||||||
config = []
|
config = []
|
||||||
|
|
||||||
config.append({'project': {'url' : git_url, 'timestamp' : time.time()}})
|
config.append({'project': {'url' : git_url, 'timestamp' : time.time()}})
|
||||||
|
|||||||
+42
-4
@@ -12,8 +12,7 @@ import git_utils
|
|||||||
import git
|
import git
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
# can't find a google version
|
CELL_URL = 'https://skywater-pdk.readthedocs.io/en/main/contents/libraries/sky130_fd_sc_hd/cells/'
|
||||||
CELL_URL = 'https://antmicro-skywater-pdk-docs.readthedocs.io/en/test-submodules-in-rtd/contents/libraries/sky130_fd_sc_ls/cells/'
|
|
||||||
|
|
||||||
|
|
||||||
class Project():
|
class Project():
|
||||||
@@ -293,15 +292,54 @@ class Project():
|
|||||||
def fetch_wokwi_files(self):
|
def fetch_wokwi_files(self):
|
||||||
logging.info("fetching wokwi files")
|
logging.info("fetching wokwi files")
|
||||||
src_file = self.src_files[0]
|
src_file = self.src_files[0]
|
||||||
url = "https://wokwi.com/api/projects/{}/verilog".format(self.wokwi_id)
|
url = f"https://wokwi.com/api/projects/{self.wokwi_id}/verilog"
|
||||||
git_utils.fetch_file(url, os.path.join(self.local_dir, "src", src_file))
|
git_utils.fetch_file(url, os.path.join(self.local_dir, "src", src_file))
|
||||||
|
|
||||||
# also fetch the wokwi diagram
|
# also fetch the wokwi diagram
|
||||||
url = "https://wokwi.com/api/projects/{}/diagram.json".format(self.wokwi_id)
|
url = f"https://wokwi.com/api/projects/{self.wokwi_id}/diagram.json"
|
||||||
diagram_file = "wokwi_diagram.json"
|
diagram_file = "wokwi_diagram.json"
|
||||||
git_utils.fetch_file(url, os.path.join(self.local_dir, "src", diagram_file))
|
git_utils.fetch_file(url, os.path.join(self.local_dir, "src", diagram_file))
|
||||||
|
|
||||||
|
# attempt to download the *optional* truthtable for the project
|
||||||
|
truthtable_file = "truthtable.md"
|
||||||
|
url = f"https://wokwi.com/api/projects/{self.wokwi_id}/{truthtable_file}"
|
||||||
|
try:
|
||||||
|
git_utils.fetch_file(url, os.path.join(self.local_dir, "src", truthtable_file))
|
||||||
|
logging.info(f'Wokwi project {self.wokwi_id} has a truthtable included, will test!')
|
||||||
|
self.install_wokwi_testing()
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def install_wokwi_testing(self, destination_dir='src', resource_dir=None):
|
||||||
|
if resource_dir is None or not len(resource_dir):
|
||||||
|
resource_dir = os.path.join(os.path.dirname(__file__), 'testing')
|
||||||
|
|
||||||
|
# directories in testing/lib to copy over
|
||||||
|
pyLibsDir = os.path.join(resource_dir, 'lib')
|
||||||
|
|
||||||
|
# src template dir
|
||||||
|
srcTplDir = os.path.join(resource_dir, 'src-tpl')
|
||||||
|
|
||||||
|
for libfullpath in glob.glob(os.path.join(pyLibsDir, '*')):
|
||||||
|
logging.info(f'Copying {libfullpath} to {destination_dir}')
|
||||||
|
shutil.copytree(
|
||||||
|
libfullpath,
|
||||||
|
os.path.join(destination_dir, os.path.basename(libfullpath)),
|
||||||
|
dirs_exist_ok=True)
|
||||||
|
|
||||||
|
for srcTemplate in glob.glob(os.path.join(srcTplDir, '*')):
|
||||||
|
with open(srcTemplate, 'r') as f:
|
||||||
|
contents = f.read()
|
||||||
|
customizedContents = re.sub('WOKWI_ID', str(self.wokwi_id), contents)
|
||||||
|
outputFname = os.path.basename(srcTemplate)
|
||||||
|
with open(os.path.join(destination_dir, outputFname), 'w') as outf:
|
||||||
|
logging.info(f'writing src tpl to {outputFname}')
|
||||||
|
outf.write(customizedContents)
|
||||||
|
outf.close()
|
||||||
|
|
||||||
def create_user_config(self):
|
def create_user_config(self):
|
||||||
|
if self.is_wokwi():
|
||||||
|
self.fetch_wokwi_files()
|
||||||
logging.info("creating include file")
|
logging.info("creating include file")
|
||||||
filename = 'user_config.tcl'
|
filename = 'user_config.tcl'
|
||||||
with open(os.path.join(self.local_dir, 'src', filename), 'w') as fh:
|
with open(os.path.join(self.local_dir, 'src', filename), 'w') as fh:
|
||||||
|
|||||||
Reference in New Issue
Block a user