@@ -91,43 +91,59 @@ function defaultExtension(fileRef) {
9191 return extension ;
9292}
9393
94+ function defaultEncoding ( fileRef ) {
95+ var encoding = ENCODING_BY_FILETYPE [ fileRef . lastKnownFileType ] ;
9496
95- // dunno
96- return 'unknown' ;
97+ if ( encoding ) {
98+ return encoding ;
99+ }
97100}
98101
99- function fileEncoding ( file ) {
100- if ( file . lastType != BUNDLE && ! file . customFramework ) {
101- return DEFAULT_FILE_ENCODING ;
102+ function defaultGroup ( fileRef ) {
103+ var groupName = GROUP_BY_FILETYPE [ fileRef . lastKnownFileType ] ;
104+
105+ if ( ! groupName ) {
106+ return DEFAULT_GROUP ;
102107 }
108+
109+ return groupName ;
103110}
104111
105- function defaultSourceTree ( file ) {
106- if ( ( file . lastType == DYLIB || file . lastType == FRAMEWORK ) && ! file . customFramework ) {
107- return 'SDKROOT' ;
108- } else {
109- return DEFAULT_SOURCE_TREE ;
112+ function defaultSourcetree ( fileRef ) {
113+ var sourcetree = SOURCETREE_BY_FILETYPE [ fileRef . lastKnownFileType ] ;
114+
115+ if ( fileRef . customFramework ) {
116+ return filePath ;
117+ }
118+
119+ if ( fileRef . explicitFileType ) {
120+ return DEFAULT_PRODUCT_SOURCETREE ;
110121 }
122+
123+ return sourcetree ;
111124}
112125
113- function correctPath ( file , filepath ) {
114- if ( file . lastType == FRAMEWORK && ! file . customFramework ) {
115- return 'System/Library/Frameworks/' + filepath ;
116- } else if ( file . lastType == DYLIB ) {
117- return 'usr/lib/' + filepath ;
118- } else {
119- return filepath ;
126+ function defaultPath ( fileRef , filePath ) {
127+ var defaultPath = PATH_BY_FILETYPE [ fileRef . lastKnownFileType ] ;
128+
129+ if ( fileRef . customFramework ) {
130+ return filePath ;
131+ }
132+ if ( defaultPath ) {
133+ return path . join ( defaultPath , filePath ) ;
120134 }
135+
136+ return filePath ;
121137}
122138
123- function correctGroup ( file ) {
124- if ( file . lastType == SOURCE_FILE ) {
125- return 'Sources' ;
126- } else if ( file . lastType == DYLIB || file . lastType == ARCHIVE || file . lastType == FRAMEWORK ) {
127- return 'Frameworks' ;
128- } else {
129- return 'Resources' ;
139+ function defaultGroup ( fileRef ) {
140+ var groupName = GROUP_BY_FILETYPE [ fileRef . lastKnownFileType ] ;
141+
142+ if ( ! groupName ) {
143+ return DEFAULT_GROUP ;
130144 }
145+
146+ return defaultGroup ;
131147}
132148
133149function pbxFile ( filepath , opt ) {
@@ -136,9 +152,9 @@ function pbxFile(filepath, opt) {
136152 this . lastType = opt . lastType || detectLastType ( filepath ) ;
137153
138154 // for custom frameworks
139- if ( opt . customFramework == true ) {
140- this . customFramework = true ;
141- this . dirname = path . dirname ( filepath ) ;
155+ if ( opt . customFramework == true ) {
156+ this . customFramework = true ;
157+ this . dirname = path . dirname ( filepath ) ;
142158 }
143159
144160 this . basename = path . basename ( filepath ) ;
@@ -149,12 +165,12 @@ function pbxFile(filepath, opt) {
149165 this . fileEncoding = opt . fileEncoding || fileEncoding ( this ) ;
150166
151167 if ( opt . weak && opt . weak === true )
152- this . settings = { ATTRIBUTES : [ 'Weak' ] } ;
168+ this . settings = { ATTRIBUTES : [ 'Weak' ] } ;
153169
154170 if ( opt . compilerFlags ) {
155171 if ( ! this . settings )
156- this . settings = { } ;
157- this . settings . COMPILER_FLAGS = util . format ( '"%s"' , opt . compilerFlags ) ;
172+ this . settings = { } ;
173+ this . settings . COMPILER_FLAGS = util . format ( '"%s"' , opt . compilerFlags ) ;
158174 }
159175}
160176
0 commit comments