From 3b0db38361d6ff50d62d814e72eb1fdd0e5d762d Mon Sep 17 00:00:00 2001 From: jcorgan Date: Sat, 11 Jul 2009 02:34:31 +0000 Subject: Implements ticket:401 and ticket:402. Adds several API functions to determine build constants at runtime, and a convenience command line program to display them: From C++: const std::string gr_prefix(); const std::string gr_sysconfdir(); const std::string gr_prefsdir(); const std::string gr_build_date(); const std::string gr_svn_date(); const std::string gr_svn_version(); const std::string gr_version(); From Python: gr.prefix() gr.sysconfdir() gr.prefsdir() gr.build_date() gr.svn_date() gr.svn_version() gr.version() The new binary is 'gnuradio' and installed on the path: $ gnuradio Program options: gnuradio [options]: -h [ --help ] print help message --prefix print gnuradio installation prefix --sysconfdir print gnuradio system configuration directory --prefsdir print gnuradio preferences directory --builddate print gnuradio build date (RFC2822 format) -v [ --version ] print gnuradio version --svnversion print SVN repository version (SVN format) --svndate print SVN repository date $ git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11418 221aa14e-8319-0410-a670-987f0aec2ac5 --- gnuradio-core/src/lib/general/Makefile.am | 8 +-- gnuradio-core/src/lib/general/general.i | 4 +- gnuradio-core/src/lib/general/gr_constants.cc.in | 69 ++++++++++++++++++++++++ gnuradio-core/src/lib/general/gr_constants.h | 62 +++++++++++++++++++++ gnuradio-core/src/lib/general/gr_constants.i | 17 ++++++ gnuradio-core/src/lib/general/gr_prefix.cc.in | 29 ---------- gnuradio-core/src/lib/general/gr_prefix.h | 33 ------------ gnuradio-core/src/lib/general/gr_prefix.i | 5 -- 8 files changed, 154 insertions(+), 73 deletions(-) create mode 100644 gnuradio-core/src/lib/general/gr_constants.cc.in create mode 100644 gnuradio-core/src/lib/general/gr_constants.h create mode 100644 gnuradio-core/src/lib/general/gr_constants.i delete mode 100644 gnuradio-core/src/lib/general/gr_prefix.cc.in delete mode 100644 gnuradio-core/src/lib/general/gr_prefix.h delete mode 100644 gnuradio-core/src/lib/general/gr_prefix.i (limited to 'gnuradio-core/src/lib/general') diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am index 5564ee3d4..9b070b865 100644 --- a/gnuradio-core/src/lib/general/Makefile.am +++ b/gnuradio-core/src/lib/general/Makefile.am @@ -31,7 +31,7 @@ BUILT_SOURCES = EXTRA_DIST = \ gen_sine_table.py \ - gr_prefix.cc.in + gr_constants.cc.in libgeneral_la_SOURCES = \ gr_agc_cc.cc \ @@ -117,7 +117,7 @@ libgeneral_la_SOURCES = \ gr_pll_freqdet_cf.cc \ gr_pll_refout_cc.cc \ gr_pn_correlator_cc.cc \ - gr_prefix.cc \ + gr_constants.cc \ gr_prefs.cc \ gr_probe_avg_mag_sqrd_c.cc \ gr_probe_avg_mag_sqrd_cf.cc \ @@ -273,7 +273,7 @@ grinclude_HEADERS = \ gr_pll_freqdet_cf.h \ gr_pll_refout_cc.h \ gr_pn_correlator_cc.h \ - gr_prefix.h \ + gr_constants.h \ gr_prefs.h \ gr_probe_avg_mag_sqrd_c.h \ gr_probe_avg_mag_sqrd_cf.h \ @@ -432,7 +432,7 @@ swiginclude_HEADERS = \ gr_pll_freqdet_cf.i \ gr_pll_refout_cc.i \ gr_pn_correlator_cc.i \ - gr_prefix.i \ + gr_constants.i \ gr_prefs.i \ gr_probe_avg_mag_sqrd_c.i \ gr_probe_avg_mag_sqrd_cf.i \ diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index 0cb54870e..0684e63a5 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -105,7 +105,7 @@ #include #include #include -#include +#include #include #include #include @@ -225,7 +225,7 @@ %include "gr_pa_2x2_phase_combiner.i" %include "gr_kludge_copy.i" %include "gr_prefs.i" -%include "gr_prefix.i" +%include "gr_constants.i" %include "gr_test_types.h" %include "gr_test.i" %include "gr_unpack_k_bits_bb.i" diff --git a/gnuradio-core/src/lib/general/gr_constants.cc.in b/gnuradio-core/src/lib/general/gr_constants.cc.in new file mode 100644 index 000000000..efb0f1c77 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_constants.cc.in @@ -0,0 +1,69 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2009 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. + */ + +#if HAVE_CONFIG_H +#include +#endif + +#include + +const std::string +gr_prefix() +{ + return "@prefix@"; +} + +const std::string +gr_sysconfdir() +{ + return "@SYSCONFDIR@"; +} + +const std::string +gr_prefsdir() +{ + return "@GR_PREFSDIR@"; +} + +const std::string +gr_build_date() +{ + return "@BUILD_DATE@"; +} + +const std::string +gr_svn_date() +{ + return "@SVNDATE@"; +} + +const std::string +gr_svn_version() +{ + return "@SVNVERSION@"; +} + +const std::string +gr_version() +{ + return "@VERSION@"; +} diff --git a/gnuradio-core/src/lib/general/gr_constants.h b/gnuradio-core/src/lib/general/gr_constants.h new file mode 100644 index 000000000..e44890be0 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_constants.h @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2009 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. + */ +#ifndef INCLUDED_GR_CONSTANTS_H +#define INCLUDED_GR_CONSTANTS_H + +#include + +/*! + * \brief return ./configure --prefix argument. Typically /usr/local + */ +const std::string gr_prefix(); + +/*! + * \brief return ./configure --sysconfdir argument. Typically $prefix/etc or /etc + */ +const std::string gr_sysconfdir(); + +/*! + * \brief return preferences file directory. Typically $sysconfdir/etc/conf.d + */ +const std::string gr_prefsdir(); + +/*! + * \brief return date/time of build, as set when 'bootstrap' is run + */ +const std::string gr_build_date(); + +/*! + * \brief return repository date as set when 'bootstrap' is run + */ +const std::string gr_svn_date(); + +/*! + * \brief return repository version as set when 'bootstrap' is run + */ +const std::string gr_svn_version(); + +/*! + * \brief return version string defined in configure.ac + */ +const std::string gr_version(); + +#endif /* INCLUDED_GR_CONSTANTS_H */ diff --git a/gnuradio-core/src/lib/general/gr_constants.i b/gnuradio-core/src/lib/general/gr_constants.i new file mode 100644 index 000000000..156af4a36 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_constants.i @@ -0,0 +1,17 @@ +/* -*- c++ -*- */ + +%rename(prefix) gr_prefix; +%rename(sysconfdir) gr_sysconfdir; +%rename(prefsdir) gr_prefsdir; +%rename(build_date) gr_build_date; +%rename(svn_date) gr_svn_date; +%rename(svn_version) gr_svn_version; +%rename(version) gr_version; + +const std::string gr_prefix(); +const std::string gr_sysconfdir(); +const std::string gr_prefsdir(); +const std::string gr_build_date(); +const std::string gr_svn_date(); +const std::string gr_svn_version(); +const std::string gr_version(); diff --git a/gnuradio-core/src/lib/general/gr_prefix.cc.in b/gnuradio-core/src/lib/general/gr_prefix.cc.in deleted file mode 100644 index f03043ce1..000000000 --- a/gnuradio-core/src/lib/general/gr_prefix.cc.in +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 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 - -const std::string -gr_prefix() -{ - return "@prefix@"; -} diff --git a/gnuradio-core/src/lib/general/gr_prefix.h b/gnuradio-core/src/lib/general/gr_prefix.h deleted file mode 100644 index 0a107b98c..000000000 --- a/gnuradio-core/src/lib/general/gr_prefix.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 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. - */ -#ifndef INCLUDED_GR_PREFIX_H -#define INCLUDED_GR_PREFIX_H - -#include - -/*! - * \brief return ./configure --prefix argument. Typically /usr/local - */ -const std::string gr_prefix(); - - -#endif /* INCLUDED_GR_PREFIX_H */ diff --git a/gnuradio-core/src/lib/general/gr_prefix.i b/gnuradio-core/src/lib/general/gr_prefix.i deleted file mode 100644 index 04e1899a6..000000000 --- a/gnuradio-core/src/lib/general/gr_prefix.i +++ /dev/null @@ -1,5 +0,0 @@ -/* -*- c++ -*- */ - -%rename(prefix) gr_prefix; - -const std::string gr_prefix(); -- cgit