diff options
Diffstat (limited to 'gruel/src')
-rw-r--r-- | gruel/src/lib/pmt/Makefile.am | 8 | ||||
-rw-r--r-- | gruel/src/scheme/gnuradio/Makefile.am | 4 | ||||
-rw-r--r-- | gruel/src/scheme/gnuradio/gen-serial-tags.py | 53 | ||||
-rwxr-xr-x | gruel/src/scheme/gnuradio/gen-serial-tags.scm | 118 |
4 files changed, 59 insertions, 124 deletions
diff --git a/gruel/src/lib/pmt/Makefile.am b/gruel/src/lib/pmt/Makefile.am index 7a1f2e7d4..0c8e12dc3 100644 --- a/gruel/src/lib/pmt/Makefile.am +++ b/gruel/src/lib/pmt/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2008,2009,2010 Free Software Foundation, Inc. +# Copyright 2008,2009,2010,2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -99,7 +99,7 @@ gen_sources_deps = $(core_generator) par_gen_command = PYTHONPATH=$(top_srcdir)/gruel/src/lib/pmt srcdir=$(srcdir) $(PYTHON) $(srcdir)/generate_unv.py include $(top_srcdir)/Makefile.par.gen -# Rule to create the build header file using GUILE +# Rule to create the build header file using python # Doesn't need parallel protections because there is a single target -$(PMT_SERIAL_TAGS_H): $(srcdir)/../../scheme/gnuradio/gen-serial-tags.scm $(srcdir)/../../scheme/gnuradio/pmt-serial-tags.scm - $(RUN_GUILE) $(srcdir)/../../scheme/gnuradio/gen-serial-tags.scm $(srcdir)/../../scheme/gnuradio/pmt-serial-tags.scm $(PMT_SERIAL_TAGS_H) +$(PMT_SERIAL_TAGS_H): $(top_srcdir)/gruel/src/scheme/gnuradio/gen-serial-tags.py $(top_srcdir)/gruel/src/scheme/gnuradio/pmt-serial-tags.scm + $(PYTHON) $^ $@ diff --git a/gruel/src/scheme/gnuradio/Makefile.am b/gruel/src/scheme/gnuradio/Makefile.am index 2f8e5c8d2..e7b6bf744 100644 --- a/gruel/src/scheme/gnuradio/Makefile.am +++ b/gruel/src/scheme/gnuradio/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2007,2009,2010 Free Software Foundation, Inc. +# Copyright 2007,2009,2010,2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ include $(top_srcdir)/Makefile.common #pkgdatadir = $(datadir)/gnuradio EXTRA_DIST += \ - gen-serial-tags.scm + gen-serial-tags.py # really scheme source files FIXME wrong location dist_pkgdata_DATA = \ diff --git a/gruel/src/scheme/gnuradio/gen-serial-tags.py b/gruel/src/scheme/gnuradio/gen-serial-tags.py new file mode 100644 index 000000000..18e927beb --- /dev/null +++ b/gruel/src/scheme/gnuradio/gen-serial-tags.py @@ -0,0 +1,53 @@ +""" +// +// Copyright 2011 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 this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// +// THIS FILE IS MACHINE GENERATED FROM %s. DO NOT EDIT BY HAND. +// See %s for additional commentary. +// + +#ifndef INCLUDED_PMT_SERIAL_TAGS_H +#define INCLUDED_PMT_SERIAL_TAGS_H + +enum pst_tags { +%s +}; +#endif /* INCLUDED_PMT_SERIAL_TAGS_H */ +""" + +import sys, os, re + +if __name__ == '__main__': + if len(sys.argv) != 3: + print "Usage %s <input_scm_file> <output_hdr_file>"%__file__ + exit() + input_scm_file, output_hdr_file = sys.argv[1:] + enums = list() + for line in open(input_scm_file).readlines(): + match = re.match('^\s*\(define\s+([\w|-]+)\s+#x([0-9a-fA-F]+)\)', line) + if not match: continue + name, value = match.groups() + name = name.upper().replace('-', '_') + enums.append(' %s = 0x%s'%(name, value)) + open(output_hdr_file, 'w').write(__doc__%( + os.path.basename(__file__), + os.path.basename(input_scm_file), + ',\n'.join(enums), + )) diff --git a/gruel/src/scheme/gnuradio/gen-serial-tags.scm b/gruel/src/scheme/gnuradio/gen-serial-tags.scm deleted file mode 100755 index 7b9087228..000000000 --- a/gruel/src/scheme/gnuradio/gen-serial-tags.scm +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/guile \ --e main -s -!# -;;; -*-scheme-*- -;;; -;;; Copyright 2007 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 this program; if not, write to the Free Software Foundation, Inc., -;;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -;;; - -(use-modules (ice-9 format)) - -(defmacro when (pred . body) - `(if ,pred (begin ,@body) #f)) - -;; ---------------------------------------------------------------- - -(define (main args) - - (define (usage) - (format 0 - "usage: ~a <pmt-serial-tags.scm> <pmt_serial_tags.h>~%" - (car args))) - - (when (not (= (length args) 3)) - (usage) - (format 0 "args: ~s~%" args) - (exit 1)) - - (let ((i-file (open-input-file (cadr args))) - (h-file (open-output-file (caddr args)))) - - (write-header-comment h-file "// ") - (display "#ifndef INCLUDED_PMT_SERIAL_TAGS_H\n" h-file) - (display "#define INCLUDED_PMT_SERIAL_TAGS_H\n" h-file) - (newline h-file) - (display "enum pst_tags {\n" h-file) - - (for-each-in-file i-file - (lambda (form) - (let* ((name (cadr form)) - (c-name (string-upcase (c-ify name))) - (value (caddr form))) - ;;(format h-file "static const int ~a\t= 0x~x;~%" c-name value) - (format h-file " ~a\t= 0x~x,~%" c-name value)))) - - (display "};\n" h-file) - (display "#endif\n" h-file))) - -(define (c-ify name) - (list->string (map (lambda (c) - (if (eqv? c #\-) #\_ c)) - (string->list (symbol->string name))))) - - -(define (write-header-comment o-port prefix) - (for-each (lambda (comment) - (format o-port "~a~a~%" prefix comment)) - header-comment)) - -(define header-comment - '( - "" - "Copyright 2007 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 this program; if not, write to the Free Software Foundation, Inc.," - "51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA." - "" - "" - "THIS FILE IS MACHINE GENERATED FROM pmt-serial-tags.scm. DO NOT EDIT BY HAND." - "See pmt-serial-tags.scm for additional commentary." - "")) - - - -(define (for-each-in-file file f) - (let ((port (if (port? file) - file - (open-input-file file)))) - (letrec - ((loop - (lambda (port form) - (cond ((eof-object? form) - (when (not (eq? port file)) - (close-input-port port)) - #t) - (else - (f form) - (set! form #f) ; for GC - (loop port (read port))))))) - (loop port (read port))))) |