diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-07-21 11:37:33 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-07-21 14:53:44 +0530 |
commit | 7462b0655e714a11e4edb1e0c3ef72c74556c4e8 (patch) | |
tree | d2618a2f072c8823fef82f6f8ec6f4ec87b424c2 /recipes/x264.recipe | |
parent | 461803fec5700087ff0e91f6c16444729855b92a (diff) |
cerbero: Rework environment modification in recipes
Environment variable modification in a recipe used to be done with:
self.append_env, self.prepend_env, or self.new_env
All of these were dictionaries of {string:string} mappings, which
means that if a recipe wanted to, say, append to `CFLAGS` from
multiple places within the recipe (f.ex., `glib.recipe`), you had to
carefully juggle `=` and `+=` in recipes, which was error-prone
(f.ex., `gstreamer-1.0.recipe` `variants.nodebug` was broken).
Now that we also conditionally use `self.append_env['CFLAGS']` in
`cerbero/build/build.py` for bitcode support with make-based build
systems, it's impossible to get this right in recipes. This was
causing the cross-ios-universal builds to fail on recipes that
directly set `self.append_env['CFLAGS'] = 'foo'` such as pixman.
The dictionaries have now been replaced with the following functions:
self.append_env(varname, value1, value2, ..., sep=separator)
self.prepend_env(varname, value1, value2, ..., sep=separator)
self.set_env(varname, value1, value2, ..., sep=separator)
The separator is used to join value1, value2, etc and also while
appending/prepending to the value in the env. It is optional, and
defaults to ` ` (space).
Most often the usage is very simple to translate:
self.append_env['CFLAGS'] = ' -funroll-loops '
=>
self.append_env('CFLAGS', '-funroll-loops')
If values are omitted with `self.set_env()`, the variable is unset:
self.new_env['MAKEFLAGS'] = None
=>
self.set_env('MAKEFLAGS')
An important intended feature is that multiple calls to these
functions all take effect sequentially at build time for each build
step. So, you can call append and prepend multiple times on the same
variable, and the values will be appended and prepended in that order
to the value at build time.
Note that if you call `self.set_env()` on a variable, the variable will,
of course, be set to that value and previous append/prepend
declarations will be overriden.
Reviewed-by: Jan Schmidt <jan@centricular.com>
Diffstat (limited to 'recipes/x264.recipe')
-rw-r--r-- | recipes/x264.recipe | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/recipes/x264.recipe b/recipes/x264.recipe index f7516fd2..f651006f 100644 --- a/recipes/x264.recipe +++ b/recipes/x264.recipe @@ -13,7 +13,6 @@ class Recipe(recipe.Recipe): '--disable-strip --disable-lavf' url = 'http://download.videolan.org/pub/x264/snapshots/x264-snapshot-20161218-2245-stable.tar.bz2' tarball_dirname= 'x264-snapshot-20161218-2245-stable' - new_env = {'AS': 'yasm'} files_libs = ['libx264'] files_bins = ['x264'] @@ -24,13 +23,14 @@ class Recipe(recipe.Recipe): # clang x86-32 fails at generating proper asm PIC code # See bug https://bugzilla.gnome.org/show_bug.cgi?id=727079 enable_asm = True + AS = ['yasm'] arch = self.config.target_arch if self.config.target_arch == Architecture.X86: arch = 'i686' if self.config.target_platform == Platform.DARWIN: if self.config.target_arch == Architecture.X86: - self.new_env = {'AS': 'yasm -O2 -f macho -DPREFIX'} + AS = ['yasm', '-O2', '-f', 'macho', '-DPREFIX'] enable_asm = False if self.config.target_platform == Platform.WINDOWS: self.configure_options += ' --enable-win32thread' @@ -38,10 +38,13 @@ class Recipe(recipe.Recipe): # FIXME : Is disabling asm on ARM (< v7) still needed ? enable_asm = False elif Architecture.is_arm(self.config.target_arch): - self.new_env = {'AS': os.environ.get('CC', '')} + if 'CC' in os.environ: + AS = [os.environ['CC']] + else: + AS = [] if self.config.target_platform == Platform.IOS: if Architecture.is_arm(self.config.target_arch): - self.new_env = {'AS': 'tools/gas-preprocessor.pl ' + os.environ['CC'] + ' ' + os.environ['CFLAGS']} + AS = ['tools/gas-preprocessor.pl', os.environ['CC'], os.environ['CFLAGS']] self.patches = ['x264/0001-Disable-fembed-bitcode-incompatible-argument.patch'] elif self.config.target_arch == Architecture.X86: enable_asm = False @@ -54,6 +57,7 @@ class Recipe(recipe.Recipe): # Fails linking into an android application enable_asm = False + self.set_env('AS', *AS) if enable_asm is False: self.configure_options += ' --disable-asm ' |