summaryrefslogtreecommitdiffstats
path: root/meta/classes/staging.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-03-19 23:12:06 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2010-03-19 23:12:06 +0000
commit9c5386c1fd74d832cf6e2acad3c69b1cc90de6b2 (patch)
treeaa2db23da10e883f0f8627f5993cd2cfade2e705 /meta/classes/staging.bbclass
parent185cb38f1319856b4bdaaf4d9a73b5056be53d54 (diff)
downloadpoky-9c5386c1fd74d832cf6e2acad3c69b1cc90de6b2.tar.gz
base.bbclass: Split up as per the patch in OE.dev by Chris Larson making code more readable and modularised
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'meta/classes/staging.bbclass')
-rw-r--r--meta/classes/staging.bbclass146
1 files changed, 146 insertions, 0 deletions
diff --git a/meta/classes/staging.bbclass b/meta/classes/staging.bbclass
new file mode 100644
index 0000000000..e03ed2a5ef
--- /dev/null
+++ b/meta/classes/staging.bbclass
@@ -0,0 +1,146 @@
1python populate_sysroot_prehook () {
2 return
3}
4
5python populate_sysroot_posthook () {
6 return
7}
8
9packagedstaging_fastpath () {
10 :
11}
12
13sysroot_stage_dir() {
14 src="$1"
15 dest="$2"
16 # This will remove empty directories so we can ignore them
17 rmdir "$src" 2> /dev/null || true
18 if [ -d "$src" ]; then
19 mkdir -p "$dest"
20 cp -fpPR "$src"/* "$dest"
21 fi
22}
23
24sysroot_stage_libdir() {
25 src="$1"
26 dest="$2"
27
28 olddir=`pwd`
29 cd $src
30 las=$(find . -name \*.la -type f)
31 cd $olddir
32 echo "Found la files: $las"
33 for i in $las
34 do
35 sed -e 's/^installed=yes$/installed=no/' \
36 -e '/^dependency_libs=/s,${WORKDIR}[[:alnum:]/\._+-]*/\([[:alnum:]\._+-]*\),${STAGING_LIBDIR}/\1,g' \
37 -e "/^dependency_libs=/s,\([[:space:]']\)${libdir},\1${STAGING_LIBDIR},g" \
38 -i $src/$i
39 done
40 sysroot_stage_dir $src $dest
41}
42
43sysroot_stage_dirs() {
44 from="$1"
45 to="$2"
46
47 sysroot_stage_dir $from${includedir} $to${STAGING_INCDIR}
48 if [ "${BUILD_SYS}" = "${HOST_SYS}" ]; then
49 sysroot_stage_dir $from${bindir} $to${STAGING_DIR_HOST}${bindir}
50 sysroot_stage_dir $from${sbindir} $to${STAGING_DIR_HOST}${sbindir}
51 sysroot_stage_dir $from${base_bindir} $to${STAGING_DIR_HOST}${base_bindir}
52 sysroot_stage_dir $from${base_sbindir} $to${STAGING_DIR_HOST}${base_sbindir}
53 sysroot_stage_dir $from${libexecdir} $to${STAGING_DIR_HOST}${libexecdir}
54 sysroot_stage_dir $from${sysconfdir} $to${STAGING_DIR_HOST}${sysconfdir}
55 fi
56 if [ -d $from${libdir} ]
57 then
58 sysroot_stage_libdir $from/${libdir} $to${STAGING_LIBDIR}
59 fi
60 if [ -d $from${base_libdir} ]
61 then
62 sysroot_stage_libdir $from${base_libdir} $to${STAGING_DIR_HOST}${base_libdir}
63 fi
64 sysroot_stage_dir $from${datadir} $to${STAGING_DATADIR}
65}
66
67sysroot_stage_all() {
68 sysroot_stage_dirs ${D} ${SYSROOT_DESTDIR}
69}
70
71def is_legacy_staging(d):
72 stagefunc = bb.data.getVar('do_stage', d, True)
73 legacy = True
74 if stagefunc is None:
75 legacy = False
76 elif stagefunc.strip() == "use_do_install_for_stage":
77 legacy = False
78 elif stagefunc.strip() == "autotools_stage_all":
79 legacy = False
80 elif stagefunc.strip() == "do_stage_native" and bb.data.getVar('AUTOTOOLS_NATIVE_STAGE_INSTALL', d, 1) == "1":
81 legacy = False
82 elif bb.data.getVar('NATIVE_INSTALL_WORKS', d, 1) == "1":
83 legacy = False
84 return legacy
85
86do_populate_sysroot[dirs] = "${STAGING_DIR_TARGET}/${bindir} ${STAGING_DIR_TARGET}/${libdir} \
87 ${STAGING_DIR_TARGET}/${includedir} \
88 ${STAGING_BINDIR_NATIVE} ${STAGING_LIBDIR_NATIVE} \
89 ${STAGING_INCDIR_NATIVE} \
90 ${STAGING_DATADIR} \
91 ${S} ${B}"
92
93# Could be compile but populate_sysroot and do_install shouldn't run at the same time
94addtask populate_sysroot after do_install
95
96PSTAGING_ACTIVE = "0"
97SYSROOT_PREPROCESS_FUNCS ?= ""
98SYSROOT_DESTDIR = "${WORKDIR}/sysroot-destdir/"
99SYSROOT_LOCK = "${STAGING_DIR}/staging.lock"
100
101
102python do_populate_sysroot () {
103 #
104 # if do_stage exists, we're legacy. In that case run the do_stage,
105 # modify the SYSROOT_DESTDIR variable and then run the staging preprocess
106 # functions against staging directly.
107 #
108 # Otherwise setup a destdir, copy the results from do_install
109 # and run the staging preprocess against that
110 #
111 pstageactive = (bb.data.getVar("PSTAGING_ACTIVE", d, True) == "1")
112 lockfile = bb.data.getVar("SYSROOT_LOCK", d, True)
113 stagefunc = bb.data.getVar('do_stage', d, True)
114 legacy = is_legacy_staging(d)
115 if legacy:
116 bb.data.setVar("SYSROOT_DESTDIR", "", d)
117 bb.note("Legacy staging mode for %s" % bb.data.getVar("FILE", d, True))
118 lock = bb.utils.lockfile(lockfile)
119 bb.build.exec_func('populate_sysroot_prehook', d)
120 bb.build.exec_func('do_stage', d)
121 for f in (bb.data.getVar('SYSROOT_PREPROCESS_FUNCS', d, True) or '').split():
122 bb.build.exec_func(f, d)
123 bb.build.exec_func('populate_sysroot_posthook', d)
124 bb.utils.unlockfile(lock)
125 else:
126 dest = bb.data.getVar('D', d, True)
127 sysrootdest = bb.data.expand('${SYSROOT_DESTDIR}${STAGING_DIR_TARGET}', d)
128 bb.mkdirhier(sysrootdest)
129
130 bb.build.exec_func("sysroot_stage_all", d)
131 #os.system('cp -pPR %s/* %s/' % (dest, sysrootdest))
132 for f in (bb.data.getVar('SYSROOT_PREPROCESS_FUNCS', d, True) or '').split():
133 bb.build.exec_func(f, d)
134 bb.build.exec_func("packagedstaging_fastpath", d)
135
136 lock = bb.utils.lockfile(lockfile)
137 os.system(bb.data.expand('cp -pPR ${SYSROOT_DESTDIR}${TMPDIR}/* ${TMPDIR}/', d))
138 bb.utils.unlockfile(lock)
139}
140
141python () {
142 if is_legacy_staging(d):
143 bb.note("Legacy staging mode for %s" % bb.data.getVar("FILE", d, True))
144}
145
146