|
From: | Jacob Gilbert |
Subject: | Re: [Discuss-gnuradio] OOT Module Template Expansion Issues |
Date: | Thu, 24 Mar 2016 21:12:26 -0600 |
I agree my current approach of clobbering the generate_helper.py file that GrMiscUtils sticks into build/lib and build/include is not a good one. I am only using it because right now the `include(GrMiscUtils)` points to the module in <install_prefix>/lib/cmake/gnuradio/GrMiscUtils.cmake. I'd rather it be pointed to the module inside the OOT at <gr-module>/cmake/Modules/GrMiscUtils.cmake, where almost everything I put above already lives.If that can work we just have to add the appropriate:sys.path.append('${CMAKE_CURRENT_SOURCE_DIR}/../python')orsys.path.append('${CMAKE_CURRENT_SOURCE_DIR}/../../python')lines in the GR_EXPAND_X... macros inside the gr_modtool template here: https://github.com/gnuradio/gnuradio/blob/master/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrMiscUtils.cmake. I just don't understand cmake enough to understand how to get it to use the GrMiscUtils inside the OOT module.JacobOn Thu, Mar 24, 2016 at 6:48 PM, Martin Braun <address@hidden> wrote:You can't point to the module inside GNU Radio, because that might not
be installed when you're developing a module.
If your way works, that's great, but maybe this can be factored out into
a single CMake module as not to bloat the individual CMakeLists.txt files.
Cheers,
Martin
On 03/24/2016 05:24 PM, Jacob Gilbert wrote:
> Thanks Martin,
>
> I added something like this to the CMakeLists.txt files in lib and
> include/testmod:
>
> file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
> "#!${PYTHON_EXECUTABLE}
> import sys, os, re
> sys.path.append('${GR_RUNTIME_PYTHONPATH}')
> sys.path.append('${CMAKE_CURRENT_SOURCE_DIR}/../python')
> os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}'
> os.chdir('${CMAKE_CURRENT_BINARY_DIR}')
> if __name__ == '__main__':
> import build_utils
> root, inp = sys.argv[1:3]
> for sig in sys.argv[3:]:
> name = re.sub ('X+', sig, root)
> d = build_utils.standard_impl_dict2(name, sig, '${component}')
> build_utils.expand_template(d, inp)
> ")
>
> Is that what you mean? Or can I tell CMake to use the module in
> tesmod/cmake/Modules/GrPlatform.cmake?
>
> I'd like to know the recommended way, and we can get this added into the
> modtool templates.
>
> Jacob
>
> On Thu, Mar 24, 2016 at 6:05 PM, Martin Braun <address@hidden
> > address@hidden <mailto:address@hidden>> <mailto:address@hidden>> wrote:
>
> The short answer is, the templated in-tree stuff has access to some
> modules we don't actually export to OOTs. You'll need to copy the
> template infrastructure into your OOT.
>
> Cheers,
> Martin
>
> On 03/24/2016 11:25 AM, Jacob Gilbert wrote:
> > I am attempting to add several templatized blocks to an OOT module and
> > am having trouble with getting things to build correctly.
> >
> > After using modtool to add the new block, adding the .t extensions to
> > the impl.cc/imp.h/.h <http://impl.cc/imp.h/.h>
> <http://impl.cc/imp.h/.h> files, and adding test
> > code, I added the following to ../lib/CMakeLists.txt:
> >
> >
> > include(GrMiscUtils)
> > GR_EXPAND_X_CC_H(testmod testblock_X_impl c f i s b)
> >
> > ...
> >
> > list(APPEND testmod_sources
> > ${generated_sources}
> > <other block sources...>
> >
> >
> > and the following to ../include/testmod/CMakeLists.txt:
> >
> >
> > include(GrMiscUtils)
> > GR_EXPAND_X_H(testmod testblock_X c f i s b)
> >
> > add_custom_target(testmod_generated_includes DEPENDS
> > ${generated_includes}
> > )
> >
> > ...
> >
> > install(FILES
> > ${generated_includes}
> >
> > <other header files...>
> >
> >
> >
> > These were borrowed from in-tree templates like fir_filter_XXX; I was
> > unable to find an OOT module using templates. I also added appropriate
> > #include, %include, and GR_SWIG_BLOCK_MAGIC2 to
> swig/testmod_swig.i for
> > each of the generated blocks. However, when I attempt to build I
> get the
> > following error:
> >
> > File
> > "/home/jacob/gr-testmod/build/include/testmod/generate_helper.py",
> > line 9, in <module>
> > import build_utils
> > ImportError: No module named build_utils
> >
> >
> >
> > This obviously does not happen to in-tree modules. I attempted to
> modify
> > the gr-testmod/cmake/Modules/GrMiscUtils.cmake file where the
> > GR_EXPAND_.X..() macros are defined to explicitly include the
> > appropriate path, however it appears that by default the include
> > statement I am using actually uses the GrMiscUtils.cmake installed
> with
> > gnuradio (into /usr/local/lib/cmake/gnuradio/ in my case). If I modify
> > the used GR_EXPAND_X... macros and manually add the correct path
> > (sys.path.append('${CMAKE_CURRENT_SOURCE_DIR}/../python') or
> > '../../python' in the case of the include macro), expansion works
> > correctly, however this makes the code very un-portable.
> >
> > Given my elementary understand of CMake, I have no idea what I am
> doing
> > incorrectly, or what changes if any should be made to modtool, but
> I was
> > unable to find any other documents on how to go about doing this.
> >
> > Thanks,
> > Jacob
> >
> >
> > _______________________________________________
> > Discuss-gnuradio mailing list
> > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> >
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden <mailto:address@hidden>
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
>
_______________________________________________
Discuss-gnuradio mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
[Prev in Thread] | Current Thread | [Next in Thread] |