Skip to content

fix: Add C++ Source files to the Sources group … #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions lib/pbxFile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var $path = require('path'),
util = require('util'),
HEADER_FILE_TYPE_SUFFIX = ".h",
SOURCE_CODE_FILE_TYPE_PREFIX = "sourcecode.",
M_EXTENSION = /[.]m$/, SOURCE_FILE = 'sourcecode.c.objc',
C_EXTENSION = /[.]c$/, C_SOURCE_FILE = 'sourcecode.c',
H_EXTENSION = /[.]h$/, HEADER_FILE = 'sourcecode.c.h',
Expand Down Expand Up @@ -32,6 +34,14 @@ function fileTypes() {
}
}

function isSourceOrHeaderFileType(fileType) {
return fileType.startsWith(SOURCE_CODE_FILE_TYPE_PREFIX);
}

function isHeaderFileType(fileType) {
return fileType.endsWith(HEADER_FILE_TYPE_SUFFIX);
}

function detectLastType(path) {
if (M_EXTENSION.test(path))
return SOURCE_FILE;
Expand Down Expand Up @@ -65,10 +75,10 @@ function detectLastType(path) {

if (ARCHIVE_EXTENSION.test(path))
return ARCHIVE;

if (PNG_EXTENSION.test(path))
return PNG_IMAGE;

// dunno
return 'unknown';
}
Expand Down Expand Up @@ -98,7 +108,7 @@ function correctPath(file, filepath) {
}

function correctGroup(file) {
if (file.lastType == SOURCE_FILE) {
if (isSourceOrHeaderFileType(file.lastType) && !isHeaderFileType(file.lastType)) {
return 'Sources';
} else if (file.lastType == DYLIB || file.lastType == ARCHIVE || file.lastType == FRAMEWORK) {
return 'Frameworks';
Expand Down Expand Up @@ -137,5 +147,7 @@ function pbxFile(filepath, opt) {

module.exports = {
pbxFile: pbxFile,
fileTypes: fileTypes
fileTypes: fileTypes,
isSourceOrHeaderFileType,
isHeaderFileType,
}
Loading