summaryrefslogtreecommitdiff
path: root/gr-utils
diff options
context:
space:
mode:
authorTom Rondeau2012-12-12 18:15:32 -0500
committerTom Rondeau2012-12-12 18:15:32 -0500
commit9ac98067a8529d80501ab3c8122b3ce11e896657 (patch)
tree31d9b7b384156d9cd3d9a23e57611563b5576487 /gr-utils
parent619a167471d060e2f1b49a9aac55a23b327afa88 (diff)
parentaeb7bbfdcb7cdab610de4b2576ecf7a3a92f8d50 (diff)
downloadgnuradio-9ac98067a8529d80501ab3c8122b3ce11e896657.tar.gz
gnuradio-9ac98067a8529d80501ab3c8122b3ce11e896657.tar.bz2
gnuradio-9ac98067a8529d80501ab3c8122b3ce11e896657.zip
Merge branch 'master' into file_meta_data
Conflicts: gr-utils/src/python/CMakeLists.txt
Diffstat (limited to 'gr-utils')
-rw-r--r--gr-utils/src/python/CMakeLists.txt1
-rwxr-xr-xgr-utils/src/python/grcc66
2 files changed, 67 insertions, 0 deletions
diff --git a/gr-utils/src/python/CMakeLists.txt b/gr-utils/src/python/CMakeLists.txt
index 13fa06bbc..d2af6b952 100644
--- a/gr-utils/src/python/CMakeLists.txt
+++ b/gr-utils/src/python/CMakeLists.txt
@@ -51,6 +51,7 @@ GR_PYTHON_INSTALL(
gr_plot_qt
gr_filter_design
gr_read_file_metadata
+ grcc
DESTINATION ${GR_RUNTIME_DIR}
COMPONENT "utils"
)
diff --git a/gr-utils/src/python/grcc b/gr-utils/src/python/grcc
new file mode 100755
index 000000000..7e5665dc0
--- /dev/null
+++ b/gr-utils/src/python/grcc
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+#
+# 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.
+#
+
+try:
+ from grc.python.Platform import Platform
+except ImportError:
+ from gnuradio.grc.python.Platform import Platform
+
+from optparse import OptionParser
+import os, sys
+
+class grcc:
+ def __init__(self, grcfile, out_dir):
+ self.out_dir = out_dir
+ self.platform = Platform()
+ data = self.platform.parse_flow_graph(grcfile)
+
+ self.fg = self.platform.get_new_flow_graph()
+ self.fg.import_data(data)
+ self.fg.validate()
+
+ self.gen = self.platform.get_generator()(self.fg, out_dir)
+ self.gen.write()
+
+ def exec_program(self):
+ progname = self.fg.get_option('id')
+ os.system("{0}/{1}.py".format(self.out_dir, progname))
+
+if __name__ == "__main__":
+ usage="%prog: [options] filename"
+ description = "Compiles a GRC file (.grc) into a GNU Radio Python program. The program is stored in ~/.grc_gnuradio by default, but this location can be changed with the -d option."
+
+ parser = OptionParser(conflict_handler="resolve", usage=usage, description=description)
+ parser.add_option("-d", "--directory", type="string", default='{0}/.grc_gnuradio/'.format(os.environ["HOME"]),
+ help="Specify the directory to output the compile program [default=%default]")
+ parser.add_option("-e", "--execute", action="store_true", default=False,
+ help="Run the program after compiling [default=%default]")
+ (options, args) = parser.parse_args ()
+
+ if(len(args) != 1):
+ sys.stderr.write("Please specify a GRC file name to compile.\n")
+ sys.exit(1)
+
+ g = grcc(args[0], options.directory+"/")
+
+ if(options.execute):
+ g.exec_program()