From af3fbe432fe16efb05f26c24a0fa9724680dc8dd Mon Sep 17 00:00:00 2001
From: JaredD <jareddpub@gmail.com>
Date: Mon, 27 Sep 2021 09:04:13 -0600
Subject: grc: Implement grcc --output switch for hierarchical blocks

* grc: Implement --output functionality for grcc

Reference gnradio Issue #2799.

This commit adjusts some logic and code to enable the --output switch
for grcc.
Prior to this commit, grcc would only output to the GRC_HIER_PATH.
The commit adjusts the various Generators in grc/core/generator to
consistently use
output_dir for the output directory.
If it's None, then take from the platform.config.hier_block_lib_dir
attribute which can be set via the
GRC_HIER_PATH env var.
The cpp_top_block generator was also modified to remote its __init__ function
which appeared identical to its base TopBlockGenerator.
I did not test c++ GRC output.

* Make output directory if does not exist
* Duplicate TopBlockGenerator __init__ without .py extension; base class object
* Typo in os.makedirs kwarg
* Added _warnings method from TopBlockGenerator

Signed-off-by: Jared Dulmage <jared.dulmage@caliola.com>
---
 grc/core/generator/Generator.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'grc/core/generator/Generator.py')

diff --git a/grc/core/generator/Generator.py b/grc/core/generator/Generator.py
index 204ee7e620..3f1831cc1b 100644
--- a/grc/core/generator/Generator.py
+++ b/grc/core/generator/Generator.py
@@ -15,14 +15,14 @@ from .cpp_hier_block import CppHierBlockGenerator
 class Generator(object):
     """Adaptor for various generators (uses generate_options)"""
 
-    def __init__(self, flow_graph, file_path):
+    def __init__(self, flow_graph, output_dir):
         """
         Initialize the generator object.
         Determine the file to generate.
 
         Args:
             flow_graph: the flow graph object
-            file_path: the path to the grc file
+            output_dir: the output path for generated files
         """
         self.generate_options = flow_graph.get_option('generate_options')
         self.output_language = flow_graph.get_option('output_language')
@@ -45,7 +45,7 @@ class Generator(object):
             else:
                 generator_cls = CppTopBlockGenerator
 
-        self._generator = generator_cls(flow_graph, file_path)
+        self._generator = generator_cls(flow_graph, output_dir)
 
     def __getattr__(self, item):
         """get all other attrib from actual generator object"""
-- 
cgit v1.2.3