Revert "[TFM] Update TizenFX TFM to net6.0 (#5360)" (#5436)
[platform/core/csapi/tizenfx.git] / packaging / maketfm.py
1 import os
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 = []
11 tfm_list2 = []
12 for meta_child in root.iter():
13     if meta_child.tag == "{http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd}metadata":
14         for depen_child in meta_child:
15             if depen_child.tag == "{http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd}dependencies":
16                 for group in depen_child:
17                     tfm = group.attrib["targetFramework"].lower()
18                     if tfm.startswith("tizen"):
19                         if len(tfm) == 8:
20                             tfm_list1.append(tfm.replace(".", "").strip())
21                         else:
22                             tfm_list2.append(tfm.strip())
23
24 tfm_list1 = list(set(tfm_list1))
25 tfm_list1.sort(reverse=True)
26 tfm_list2 = list(set(tfm_list2))
27 tfm_list2.sort(reverse=True)
28 tfm_list = tfm_list2 + tfm_list1
29
30 f = open(spec_dir,'r')
31 origin_data = f.read()
32 f.close()
33
34 new_data = origin_data.replace("@tfm_support@", ':'.join(tfm_list))
35
36 f = open(spec_dir, 'w')
37 f.write(new_data)
38 f.close()