コード例 #1
0
 def __init__(self, productMakefile):
     self.__targetName = productMakefile.split('.')[0]
     self.__productFilePath = '/'.join(
         [toPosixPath(attributes.PRODUCT_DIRECTORY), productMakefile])
     if not os.path.isfile(self.__productFilePath):
         raise StatMakefileGeneratorException(
             "The product file '{0}' was not found".format(
                 self.__productFilePath))
コード例 #2
0
 def __init__(self):
     super(StatConfiguration, self).__init__()
     self.update(TOOL_VERSION=attributes.VERSION,
                 OUTPUT_DIR=attributes.OUTPUT_DIRECTORY,
                 STAT_ROOT=toPosixPath(os.path.relpath(attributes.TOOL_PATH)),
                 DUMMIES_DIR=attributes.DUMMIES_DIRECTORY)
     self.__products = [item[:-4] for item in listMakefiles(attributes.PRODUCT_DIRECTORY)]
     self.__autoGenerated = {}
     self.__readUserConfiguration()
     self.__readAutoGenerated()
コード例 #3
0
 def test_getFileLocationThroughoutCurrentPathUponNotExistingFile(self):
     filePath = os.path.join(*'/home/product/config.mak'.split('/'))
     currentPath = os.path.dirname(filePath)
     self._fakeOs.addMockForFunction('getcwd', currentPath)
     for dummyIndex in range(len(
             services.toPosixPath(filePath).split('/'))):
         self._fakeOs.path.addMockForFunction('isfile', False)
     location = services.getFileLocationThroughoutCurrentPath(
         os.path.basename(filePath))
     self.assertIsNone(location)
コード例 #4
0
 def generate(self):
     variables = self.__constructVariablesInitialization()
     fileContext = _makFileTemplate.format(
         variables=variables,
         tool_path=toPosixPath(os.path.relpath(attributes.TOOL_PATH)),
         product_file_path=self.__productFilePath)
     fileName = attributes.AUTO_GENERATED_MAKEFILE
     directory = os.path.dirname(fileName)
     mkdir(directory, exist_ok=True)
     fileHandle = open(fileName, 'w')
     fileHandle.write(fileContext)
     fileHandle.flush()
     fileHandle.close()
コード例 #5
0
 def test_getFileLocationThroughoutCurrentPathUponFileFromSomeParentDirectory(
         self):
     filePath = os.path.join(*'/home/product/config.mak'.split('/'))
     cwdOffset = os.path.join(*'fw/module/src'.split('/'))
     currentPath = os.path.join(os.path.dirname(filePath), cwdOffset)
     self._fakeOs.addMockForFunction('getcwd', currentPath)
     for dummyIndex in range(len(
             services.toPosixPath(cwdOffset).split('/'))):
         self._fakeOs.path.addMockForFunction('isfile', False)
     self._fakeOs.path.addMockForFunction('isfile', True)
     location = services.getFileLocationThroughoutCurrentPath(
         os.path.basename(filePath))
     self.assertEqual(filePath, location)
コード例 #6
0
 def test___init__basics(self):
     config = StatConfiguration()
     self.assertEqual(attributes.VERSION, config['TOOL_VERSION'])
     self.assertEqual(toPosixPath(attributes.OUTPUT_DIRECTORY),
                      toPosixPath(config['OUTPUT_DIR']))
     self.assertEqual(toPosixPath(os.path.relpath(attributes.TOOL_PATH)),
                      toPosixPath(config['STAT_ROOT']))
     self.assertEqual(toPosixPath(attributes.DUMMIES_DIRECTORY),
                      toPosixPath(config['DUMMIES_DIR']))
コード例 #7
0
 def test_toPosixPath(self):
     original = 'home\\feature\\inc'
     expected = 'home/feature/inc'
     self.assertEqual(expected, services.toPosixPath(expected))
     self.assertEqual(expected, services.toPosixPath(original))
コード例 #8
0
 def getAttributes(self):
     return dict(MSVS_DEV=toPosixPath(self.__devBatchFile))