Skip to content

Commit a929177

Browse files
committed
feat: Support various C++ file extensions
* Objective C++ Source (.mm) * C++ Source (.cpp, .cxx, .c++, .cc) * C++ Header (.hpp, .hxx, .h++, .hh)
1 parent 23214db commit a929177

File tree

2 files changed

+64
-50
lines changed

2 files changed

+64
-50
lines changed

lib/pbxFile.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ var $path = require('path'),
22
util = require('util'),
33
M_EXTENSION = /[.]m$/, SOURCE_FILE = 'sourcecode.c.objc',
44
H_EXTENSION = /[.]h$/, HEADER_FILE = 'sourcecode.c.h',
5+
MM_EXTENSION = /[.]mm$/, MM_SOURCE_FILE = 'sourcecode.cpp.objcpp',
6+
HPP_EXTENSION = /[.](hpp|hxx|h\+\+|hh)$/, CPP_HEADER_FILE = 'sourcecode.cpp.h',
7+
CPP_EXTENSION = /[.](cpp|cxx|c\+\+|cc)$/, CPP_SOURCE_FILE = 'sourcecode.cpp.cpp',
58
BUNDLE_EXTENSION = /[.]bundle$/, BUNDLE = '"wrapper.plug-in"',
69
XIB_EXTENSION = /[.]xib$/, XIB_FILE = 'file.xib',
710
DYLIB_EXTENSION = /[.]dylib$/, DYLIB = '"compiled.mach-o.dylib"',
@@ -28,9 +31,18 @@ function detectLastType(path) {
2831
if (M_EXTENSION.test(path))
2932
return SOURCE_FILE;
3033

34+
if (MM_EXTENSION.test(path))
35+
return MM_SOURCE_FILE;
36+
3137
if (H_EXTENSION.test(path))
3238
return HEADER_FILE;
3339

40+
if (HPP_EXTENSION.test(path))
41+
return CPP_HEADER_FILE;
42+
43+
if (CPP_EXTENSION.test(path))
44+
return CPP_SOURCE_FILE;
45+
3446
if (BUNDLE_EXTENSION.test(path))
3547
return BUNDLE;
3648

@@ -45,10 +57,10 @@ function detectLastType(path) {
4557

4658
if (ARCHIVE_EXTENSION.test(path))
4759
return ARCHIVE;
48-
60+
4961
if (PNG_EXTENSION.test(path))
5062
return PNG_IMAGE;
51-
63+
5264
// dunno
5365
return 'unknown';
5466
}
@@ -105,7 +117,7 @@ function pbxFile(filepath, opt) {
105117
this.sourceTree = opt.sourceTree || defaultSourceTree(this);
106118
this.fileEncoding = opt.fileEncoding || fileEncoding(this);
107119

108-
if (opt.weak && opt.weak === true)
120+
if (opt.weak && opt.weak === true)
109121
this.settings = { ATTRIBUTES: ['Weak'] };
110122

111123
if (opt.compilerFlags) {

0 commit comments

Comments
 (0)