645
|
1 |
#============================================================================
|
|
2 |
#Name : conftool.py
|
|
3 |
#Part of : Helium
|
|
4 |
|
|
5 |
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
6 |
#All rights reserved.
|
|
7 |
#This component and the accompanying materials are made available
|
|
8 |
#under the terms of the License "Eclipse Public License v1.0"
|
|
9 |
#which accompanies this distribution, and is available
|
|
10 |
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
11 |
#
|
|
12 |
#Initial Contributors:
|
|
13 |
#Nokia Corporation - initial contribution.
|
|
14 |
#
|
|
15 |
#Contributors:
|
|
16 |
#
|
|
17 |
#Description:
|
|
18 |
#===============================================================================
|
|
19 |
|
|
20 |
from packager.datasources.api import DataSource, DATASOURCES
|
|
21 |
from Blocks.Packaging.BuildData import PlainBuildData
|
|
22 |
import logging
|
|
23 |
import re
|
|
24 |
import os
|
|
25 |
|
|
26 |
logger = logging.getLogger('packager.datasources.conftool')
|
|
27 |
|
|
28 |
class ConEDataSource(DataSource):
|
|
29 |
""" Extract information from ConE logs """
|
|
30 |
def __init__(self, epocroot, data=None):
|
|
31 |
DataSource.__init__(self, epocroot, data)
|
|
32 |
|
|
33 |
def getTargetFiles(self):
|
|
34 |
""" Get the generated files from the log output. """
|
|
35 |
result = []
|
|
36 |
txtFile = open(self._data['filename'], 'r')
|
|
37 |
matcher = re.compile(r"^\s*Generating file '(.+)'\.\.\.\s*$")
|
|
38 |
for line in txtFile:
|
|
39 |
res = matcher.match(line)
|
|
40 |
if res:
|
|
41 |
result.append(os.path.normpath(os.path.join(self.epocroot,
|
|
42 |
res.group(1))))
|
|
43 |
txtFile.close()
|
|
44 |
return result
|
|
45 |
|
|
46 |
def getComponents(self):
|
|
47 |
""" Get the components list from the cli input. """
|
|
48 |
if 'name' not in self._data:
|
|
49 |
raise Exception("The name property has not be defined.")
|
|
50 |
if 'version' not in self._data:
|
|
51 |
raise Exception("The version property has not be defined.")
|
|
52 |
|
|
53 |
if 'filename' not in self._data:
|
|
54 |
raise Exception("The input conftool log file is not defined")
|
|
55 |
|
|
56 |
#todo: add the source iby / path for conftool input
|
|
57 |
build_data = PlainBuildData()
|
|
58 |
build_data.setComponentName(self._data['name'])
|
|
59 |
build_data.setComponentVersion(self._data['version'])
|
|
60 |
build_data.setSourceRoot(self.epocroot)
|
|
61 |
build_data.setTargetRoot(self.epocroot)
|
|
62 |
build_data.addTargetFiles([path[len(self.epocroot):].lstrip(os.sep) for path in self.getTargetFiles()])
|
|
63 |
return [build_data]
|
|
64 |
|
|
65 |
def getHelp(self):
|
|
66 |
""" Returns the help. """
|
|
67 |
return """
|
|
68 |
name Defines the name of the component
|
|
69 |
version Defines the version of the component
|
|
70 |
filename Defines the log file name of ctool
|
|
71 |
"""
|
|
72 |
|
|
73 |
|
|
74 |
DATASOURCES['cone'] = ConEDataSource |