]>
git.saurik.com Git - wxWidgets.git/blob - build/osx/fix_xcode_ids.py
23dbe250dd0315b8dcab0e9428de7ae67d8596fa
3 ###############################################################################
4 # Name: build/osx/fix_xcode_ids.py
5 # Author: Dimitri Schoolwerth
8 # Copyright: (c) 2010 wxWidgets team
9 # Licence: wxWindows licence
10 ###############################################################################
15 USAGE
= """fix_xcode_ids - Modifies an Xcode project in-place to use the same identifiers (based on name) instead of being different on each regeneration"
16 Usage: fix_xcode_ids xcode_proj_dir"""
22 projectFile
= sys
. argv
[ 1 ] + "/project.pbxproj"
24 fin
= open ( projectFile
, "r" )
29 # Xcode identifiers (IDs) consist of 24 hexadecimal digits
30 idMask
= "[A-Fa-f0-9] {24} "
32 # key = original ID found in project
33 # value = ID it will be replaced by
36 # some of the strings to match to find definitions of Xcode IDs:
38 # from PBXBuildFile section:
39 # 0123456789ABCDEF01234567 /* filename.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEDCBA9876543210FEDCBA98 /* filename.cpp */; };
41 # from PBXFileReference section:
42 # FEDCBA9876543210FEDCBA98 /* filename.cpp */ = {isa = PBXFileReference; lastKnownFileType = file; name = any.cpp; path = ../../src/common/filename.cpp; sourceTree = "<group>"; };
44 # from remaining sections:
45 # 890123456789ABCDEF012345 /* Name */ = {
47 # Capture the first comment between /* and */ (file/section name) as a group
48 rc
= re
. compile ( "\s+(" + idMask
+ ") /\* (.+) \*/ = {.*$" , re
. MULTILINE
)
49 dict = rc
. findall ( strIn
)
51 # convert a name to an identifier for Xcode
53 from uuid
import uuid3
, UUID
54 return uuid3 ( UUID ( "349f853c-91f8-4eba-b9b9-5e9f882e693c" ), name
). hex [: 24 ]. upper ()
57 # s[0] is the original ID, s[1] is the name
59 # Some names can appear twice or even more (depending on number of
60 # targets), make them unique
61 while newId
in idDict
. values () :
62 # [2:-1] to skip prepended 0x and trailing L
63 newId
= hex ( int ( newId
, 16 ) + 1 )[ 2 :- 1 ]. upper ()
65 assert ( not s
[ 0 ] in idDict
)
69 # replace all found identifiers with the new ones
71 return idDict
[ match
. group ( 0 )]
73 strOut
= re
. sub ( idMask
, repl
, strIn
)
75 fout
= open ( projectFile
, "w" )