aboutsummaryrefslogtreecommitdiffstats
path: root/lib/oeqa/sdkmingw/testsdk.py
blob: 5c80bb4258cc561e5710e5c559c11ce4e13feac8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Copyright 2018 by Garmin Ltd. or its subsidiaries
# Released under the MIT license (see COPYING.MIT)

from oeqa.sdk.testsdk import TestSDK
from oeqa.sdkmingw.context import OESDKMinGWTestContext, OESDKMinGWTestContextExecutor

class TestSDKMinGW(TestSDK):
    context_executor_class = OESDKMinGWTestContextExecutor
    context_class = OESDKMinGWTestContext

    def get_tcname(self, d):
        """
        Get the name of the SDK file
        """
        return d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE}")

    def extract_sdk(self, tcname, sdk_dir, d):
        """
        Extract the SDK to the specified location
        """
        import subprocess

        try:
            # TODO: It would be nice to try and extract the SDK in Wine to make
            # sure it is well formed
            
            # TODO: Extract SDK according to SDK_ARCHIVE_TYPE, need to change if
            # oe-core support other types.
            if d.getVar("SDK_ARCHIVE_TYPE") == "zip":
                subprocess.check_output(['unzip', '-d', sdk_dir, tcname])
            else:
                subprocess.check_output(['tar', '-xf', tcname, '-C', sdk_dir])

        except subprocess.CalledProcessError as e:
            bb.fatal("Couldn't install the SDK:\n%s" % e.output.decode("utf-8"))

    def setup_context(self, d):
        """
        Return a dictionary of additional arguments that should be passed to
        the context_class on construction
        """
        wine_prefix = d.getVar('TESTSDK_WINEPREFIX') or d.expand('${WORKDIR}/testimage-wine/')
        bb.utils.remove(wine_prefix, True)

        return {
            'wine_prefix': wine_prefix,
            'wine_arch': d.getVar('TESTSDK_WINEARCH') or 'win64',
            'wine_devices': {
                'w:': d.getVar("WORKDIR"),
            }
        }