Discussion:
[Scons-users] Optional targets
s***@triad.rr.com
2018-01-15 20:15:27 UTC
Permalink
Quick question: Whats the best way to handle targets that may or may not get created?

I have a custom builder (with emitter) and a custom installer for a particular source file. Basically, these build and install a couple of different locale specific files from each single source.

My problem is we don't support every locale for every different source. In other words, we might generate a copy for both the en_US and fr_CA locales for one source, but only fr_CA for another source. I cannot know ahead of time which ones get created (driven by the source file itself). So I call the builder for the source and then use an emitter to enumerate every single possible outcome. However, the installer forces the build to fail if one of the locales does not get created; even though its absence is "OK".

Clearly, ideally I would not try to install what does not exist, but since the custom installer is "pre-parsed" in SCons, any work around I come up - like "if os.path.isfile(localeFile)" - fails. This is because no target never exists before the building starts and no dependencies are ever created and the builder never runs.

There has to be a quick trick for this. Any ideas?
Bobby Casey
2018-01-15 20:38:39 UTC
Permalink
Would it be possible for you to create a script (or Python function) that
parses the file to determine which files should be generated and call that
from the emitter? It's not a great solution but may be enough to get you by.
Post by s***@triad.rr.com
Quick question: Whats the best way to handle targets that may or may not get created?
I have a custom builder (with emitter) and a custom installer for a
particular source file. Basically, these build and install a couple of
different locale specific files from each single source.
My problem is we don't support every locale for every different source.
In other words, we might generate a copy for both the en_US and fr_CA
locales for one source, but only fr_CA for another source. I cannot know
ahead of time which ones get created (driven by the source file itself).
So I call the builder for the source and then use an emitter to enumerate
every single possible outcome. However, the installer forces the build to
fail if one of the locales does not get created; even though its absence is
"OK".
Clearly, ideally I would not try to install what does not exist, but since
the custom installer is "pre-parsed" in SCons, any work around I come up -
like "if os.path.isfile(localeFile)" - fails. This is because no target
never exists before the building starts and no dependencies are ever
created and the builder never runs.
There has to be a quick trick for this. Any ideas?
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
Loading...