diff --git a/scripts/CommandBuilders/CleanBuildCommandBuilder.py b/scripts/CommandBuilders/CleanBuildCommandBuilder.py index cd8639f..a4740b4 100644 --- a/scripts/CommandBuilders/CleanBuildCommandBuilder.py +++ b/scripts/CommandBuilders/CleanBuildCommandBuilder.py @@ -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': diff --git a/scripts/UnitTests/CleanBuildParser/test_cleanBuildParser.py b/scripts/UnitTests/CleanBuildParser/test_cleanBuildParser.py index 48c3bcc..18c6065 100644 --- a/scripts/UnitTests/CleanBuildParser/test_cleanBuildParser.py +++ b/scripts/UnitTests/CleanBuildParser/test_cleanBuildParser.py @@ -1,5 +1,5 @@ import unittest -from parser import CleanBuildParser +from parser.CleanBuildParser import CleanBuildParser class TestCleanBuildParser(unittest.TestCase): diff --git a/scripts/UnitTests/ProjectParser/test_projectParser.py b/scripts/UnitTests/ProjectParser/test_projectParser.py index e86ff30..d3dc1f2 100644 --- a/scripts/UnitTests/ProjectParser/test_projectParser.py +++ b/scripts/UnitTests/ProjectParser/test_projectParser.py @@ -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]) \ No newline at end of file + self.assertEqual('Dir/../Some Folder/CoolApp.csproj', result[0]) + self.assertEqual('OutputPath', result[1]) + self.assertEqual('Output', result[2]) \ No newline at end of file diff --git a/scripts/UnitTests/SettingsParser/test_SettingsParser.py b/scripts/UnitTests/SettingsParser/test_SettingsParser.py index 2ad2ad4..b391cc3 100644 --- a/scripts/UnitTests/SettingsParser/test_SettingsParser.py +++ b/scripts/UnitTests/SettingsParser/test_SettingsParser.py @@ -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'" diff --git a/scripts/UnitTests/SolutionToolkit/__init__.py b/scripts/UnitTests/SolutionToolkit/__init__.py deleted file mode 100644 index cc31abc..0000000 --- a/scripts/UnitTests/SolutionToolkit/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__author__ = 'rzaitov' diff --git a/scripts/UnitTests/SolutionToolkit/test_remove_project_sections.py b/scripts/UnitTests/SolutionToolkit/test_remove_project_sections.py deleted file mode 100644 index 3a3cc14..0000000 --- a/scripts/UnitTests/SolutionToolkit/test_remove_project_sections.py +++ /dev/null @@ -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 -""" \ No newline at end of file diff --git a/scripts/build.py b/scripts/build.py deleted file mode 100644 index fe8828a..0000000 --- a/scripts/build.py +++ /dev/null @@ -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) \ No newline at end of file diff --git a/scripts/commands/DeleteBackupCommand.py b/scripts/commands/DeleteBackupCommand.py index c34add1..5246d1a 100644 --- a/scripts/commands/DeleteBackupCommand.py +++ b/scripts/commands/DeleteBackupCommand.py @@ -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) \ No newline at end of file + for d in dirs: + shutil.rmtree(d) \ No newline at end of file diff --git a/scripts/commands/PatchCsprojCommand.py b/scripts/commands/PatchCsprojCommand.py index ef9ccb0..b801d11 100644 --- a/scripts/commands/PatchCsprojCommand.py +++ b/scripts/commands/PatchCsprojCommand.py @@ -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) \ No newline at end of file + dictionary = { self.__key : self.__value } + patcher.AddOrReplace(dictionary, self.__slnConfig) \ No newline at end of file diff --git a/scripts/commands/PatchInfoPlistCommand.py b/scripts/commands/PatchInfoPlistCommand.py index fbd97b0..d85cb00 100644 --- a/scripts/commands/PatchInfoPlistCommand.py +++ b/scripts/commands/PatchInfoPlistCommand.py @@ -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) diff --git a/scripts/commands/RemoveProjectCommand.py b/scripts/commands/RemoveProjectCommand.py index d29082c..3bdb943 100644 --- a/scripts/commands/RemoveProjectCommand.py +++ b/scripts/commands/RemoveProjectCommand.py @@ -1,4 +1,4 @@ -from utils.sln.patcher import Patcher +from utils.sln.Patcher import Patcher class RemoveProjectCommand: diff --git a/scripts/instruments.py b/scripts/instruments.py deleted file mode 100644 index 357a700..0000000 --- a/scripts/instruments.py +++ /dev/null @@ -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 \ No newline at end of file diff --git a/scripts/parser/CleanBuildParser.py b/scripts/parser/CleanBuildParser.py index 78c08bb..d0461a0 100644 --- a/scripts/parser/CleanBuildParser.py +++ b/scripts/parser/CleanBuildParser.py @@ -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 diff --git a/scripts/parser/SettingsParser/SettingsMerger.py b/scripts/parser/SettingsParser/SettingsMerger.py index 366f971..c3cd2f8 100644 --- a/scripts/parser/SettingsParser/SettingsMerger.py +++ b/scripts/parser/SettingsParser/SettingsMerger.py @@ -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) diff --git a/scripts/parser/ShParser.py b/scripts/parser/ShParser.py index b284d8c..0067883 100644 --- a/scripts/parser/ShParser.py +++ b/scripts/parser/ShParser.py @@ -21,4 +21,4 @@ class ShParser(LineParser): def isValidLine(self, line): assert line is not None - return line.startswith('sh ') \ No newline at end of file + return line.startswith('sh ') diff --git a/scripts/patch.py b/scripts/patch.py deleted file mode 100644 index 07e5465..0000000 --- a/scripts/patch.py +++ /dev/null @@ -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'.*?' - condesign_key_node = r'{0}'.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') - diff --git a/scripts/settings.py b/scripts/settings.py index d448715..0ebec86 100644 --- a/scripts/settings.py +++ b/scripts/settings.py @@ -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 } diff --git a/scripts/utils/PathConverter/__init__.py b/scripts/utils/PathConverter/__init__.py deleted file mode 100644 index cc31abc..0000000 --- a/scripts/utils/PathConverter/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__author__ = 'rzaitov' diff --git a/scripts/utils/PathConverter/converter_base.py b/scripts/utils/PathConverter/converter_base.py deleted file mode 100644 index f070b93..0000000 --- a/scripts/utils/PathConverter/converter_base.py +++ /dev/null @@ -1,6 +0,0 @@ - - -class ConverterBase: - - def Convert(self, rel_path): - return None diff --git a/scripts/utils/PathConverter/path_converter.py b/scripts/utils/PathConverter/path_converter.py deleted file mode 100644 index 36927e4..0000000 --- a/scripts/utils/PathConverter/path_converter.py +++ /dev/null @@ -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) \ No newline at end of file