@@ -22,22 +22,35 @@ var DEFAULT_SOURCETREE = '"<group>"',
22
22
DEFAULT_PRODUCT_SOURCETREE = 'BUILT_PRODUCTS_DIR' ,
23
23
DEFAULT_FILEENCODING = 4 ,
24
24
DEFAULT_GROUP = 'Resources' ,
25
- DEFAULT_FILETYPE = 'unknown' ;
25
+ DEFAULT_FILETYPE = 'unknown' ,
26
+ HEADER_FILE_TYPE_SUFFIX = ".h" ,
27
+ SOURCE_CODE_FILE_TYPE_PREFIX = "sourcecode." ;
26
28
27
29
var FILETYPE_BY_EXTENSION = {
28
30
a : 'archive.ar' ,
29
31
app : 'wrapper.application' ,
30
32
appex : 'wrapper.app-extension' ,
31
33
bundle : 'wrapper.plug-in' ,
34
+ c : 'sourcecode.c.c' ,
35
+ cc : 'sourcecode.cpp.cpp' ,
36
+ cpp : 'sourcecode.cpp.cpp' ,
37
+ cxx : 'sourcecode.cpp.cpp' ,
38
+ 'c++' : 'sourcecode.cpp.cpp' ,
32
39
dylib : 'compiled.mach-o.dylib' ,
33
40
framework : 'wrapper.framework' ,
34
41
h : 'sourcecode.c.h' ,
42
+ hh : 'sourcecode.cpp.h' ,
43
+ hpp : 'sourcecode.cpp.h' ,
44
+ hxx : 'sourcecode.cpp.h' ,
45
+ 'h++' : 'sourcecode.cpp.h' ,
35
46
m : 'sourcecode.c.objc' ,
47
+ mm : 'sourcecode.cpp.objcpp' ,
36
48
markdown : 'text' ,
37
49
mdimporter : 'wrapper.cfbundle' ,
38
50
octest : 'wrapper.cfbundle' ,
39
51
pch : 'sourcecode.c.h' ,
40
52
plist : 'text.plist.xml' ,
53
+ png : "image.png" ,
41
54
sh : 'text.script.sh' ,
42
55
swift : 'sourcecode.swift' ,
43
56
tbd : 'sourcecode.text-based-dylib-definition' ,
@@ -56,8 +69,11 @@ var FILETYPE_BY_EXTENSION = {
56
69
'wrapper.framework' : 'Frameworks' ,
57
70
'embedded.framework' : 'Embed Frameworks' ,
58
71
'sourcecode.c.h' : 'Resources' ,
72
+ 'sourcecode.c.c' : 'Sources' ,
59
73
'sourcecode.c.objc' : 'Sources' ,
60
- 'sourcecode.swift' : 'Sources'
74
+ 'sourcecode.swift' : 'Sources' ,
75
+ 'sourcecode.cpp.cpp' : 'Sources' ,
76
+ 'sourcecode.cpp.objcpp' : 'Sources'
61
77
} ,
62
78
PATH_BY_FILETYPE = {
63
79
'compiled.mach-o.dylib' : 'usr/lib/' ,
@@ -72,7 +88,11 @@ var FILETYPE_BY_EXTENSION = {
72
88
ENCODING_BY_FILETYPE = {
73
89
'sourcecode.c.h' : 4 ,
74
90
'sourcecode.c.h' : 4 ,
91
+ 'sourcecode.cpp.h' : 4 ,
92
+ 'sourcecode.c.c' : 4 ,
75
93
'sourcecode.c.objc' : 4 ,
94
+ 'sourcecode.cpp.cpp' : 4 ,
95
+ 'sourcecode.cpp.objcpp' : 4 ,
76
96
'sourcecode.swift' : 4 ,
77
97
'text' : 4 ,
78
98
'text.plist.xml' : 4 ,
@@ -81,6 +101,13 @@ var FILETYPE_BY_EXTENSION = {
81
101
'text.plist.strings' : 4
82
102
} ;
83
103
104
+ function isSourceOrHeaderFileType ( fileType ) {
105
+ return fileType . startsWith ( SOURCE_CODE_FILE_TYPE_PREFIX ) ;
106
+ }
107
+
108
+ function isHeaderFileType ( fileType ) {
109
+ return fileType . endsWith ( HEADER_FILE_TYPE_SUFFIX ) ;
110
+ }
84
111
85
112
function unquoted ( text ) {
86
113
return text == null ? '' : text . replace ( / ( ^ " ) | ( " $ ) / g, '' )
@@ -186,7 +213,7 @@ function defaultGroup(fileRef) {
186
213
function pbxFile ( filepath , opt ) {
187
214
var opt = opt || { } ;
188
215
189
- this . basename = path . basename ( filepath ) ;
216
+ this . basename = opt . basename || path . basename ( filepath ) ;
190
217
this . lastKnownFileType = opt . lastKnownFileType || detectType ( filepath ) ;
191
218
this . group = detectGroup ( this , opt ) ;
192
219
@@ -230,4 +257,8 @@ function pbxFile(filepath, opt) {
230
257
}
231
258
}
232
259
233
- module . exports = pbxFile ;
260
+ module . exports = {
261
+ pbxFile : pbxFile ,
262
+ isSourceOrHeaderFileType,
263
+ isHeaderFileType
264
+ }
0 commit comments