Skip to content

Commit 733e10a

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 733e10a

File tree

2 files changed

+80
-58
lines changed

2 files changed

+80
-58
lines changed

lib/pbxFile.js

+31-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
var $path = require('path'),
22
util = require('util'),
33
M_EXTENSION = /[.]m$/, SOURCE_FILE = 'sourcecode.c.objc',
4+
C_EXTENSION = /[.]c$/, C_SOURCE_FILE = 'sourcecode.c',
45
H_EXTENSION = /[.]h$/, HEADER_FILE = 'sourcecode.c.h',
6+
MM_EXTENSION = /[.]mm$/, MM_SOURCE_FILE = 'sourcecode.cpp.objcpp',
7+
HPP_EXTENSION = /[.](hpp|hxx|h\+\+|hh)$/, CPP_HEADER_FILE = 'sourcecode.cpp.h',
8+
CPP_EXTENSION = /[.](cpp|cxx|c\+\+|cc)$/, CPP_SOURCE_FILE = 'sourcecode.cpp.cpp',
59
BUNDLE_EXTENSION = /[.]bundle$/, BUNDLE = '"wrapper.plug-in"',
610
XIB_EXTENSION = /[.]xib$/, XIB_FILE = 'file.xib',
711
DYLIB_EXTENSION = /[.]dylib$/, DYLIB = '"compiled.mach-o.dylib"',
@@ -13,24 +17,40 @@ var $path = require('path'),
1317

1418
function fileTypes() {
1519
return {
16-
SOURCE_FILE: SOURCE_FILE,
17-
HEADER_FILE: HEADER_FILE,
18-
BUNDLE: BUNDLE,
19-
XIB_FILE: XIB_FILE,
20-
FRAMEWORK: FRAMEWORK,
21-
DYLIB: DYLIB,
22-
ARCHIVE: ARCHIVE,
23-
PNG_IMAGE: PNG_IMAGE
20+
SOURCE_FILE,
21+
C_SOURCE_FILE,
22+
HEADER_FILE,
23+
MM_SOURCE_FILE,
24+
CPP_HEADER_FILE,
25+
CPP_SOURCE_FILE,
26+
BUNDLE,
27+
XIB_FILE,
28+
FRAMEWORK,
29+
DYLIB,
30+
ARCHIVE,
31+
PNG_IMAGE,
2432
}
2533
}
2634

2735
function detectLastType(path) {
2836
if (M_EXTENSION.test(path))
2937
return SOURCE_FILE;
3038

39+
if (C_EXTENSION.test(path))
40+
return C_SOURCE_FILE;
41+
3142
if (H_EXTENSION.test(path))
3243
return HEADER_FILE;
3344

45+
if (MM_EXTENSION.test(path))
46+
return MM_SOURCE_FILE;
47+
48+
if (CPP_EXTENSION.test(path))
49+
return CPP_SOURCE_FILE;
50+
51+
if (HPP_EXTENSION.test(path))
52+
return CPP_HEADER_FILE;
53+
3454
if (BUNDLE_EXTENSION.test(path))
3555
return BUNDLE;
3656

@@ -45,10 +65,10 @@ function detectLastType(path) {
4565

4666
if (ARCHIVE_EXTENSION.test(path))
4767
return ARCHIVE;
48-
68+
4969
if (PNG_EXTENSION.test(path))
5070
return PNG_IMAGE;
51-
71+
5272
// dunno
5373
return 'unknown';
5474
}
@@ -105,7 +125,7 @@ function pbxFile(filepath, opt) {
105125
this.sourceTree = opt.sourceTree || defaultSourceTree(this);
106126
this.fileEncoding = opt.fileEncoding || fileEncoding(this);
107127

108-
if (opt.weak && opt.weak === true)
128+
if (opt.weak && opt.weak === true)
109129
this.settings = { ATTRIBUTES: ['Weak'] };
110130

111131
if (opt.compilerFlags) {

0 commit comments

Comments
 (0)