mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 12:59:02 +02:00
native/cross: Add ar wrapper for determinism
Add a wrapper around ar calls for native/cross recipes. This wrapper adds the -D option so that deterministic archives are built for native/cross output. This improves the changes of hash equivalence matches and hence build artefact reuse. We don't need this in the target case since we compile binutils-cross with an option making this the default. We need a wrapper since we need to remove the "u" option and replace it with "D" but also allow things like "--version" to continue to work too. (From OE-Core rev: 59922c95fcb20c66634c5677012d490be2246b0b) Signed-off-by: Jacob Kroon <jacob.kroon@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
921d3aa667
commit
096c9037bc
|
@ -93,3 +93,5 @@ python do_addto_recipe_sysroot () {
|
||||||
}
|
}
|
||||||
addtask addto_recipe_sysroot after do_populate_sysroot
|
addtask addto_recipe_sysroot after do_populate_sysroot
|
||||||
do_addto_recipe_sysroot[deptask] = "do_populate_sysroot"
|
do_addto_recipe_sysroot[deptask] = "do_populate_sysroot"
|
||||||
|
|
||||||
|
PATH:prepend = "${COREBASE}/scripts/cross-intercept:"
|
||||||
|
|
1
scripts/cross-intercept/ar
Symbolic link
1
scripts/cross-intercept/ar
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../native-intercept/ar
|
32
scripts/native-intercept/ar
Executable file
32
scripts/native-intercept/ar
Executable file
|
@ -0,0 +1,32 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
#
|
||||||
|
# Wrapper around 'ar' that defaults to deterministic archives
|
||||||
|
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# calculate path to the real 'ar'
|
||||||
|
path = os.environ['PATH']
|
||||||
|
path = path.replace(os.path.dirname(sys.argv[0]), '')
|
||||||
|
real_ar = shutil.which('ar', path=path)
|
||||||
|
|
||||||
|
if len(sys.argv) == 1:
|
||||||
|
os.execl(real_ar, 'ar')
|
||||||
|
|
||||||
|
# modify args to mimic 'ar' configured with --default-deterministic-archives
|
||||||
|
argv = sys.argv
|
||||||
|
if argv[1].startswith('--'):
|
||||||
|
# No modifier given
|
||||||
|
None
|
||||||
|
else:
|
||||||
|
# remove the optional '-'
|
||||||
|
if argv[1][0] == '-':
|
||||||
|
argv[1] = argv[1][1:]
|
||||||
|
if 'U' in argv[1]:
|
||||||
|
sys.stderr.write("ar: non-deterministic mode requested\n")
|
||||||
|
else:
|
||||||
|
argv[1] = argv[1].replace('u', '')
|
||||||
|
argv[1] = 'D' + argv[1]
|
||||||
|
|
||||||
|
os.execv(real_ar, argv)
|
Loading…
Reference in New Issue
Block a user