Реализовал билд проекта

This commit is contained in:
Rustam Zaitov 2013-09-15 03:50:18 +04:00
parent c5278ea5d0
commit 893a98feea
2 changed files with 39 additions and 25 deletions

View File

@ -1,6 +1,4 @@
from subprocess import call
import os
import re
import settings
import instruments
@ -20,29 +18,11 @@ import instruments
# print(projects_to_build)
sln_config = "Debug|iPhone Simulator"
build_cmd_pattern = '{0} -v build "--configuration:{1}" "--target:Build" {2}'
# build_cmd_text = build_cmd_pattern.format(settings.mdtool, sln_config, settings.sln_path)
# print(build_cmd_text)
# ret_code = call(build_cmd_text, shell=True)
# print('finished with return code: {0}'.format(ret_code))
sln_dir = os.path.dirname(settings.sln_path)
# sln_file = open(settings.sln_path)
# sln_file_content = sln_file.read()
# print(sln_file_content)
# project_description_re = re.compile(r' = "(?P<project_name>\S+)", "(?P<project_rel_path>[\S\\]+csproj)"')
# match_iter = project_description_re.finditer(sln_file_content)
instruments.CreateOrRestoreFromBackup(sln_dir, settings.files_for_backup)
instruments.RemoveProjectFromSolution(settings.sln_path, settings.projects_to_exclude)
instruments.CleanSolution(settings.mdtool, settings.sln_path)
instruments.BuildSolution(settings.mdtool, settings.sln_path, sln_config)
# project_descriptions = [m.groupdict() for m in match_iter]
# for project_description in project_descriptions:
# rel_path = project_description['project_rel_path'].replace('\\', '/')
# abs_path = os.path.join(sln_dir, rel_path)
# build_cmd_text = build_cmd_pattern.format(settings.mdtool, sln_config, abs_path)
# print(build_cmd_text)
# ret_code = call(build_cmd_text, shell=True)
# print('finished with return code: {0}'.format(ret_code))
# instruments.CreateOrRestoreFromBackup(sln_dir, settings.files_for_backup)
# instruments.DeleteBackups(sln_dir, settings.files_for_backup)

View File

@ -1,5 +1,7 @@
from subprocess import call
import shutil
import os
import re
def MapToBackupName(origin_path):
@ -49,4 +51,36 @@ def ResetDirectory(base_dir, relative_path_to_files):
CreateOrRestoreFromBackup(base_dir, relative_path_to_files)
DeleteBackups(base_dir, relative_path_to_files)
return None
return None
def RemoveProjectFromSolution(abs_path_to_sln, project_names):
sln_file = open(abs_path_to_sln, 'r+')
content = sln_file.read()
for pn in project_names:
reg_pattern = r'\n*Project.*?"{0}".*?\n*EndProject'.format(pn)
content = re.sub(reg_pattern, "", content)
sln_file.seek(0)
sln_file.write(content)
sln_file.truncate()
sln_file.close()
def CleanSolution(mdtool, abs_path_to_sln):
clean_cmd_pattern = '{0} -v build "--target:Clean" {1}'
clean_cmd_text = clean_cmd_pattern.format(mdtool, 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))