aboutsummaryrefslogtreecommitdiff
path: root/tools/interface_generator
diff options
context:
space:
mode:
Diffstat (limited to 'tools/interface_generator')
-rw-r--r--tools/interface_generator/BUILD.bazel38
-rw-r--r--tools/interface_generator/bin/BUILD.bazel57
-rw-r--r--tools/interface_generator/bin/interface_definition.py (renamed from tools/interface_generator/interface_definition.py)0
-rwxr-xr-xtools/interface_generator/bin/interface_generator.py (renamed from tools/interface_generator/interface_generator.py)5
-rw-r--r--tools/interface_generator/bin/templates.py (renamed from tools/interface_generator/templates.py)0
-rw-r--r--tools/interface_generator/bin/templates/__c_functions.mako (renamed from tools/interface_generator/templates/__c_functions.mako)0
-rw-r--r--tools/interface_generator/bin/templates/__c_system_include.mako (renamed from tools/interface_generator/templates/__c_system_include.mako)0
-rw-r--r--tools/interface_generator/bin/templates/__c_types.mako (renamed from tools/interface_generator/templates/__c_types.mako)0
-rw-r--r--tools/interface_generator/bin/templates/__header.mako (renamed from tools/interface_generator/templates/__header.mako)0
-rw-r--r--tools/interface_generator/bin/templates/interface.h.mako (renamed from tools/interface_generator/templates/interface.h.mako)0
-rw-r--r--tools/interface_generator/bin/templates/interface_mock.cpp.mako (renamed from tools/interface_generator/templates/interface_mock.cpp.mako)0
-rw-r--r--tools/interface_generator/bin/templates/interface_mock.hpp.mako (renamed from tools/interface_generator/templates/interface_mock.hpp.mako)0
-rwxr-xr-xtools/interface_generator/bin/templates_unittest.py (renamed from tools/interface_generator/templates_unittest.py)7
-rw-r--r--tools/interface_generator/defs.bzl2
14 files changed, 67 insertions, 42 deletions
diff --git a/tools/interface_generator/BUILD.bazel b/tools/interface_generator/BUILD.bazel
index e62d7b9..8c4bde6 100644
--- a/tools/interface_generator/BUILD.bazel
+++ b/tools/interface_generator/BUILD.bazel
@@ -1,7 +1,4 @@
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
-load("@pip//:requirements.bzl", "requirement")
-load(":defs.bzl", "generate_interface")
-load("//private:defs.bzl", "py_pytest")
package(default_visibility = ["//visibility:public"])
@@ -12,40 +9,5 @@ compile_pip_requirements(
requirements_txt = "requirements_lock.txt",
)
-py_binary(
- name = "interface_generator",
- srcs = [
- "interface_definition.py",
- "interface_generator.py",
- "templates.py",
- ],
- data = glob(["templates/*"]) + ["LICENSE.md"],
- main = "interface_generator.py",
- deps = ["@pip//mako"],
-)
-
-# interface generator python tests
-py_test(
- name = "templates_unittest",
- srcs = [
- "templates.py",
- "templates_unittest.py",
- ],
- data = glob(["templates/*"]),
- deps = ["@pip//mako"],
-)
-
-py_pytest(
- name = "pytest",
- srcs = [
- "interface_definition.py",
- "interface_generator.py",
- "templates.py",
- ],
- deps = [
- requirement("mako"),
- ],
-)
-
# make license available to test package
exports_files(["LICENSE.md"])
diff --git a/tools/interface_generator/bin/BUILD.bazel b/tools/interface_generator/bin/BUILD.bazel
new file mode 100644
index 0000000..c593b93
--- /dev/null
+++ b/tools/interface_generator/bin/BUILD.bazel
@@ -0,0 +1,57 @@
+load("@pip//:requirements.bzl", "requirement")
+load("//private:defs.bzl", "py_pytest")
+
+""" interface definition """
+
+py_library(
+ name = "interface_definition",
+ srcs = ["interface_definition.py"],
+)
+
+""" templates """
+
+py_library(
+ name = "templates",
+ srcs = ["templates.py"],
+ data = glob(["templates/*"]),
+)
+
+py_test(
+ name = "templates_unittest",
+ srcs = ["templates_unittest.py"],
+ imports = ["."],
+ deps = [":templates"],
+)
+
+""" interface_generator """
+
+py_binary(
+ name = "interface_generator",
+ srcs = [
+ "interface_generator.py",
+ "templates.py",
+ ],
+ data = ["//:LICENSE.md"],
+ imports = ["."],
+ visibility = ["//visibility:public"],
+ deps = [
+ ":interface_definition",
+ ":templates",
+ requirement("mako"),
+ ],
+)
+
+""" pytest """
+
+py_pytest(
+ name = "pytest",
+ srcs = [
+ "interface_definition.py",
+ "interface_generator.py",
+ "templates.py",
+ ],
+ deps = [
+ ":interface_generator",
+ requirement("mako"),
+ ],
+)
diff --git a/tools/interface_generator/interface_definition.py b/tools/interface_generator/bin/interface_definition.py
index 3b9c4a3..3b9c4a3 100644
--- a/tools/interface_generator/interface_definition.py
+++ b/tools/interface_generator/bin/interface_definition.py
diff --git a/tools/interface_generator/interface_generator.py b/tools/interface_generator/bin/interface_generator.py
index 0693897..90d03ba 100755
--- a/tools/interface_generator/interface_generator.py
+++ b/tools/interface_generator/bin/interface_generator.py
@@ -19,7 +19,7 @@ PROG = {
def generate_file(template: Path, templates: Path, output, kwargs):
"""generate file using a tempalte and write it to the output location"""
- lookup = TemplateLookup(directories=[".", "templates"])
+ lookup = TemplateLookup(directories=[".", templates.absolute()])
mako_template = lookup.get_template(str(template.relative_to(templates)))
result = mako_template.render(**kwargs, PROG=PROG)
@@ -51,7 +51,7 @@ def main():
"-t",
"--templates",
type=Path,
- default=Path("templates"),
+ default=Path(sys.argv[0]).parent / "templates",
help="templates location",
)
parser.add_argument(
@@ -76,6 +76,7 @@ def main():
# print(interface)
for template in get_templates(args.templates):
+ # print(template)
generate_file(template, args.templates, args.output, interface)
diff --git a/tools/interface_generator/templates.py b/tools/interface_generator/bin/templates.py
index d6a6bb5..d6a6bb5 100644
--- a/tools/interface_generator/templates.py
+++ b/tools/interface_generator/bin/templates.py
diff --git a/tools/interface_generator/templates/__c_functions.mako b/tools/interface_generator/bin/templates/__c_functions.mako
index 2e40119..2e40119 100644
--- a/tools/interface_generator/templates/__c_functions.mako
+++ b/tools/interface_generator/bin/templates/__c_functions.mako
diff --git a/tools/interface_generator/templates/__c_system_include.mako b/tools/interface_generator/bin/templates/__c_system_include.mako
index d6a9d09..d6a9d09 100644
--- a/tools/interface_generator/templates/__c_system_include.mako
+++ b/tools/interface_generator/bin/templates/__c_system_include.mako
diff --git a/tools/interface_generator/templates/__c_types.mako b/tools/interface_generator/bin/templates/__c_types.mako
index ce6b6b5..ce6b6b5 100644
--- a/tools/interface_generator/templates/__c_types.mako
+++ b/tools/interface_generator/bin/templates/__c_types.mako
diff --git a/tools/interface_generator/templates/__header.mako b/tools/interface_generator/bin/templates/__header.mako
index 24b0381..24b0381 100644
--- a/tools/interface_generator/templates/__header.mako
+++ b/tools/interface_generator/bin/templates/__header.mako
diff --git a/tools/interface_generator/templates/interface.h.mako b/tools/interface_generator/bin/templates/interface.h.mako
index 47ea940..47ea940 100644
--- a/tools/interface_generator/templates/interface.h.mako
+++ b/tools/interface_generator/bin/templates/interface.h.mako
diff --git a/tools/interface_generator/templates/interface_mock.cpp.mako b/tools/interface_generator/bin/templates/interface_mock.cpp.mako
index 721f2c4..721f2c4 100644
--- a/tools/interface_generator/templates/interface_mock.cpp.mako
+++ b/tools/interface_generator/bin/templates/interface_mock.cpp.mako
diff --git a/tools/interface_generator/templates/interface_mock.hpp.mako b/tools/interface_generator/bin/templates/interface_mock.hpp.mako
index e33d50e..e33d50e 100644
--- a/tools/interface_generator/templates/interface_mock.hpp.mako
+++ b/tools/interface_generator/bin/templates/interface_mock.hpp.mako
diff --git a/tools/interface_generator/templates_unittest.py b/tools/interface_generator/bin/templates_unittest.py
index 594753d..feb418a 100755
--- a/tools/interface_generator/templates_unittest.py
+++ b/tools/interface_generator/bin/templates_unittest.py
@@ -1,13 +1,18 @@
#!/usr/bin/env python3
+import sys
import unittest
import templates
from pathlib import Path
class Templates(unittest.TestCase):
+ def test_templates_dir_in_argv_0(self):
+ path = Path(sys.argv[0]).parent
+ self.assertTrue("templates" in [ item.name for item in path.iterdir() ])
+
def test_get_templates(self):
- path = Path("templates")
+ path = Path(sys.argv[0]).parent / "templates"
result = templates.get_templates(path)
self.assertGreater(len(result), 0)
diff --git a/tools/interface_generator/defs.bzl b/tools/interface_generator/defs.bzl
index d5c6f91..238588f 100644
--- a/tools/interface_generator/defs.bzl
+++ b/tools/interface_generator/defs.bzl
@@ -37,7 +37,7 @@ generate_interface_rule = rule(
cfg = "exec",
allow_files = True,
providers = [DefaultInfo],
- default = Label("//:interface_generator"),
+ default = Label("//bin:interface_generator"),
),
"outs": attr.output_list(),
},