On Fri, Oct 5, 2012 at 12:46 PM, Eric Boren <
bor...@google.com> wrote:
> Okay, I'll zoom all the way out. We want to be able to create a single
> static library for the "core" Skia functionality, plus a few accessory
> static libs. For our core library, however, we have one or two sets of
> source files which require a different set of cflags from the rest of the
> targets, so we can't just glob all of the sources into one target. So, we
> end up with multiple static libraries we want linked together. AR doesn't
> really do this, so I've written a little script to merge multiple static
> libs into one. I'm doing this using an action to launch the script.
>
> Essentially, there were two related problems I was trying to solve. The
> first was to have a meta-target for all of the static libraries (core +
> accessories) so that we can run "make static_libs" but also be able to run
> "make some_accessory_lib". That required propagating the dependencies from
> the static_libs meta-target to the "all" target, which I was attempting to
> do by creating a list of the static library targets and manipulating it to
> get the paths to be correct. This is solved with direct_dependent_settings.
The dependencies between your meta-target 'all' (which I presume is of
type: none) and your meta-target 'static_libs' (which I also presume
is of type: none) should already be propagating. The only reason for
'direct_dependent_settings' + 'export_dependent_settings' is you
expect other consumers to be depending on skia.gyp:all for
linking/compile information, which is generally a very uncommon use of
a meta-target.
That said, it does sound like your solution was solved.
>
> The second problem is to link multiple static libraries into one "core"
> library. Right now I list the component parts in 'dependencies' and then
> list their outputs as inputs to the action which calls my merge script.
> Again, I wanted to do this by manipulating a list, so that I could derive
> the target dependencies and action inputs from the same place. It seems
> like you're suggesting that there's an easier way to pipe the output
> filepaths from the dependencies to the action inputs?
So, teasing out the feature, the 'ideal' world would have creating a
single ("fat") static library from multiple input thin archives would
be a fine solution, right? Something essentially akin to the
"loadable_module" target type, but in a way that dependents can still
statically link to.
Such a feature would generally only be preferable when dealing with
'dist' type packaging - that is, where skia.gyp can be used to create
a re-distributable static library. In the case of say, using Chromium
with skia, it would actually be preferable *not* to use such a 'fat'
archive, and instead use 'thin' archives (quicker link times with less
RAM)
Perhaps that's something worth exploring separately.
Under current functionality of GYP, you can *probably* do some
creative cheating here. I suspect the example I'm about to provide
won't work, but hopefully it'll point you to the right functionality.
{
'target_name': 'example',
'type: 'static_library',
'variables': {
'my_dependencies': [
'a.gyp:a',
'b.gyp:b',
'c.gyp:c',
],
},
'dependencies': [
'<@(my_dependencies)',
],
'actions': [
{
'action_name': 'test',
'variables': {
'dependency_file': '<|(dependencies.txt <@(my_dependencies))',
},
'inputs': [ ... ],
'action': [
'myscript.py',
'<(PRODUCT_DIR)',
'<(dependency_file)'
],
},
],
}
That will invoke myscript.py with the path to the PRODUCT_DIR and the
path to a text file, whose contents will be something like
[path_relative_to_current_gyp_file_dir]/a.gyp:a
[path_relative_to_current_gyp_file_dir]/b.gyp:b
[path_relative_to_current_gyp_file_dir]/c.gyp:c
Which you can use to then normpath, cut, etc.
Altogether, it's a giant hack, but I think it should do what you want.
It just means you have to move your processing of a.gyp:a from GYP
(where, as Mark said, it's "not supported") into your helper script
(which you then end up coding against how GYP behaves, which is not
ideal)