Release 11.0.0.18217
[platform/core/csapi/tizenfx.git] / packaging / maketfm.py
1 import os, re
2 import xml.etree.ElementTree as ET
3
4 scrpit_dir = os.path.dirname(os.path.abspath(__file__))
5 spec_dir = os.path.join(scrpit_dir, "csapi-tizenfx.spec")
6 nuspec_file = os.path.join(scrpit_dir, "../pkg/Tizen.NET/Tizen.NET.nuspec")
7 tree = ET.parse(nuspec_file)
8 root = tree.getroot()
9
10 tfm_list1 = [] #tizen90, tizen80, tizen70, tizen60, tizen50, tizen40
11 tfm_list2 = [] #tizen10.0
12 tfm_list3 = [] #net6.0-tizen8.0, net6.0-tizen, net6.0
13 for meta_child in root.iter():
14     if meta_child.tag == "{http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd}metadata":
15         for depen_child in meta_child:
16             if depen_child.tag == "{http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd}dependencies":
17                 for group in depen_child:
18                     tfm = group.attrib["targetFramework"].lower()
19                     if tfm.startswith("tizen"):
20                         if len(tfm) == 8:
21                             tfm_list1.append(tfm.replace(".", "").strip())
22                         else:
23                             tfm_list2.append(tfm.strip())
24                     elif tfm.startswith("net"):
25                         if len(tfm) < 8:
26                             tfm_list3.append(tfm.strip() + "-tizen")
27                         tfm_list3.append(tfm.strip())
28
29
30 tfm_list1 = list(set(tfm_list1))
31 tfm_list1.sort(reverse=True)
32 tfm_list2 = list(set(tfm_list2))
33 tfm_list2.sort(reverse=True)
34 tfm_list3 = list(set(tfm_list3))
35 tfm_list3.sort(key=len)
36 tfm_list3.sort(key=lambda s: float(re.search(r'(\d+)\.', s).group()[0]))
37 tfm_list3.reverse()
38 tfm_list = tfm_list3 + tfm_list2 + tfm_list1
39
40 f = open(spec_dir,'r')
41 origin_data = f.read()
42 f.close()
43
44 new_data = origin_data.replace("@tfm_support@", ':'.join(tfm_list))
45
46 f = open(spec_dir, 'w')
47 f.write(new_data)
48 f.close()