diff options
Diffstat (limited to 'classes/sdk-sources.bbclass')
-rw-r--r-- | classes/sdk-sources.bbclass | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/classes/sdk-sources.bbclass b/classes/sdk-sources.bbclass new file mode 100644 index 0000000..1c3629b --- /dev/null +++ b/classes/sdk-sources.bbclass | |||
@@ -0,0 +1,90 @@ | |||
1 | ############################################################################# | ||
2 | ## | ||
3 | ## Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). | ||
4 | ## | ||
5 | ## This file is part of the Qt Enterprise Embedded Scripts of the Qt | ||
6 | ## framework. | ||
7 | ## | ||
8 | ## $QT_BEGIN_LICENSE$ | ||
9 | ## Commercial License Usage Only | ||
10 | ## Licensees holding valid commercial Qt license agreements with Digia | ||
11 | ## with an appropriate addendum covering the Qt Enterprise Embedded Scripts, | ||
12 | ## may use this file in accordance with the terms contained in said license | ||
13 | ## agreement. | ||
14 | ## | ||
15 | ## For further information use the contact form at | ||
16 | ## http://www.qt.io/contact-us. | ||
17 | ## | ||
18 | ## | ||
19 | ## $QT_END_LICENSE$ | ||
20 | ## | ||
21 | ############################################################################# | ||
22 | |||
23 | python do_fetch () { | ||
24 | src_uri = (d.getVar('SRC_URI', True) or "").split() | ||
25 | if len(src_uri) == 0: | ||
26 | return | ||
27 | |||
28 | sdk_path = d.getVar('QT_SDK_PATH', True) or "" | ||
29 | if len(sdk_path) != 0: | ||
30 | uris = list(src_uri); | ||
31 | for url in uris: | ||
32 | ud = list(bb.fetch2.decodeurl(url)) | ||
33 | if ("sdk-uri" in ud[5]): | ||
34 | src_uri.remove(url) | ||
35 | |||
36 | |||
37 | if len(src_uri) == 0: | ||
38 | return | ||
39 | |||
40 | try: | ||
41 | fetcher = bb.fetch2.Fetch(src_uri, d) | ||
42 | fetcher.download() | ||
43 | except bb.fetch2.BBFetchException as e: | ||
44 | raise bb.build.FuncFailed(e) | ||
45 | } | ||
46 | |||
47 | python do_unpack () { | ||
48 | src_uri = (d.getVar('SRC_URI', True) or "").split() | ||
49 | if len(src_uri) == 0: | ||
50 | return | ||
51 | |||
52 | rootdir = d.getVar('WORKDIR', True) | ||
53 | |||
54 | sdk_path = d.getVar('QT_SDK_PATH', True) or "" | ||
55 | if len(sdk_path) != 0: | ||
56 | uris = list(src_uri); | ||
57 | for url in uris: | ||
58 | ud = list(bb.fetch2.decodeurl(url)) | ||
59 | if ("sdk-uri" in ud[5]): | ||
60 | unpack_local_uri(ud, d) | ||
61 | src_uri.remove(url) | ||
62 | |||
63 | if len(src_uri) == 0: | ||
64 | return | ||
65 | |||
66 | try: | ||
67 | fetcher = bb.fetch2.Fetch(src_uri, d) | ||
68 | fetcher.unpack(rootdir) | ||
69 | except bb.fetch2.BBFetchException as e: | ||
70 | raise bb.build.FuncFailed(e) | ||
71 | } | ||
72 | |||
73 | def unpack_local_uri(ud, d): | ||
74 | import subprocess | ||
75 | rootdir = d.getVar('WORKDIR', True) | ||
76 | sdk_path = d.getVar('QT_SDK_PATH', True) | ||
77 | |||
78 | destdir = os.path.join(rootdir, ud[5].get("destsuffix", "git")) | ||
79 | srcdir = os.path.join(sdk_path, ud[5].get("sdk-uri")) | ||
80 | cmd = "cp -vrf %s %s" % (srcdir, destdir) | ||
81 | |||
82 | bb.note("Unpacking SDK sources %s to %s" % (srcdir, destdir)) | ||
83 | |||
84 | if os.path.exists(destdir): | ||
85 | bb.utils.prunedir(destdir) | ||
86 | |||
87 | ret = subprocess.call(cmd, shell=True) | ||
88 | |||
89 | if ret != 0: | ||
90 | raise bb.fetch.UnpackError("Unpack command %s failed with return value %s" % (cmd, ret), ud) | ||