[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Discuss-gnuradio] OOT Module Template Expansion Issues
From: |
Martin Braun |
Subject: |
Re: [Discuss-gnuradio] OOT Module Template Expansion Issues |
Date: |
Thu, 24 Mar 2016 21:36:57 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 |
Jacob,
the best way is probably to submit a pull request and then continue the
discussion there, where we can do code reviews.
Thanks!
Martin
On 03/24/2016 08:12 PM, Jacob Gilbert wrote:
> Just as a little more information, it looks like the top-level
> gr_modtool CMake template does attempt to set it's own module directory
> as the top priority
> (https://github.com/gnuradio/gnuradio/blob/master/gr-utils/python/modtool/gr-newmod/CMakeLists.txt#L35),
> however the find_package command
> (https://github.com/gnuradio/gnuradio/blob/master/gr-utils/python/modtool/gr-newmod/CMakeLists.txt#L114)
> makes the system module path a higher preference.
>
> Re-adding the OOT module directory to the top of CMAKE_MODULE_PATH fixes
> this (though it now appears twice in CMAKE_MODULE_PATH) and allows the
> fix mentioned above to succeed. Is this an acceptable way of handling
> things?
>
> Jacob
>
> On Thu, Mar 24, 2016 at 7:00 PM, Jacob Gilbert
> <address@hidden <mailto:address@hidden>> wrote:
>
> 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')
> or
> sys.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.
>
> Jacob
>
> On Thu, Mar 24, 2016 at 6:48 PM, Martin Braun
> <address@hidden <mailto: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 <mailto: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>
> > <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
> > > address@hidden
> <mailto:address@hidden>
> <mailto:address@hidden <mailto:address@hidden>>
> > > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> > >
> >
> >
> > _______________________________________________
> > Discuss-gnuradio mailing list
> > address@hidden <mailto:address@hidden>
> <mailto:address@hidden <mailto:address@hidden>>
> > 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
>
>
>