summaryrefslogtreecommitdiff
path: root/grc/core/platform.py
diff options
context:
space:
mode:
authorJaredD <jareddpub@gmail.com>2021-09-27 09:04:13 -0600
committerGitHub <noreply@github.com>2021-09-27 11:04:13 -0400
commitaf3fbe432fe16efb05f26c24a0fa9724680dc8dd (patch)
tree4a6666b61cbdafc7596d0647d9992a153dd34353 /grc/core/platform.py
parent91e9ddf8e1c37adff0c982c80bd1792df58cbe23 (diff)
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>
Diffstat (limited to 'grc/core/platform.py')
-rw-r--r--grc/core/platform.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/grc/core/platform.py b/grc/core/platform.py
index 42d5b660c7..1064dc6ba2 100644
--- a/grc/core/platform.py
+++ b/grc/core/platform.py
@@ -73,7 +73,7 @@ class Platform(Element):
if os.path.exists(os.path.normpath(file_path)):
return file_path
- def load_and_generate_flow_graph(self, file_path, out_path=None, hier_only=False):
+ def load_and_generate_flow_graph(self, file_path, out_dir=None, hier_only=False):
"""Loads a flow graph from file and generates it"""
Messages.set_indent(len(self._auto_hier_block_generate_chain))
Messages.send('>>> Loading: {}\n'.format(file_path))
@@ -101,17 +101,16 @@ class Platform(Element):
Messages.set_indent(len(self._auto_hier_block_generate_chain))
try:
- generator = self.Generator(flow_graph, out_path or file_path)
+ if flow_graph.get_option('generate_options').startswith('hb'):
+ generator = self.Generator(flow_graph, out_dir)
+ else:
+ generator = self.Generator(flow_graph, out_dir or file_path)
Messages.send('>>> Generating: {}\n'.format(generator.file_path))
generator.write()
except Exception as e:
Messages.send('>>> Generate Error: {}: {}\n'.format(file_path, str(e)))
return None, None
- if flow_graph.get_option('generate_options').startswith('hb'):
- # self.load_block_xml(generator.file_path_xml)
- # TODO: implement yml output for hier blocks
- pass
return flow_graph, generator.file_path
def build_library(self, path=None):