Skip to content

Commit

Permalink
getting cleaned up for 0.0.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
mballance committed Feb 11, 2019
1 parent 4986e5f commit 49e20f1
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 67 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ChangeLog

## 0.0.1
- Initial release with support for simple templates

32 changes: 32 additions & 0 deletions bin/vte
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
#****************************************************************************
#* vte launcher
#****************************************************************************

# First, determine the location of this script
if test -f $0; then
script_dir=$(dirname $0)
script_dir=$(cd $script_dir ; pwd)
else
# Find ourselves in the PATH
for elem in $(echo PATH | sed -e 's%:% %g'); do
script=${elem}/$0
if test -f $script; then
script_dir=$elem
break
fi
done
fi

vte_dir=$(dirname ${script_dir})
# Need to adjust PYTHONPATH to find dependencies
export PYTHONPATH=${vte_dir}/lib:$PYTHONPATH

# This is a development area
if test -d ${vte_dir}/src; then
export PYTHONPATH=${vte_dir}/src:$PYTHONPATH
fi

python3 -m vte ${@:1}


42 changes: 0 additions & 42 deletions bin/vte.py

This file was deleted.

14 changes: 11 additions & 3 deletions scripts/ivpm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ BUILD_DIR := $(ROOT_DIR)/build
BUILD_DEPS += $(BUILD_DIR)/pyyaml.d
BUILD_DEPS += $(BUILD_DIR)/jinja2.d
BUILD_DEPS += $(BUILD_DIR)/markupsafe.d
EDAPACK_BUILD_URL=https://github.com/EDAPack/edapack-build

-include $(PACKAGES_DIR)/packages.mk
include $(ROOT_DIR)/etc/ivpm.info
Expand All @@ -27,6 +28,8 @@ MARKUPSAFE_DIR=markupsafe-$(MARKUPSAFE_VERSION)
MARKUPSAFE_TGZ=$(BUILD_DIR)/$(MARKUPSAFE_DIR).tar.gz
MARKUPSAFE_URL=https://github.com/pallets/markupsafe/archive/$(MARKUPSAFE_VERSION).tar.gz

PACKAGE=$(BUILD_DIR)/vte-$(version).tar.gz

RULES := 1

ifeq (true,$(PHASE2))
Expand Down Expand Up @@ -79,8 +82,13 @@ $(MARKUPSAFE_TGZ) :
$(Q)if test ! -d `dirname $@`; then mkdir -p `dirname $@`; fi
$(Q)wget -O $@ $(MARKUPSAFE_URL)

release :
echo "TODO: release"
exit 1
release : $(PACKAGE) $(PACKAGES_DIR)/upload.py
$(Q)python3 $(PACKAGES_DIR)/upload.py \
--user mballance --repo vte \
--key $(GITHUB_API_TOKEN) --version $(version) $(PACKAGE)

$(PACKAGES_DIR)/upload.py :
$(Q)mkdir -p $(PACKAGES_DIR)
$(Q)$(WGET) -O $@ $(EDAPACK_BUILD_URL)/raw/master/scripts/upload.py

-include $(PACKAGES_DIR)/packages.mk
27 changes: 27 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

import os
from setuptools import setup

setup(
name = "vte",
packages=['vte'],
package_dir = {'vte' : 'src/vte'},
author = "Matthew Ballance",
author_email = "[email protected]",
description = ("VTE is a Verification Template Engine for generating content for verification environments from template files and parameters."),
license = "Apache 2.0",
keywords = ["SystemVerilog", "Verilog", "RTL", "GoogleTest"],
url = "https://github.com/mballance/vte",
entry_points={
'console_scripts': [
'vte = vte.__main__:main'
]
},
setup_requires=[
'setuptools_scm',
],
install_requires=[
'jinja2>=2.10'
],
)

45 changes: 33 additions & 12 deletions src/vte/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ def substitute(vars, str):

return str

def list_templates(args, rgy):
print("list_templates")
template_ids = sorted(rgy.template_map.keys())

max_len = 0
for id in template_ids:
if len(id) > max_len:
max_len = len(id)

fmt_str = "%-" + str(max_len) + "s - %s"
for id in template_ids:
print(fmt_str % (id, rgy.template_map[id].desc))

def generate(args, parameters, rgy):
if args.template not in rgy.template_map.keys():
print("Error: template does not exist")
Expand Down Expand Up @@ -140,21 +153,12 @@ def main():
metavar="KEY=VALUE",
nargs="*",
help="Specify other template variables")

list_cmd = subparser.add_parser("list",
help="list available templates")

args = parser.parse_args()

if args.name.find("=") != -1:
print("Error: name contains '='")
exit(1)

# Check that parameters are properly-specified
parameters = {}
for param in args.parameters:
idx = param.find("=")
if idx == -1:
print("Error: parameter specification \"" + param + "\" doesn't contain '='");
exit(1)
parameters[param[:idx]] = param[idx+1:]

template_path = []
template_path.append("/project/fun/vte/vte-mballance/templates")
Expand All @@ -167,7 +171,24 @@ def main():
rgy = template_rgy.TemplateRgy(template_path)

if args.subcmd == "generate":
if args.name.find("=") != -1:
print("Error: name contains '='")
exit(1)

# Check that parameters are properly-specified
parameters = {}
for param in args.parameters:
idx = param.find("=")
if idx == -1:
print("Error: parameter specification \"" + param + "\" doesn't contain '='");
exit(1)
parameters[param[:idx]] = param[idx+1:]

generate(args, parameters, rgy)
elif args.subcmd == "list":
list_templates(args, rgy)
else:
exit(1);


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion src/vte/template_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ def __init__(self, outdir, template):
self.env = Environment(loader=templLoader)

def generate(self):
print "Generate"
print("Generate")
6 changes: 6 additions & 0 deletions src/vte/template_rgy.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(self,
self.tmpl_id = tmpl_id
self.tmpl_dir = os.path.dirname(vte_file)
self.parameters = {}
self.desc = ""

vte = configparser.ConfigParser()
vte.read(vte_file)
Expand All @@ -49,6 +50,11 @@ def __init__(self,

param = Parameter(pname, desc, has_default, default_val)
self.parameters[pname] = param
elif s == "template":
if "desc" in vte[s].keys():
self.desc = vte[s]["desc"];
else:
print("Warning: unhandled section \"" + s + "\" in template " + self.tmpl_id)

def list_templates(self):
templates = []
Expand Down
11 changes: 2 additions & 9 deletions src/vte/vte.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,9 @@
#*
#****************************************************************************
import sys
import yaml

class VTETemplate(yaml.YAMLObject):
yaml_tag = u'!VTETemplate'

def __init__(self, name):
self.name = name

def vte_main(vte_dir, argv):
print "Hello from vte_main"
print("Hello from vte_main")

if __name__ == "main":
vte_main("foo", sys.argv)
vte_main("foo", sys.argv)
8 changes: 8 additions & 0 deletions templates/ivpm/project/.vte
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#********************************************************************
#* ivpm.project
#*
#* Creates a template project for a new IVPM project
#********************************************************************

[template]

0 comments on commit 49e20f1

Please sign in to comment.