]>
Commit | Line | Data |
---|---|---|
de8ee011 A |
1 | #!/usr/bin/python |
2 | ||
3 | import os, sys, shutil | |
4 | ||
5 | # Temporarily change folder to another folder and then go back | |
6 | class Temp_Chdir: | |
7 | def __init__(self, newDir): | |
8 | self.prevDir = os.getcwd() | |
9 | self.newDir = newDir | |
10 | ||
11 | def __enter__(self): | |
12 | os.chdir(self.newDir) | |
13 | ||
14 | def __exit__(self, type, value, traceback): | |
15 | os.chdir(self.prevDir) | |
16 | ||
17 | # Print and execute something | |
18 | def execute(cmd): | |
19 | print('Command to execute: ' + cmd) | |
20 | ret = os.system(cmd) | |
21 | if (ret != 0): raise Exception('Shell command failed with error code {}'.format(ret)) | |
22 | return ret | |
23 | ||
24 | if ( len(sys.argv) != 4 ): | |
25 | raise Exception('Usage : python CreateRelease.py <Project Root Folder> <ReleaseNumber> <Configuration>') | |
26 | ||
27 | ||
28 | PROJECT_ROOT_FOLDER = sys.argv[1] | |
29 | REL = sys.argv[2] | |
30 | CONF = sys.argv[3] | |
31 | if CONF not in ['Debug', 'Release']: | |
32 | raise Exception('Bad confuguration {}'.format(CONF)) | |
33 | ||
34 | print('Creating HFSPlugin Project [{}] Release [{}]...'.format(PROJECT_ROOT_FOLDER, REL)) | |
35 | SVN_URL = 'http://iliha1-svn01.euro.apple.com/svn/Integration/S4E/production/Files/hfs_plugin' | |
36 | ||
37 | shutil.rmtree('/tmp/tmp_HFSPlugin', ignore_errors=True) | |
38 | ||
39 | with Temp_Chdir('/tmp'): | |
40 | execute('svn co {} tmp_HFSPlugin --depth immediates'.format(SVN_URL)) | |
41 | os.makedirs('tmp_HFSPlugin/{}'.format(REL)) | |
42 | ||
43 | ||
44 | targetsInfo = { | |
45 | 'iOS' : { | |
46 | 'sdk' : 'iphoneos.internal', | |
47 | 'buildDir' : 'build/{}-iphoneos/'.format(CONF) | |
48 | }, | |
49 | 'OSX' : { | |
50 | 'sdk' : 'macosx.internal', | |
51 | 'buildDir' : 'build/{}/'.format(CONF) | |
52 | } | |
53 | } | |
54 | ||
55 | with Temp_Chdir(PROJECT_ROOT_FOLDER): | |
56 | ||
57 | for target, info in targetsInfo.items(): | |
58 | execute('mkdir -p /tmp/tmp_HFSPlugin/{}/{}'.format(REL, target)) | |
59 | execute('xcodebuild -target livefiles_hfs -sdk {} -configuration {}'.format(info['sdk'], CONF)) | |
60 | shutil.copy('{}/livefiles_hfs.dylib'.format(info['buildDir']), '/tmp/tmp_HFSPlugin/{}/{}/'.format(REL, target)) | |
61 | ||
62 | execute('echo xcodebuild configuration : {} > /tmp/tmp_HFSPlugin/{}/release_notes.txt'.format(CONF, REL)) | |
63 | execute('echo Source branch : `git rev-parse --abbrev-ref HEAD` >> /tmp/tmp_HFSPlugin/{}/release_notes.txt'.format(REL)) | |
64 | execute('echo Last commit Hash : `git rev-parse HEAD` >> /tmp/tmp_HFSPlugin/{}/release_notes.txt'.format(REL)) | |
65 | execute('echo "\n\n In Order to checkout the source files execute :\n\tgit checkout `git rev-parse --abbrev-ref HEAD` \n\tgit checkout `git rev-parse HEAD`" >> /tmp/tmp_HFSPlugin/{}/release_notes.txt'.format(REL)) | |
66 | ||
67 | ## Add to SVN: | |
68 | with Temp_Chdir('/tmp/tmp_HFSPlugin'): | |
69 | execute('svn add {}'.format(REL)) | |
70 | execute('svn ci -m "Added release {}"'.format(REL)) | |
71 | ||
72 | print('All set! {} HFSPlugin release is ready'.format(REL)) | |
73 |