Merge branch 'BS-36'
This commit is contained in:
commit
6354c67bc3
|
|
@ -34,7 +34,7 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignProvision>MyProvisioningValue</CodesignProvision><CodesignKey>MyCodesignValue</CodesignKey></PropertyGroup>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
restore from backup # восстанавливаем из бэкапа (исходники от сборки предыдущей конфигурации могут быть модифицированными)
|
||||
create backup
|
||||
# restore from backup # восстанавливаем из бэкапа (исходники от сборки предыдущей конфигурации могут быть модифицированными)
|
||||
# create backup
|
||||
|
||||
sh echo '{@sln_config}'
|
||||
|
||||
inside 'BuildSample/BuildSample.sln' remove NotCompileApp project
|
||||
|
||||
inside 'BuildSample/BuildSample/CoolApp.csproj' set OutputPath to 'Output' for '{@sln_config}'
|
||||
inside 'BuildSample/BuildSample/CoolApp.csproj' set AssemblyName to 'CoolApp' for ''
|
||||
|
||||
inside 'BuildSample/BuildSample/Info.plist' set CFBundleVersion to '{@version}'
|
||||
inside 'BuildSample/BuildSample/Info.plist' set CFBundleDisplayName to 'CoolApp'
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
__author__ = 'rzaitov'
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import unittest
|
||||
from utils.CsprojPatcher import CsprojPatcher
|
||||
|
||||
|
||||
class TestCsprojPatcher(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.patcher = CsprojPatcher('NotExists.sln')
|
||||
|
||||
def test_CheckPropertyGroupCondition(self):
|
||||
self.checkFit(" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ", 'Debug|iPhoneSimulator')
|
||||
self.checkFit(" '$(Configuration)|$(Platform)'=='Debug|iPhoneSimulator' ", 'Debug|iPhoneSimulator')
|
||||
self.checkFit("'$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator'", 'Debug|iPhoneSimulator')
|
||||
self.checkFit("'$(Configuration)|$(Platform)'=='Debug|iPhoneSimulator'", 'Debug|iPhoneSimulator')
|
||||
|
||||
self.checkFit(" '$(Configuration)' == '' ", '')
|
||||
self.checkFit(" '$(Configuration)'=='' ", '')
|
||||
self.checkFit("'$(Configuration)' == ''", '')
|
||||
self.checkFit("'$(Configuration)'==''", '')
|
||||
|
||||
def checkFit(self, conditionAttrValue, slnConfig):
|
||||
isFit = self.patcher.IsValueFitFor(slnConfig, conditionAttrValue)
|
||||
self.assertTrue(True, isFit)
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ class InsideCsprojSetParser(InsideParserBase):
|
|||
|
||||
keyRegexp = r'(?P<key>[a-zA-Z]+)'
|
||||
valueRegexp = r"'(?P<value>[^']+)'"
|
||||
slnConfigRegexp = r"'(?P<config>[a-zA-Z|]+)'$"
|
||||
slnConfigRegexp = r"'(?P<config>[a-zA-Z|]*)'$"
|
||||
|
||||
regexpSource = self.startsWith('inside') + self.filePathRegexp + self.keywordToken('set') + keyRegexp + \
|
||||
self.keywordToken('to') + valueRegexp + self.keywordToken('for') + slnConfigRegexp
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import xml.etree.ElementTree as eT
|
||||
eT.register_namespace('', "http://schemas.microsoft.com/developer/msbuild/2003")
|
||||
|
||||
|
|
@ -8,35 +9,37 @@ class CsprojPatcher:
|
|||
self._namespaces = {'ns': 'http://schemas.microsoft.com/developer/msbuild/2003'}
|
||||
|
||||
|
||||
def FetchPropertyGroup(self, sln_config_name):
|
||||
self._tree = eT.parse(self._csproj_abs_path)
|
||||
project_element = self._tree.getroot()
|
||||
def FetchPropertyGroup(self, slnConfigName):
|
||||
assert slnConfigName is not None
|
||||
|
||||
property_group = self.GetPropertyGroupBy(project_element, sln_config_name)
|
||||
return property_group
|
||||
self._tree = eT.parse(self._csproj_abs_path)
|
||||
projectElement = self._tree.getroot()
|
||||
|
||||
property_group = self.GetPropertyGroupBy(projectElement, slnConfigName)
|
||||
return property_group
|
||||
|
||||
def WriteTree(self):
|
||||
self._tree.write(self._csproj_abs_path, xml_declaration=True, encoding='utf-8', method="xml")
|
||||
|
||||
|
||||
def GetPropertyGroupBy(self, project_element, config_name):
|
||||
assert project_element is not None
|
||||
assert config_name is not None
|
||||
|
||||
property_groups = project_element.findall('ns:PropertyGroup', self._namespaces)
|
||||
|
||||
prop_group = None
|
||||
|
||||
for pg_elem in property_groups:
|
||||
# atr_value мб None для первого PropertyGroup
|
||||
atr_value = pg_elem.get('Condition')
|
||||
|
||||
if atr_value is None:
|
||||
continue
|
||||
|
||||
is_fit = self.IsValueFitFor(config_name, atr_value)
|
||||
|
||||
if is_fit:
|
||||
prop_group = pg_elem
|
||||
break
|
||||
|
||||
return prop_group
|
||||
return prop_group
|
||||
|
||||
|
||||
def Remove(self, tag_names, sln_config_name):
|
||||
|
|
@ -46,13 +49,24 @@ class CsprojPatcher:
|
|||
|
||||
|
||||
def AddOrReplace(self, key_value_dict, sln_config_name):
|
||||
assert key_value_dict is not None
|
||||
assert sln_config_name is not None
|
||||
|
||||
property_group = self.FetchPropertyGroup(sln_config_name)
|
||||
self.AddOrReplaceTagsFor(property_group, key_value_dict)
|
||||
self.WriteTree()
|
||||
|
||||
|
||||
def IsValueFitFor(self, config_name, condition_attr_value):
|
||||
result = "'{0}'".format(config_name) in condition_attr_value
|
||||
if condition_attr_value is None:
|
||||
result = config_name == '' or config_name is None
|
||||
else:
|
||||
# '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator'
|
||||
configValue = condition_attr_value.split('==')[1]
|
||||
configValue = configValue.strip()
|
||||
|
||||
result = "'{0}'".format(config_name) == configValue
|
||||
|
||||
return result
|
||||
|
||||
|
||||
|
|
@ -65,12 +79,19 @@ class CsprojPatcher:
|
|||
|
||||
|
||||
def AddOrReplaceTagsFor(self, property_group_element, key_value_dict):
|
||||
assert property_group_element is not None
|
||||
assert key_value_dict is not None
|
||||
|
||||
for k in key_value_dict:
|
||||
v = key_value_dict[k]
|
||||
self.AppendOrReplaceValueByKey(k, v, property_group_element)
|
||||
|
||||
|
||||
def AppendOrReplaceValueByKey(self, tag_name, value, property_group_element):
|
||||
assert tag_name is not None
|
||||
assert value is not None
|
||||
assert property_group_element is not None
|
||||
|
||||
tag = property_group_element.find('ns:{0}'.format(tag_name), self._namespaces)
|
||||
|
||||
if tag is None:
|
||||
|
|
|
|||
Loading…
Reference in New Issue