check-platform.py 1.56 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
#!/usr/bin/python3
import os
import sys
import argparse
import subprocess
import yaml
from helperslib import BuildSpecs, Buildable, CommonUtils, EnvironmentHandler

parser = argparse.ArgumentParser(description='Utility to check if metainfo.yaml is lying.', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('metainfo', nargs='+', help='metainfo.yaml files', type=str)
arguments = parser.parse_args()

allPlatforms = {
14 15
    'SUSEQt5.10': 'Linux',
    'SUSEQt5.11': 'Linux',
16
    'SUSEQt5.12': 'Linux',
17
    'FreeBSDQt5.12': 'FreeBSD',
18
    'WindowsMSVCQt5.11': 'Windows',
19
    None: 'MacOSX',
20
    'AndroidQt5.12': 'Android'
21 22 23 24 25 26 27 28
}

resolver = Buildable.DependencyResolver()
resolver.loadProjectsFromTree(os.path.join( CommonUtils.scriptsBaseDirectory(), 'repo-metadata', 'projects' ))
resolver.loadProjectsIgnoreRules(os.path.join( CommonUtils.scriptsBaseDirectory(), 'local-metadata', 'project-ignore-rules.yaml' ))

for metainfo in arguments.metainfo:
    metainfoFile = open(metainfo, 'r', encoding='utf-8')
29
    read = yaml.safe_load(metainfoFile)
30 31 32 33 34 35
    platforms = [p['name'] for p in read['platforms']]
    if 'All' in platforms:
        platforms = allPlatforms.values()

    projectname=os.path.split(metainfo)[-2]
    p = resolver.retrieveProject( projectname )
36 37 38
    if not p: # could not find the project for some reason
        continue

39 40 41 42
    ignoredPlatforms = [allPlatforms[ignoredPlatform] for ignoredPlatform in p.ignoredOnPlatforms]
    for ip in ignoredPlatforms:
        if ip in platforms:
            print('%s: %s is disabled in build.kde.org' % (projectname, ip))