Browse files

added Paul Miller's grcc script

  • Loading branch information...
1 parent b089505 commit 98451b30d48b0a805c1cba9177c7de331a93fce8 @guruofquality committed Jul 25, 2012
Showing with 89 additions and 0 deletions.
  1. +1 −0 CMakeLists.txt
  2. +28 −0 scripts/CMakeLists.txt
  3. +60 −0 scripts/grcc
View
1 CMakeLists.txt
@@ -204,3 +204,4 @@ add_subdirectory(lib)
add_subdirectory(swig)
add_subdirectory(python)
add_subdirectory(grc)
+add_subdirectory(scripts)
View
28 scripts/CMakeLists.txt
@@ -0,0 +1,28 @@
+# Copyright 2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+########################################################################
+include(GrPython)
+
+GR_PYTHON_INSTALL(
+ PROGRAMS
+ grcc
+ DESTINATION ${GR_RUNTIME_DIR}
+ COMPONENT "extras_python"
+)
View
60 scripts/grcc
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+"""
+License and Copyright:
+ Copyright Paul Miller 2012
+
+ This program is really just copied from GNU Radio (via source
+ diving). Please considered it licensed under whatever
+ licenses (and versions) GNU Radio itself is using.
+
+Usage: grcc [list of grc files to compile]
+
+Options:
+ --version show program's version number and exit
+ -h, --help show this help message and exit
+ -v, --verbose verbose output during compile [default=False]
+"""
+
+import sys
+import os
+from optparse import OptionParser
+from gnuradio import gr
+from gnuradio.grc.python.Constants import HIER_BLOCKS_LIB_DIR
+from gnuradio.grc.python.Platform import Platform
+
+def compile_one(file_name, output_dir):
+ platform = Platform()
+ state = platform.parse_flow_graph(file_name)
+ flowgraph = platform.get_new_flow_graph()
+
+ flowgraph.import_data(state)
+ flowgraph.validate();
+
+ generator = platform.get_generator()( flowgraph, output_dir )
+
+ generator.write()
+
+if __name__ == "__main__":
+ usage = 'usage: %prog [list of grc files to compile]'
+ version = """
+GNU Radio Companion Compiler %s
+
+This program is part of GNU Radio
+grcc comes with ABSOLUTELY NO WARRANTY.
+This is free software,
+and you are welcome to redistribute it.
+"""%gr.version()
+
+ parser = OptionParser(usage=usage, version=version)
+ parser.add_option("-v", "--verbose", action="store_true", default=False,
+ help="verbose output during compile [default=%default]")
+ (options, args) = parser.parse_args()
+
+ output_dir = HIER_BLOCKS_LIB_DIR
+
+ if "GRC_OUTPUT_DIRECTORY" in os.environ:
+ output_dir = os.environ["GRC_OUTPUT_DIRECTORY"]
+
+ for x in args:
+ if options.verbose: print "compiling %s -> %s" % (x, output_dir)
+ compile_one(x, output_dir)

0 comments on commit 98451b3

Please sign in to comment.