master
Max 1 week ago
parent f010f3f5dc
commit e7fc1c6c45
  1. 44
      add_gr3.9.py
  2. 20
      scripts/do_sedm.sh

@ -27,11 +27,11 @@ print('\n%s Copyright 2022, Max H. Parke KA1RBI\nhttps://osmocom.org/projects/op
TLD = 'op25'
MODS={
'op25': 'decoder_bf decoder_ff fsk4_demod_ff fsk4_slicer_fb pcap_source_b'.split(),
'op25': 'decoder_bf decoder_ff fsk4_demod_ff fsk4_slicer_fb pcap_source_b message msg_queue msg_handler'.split(),
'op25_repeater': 'ambe_encoder_sb dmr_bs_tx_bb dstar_tx_sb frame_assembler fsk4_slicer_fb gardner_costas_cc nxdn_tx_sb p25_frame_assembler vocoder ysf_tx_sb'.split()
}
SKIP_CC = 'd2460.cc qa_op25.cc test_op25.cc qa_op25_repeater.cc test_op25_repeater.cc'.split()
SKIP_CC = 'd2460.cc qa_op25.cc test_op25.cc qa_op25_repeater.cc test_op25_repeater.cc message.cc msg_queue.cc msg_handler.cc'.split()
SRC_DIR = sys.argv[1]
DEST_DIR = sys.argv[2]
@ -59,15 +59,28 @@ os.chdir(op25_dir)
SCRIPTS = SRC_DIR + '/scripts'
TXT = """add_library(op25-message SHARED message.cc msg_queue.cc msg_handler.cc)
install(TARGETS op25-message EXPORT op25-message-export DESTINATION lib)
install(EXPORT op25-message-export DESTINATION ${GR_CMAKE_DIR})
target_include_directories(op25-message
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
PUBLIC $<INSTALL_INTERFACE:include>
)
"""
def edit_cmake(filename, mod, srcfiles):
lines = open(filename).read().rstrip().split('\n')
srcdefs = []
state = 0
end_mark = 0
add_library = 0
tll = 0 # target_link_library
srcfiles = [s.split('/')[-1] for s in srcfiles if s.endswith('.cc') or s.endswith('.c') or s.endswith('.cpp')]
lines = [l for l in lines if l.strip() not in SKIP_CC]
for i in range(len(lines)):
if lines[i].startswith('list(APPEND op25_') and '_sources' in lines[i]:
if 'add_library' in lines[i] and 'gnuradio-op25' in lines[i]:
add_library = i
if lines[i].startswith('list(APPEND op25_') and ('_sources' in lines[i] or '_python_files' in lines[i]):
state = 1
continue
elif ')' in lines[i] and state:
@ -82,13 +95,16 @@ def edit_cmake(filename, mod, srcfiles):
srcdefs.append(lines[i].strip())
srcfiles = [" %s" % s for s in srcfiles if s not in srcdefs and s not in SKIP_CC]
tlls = {
'op25': 'target_link_libraries(gnuradio-op25 gnuradio::gnuradio-runtime Boost::system Boost::program_options Boost::filesystem Boost::thread itpp pcap)',
'op25_repeater': 'target_link_libraries(gnuradio-op25_repeater PUBLIC gnuradio::gnuradio-runtime gnuradio::gnuradio-filter PRIVATE imbe_vocoder)'
'op25': 'target_link_libraries(gnuradio-op25 gnuradio::gnuradio-runtime Boost::system Boost::program_options Boost::filesystem Boost::thread itpp pcap op25-message)',
'op25_repeater': 'target_link_libraries(gnuradio-op25_repeater PUBLIC gnuradio::gnuradio-runtime gnuradio::gnuradio-filter op25-message PRIVATE imbe_vocoder)'
}
assert tll # fail if target_link_libraries line not found
lines[tll] = tlls[mod]
if mod == 'op25_repeater':
lines = lines[:tll] + ['\n' + 'add_subdirectory(imbe_vocoder)\n'] + lines[tll:]
elif mod == 'op25':
assert add_library > 0
lines = lines[:add_library] + [s for s in TXT.split('\n')] + lines[add_library:]
new_lines = lines[:end_mark] + srcfiles + lines[end_mark:]
s = '\n'.join(new_lines)
@ -130,9 +146,11 @@ for mod in sorted(MODS.keys()):
print('gr_modtool newmod %s getcwd now %s' % (mod, os.getcwd()))
pfx = '%s/op25/gr-%s' % (SRC_DIR, mod)
lib = '%s/lib' % pfx
s_py = '%s/python/op25/bindings' % pfx
incl = '%s/include/%s' % (pfx, mod)
d_pfx = '%s/op25/gr-%s' % (DEST_DIR, mod)
d_lib = '%s/lib' % d_pfx
d_py = '%s/python/op25/bindings' % d_pfx
d_incl_alt1 = '%s/include/%s' % (d_pfx, mod)
d_incl_alt2 = '%s/include/gnuradio/%s' % (d_pfx, mod)
if os.path.isdir(d_incl_alt1):
@ -141,6 +159,12 @@ for mod in sorted(MODS.keys()):
d_incl = d_incl_alt2
sl = 'gnuradio/%s' % mod
os.symlink(sl, '%s/include/%s' % (d_pfx, mod))
if mod == 'op25_repeater':
p_pfx = '%s/op25/gr-%s' % (DEST_DIR, 'op25')
p_incl = '%s/include/%s' % (p_pfx, 'op25')
d = '/'.join(d_incl.split('/')[:-1])
os.symlink(p_incl, '%s/include/%s' % (d_pfx, 'op25'))
else:
sys.stderr.write('neither %s nor %s found, aborting\n' % (d_incl_alt1, d_incl_alt2))
sys.exit(1)
@ -149,12 +173,12 @@ for mod in sorted(MODS.keys()):
include = '%s/%s.h' % (incl, block)
args = get_args_from_h(include)
t = 'sync' if block == 'fsk4_slicer_fb' or block == 'pcap_source_b' else 'general'
if block == 'message' or block == 'msg_queue' or block == 'msg_handler':
t = 'noblock'
print ('add %s %s type %s directory %s args %s' % (mod, block, t, os.getcwd(), args))
m = ModToolAdd(blockname=block,block_type=t,lang='cpp',copyright='Steve Glass, OP25 Group', argument_list=args)
m.run()
assert os.path.isdir(d_incl)
srcfiles = []
srcfiles += glob.glob('%s/lib/*.cc' % pfx)
srcfiles += glob.glob('%s/lib/*.cpp' % pfx)
@ -163,6 +187,7 @@ for mod in sorted(MODS.keys()):
hfiles = glob.glob('%s/*.h' % incl)
assert os.path.isdir(d_lib)
assert os.path.isdir(d_incl)
for f in srcfiles:
shutil.copy(f, d_lib)
@ -198,4 +223,9 @@ for mod in sorted(MODS.keys()):
m = ModToolGenBindings(block, addl_includes='', define_symbols='', update_hash_only=False)
m.run()
if mod == 'op25':
py_cc_srcfiles = 'message_python.cc msg_handler_python.cc msg_queue_python.cc'.split()
for f in py_cc_srcfiles:
shutil.copy('%s/%s' % (s_py, f), d_py)
os.chdir(op25_dir)

@ -1,15 +1,19 @@
#! /bin/bash
me=$0
dir=$1
files=`grep -l msg_queue ${dir}/*.h`
srcs=`find lib include -name '*.c' -o -name '*.h' -o -name '*.cc'`
dir=`pwd`
echo "$me processing directory $dir, files $files"
files=`grep -l -e 'gr::message' -e 'gr::msg_queue' $srcs`
for f in $files; do
echo $me editing file $f in $dir
sed -i 's%gr::msg_queue%gr::op25::msg_queue%g' $f
sed -i 's%gr::message%gr::op25::message%g' $f
done
files=`grep -l -e 'include.*gnuradio/message' -e 'include.*gnuradio/msg_queue' $srcs`
for f in $files; do
echo processing $f
sed -i -f - $f << EOF
/include.*block.h/a\
#include <gnuradio/msg_queue.h>
EOF
echo $me editing file $f in $dir
sed -i 's%gnuradio/msg_queue%op25/msg_queue%g' $f
sed -i 's%gnuradio/message%op25/message%g' $f
done

Loading…
Cancel
Save