2012/1/28 Paul Eggleton <[email protected]> > On Saturday 28 January 2012 13:42:32 Frans Meulenbroeks wrote: > > In order to allow backtracking of the sources for a binary build with > OE, I > > would like to (automatically) add the hash of the top level commit (and > > maybe also the branch) of the oe git tree my recipe lives in). > > E.g. in main.c I would like to have a var say: > > const char * const buildfrom = "oe branch 2011.03-maintence hash > > 1234567890"; or something like that. > > > > What would be the best way to get that info into my program? > > (my best guess at the moment is to use a macro and compile with > > -DOE_IDENT="....." or so and say char *buildfrom = OE_IDENT; but not > > really sure what the best way is to fill OE_IDENT and pass it to the > > recipe.) > > Interesting question! Putting the information in a define specified on the > compiler command line would be one way; another way would be to have the > recipe write to/append to/subsitute into a header file that you can > #include in > the source. You would also probably want to include ${DATE} in the > recipe's PV > or use some other mechanism to ensure it gets rebuilt every time you build > an > image. > > I guess you are still using OE-Classic, but in OE-Core we now have a > function > in base.bbclass called get_layers_branch_rev that will return the git > branch/revision information for all enabled layers. It was split out from > the > code in the same bbclass that displays this information when BitBake > starts, > so I guess you could just make a copy of it into your recipe for > OE-Classic. > > Cheers, > Paul > > HI Paul,
Thanks for the feedback. Indeed I'm still on oe classic; the product in which I am putting this is close to release so I cannot switch any more. Writing into a header file is also something that I considered and that is also probably quite feasible. (and maybe even simpler, if it is done in a do_configure step or so, passing shell varables through bitbake to CFLAGS is not really trivial; as far as I know I cannot use things like `git log | head -1` and assign it to a var in the recipe (it might be possbile with some python, but that is outside my league). With respect to rebuilding the app. Yeah, didn' t think of that. It is not too much of a concern, because all our products are build from scratch on an autobuilder and the test images and later the release are pulled from that autobuilder, so I always know that the app info is correct. Then again, rethinking it, it seems I am making things way too complicated. Guess the simplest solution is just to do some postprocessing when the rootfs is created and make a file /etc/buildinfo or so and read that from the app. (We only distribute images, not complete apps). (Actually I do already something like that in the top level makefile that I have to collect all data for the autobuilder). Thanks alot for your advice. Frans PS: saw the reply from Khem while typing this. Probably even simpler. add a small makefile rule to the project to create the version .h file. I seem to recall u-boot does something similar. Might need to pass the path from the recipe though, otherwise I'll have to come up with something like ../../../../../../openembedded.git or so _______________________________________________ Openembedded-devel mailing list [email protected] http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel
