[Build] Fix wrong relative path in maketfm.py (#2059)
[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_list = []
11 for meta_child in root.iter():
12     if meta_child.tag == "{http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd}metadata":
13         for depen_child in meta_child:
14             if depen_child.tag == "{http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd}dependencies":
15                 for group in depen_child:
16                     tfm = group.attrib["targetFramework"].lower()
17                     tfm = tfm.replace(".", "")
18                     tfm = tfm.replace("20", "2.0")
19                     if tfm.strip():
20                         tfm_list.append(tfm)
21
22 tfm_list = list(set(tfm_list))
23 tfm_list.sort(reverse=True)
24
25 f = open(spec_dir,'r')
26 origin_data = f.read()
27 f.close()
28
29 new_data = origin_data.replace("@tfm_support@", ':'.join(tfm_list))
30
31 f = open(spec_dir, 'w')
32 f.write(new_data)
33 f.close()