utils/vlog: Fix relative path generation and empty model files

Signed-off-by: David Shah <davey1576@gmail.com>
diff --git a/vlog_to_model.py b/vlog_to_model.py
index a382e7b..b4a3463 100755
--- a/vlog_to_model.py
+++ b/vlog_to_model.py
@@ -90,8 +90,10 @@
 if len(deps_files) > 0:
     # Has dependencies, not a leaf model
     for df in sorted(deps_files):
-        module_path = os.path.dirname(df)
-        module_basename = os.path.basename(df)
+        abs_base = os.path.dirname(os.path.abspath(args.infiles[0]))
+        abs_dep = os.path.normpath(os.path.join(abs_base, df))
+        module_path = os.path.dirname(abs_dep)
+        module_basename = os.path.basename(abs_dep)
         wm = re.match(r"([A-Za-z0-9_]+)\.sim\.v", module_basename)
         if wm:
             model_path = "%s/%s.model.xml" % (module_path, wm.group(1).lower())
@@ -132,6 +134,9 @@
                 assert(False) #how does VPR specify inout (only applicable for PACKAGEPIN of an IO primitive)
 
 
+if len(models_xml) == 0:
+    models_xml.insert(0, ET.Comment("this file is intentionally left blank"))
+
 f = open(outfile, 'w')
 f.write(ET.tostring(models_xml, pretty_print=True).decode('utf-8'))
 f.close()
diff --git a/xmlinc.py b/xmlinc.py
index eb546b8..b7f470b 100644
--- a/xmlinc.py
+++ b/xmlinc.py
@@ -5,6 +5,11 @@
 
 xi_include = "{%s}include" % xi_url
 
+def make_relhref(outfile, href):
+    outpath = os.path.dirname(os.path.abspath(outfile))
+    relpath = os.path.relpath(os.path.dirname(os.path.abspath(href)), outpath)
+    return os.path.join(relpath, os.path.basename(href))
+
 def include_xml(parent, href, outfile, xptr = None):
     """
     Generate an XML include, using a relative path.
@@ -16,9 +21,7 @@
     outfile : path to output file, for relative path generation
     xptr : optional value for xpointer attribute
     """
-    outpath = os.path.dirname(outfile)
-    relhref = os.path.relpath(href, outpath)
-    xattrs = {'href': relhref}
+    xattrs = {'href': make_relhref(outfile, href)}
     if xptr is not None:
         xattrs["xpointer"] = xptr
     return ET.SubElement(parent, xi_include, xattrs)