What are the implications of setting FILESEXTRAPATHS in a .bb file (rather than a .bbappend)? - embedded-linux

The Yocto docs suggest that the variable FILESEXTRAPATHS should only be set in a .bbappend file, and by implication, not in a base .bb recipe:
Best practices dictate that you accomplish this by using FILESEXTRAPATHS from within a .bbappend file [source].
What are the implications of defining this in a .bb recipe? It works - but is it technically incorrect or unsupported? I'm looking to adhere to best practice.
Background: I want to use it to include a source directory elsewhere in a mono-repository (outside of the layer), in a case where setting EXTERNALSRC is not appropriate.

Admit that you have a .bbappend in an other layer with a files directory which contain your sources.
In this .bbappend file you want to add sources with SRC_URI+= "mysource" which is located in files/mysource.
In this case FILESEXTRAPATHS is used to locate your sources. Otherwise it may not be recognized.

Related

Yocto kernel config propagation

In my Yocto system, I have a layer defining a bunch of patches on the linux kernel, as well as a file "defconfig" containing kernel configuration. When I modify this file, changes are reflected in the image I build.
However, a few changes are being overruled and I have a hard time figuring out how or where. I do find a bunch of defconfig files in other layers, but is there any easy way to figure out which ones are applied and in what order?
Thanks
It is not other defconfigs that overrule your configuration (at least not in an even only remotely sane setup), but configuration fragments (creating fragments). You can find out what happens exactly like that:
bitbake -e virtual/kernel | less
(you can of course choose another pager, or redirect to a file for additional processing)
And look for:
KERNEL_FEATURES
--> here you can find a list of kernel configuration fragments in the form of .scc files that are applied to your build
SRC_URI
--> this should mention the path to your defconfig file, and no second one.
Please note that this description only holds entirely true for setups that include a kernel defconfig. If you are working without one, things can be different.

wxWidgets: Preferred way to name .po/.mo files: en/app.mo or en.mo?

My application is to be written using wxWidgets, but the question may be related to using gettext in general.
For the application named app, some sources suggest I sould create <lang>/ subdirectory, create the app.po file inside with the translation, and convert it to the distributed app.mo file in the subdir.
Another approach is to create app.pot (i.e. the template from the sources via xgettext), and to msginit and msgmerge it to the <lang>.po for the language.
For the first approach, more .mo files can be put inside the <lang>/ subdirectory. Also the wxLocale::AddCatalog() gets the domain name (where the domain can naturally be app, wxstd, etc.). On the other hand, the <lang>.po file name is descriptive on itself -- wherever it is located.
What are the pros and cons of the two approaches? Is there any text that explains the path to be chosen?
Thanks for your time and experience,
Petr
The Unix convention is to use app.mo for binary catalogs, see the contents of /usr/share/locale directory. Sometimes lang.po is however used for the source ones, as done in wxWidgets itself (see its locale subdirectory), but they're still installed into language-specific subdirectory using the app-dependent name.

Automatically extracting gcc -I paths for indexing source code in Emacs

After reading:
A Gentle Introduction to CEDET
A Functional Introduction to CEDET-EDE
I learn that when creating a project folder with an existing make file and source code, I can have semantic index the files by either:
defining a simple EDE project with:
(ede-cpp-root-project ... :system-include-path '( "~/exp/include/boost_1_37" )
or by specifying the include paths to semantic directly with
(semantic-add-system-include "~/exp/include/boost_1_37" 'c++-mode)
But this still requires me to type the paths manually. Is there any way to automatically extract the include paths for semantic from an existing make file?
Background:
Some IDEs have a function to autodiscover gcc -I paths from an existing make file. For example, in Eclipse, you can create a project on a path with an existing make file and source code, and Eclipse would infer the include paths for its "intellisense" when building the project (I presume Eclipse parses the output of GNU make to do this). I would like to do the same in Emacs.
The answer is "yes": There's a way to discover this include path. AFAIK the code for it hasn't been written yet (tho I may be mistaken on this one). All you need to do is to run make -n and look for the "-I" in the output. Of course, the devil is in the details, but it should be possible to write a proof-of-concept fairly easily.

Xcode header inclusion conflict [duplicate]

I have a project that was compiling ok within g++(I can't see the version right now) and now on xCode it is not.
I think that I got the problem now... I have a String.h file in my project and it seems tha the xCode compiler(that is gcc) is trying to add my own string file from the < cstring >... I am not sure of it, but take a look at this picture
http://www.jode.com.br/Joe/xCode1.png
from what it looks like, it is including my own instead of the system file, I was wondering... shouldn't #include < file > be a system include? because of the < > ? and shouldn't the system include a file within its own path and not the original path of my application?
As I said, I am not sure if this is what happening because I am just migrating to osx these past 2 days...
I was going to change my class and file name to not conflict, so it would work, if this is really the problem, but I was wondering, there should be another way to do this, because now my project isn't that big so I can do this in some time, but what if the project was bigger? it would be dificult to change all includes and class names...
Any help is appreciated
Thanks,
Jonathan
i had the same problem and it was hard to solve. took my hours to fix/find out.
the problem is the headermap of xcode. and the solution - besides avoiding those kind of reserved names, which is a good idea in general, but not always possible with third-party libs - is to add
USE_HEADERMAP = NO
to your user defined settings.
kudos to these guys:
http://meidell.dk/archives/2010/05/08/xcode-header-map-files/
http://www.cocoabuilder.com/archive/xcode/262586-header-file-problem-sorry-to-bug-this-list.html
Naming your headers with the same name as standard headers like string.h and including them simply with #include <String.h> is asking for trouble (the difference in casing makes no difference on some platforms).
As you said, however, it would be difficult to try to figure out what those are in advance when naming your headers. Thus, the easiest way to do this is to set to set your include path one directory level outside of a sub-directory in which your headers reside, ex:
#include <Jonathan/String.h>
Now you don't have to worry about whether the String.h file name conflicts with something in one the libraries you are using unless they happen to also be including <Jonathan/String.h> which is unlikely. All decent third-party libraries do this as well. We don't include <function.hpp> in boost, for instance, but instead include <boost/function.hpp>. Same with GL/GL.h instead of simply GL.h. This practice avoids conflicts for the most part and you don't have to work around problems by renaming String.h to something like Text.h.
Yes, if you use
#include "file"
the local directory is looked first and
#include <file>
only the system include folders are looked.
Notice the word first only in the first case. This means that every time is included your local version should never be reached (unless you have included your source path within the INCLUDE directive).
Said that, my dummy suggestion is to rename your local file with an unambiguous name...
On OSX the filesystem is case insensitive - so String.h you can wind up with conflicts like that. String.h == string.h
it worked by changing the name from String.h to Text.h
but that makes no sense, since the std library is including it's own string.h and not mine.
I mean, makes no sense for a developer to create his files thinking of what names he can't use, for an instance, lets say I change my String.h to Text.h(I already did, I need to work and this is not letting me) ad somehow I had to include another templated library that has a include called Text.h, would I have to change my text.h again or not use this new library? there should be an alternative.
Or shouldn't it?
thanks for the help so far,
Jonathan
Two things you're running into:
As noted above, the filesystem on Mac OS is case-insensitive unless you specifically set up your filesystem to be case-sensitive.
gcc does not distinguish all that much between local and system header include paths. When you specify a directory to be added to the path via -I, that directory will be used to locate both local and system includes. Only when you use -iquote or -I- does a directory get skipped for locating system includes. Further, the builtin "system include" directories on the compiler's search path are always searched for local includes.
Note that the current directory is used for local but not system includes. In this case, I believe it's picking up String.h because the project settings explicitly add the top-level project directory to the include path.
The workaround I would suggest, rather than renaming your includes, is to put your utilities into a directory whose name is unique for your project, and specify that directory in your include directive. For example:
#include "Josk/String.h"
and make sure Josk/ itself isn't in your include search path. This way you aren't stuck with an awkward rename, though you may have to shuffle some files around in your project. You may also need to edit your project settings to make sure the parent directory of that utility directory is in your include path.
Another possibility to try is, if you see the top-level project directory added to your project's include path, remove it. This ought to keep items in your top-level project directory from being searched for system includes.
Finally, you may also be able to avoid this problem in this specific case by changing the case sensitivity of your file system. This can break some Mac applications, though, so research the issue before you embark on this – or pick a volume that nothing else is using.
This question already has some very good answers, yet none of them summarizes in all detail how the compiler will search for header files in general; or more precisely, how Xcode will make the compiler search for them.
When you include a user header, those are header files between quotes ("..."), the following search order applies:
The directory of the file performing the include.
All header search paths in the order provided.
First match inside a header map file, if headers maps are enabled.
Note that the full include path is used. So if your include is in the file foo/bar/file.c and you do a #include "subdir/header.h", then the first lookup will be foo/bar/subdir/header.h.
If that file doesn't exist, the compiler iterates the user header search paths. Those are provided by the build setting User Header Search Path (within config files or on command line it's named USER_HEADER_SEARCH_PATHS). Multiple such path can exist and again, the full include path is attached to each of them until there's a match.
If provides no match either and the build setting Use Header Maps (USE_HEADERMAP) is enabled, Xcode generates a map file of all your header files in the project and searches this map file for an entry that matches the name of the included file. In that case the path is irrelevant, as it would also match just the name of the file.
For system headers, those between spiky braces (<...>), only the search paths from the build setting System Header Search Paths (SYSTEM_HEADER_SEARCH_PATHS) are searched.
However if the build setting Always Search User Paths (ALWAYS_SEARCH_USER_PATHS) is enabled, the user search paths are also searched for system header includes. This allows you to override a system header with your own user header of the same name. Note however, that this is deprecated by Xcode and shouldn't be done anymore.
If your file system is case-insensitive, default on macOS, then case will play no role during all searches.
If you want maximum control over which file is being included, disable header maps and always include with a path relative to the file performing the include (you may use ".." as well). This avoids any ambiguity.

Is it possible to generate a .h macros file from bjam?

I need to dynamically generate some macros into a .h configuration file that C programs can include in order to check which options are enabled, in a fashion similar to what is possible with CMake's CONFIGURE_FILE macro. But after looking in the doc and the web, I could not find something useful. Is it possible to generate such a file from bjam and have the dependencies handled correctly? If so, how would you do it?
Yes it's possible.. The way to do it boils down to defining a make target for the header and using the #() file output action support in bjam. You would set up a set of configuration variables on the header target and the action would use them to generated the file. That is what I do in one of the library extensions I wrote (see GIF lib extension). I also wrote some basic support for automating some of the tasks, but it still ends up being functionally the same, to create text files in the ext.jam utility. To allow easier definition of header configuration files that change based on Boost Build features (see Irrlicht 3D lib extension). Basically you can do just about anything you can think of with the make target since it's implementation is entirely up to you.

Resources