forked from rixon/homebrew-gnuradio
-
Notifications
You must be signed in to change notification settings - Fork 4
/
gnuradio.rb
287 lines (247 loc) · 9.37 KB
/
gnuradio.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
class Gnuradio < Formula
desc "SDK providing the signal processing runtime and processing blocks"
homepage "https://gnuradio.org/"
url "https://gnuradio.org/releases/gnuradio/gnuradio-3.7.10.1.tar.gz"
sha256 "63d7b65cc4abe22f47b8f41caaf7370a0a502b91e36e29901ba03e8838ab4937"
head "https://github.com/gnuradio/gnuradio.git"
bottle do
sha256 "4d064a778aa85bb11b16a9bb3ebcb2c403ab40405ffd54bf50ef35c5d8f14c2d" => :sierra
sha256 "1578ae20b2b080b2c71e7ff6ffb30179d8896e77853aa68c1266a4ed1eca36c5" => :el_capitan
sha256 "2125887a9ea16693e55a88ac70b5a3ae9e31df932f3a624169dd2620e53cece5" => :yosemite
end
# Fixes linkage of python (swig) bindings directly to python
# https://github.com/gnuradio/gnuradio/pull/1146
# Merged into master, probably will be in next release
patch do
url "https://github.com/gnuradio/gnuradio/pull/1146.patch?full_index=2"
sha256 "c4768a30cb675255485a8d12aa2c01ba7bb287d8a2e82088148df43715460701"
end
option "without-python", "Build without python support"
option "with-qt", "Build with Qt support"
depends_on "pkg-config" => :build
depends_on 'python@2'
depends_on "boost"
depends_on "cppunit"
depends_on "gsl"
depends_on "zeromq"
depends_on "numpy" if build.with? "python"
depends_on "swig" => :build if build.with? "python"
depends_on "cmake" => :build
depends_on 'pyqt@4' if build.with? "qt"
depends_on 'qwt-qt4' if build.with? "qt"
# For documentation
depends_on "doxygen" => :optional
depends_on "sphinx-doc" => :optional
depends_on "uhd" => :recommended
depends_on "sdl" => :recommended
depends_on "jack" => :optional
depends_on "portaudio" => :recommended
depends_on "pygtk" => :recommended
depends_on "wxpython" => :recommended
# Upstream PR from 17 Apr 2018 "Boost 1.67.0 compatibility"
patch do
url "https://github.com/gnuradio/gnuradio/pull/1733.patch?full_index=1"
sha256 "f02a04fb179a9b525b5e4ba8171ce5737c16d64f06f0e318ce092c6b4e19025f"
end
# cheetah starts here
resource "Markdown" do
url "https://pypi.python.org/packages/source/M/Markdown/Markdown-2.4.tar.gz"
sha256 "b8370fce4fbcd6b68b6b36c0fb0f4ec24d6ba37ea22988740f4701536611f1ae"
end
resource "Cheetah" do
url "https://pypi.python.org/packages/source/C/Cheetah/Cheetah-2.4.4.tar.gz"
sha256 "be308229f0c1e5e5af4f27d7ee06d90bb19e6af3059794e5fd536a6f29a9b550"
end
# cheetah ends here
resource "lxml" do
url "https://pypi.python.org/packages/source/l/lxml/lxml-2.0.tar.gz"
sha256 "062e6dbebcbe738eaa6e6298fe38b1ddf355dbe67a9f76c67a79fcef67468c5b"
end
resource "cppzmq" do
url "https://github.com/zeromq/cppzmq/raw/a4459abdd1d70fd980f9c166d73da71fe9762e0b/zmq.hpp"
sha256 "f042d4d66e2a58bd951a3eaf108303e862fad2975693bebf493931df9cd251a5"
end
patch :DATA
def install
ENV["CHEETAH_INSTALL_WITHOUT_SETUPTOOLS"] = "1"
ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python2.7/site-packages"
res = %w[Markdown Cheetah lxml]
res.each do |r|
resource(r).stage do
system "python2", *Language::Python.setup_install_args(libexec/"vendor")
end
end
resource("cppzmq").stage include.to_s
args = std_cmake_args
args << "-DCMAKE_CXX_STANDARD=11"
python_prefix = `python2-config --prefix`.strip
if File.exist? "#{python_prefix}/Python"
# Python was compiled with --framework:
args << "-DPYTHON_LIBRARY='#{python_prefix}/Python'"
args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/Headers'"
end
args << "-DGR_PKG_CONF_DIR=#{etc}/gnuradio/conf.d"
args << "-DGR_PREFSDIR=#{etc}/gnuradio/conf.d"
args << "-DENABLE_DEFAULT=OFF"
enabled_components = %w[gr-analog gr-fft volk gr-filter gnuradio-runtime
gr-blocks testing gr-pager gr-noaa gr-channels
gr-audio gr-fcd gr-vocoder gr-fec gr-digital
gr-dtv gr-atsc gr-trellis gr-zeromq]
if build.with? "python"
enabled_components << "python"
enabled_components << "gr-utils"
enabled_components << "grc" if build.with? "pygtk"
enabled_components << "gr-wxgui" if build.with? "wxpython"
end
enabled_components << "gr-wavelet"
enabled_components << "gr-video-sdl" if build.with? "sdl"
enabled_components << "gr-uhd" if build.with? "uhd"
enabled_components << "doxygen" if build.with? "doxygen"
enabled_components << "sphinx" if build.with? "sphinx"
enabled_components << "gr-qtgui" if build.with? "qt"
enabled_components.each do |c|
args << "-DENABLE_#{c.upcase.split("-").join("_")}=ON"
end
mkdir "build" do
system "cmake", "..", *args
system "make"
system "make", "install"
end
rm bin.children.reject(&:executable?)
bin.env_script_all_files(libexec/"bin", :PYTHONPATH => ENV["PYTHONPATH"])
end
test do
system("#{bin}/gnuradio-config-info -v")
(testpath/"test.c++").write <<-EOS.undent
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/null_source.h>
#include <gnuradio/blocks/null_sink.h>
#include <gnuradio/blocks/head.h>
#include <gnuradio/gr_complex.h>
class top_block : public gr::top_block {
public:
top_block();
private:
gr::blocks::null_source::sptr null_source;
gr::blocks::null_sink::sptr null_sink;
gr::blocks::head::sptr head;
};
top_block::top_block() : gr::top_block("Top block") {
long s = sizeof(gr_complex);
null_source = gr::blocks::null_source::make(s);
null_sink = gr::blocks::null_sink::make(s);
head = gr::blocks::head::make(s, 1024);
connect(null_source, 0, head, 0);
connect(head, 0, null_sink, 0);
}
int main(int argc, char **argv) {
top_block top;
top.run();
}
EOS
system ENV.cxx,
"-lgnuradio-blocks", "-lgnuradio-runtime", "-lgnuradio-pmt",
"-lboost_system",
(testpath/"test.c++"),
"-o", (testpath/"test")
system (testpath/"test")
if build.with? "python"
(testpath/"test.py").write <<-EOS.undent
from gnuradio import blocks
from gnuradio import gr
class top_block(gr.top_block):
def __init__(self):
gr.top_block.__init__(self, "Top Block")
self.samp_rate = 32000
s = gr.sizeof_gr_complex
self.blocks_null_source_0 = blocks.null_source(s)
self.blocks_null_sink_0 = blocks.null_sink(s)
self.blocks_head_0 = blocks.head(s, 1024)
self.connect((self.blocks_head_0, 0),
(self.blocks_null_sink_0, 0))
self.connect((self.blocks_null_source_0, 0),
(self.blocks_head_0, 0))
def main(top_block_cls=top_block, options=None):
tb = top_block_cls()
tb.start()
tb.wait()
main()
EOS
system "python2", (testpath/"test.py")
cd(testpath) do
system "#{bin}/gr_modtool", "newmod", "test"
cd("gr-test") do
system "#{bin}/gr_modtool", "add", "-t", "general", "test_ff", "-l",
"python2", "-y", "--argument-list=''", "--add-python-qa"
end
end
end
end
end
__END__
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ca13431cd..5df7d7bb8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -278,7 +278,7 @@ include(GrBoost)
########################################################################
# Enable python component
########################################################################
-find_package(PythonLibs 2)
+find_package(PythonLibs 2)
find_package(SWIG)
if(SWIG_FOUND)
@@ -291,7 +291,6 @@ endif(SWIG_FOUND)
include(GrComponent)
GR_REGISTER_COMPONENT("python-support" ENABLE_PYTHON
- PYTHONLIBS_FOUND
SWIG_FOUND
SWIG_VERSION_CHECK
)
diff --git a/gnuradio-runtime/CMakeLists.txt b/gnuradio-runtime/CMakeLists.txt
index 766064250..9c644817e 100644
--- a/gnuradio-runtime/CMakeLists.txt
+++ b/gnuradio-runtime/CMakeLists.txt
@@ -36,7 +36,6 @@ include(GrComponent)
GR_REGISTER_COMPONENT("gnuradio-runtime" ENABLE_GNURADIO_RUNTIME
Boost_FOUND
ENABLE_VOLK
- PYTHONINTERP_FOUND
)
GR_SET_GLOBAL(GNURADIO_RUNTIME_INCLUDE_DIRS
diff --git a/gr-qtgui/CMakeLists.txt b/gr-qtgui/CMakeLists.txt
index ad10363c1..00ae7c9aa 100644
--- a/gr-qtgui/CMakeLists.txt
+++ b/gr-qtgui/CMakeLists.txt
@@ -26,7 +26,8 @@ find_package(Qt4 4.2.0 COMPONENTS QtCore QtGui)
find_package(Qwt)
-find_package(PythonLibs 2)
+#find_package(PythonInterp 2)
+#find_package(PythonLibs 2)
include(GrPython)
GR_PYTHON_CHECK_MODULE("PyQt4" PyQt4 True PYQT4_FOUND)
@@ -49,7 +50,6 @@ GR_REGISTER_COMPONENT("gr-qtgui" ENABLE_GR_QTGUI
ENABLE_GNURADIO_RUNTIME
ENABLE_GR_FFT
ENABLE_GR_FILTER
- PYTHONLIBS_FOUND
${qt_gui_python_deps}
)
diff --git a/gr-qtgui/lib/CMakeLists.txt b/gr-qtgui/lib/CMakeLists.txt
index b1ee58039..80a129429 100644
--- a/gr-qtgui/lib/CMakeLists.txt
+++ b/gr-qtgui/lib/CMakeLists.txt
@@ -169,9 +169,11 @@ endif(WIN32)
include(GrPython)
if(ENABLE_PYTHON)
add_definitions(-DENABLE_PYTHON)
- list(APPEND qtgui_libs
- ${PYTHON_LIBRARIES}
- )
+ if(APPLE)
+ list(APPEND qtgui_libs "-undefined dynamic_lookup")
+ else()
+ list(APPEND qtgui_libs ${PYTHON_LIBRARIES})
+ endif(APPLE)
endif(ENABLE_PYTHON)
add_definitions(-DQWT_DLL) #setup QWT library linkage