Удалил неиспользуемые файлы

This commit is contained in:
rzaitov 2013-11-01 18:09:31 +04:00
parent 0758b2e436
commit e18bebeae5
20 changed files with 21 additions and 318 deletions

View File

@ -32,8 +32,6 @@ class CleanBuildCommandBuilder:
return command
def __getCommandByToken(self, slnPath, slnConfig):
command = None
if self.__commandToken == 'clean':
command = CleanCommand(self.__pathToBuildUtil, slnPath, slnConfig)
elif self.__commandToken == 'build':

View File

@ -1,5 +1,5 @@
import unittest
from parser import CleanBuildParser
from parser.CleanBuildParser import CleanBuildParser
class TestCleanBuildParser(unittest.TestCase):

View File

@ -25,8 +25,8 @@ class TestCsprojParser(unittest.TestCase):
def test_parse(self):
line = "inside 'Dir/../Some Folder/CoolApp.csproj' set OutputPath to 'Output'"
tuple = self.parser.parseLine(line)
result = self.parser.parseLine(line)
self.assertEqual('Dir/../Some Folder/CoolApp.csproj', tuple[0])
self.assertEqual('OutputPath', tuple[1])
self.assertEqual('Output', tuple[2])
self.assertEqual('Dir/../Some Folder/CoolApp.csproj', result[0])
self.assertEqual('OutputPath', result[1])
self.assertEqual('Output', result[2])

View File

@ -7,23 +7,6 @@ class TestSettingsParser(unittest.TestCase):
def setUp(self):
self.parser = SettingsParser()
def test_getSettingsDictByPath(self):
len0 = len(self.parser.settings)
self.assertEqual(0, len0)
self.parser.getSettingsDictByPath(['one'])
len1 = len(self.parser.settings)
self.assertEqual(1, len1)
self.parser.getSettingsDictByPath(['one', 'two'])
len1 = len(self.parser.settings)
self.assertEqual(1, len1)
self.parser.getSettingsDictByPath(['another', 'two'])
len2 = len(self.parser.settings)
self.assertEqual(2, len2)
def test_processLine(self):
line1 = "x.y.name1 = 'value1'"
line2 = "x.y.name2 = 'value2'"

View File

@ -1 +0,0 @@
__author__ = 'rzaitov'

View File

@ -1,44 +0,0 @@
import unittest
from utils.sln import sln_toolkit_base as sln
class TestRemoveProjectSections(unittest.TestCase):
def test_RemoveProjectSections(self):
toolkit = sln.SolutionToolkitBase()
patched_content = toolkit.RemoveProjectSectionsFrom(TestRemoveProjectSections.sln_content_original, ['NotCompileApp'])
self.assertEqual(TestRemoveProjectSections.sln_content_patched, patched_content)
sln_content_original = r"""
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoolApp", "BuildSample\CoolApp.csproj", "{E7393DD4-5E5F-456A-89AB-000EC63BD901}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NotCompileApp", "NotCompileApp\NotCompileApp.csproj", "{3DE4FDFA-1502-44CF-9B73-78B6D730C59F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Domain", "Domain\Domain.csproj", "{BD5EC0A1-EDC9-4D90-BACF-AE54F26148C1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Release|iPhoneSimulator = Release|iPhoneSimulator
Debug|iPhone = Debug|iPhone
Release|iPhone = Release|iPhone
EndGlobalSection
"""
sln_content_patched = r"""
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoolApp", "BuildSample\CoolApp.csproj", "{E7393DD4-5E5F-456A-89AB-000EC63BD901}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Domain", "Domain\Domain.csproj", "{BD5EC0A1-EDC9-4D90-BACF-AE54F26148C1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Release|iPhoneSimulator = Release|iPhoneSimulator
Debug|iPhone = Debug|iPhone
Release|iPhone = Release|iPhone
EndGlobalSection
"""

View File

@ -1,56 +0,0 @@
import os
import imp
import argparse
import settings
import instruments
keys = instruments.GetConfigKeys(settings.build_ready_configs)
parser = argparse.ArgumentParser()
for key in keys:
arg = "--{0}".format(key)
parser.add_argument(arg)
args = parser.parse_args()
cmd_args = vars(args)
# remove unset key-values pairs
for k in cmd_args.keys():
if cmd_args[k] is None:
del cmd_args[k]
print cmd_args
build_ready_configs = instruments.GetUnionConfigs(settings.build_ready_configs, cmd_args)
for bc in build_ready_configs:
print bc['name']
sln_path = bc['sln_path']
sln_dir = os.path.dirname(sln_path)
instruments.CreateOrRestoreFromBackup(sln_dir, bc['files_for_backup'])
instruments.RemoveProjectFromSolution(sln_path, bc['projects_to_exclude'])
# try patch source code files
path_function = bc['patch']
if path_function is not None:
path_function(bc)
if bc['action'] == 'build':
instruments.CleanSolution(bc['mdtool'], sln_path, bc['sln_config'])
instruments.BuildSolution(bc['mdtool'], sln_path, bc['sln_config'])
instruments.CreateOrRestoreFromBackup(sln_dir, bc['files_for_backup'])
instruments.DeleteBackups(sln_dir, bc['files_for_backup'])
if 'post_build_file' in bc and 'post_build_actions' in bc:
path_to_script = bc['post_build_file']
module_name = os.path.splitext(os.path.basename(path_to_script))[0]
post_build = imp.load_source(module_name, path_to_script)
for func_name in bc['post_build_actions']:
func = getattr(post_build, func_name)
func(bc)

View File

@ -4,5 +4,5 @@ import shutil
class DeleteBackupCommand:
def execute(self):
dirs = [name for name in os.listdir('.') if os.path.isdir(os.path.join('.', name)) & name.startswith('backup.')]
for dir in dirs:
shutil.rmtree(dir)
for d in dirs:
shutil.rmtree(d)

View File

@ -1,4 +1,4 @@
import utils.csproj.patcher as csproj
import utils.csproj.Patcher as csproj
class PatchCsprojCommand():
def __init__(self, csprojAbsPath, key, value, slnConfig):
@ -15,5 +15,5 @@ class PatchCsprojCommand():
def execute(self):
patcher = csproj.Patcher(self.__csprojAbsPath)
dict = { self.__key : self.__value }
patcher.AddOrReplace(dict, self.__slnConfig)
dictionary = { self.__key : self.__value }
patcher.AddOrReplace(dictionary, self.__slnConfig)

View File

@ -1,4 +1,4 @@
from utils.infoplist.patcher import Patcher
from utils.infoplist.Patcher import Patcher
class PatchInfoPlistCommand():
@ -14,5 +14,5 @@ class PatchInfoPlistCommand():
def execute(self):
patcher = Patcher(self.__pathToPlist)
dict = { self.__key : self.__value }
patcher.AddOrReplace(dict)
dictionary = { self.__key : self.__value }
patcher.AddOrReplace(dictionary)

View File

@ -1,4 +1,4 @@
from utils.sln.patcher import Patcher
from utils.sln.Patcher import Patcher
class RemoveProjectCommand:

View File

@ -1,119 +0,0 @@
from subprocess import call
import shutil
import os
from utils.sln import patcher as sln
def MapToBackupName(origin_path):
backup_path = "{0}.build_backup".format(origin_path)
return backup_path
def FetchAbsOriginBackupInfo(base_dir, rel_path_to_origin_files):
abs_path_to_origin_files = [os.path.join(base_dir, rel) for rel in rel_path_to_origin_files]
abs_origin_backup_infos = [{'origin': p, 'backup': MapToBackupName(p)} for p in abs_path_to_origin_files]
return abs_origin_backup_infos
def CreateOrRestoreFromBackup(base_dir, relative_path_to_files):
abs_origin_backup_infos = FetchAbsOriginBackupInfo(base_dir, relative_path_to_files)
for aobi in abs_origin_backup_infos:
abs_original = aobi['origin']
abs_backup = aobi['backup']
if os.path.exists(abs_backup):
# restore from backup
shutil.copyfile(abs_backup, abs_original)
else:
# create backup
shutil.copyfile(abs_original, abs_backup)
return None
def DeleteBackups(base_dir, relative_path_to_files):
abs_origin_backup_infos = FetchAbsOriginBackupInfo(base_dir, relative_path_to_files)
for aobi in abs_origin_backup_infos:
abs_backup = aobi['backup']
if os.path.exists(abs_backup):
os.remove(abs_backup)
return None
def ResetDirectory(base_dir, relative_path_to_files):
CreateOrRestoreFromBackup(base_dir, relative_path_to_files)
DeleteBackups(base_dir, relative_path_to_files)
return None
def RemoveProjectFromSolution(abs_path_to_sln, project_names):
toolkit = sln.Patcher(abs_path_to_sln)
toolkit.removeProjects(project_names)
def CleanSolution(mdtool, abs_path_to_sln, config):
clean_cmd_pattern = '{0} -v build "--configuration:{1}" "--target:Clean" {2}'
clean_cmd_text = clean_cmd_pattern.format(mdtool, config, abs_path_to_sln)
print(clean_cmd_text)
ret_code = call(clean_cmd_text, shell=True)
print('finished with return code: {0}'.format(ret_code))
def BuildSolution(mdtool, abs_path_to_sln, config):
build_cmd_pattern = '{0} -v build "--configuration:{1}" "--target:Build" {2}'
build_cmd_text = build_cmd_pattern.format(mdtool, config, abs_path_to_sln)
print(build_cmd_text)
ret_code = call(build_cmd_text, shell=True)
print('finished with return code: {0}'.format(ret_code))
def GetUnionConfigs(configs_lst, cmd_args=None):
union_configs = []
for c_dict in configs_lst:
ancestors = GetAncestorsFromRootTo(c_dict)
if cmd_args is not None:
ancestors.append(cmd_args)
union_config = {}
for a in ancestors:
union_config.update(a)
union_configs.append(union_config)
return union_configs
def GetConfigKeys(configs_lst):
union_configs = GetUnionConfigs(configs_lst)
keys = [];
for config in union_configs:
for key in config.keys():
keys.append(key)
# remove duplicates
keys = list(set(keys))
return keys
def GetAncestorsFromRootTo(config):
ancestors = []
c = config
while c is not None:
ancestors.append(c)
c = c['parent']
ancestors.reverse()
return ancestors

View File

@ -1,6 +1,8 @@
from parser.LineParser import LineParser
import re
from parser.LineParser import LineParser
class CleanBuildParser(LineParser):
def __init__(self, commandToken):
assert commandToken is not None

View File

@ -23,10 +23,10 @@ class SettingsMerger:
return settingsDict
def overrideGuard(self, dict, key, path):
if key in dict:
def overrideGuard(self, dictionary, key, path):
if key in dictionary:
pathStr = '.'.joun(path)
msg = 'settings with name {0} by path {1} already exists with value {3}'.format(key, dict[key], pathStr)
msg = 'settings with name {0} by path {1} already exists with value {3}'.format(key, dictionary[key], pathStr)
raise Exception(msg)

View File

@ -21,4 +21,4 @@ class ShParser(LineParser):
def isValidLine(self, line):
assert line is not None
return line.startswith('sh ')
return line.startswith('sh ')

View File

@ -1,39 +0,0 @@
import re
import os
import utils.infoplist.patcher as plist
def RewriteFile(file_to_rewrite, content):
file_to_rewrite.seek(0)
file_to_rewrite.write(content)
file_to_rewrite.truncate()
file_to_rewrite.close()
def PatchSlnForIos(build_config):
sln_file = open(build_config['sln_path'], 'r+')
content = sln_file.read()
condesign_key_patt = r'<CodesignKey>.*?</CodesignKey>'
condesign_key_node = r'<CodesignKey>{0}</CodesignKey>'.format(build_config['codesign_key'])
content = re.sub(condesign_key_patt, condesign_key_node, content)
RewriteFile(sln_file, content)
def PatchInfoPlist(build_config):
sln_dir = os.path.dirname(build_config['sln_path'])
abs_info_plist_path = os.path.join(sln_dir, build_config['info_plist_rel_path'])
key_values = {'CFBundleVersion' : build_config['version']}
patcher = plist.Patcher(abs_info_plist_path)
patcher.AddOrReplace(key_values)
def PathcIos(build_config):
PatchSlnForIos(build_config)
PatchInfoPlist(build_config)
def PathcAndroid(build_config):
print('start patch ios')

View File

@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
import patch
build_root = {
'mdtool': '/Applications/Xamarin\ Studio.app/Contents/MacOS/mdtool',
'version': '0.0.0',
@ -58,7 +56,6 @@ ios_development_root = {
'std_cmd.py testflight',
],
'patch': patch.PathcIos,
'parent': ios_root
}

View File

@ -1 +0,0 @@
__author__ = 'rzaitov'

View File

@ -1,6 +0,0 @@
class ConverterBase:
def Convert(self, rel_path):
return None

View File

@ -1,11 +0,0 @@
import os
import utils.PathConverter.converter_base as cB
class PathConverter(cB.ConverterBase):
def __init__(self, sln_path):
self._sln_dir = os.path.dirname(sln_path)
def Convert(self, rel_path):
return os.path.join(self._sln_dir, rel_path)