This commit is contained in:
Yamozha
2021-04-02 02:24:13 +03:00
parent c23950b545
commit 7256d79e2c
31493 changed files with 3036630 additions and 0 deletions

32
node_modules/xcode/lib/parseJob.js generated vendored Normal file
View File

@ -0,0 +1,32 @@
/**
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
'License'); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
// parsing is slow and blocking right now
// so we do it in a separate process
var fs = require('fs'),
parser = require('./parser/pbxproj'),
path = process.argv[2],
fileContents, obj;
try {
fileContents = fs.readFileSync(path, 'utf-8');
obj = parser.parse(fileContents);
process.send(obj);
} catch (e) {
process.send(e);
process.exitCode = 1;
}

1904
node_modules/xcode/lib/parser/pbxproj.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

280
node_modules/xcode/lib/parser/pbxproj.pegjs generated vendored Normal file
View File

@ -0,0 +1,280 @@
/**
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
'License'); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
{
function merge_obj(obj, secondObj) {
if (!obj)
return secondObj;
for(var i in secondObj)
obj[i] = merge_obj(obj[i], secondObj[i]);
return obj;
}
}
/*
* Project: point of entry from pbxproj file
*/
Project
= headComment:SingleLineComment? InlineComment? _ obj:Object NewLine _
{
var proj = Object.create(null)
proj.project = obj
if (headComment) {
proj.headComment = headComment
}
return proj;
}
/*
* Object: basic hash data structure with Assignments
*/
Object
= "{" obj:(AssignmentList / EmptyBody) "}"
{ return obj }
EmptyBody
= _
{ return Object.create(null) }
AssignmentList
= _ list:((a:Assignment / d:DelimitedSection) _)+
{
var returnObject = list[0][0];
for(var i = 1; i < list.length; i++){
var another = list[i][0];
returnObject = merge_obj(returnObject, another);
}
return returnObject;
}
/*
* Assignments
* can be simple "key = value"
* or commented "key /* real key * / = value"
*/
Assignment
= SimpleAssignment / CommentedAssignment
SimpleAssignment
= id:Identifier _ "=" _ val:Value ";"
{
var result = Object.create(null);
result[id] = val
return result
}
CommentedAssignment
= commentedId:CommentedIdentifier _ "=" _ val:Value ";"
{
var result = Object.create(null),
commentKey = commentedId.id + '_comment';
result[commentedId.id] = val;
result[commentKey] = commentedId[commentKey];
return result;
}
/
id:Identifier _ "=" _ commentedVal:CommentedValue ";"
{
var result = Object.create(null);
result[id] = commentedVal.value;
result[id + "_comment"] = commentedVal.comment;
return result;
}
CommentedIdentifier
= id:Identifier _ comment:InlineComment
{
var result = Object.create(null);
result.id = id;
result[id + "_comment"] = comment.trim();
return result
}
CommentedValue
= literal:Value _ comment:InlineComment
{
var result = Object.create(null)
result.comment = comment.trim();
result.value = literal.trim();
return result;
}
InlineComment
= InlineCommentOpen body:[^*]+ InlineCommentClose
{ return body.join('') }
InlineCommentOpen
= "/*"
InlineCommentClose
= "*/"
/*
* DelimitedSection - ad hoc project structure pbxproj files use
*/
DelimitedSection
= begin:DelimitedSectionBegin _ fields:(AssignmentList / EmptyBody) _ DelimitedSectionEnd
{
var section = Object.create(null);
section[begin.name] = fields
return section
}
DelimitedSectionBegin
= "/* Begin " sectionName:Identifier " section */" NewLine
{ return { name: sectionName } }
DelimitedSectionEnd
= "/* End " sectionName:Identifier " section */" NewLine
{ return { name: sectionName } }
/*
* Arrays: lists of values, possible wth comments
*/
Array
= "(" arr:(ArrayBody / EmptyArray ) ")" { return arr }
EmptyArray
= _ { return [] }
ArrayBody
= _ head:ArrayEntry _ tail:ArrayBody? _
{
if (tail) {
tail.unshift(head);
return tail;
} else {
return [head];
}
}
ArrayEntry
= SimpleArrayEntry / CommentedArrayEntry
SimpleArrayEntry
= val:Value EndArrayEntry { return val }
CommentedArrayEntry
= val:Value _ comment:InlineComment EndArrayEntry
{
var result = Object.create(null);
result.value = val.trim();
result.comment = comment.trim();
return result;
}
EndArrayEntry
= "," / _ &")"
/*
* Identifiers and Values
*/
Identifier
= id:[A-Za-z0-9_.]+ { return id.join('') }
/ QuotedString
Value
= Object / Array / NumberValue / StringValue
NumberValue
= DecimalValue / IntegerValue
DecimalValue
= decimal:(IntegerValue "." IntegerValue)
{
// store decimals as strings
// as JS doesn't differentiate bw strings and numbers
return decimal.join('')
}
IntegerValue
= !Alpha number:Digit+ !NonTerminator
{ return parseInt(number.join(''), 10) }
StringValue
= QuotedString / LiteralString
QuotedString
= DoubleQuote str:QuotedBody DoubleQuote { return '"' + str + '"' }
QuotedBody
= str:NonQuote+ { return str.join('') }
NonQuote
= EscapedQuote / !DoubleQuote char:. { return char }
EscapedQuote
= "\\" DoubleQuote { return '\\"' }
LiteralString
= literal:LiteralChar+ { return literal.join('') }
LiteralChar
= !InlineCommentOpen !LineTerminator char:NonTerminator
{ return char }
NonTerminator
= [^;,\n]
/*
* SingleLineComment - used for the encoding comment
*/
SingleLineComment
= "//" _ contents:OneLineString NewLine
{ return contents }
OneLineString
= contents:NonLine*
{ return contents.join('') }
/*
* Simple character checking rules
*/
Digit
= [0-9]
Alpha
= [A-Za-z]
DoubleQuote
= '"'
_ "whitespace"
= whitespace*
whitespace
= NewLine / [\t ]
NonLine
= !NewLine char:Char
{ return char }
LineTerminator
= NewLine / ";"
NewLine
= [\n\r]
Char
= .

233
node_modules/xcode/lib/pbxFile.js generated vendored Normal file
View File

@ -0,0 +1,233 @@
/**
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
'License'); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
var path = require('path'),
util = require('util');
var DEFAULT_SOURCETREE = '"<group>"',
DEFAULT_PRODUCT_SOURCETREE = 'BUILT_PRODUCTS_DIR',
DEFAULT_FILEENCODING = 4,
DEFAULT_GROUP = 'Resources',
DEFAULT_FILETYPE = 'unknown';
var FILETYPE_BY_EXTENSION = {
a: 'archive.ar',
app: 'wrapper.application',
appex: 'wrapper.app-extension',
bundle: 'wrapper.plug-in',
dylib: 'compiled.mach-o.dylib',
framework: 'wrapper.framework',
h: 'sourcecode.c.h',
m: 'sourcecode.c.objc',
markdown: 'text',
mdimporter: 'wrapper.cfbundle',
octest: 'wrapper.cfbundle',
pch: 'sourcecode.c.h',
plist: 'text.plist.xml',
sh: 'text.script.sh',
swift: 'sourcecode.swift',
tbd: 'sourcecode.text-based-dylib-definition',
xcassets: 'folder.assetcatalog',
xcconfig: 'text.xcconfig',
xcdatamodel: 'wrapper.xcdatamodel',
xcodeproj: 'wrapper.pb-project',
xctest: 'wrapper.cfbundle',
xib: 'file.xib',
strings: 'text.plist.strings'
},
GROUP_BY_FILETYPE = {
'archive.ar': 'Frameworks',
'compiled.mach-o.dylib': 'Frameworks',
'sourcecode.text-based-dylib-definition': 'Frameworks',
'wrapper.framework': 'Frameworks',
'embedded.framework': 'Embed Frameworks',
'sourcecode.c.h': 'Resources',
'sourcecode.c.objc': 'Sources',
'sourcecode.swift': 'Sources'
},
PATH_BY_FILETYPE = {
'compiled.mach-o.dylib': 'usr/lib/',
'sourcecode.text-based-dylib-definition': 'usr/lib/',
'wrapper.framework': 'System/Library/Frameworks/'
},
SOURCETREE_BY_FILETYPE = {
'compiled.mach-o.dylib': 'SDKROOT',
'sourcecode.text-based-dylib-definition': 'SDKROOT',
'wrapper.framework': 'SDKROOT'
},
ENCODING_BY_FILETYPE = {
'sourcecode.c.h': 4,
'sourcecode.c.h': 4,
'sourcecode.c.objc': 4,
'sourcecode.swift': 4,
'text': 4,
'text.plist.xml': 4,
'text.script.sh': 4,
'text.xcconfig': 4,
'text.plist.strings': 4
};
function unquoted(text){
return text == null ? '' : text.replace (/(^")|("$)/g, '')
}
function detectType(filePath) {
var extension = path.extname(filePath).substring(1),
filetype = FILETYPE_BY_EXTENSION[unquoted(extension)];
if (!filetype) {
return DEFAULT_FILETYPE;
}
return filetype;
}
function defaultExtension(fileRef) {
var filetype = fileRef.lastKnownFileType && fileRef.lastKnownFileType != DEFAULT_FILETYPE ?
fileRef.lastKnownFileType : fileRef.explicitFileType;
for(var extension in FILETYPE_BY_EXTENSION) {
if(FILETYPE_BY_EXTENSION.hasOwnProperty(unquoted(extension)) ) {
if(FILETYPE_BY_EXTENSION[unquoted(extension)] === unquoted(filetype) )
return extension;
}
}
}
function defaultEncoding(fileRef) {
var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType,
encoding = ENCODING_BY_FILETYPE[unquoted(filetype)];
if (encoding) {
return encoding;
}
}
function detectGroup(fileRef, opt) {
var extension = path.extname(fileRef.basename).substring(1),
filetype = fileRef.lastKnownFileType || fileRef.explicitFileType,
groupName = GROUP_BY_FILETYPE[unquoted(filetype)];
if (extension === 'xcdatamodeld') {
return 'Sources';
}
if (opt.customFramework && opt.embed) {
return GROUP_BY_FILETYPE['embedded.framework'];
}
if (!groupName) {
return DEFAULT_GROUP;
}
return groupName;
}
function detectSourcetree(fileRef) {
var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType,
sourcetree = SOURCETREE_BY_FILETYPE[unquoted(filetype)];
if (fileRef.explicitFileType) {
return DEFAULT_PRODUCT_SOURCETREE;
}
if (fileRef.customFramework) {
return DEFAULT_SOURCETREE;
}
if (!sourcetree) {
return DEFAULT_SOURCETREE;
}
return sourcetree;
}
function defaultPath(fileRef, filePath) {
var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType,
defaultPath = PATH_BY_FILETYPE[unquoted(filetype)];
if (fileRef.customFramework) {
return filePath;
}
if (defaultPath) {
return path.join(defaultPath, path.basename(filePath));
}
return filePath;
}
function defaultGroup(fileRef) {
var groupName = GROUP_BY_FILETYPE[fileRef.lastKnownFileType];
if (!groupName) {
return DEFAULT_GROUP;
}
return defaultGroup;
}
function pbxFile(filepath, opt) {
var opt = opt || {};
this.basename = path.basename(filepath);
this.lastKnownFileType = opt.lastKnownFileType || detectType(filepath);
this.group = detectGroup(this, opt);
// for custom frameworks
if (opt.customFramework == true) {
this.customFramework = true;
this.dirname = path.dirname(filepath).replace(/\\/g, '/');
}
this.path = defaultPath(this, filepath).replace(/\\/g, '/');
this.fileEncoding = this.defaultEncoding = opt.defaultEncoding || defaultEncoding(this);
// When referencing products / build output files
if (opt.explicitFileType) {
this.explicitFileType = opt.explicitFileType;
this.basename = this.basename + '.' + defaultExtension(this);
delete this.path;
delete this.lastKnownFileType;
delete this.group;
delete this.defaultEncoding;
}
this.sourceTree = opt.sourceTree || detectSourcetree(this);
this.includeInIndex = 0;
if (opt.weak && opt.weak === true)
this.settings = { ATTRIBUTES: ['Weak'] };
if (opt.compilerFlags) {
if (!this.settings)
this.settings = {};
this.settings.COMPILER_FLAGS = util.format('"%s"', opt.compilerFlags);
}
if (opt.embed && opt.sign) {
if (!this.settings)
this.settings = {};
if (!this.settings.ATTRIBUTES)
this.settings.ATTRIBUTES = [];
this.settings.ATTRIBUTES.push('CodeSignOnCopy');
}
}
module.exports = pbxFile;

2201
node_modules/xcode/lib/pbxProject.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

309
node_modules/xcode/lib/pbxWriter.js generated vendored Normal file
View File

@ -0,0 +1,309 @@
/**
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
'License'); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
var pbxProj = require('./pbxProject'),
util = require('util'),
f = util.format,
INDENT = '\t',
COMMENT_KEY = /_comment$/,
QUOTED = /^"(.*)"$/,
EventEmitter = require('events').EventEmitter
// indentation
function i(x) {
if (x <=0)
return '';
else
return INDENT + i(x-1);
}
function comment(key, parent) {
var text = parent[key + '_comment'];
if (text)
return text;
else
return null;
}
// copied from underscore
function isObject(obj) {
return obj === Object(obj)
}
function isArray(obj) {
return Array.isArray(obj)
}
function pbxWriter(contents, options) {
if (!options) {
options = {}
}
if (options.omitEmptyValues === undefined) {
options.omitEmptyValues = false
}
this.contents = contents;
this.sync = false;
this.indentLevel = 0;
this.omitEmptyValues = options.omitEmptyValues
}
util.inherits(pbxWriter, EventEmitter);
pbxWriter.prototype.write = function (str) {
var fmt = f.apply(null, arguments);
if (this.sync) {
this.buffer += f("%s%s", i(this.indentLevel), fmt);
} else {
// do stream write
}
}
pbxWriter.prototype.writeFlush = function (str) {
var oldIndent = this.indentLevel;
this.indentLevel = 0;
this.write.apply(this, arguments)
this.indentLevel = oldIndent;
}
pbxWriter.prototype.writeSync = function () {
this.sync = true;
this.buffer = "";
this.writeHeadComment();
this.writeProject();
return this.buffer;
}
pbxWriter.prototype.writeHeadComment = function () {
if (this.contents.headComment) {
this.write("// %s\n", this.contents.headComment)
}
}
pbxWriter.prototype.writeProject = function () {
var proj = this.contents.project,
key, cmt, obj;
this.write("{\n")
if (proj) {
this.indentLevel++;
for (key in proj) {
// skip comments
if (COMMENT_KEY.test(key)) continue;
cmt = comment(key, proj);
obj = proj[key];
if (isArray(obj)) {
this.writeArray(obj, key)
} else if (isObject(obj)) {
this.write("%s = {\n", key);
this.indentLevel++;
if (key === 'objects') {
this.writeObjectsSections(obj)
} else {
this.writeObject(obj)
}
this.indentLevel--;
this.write("};\n");
} else if (this.omitEmptyValues && (obj === undefined || obj === null)) {
continue;
} else if (cmt) {
this.write("%s = %s /* %s */;\n", key, obj, cmt)
} else {
this.write("%s = %s;\n", key, obj)
}
}
this.indentLevel--;
}
this.write("}\n")
}
pbxWriter.prototype.writeObject = function (object) {
var key, obj, cmt;
for (key in object) {
if (COMMENT_KEY.test(key)) continue;
cmt = comment(key, object);
obj = object[key];
if (isArray(obj)) {
this.writeArray(obj, key)
} else if (isObject(obj)) {
this.write("%s = {\n", key);
this.indentLevel++;
this.writeObject(obj)
this.indentLevel--;
this.write("};\n");
} else {
if (this.omitEmptyValues && (obj === undefined || obj === null)) {
continue;
} else if (cmt) {
this.write("%s = %s /* %s */;\n", key, obj, cmt)
} else {
this.write("%s = %s;\n", key, obj)
}
}
}
}
pbxWriter.prototype.writeObjectsSections = function (objects) {
var key, obj;
for (key in objects) {
this.writeFlush("\n")
obj = objects[key];
if (isObject(obj)) {
this.writeSectionComment(key, true);
this.writeSection(obj);
this.writeSectionComment(key, false);
}
}
}
pbxWriter.prototype.writeArray = function (arr, name) {
var i, entry;
this.write("%s = (\n", name);
this.indentLevel++;
for (i=0; i < arr.length; i++) {
entry = arr[i]
if (entry.value && entry.comment) {
this.write('%s /* %s */,\n', entry.value, entry.comment);
} else if (isObject(entry)) {
this.write('{\n');
this.indentLevel++;
this.writeObject(entry);
this.indentLevel--;
this.write('},\n');
} else {
this.write('%s,\n', entry);
}
}
this.indentLevel--;
this.write(");\n");
}
pbxWriter.prototype.writeSectionComment = function (name, begin) {
if (begin) {
this.writeFlush("/* Begin %s section */\n", name)
} else { // end
this.writeFlush("/* End %s section */\n", name)
}
}
pbxWriter.prototype.writeSection = function (section) {
var key, obj, cmt;
// section should only contain objects
for (key in section) {
if (COMMENT_KEY.test(key)) continue;
cmt = comment(key, section);
obj = section[key]
if (obj.isa == 'PBXBuildFile' || obj.isa == 'PBXFileReference') {
this.writeInlineObject(key, cmt, obj);
} else {
if (cmt) {
this.write("%s /* %s */ = {\n", key, cmt);
} else {
this.write("%s = {\n", key);
}
this.indentLevel++
this.writeObject(obj)
this.indentLevel--
this.write("};\n");
}
}
}
pbxWriter.prototype.writeInlineObject = function (n, d, r) {
var output = [];
var self = this
var inlineObjectHelper = function (name, desc, ref) {
var key, cmt, obj;
if (desc) {
output.push(f("%s /* %s */ = {", name, desc));
} else {
output.push(f("%s = {", name));
}
for (key in ref) {
if (COMMENT_KEY.test(key)) continue;
cmt = comment(key, ref);
obj = ref[key];
if (isArray(obj)) {
output.push(f("%s = (", key));
for (var i=0; i < obj.length; i++) {
output.push(f("%s, ", obj[i]))
}
output.push("); ");
} else if (isObject(obj)) {
inlineObjectHelper(key, cmt, obj)
} else if (self.omitEmptyValues && (obj === undefined || obj === null)) {
continue;
} else if (cmt) {
output.push(f("%s = %s /* %s */; ", key, obj, cmt))
} else {
output.push(f("%s = %s; ", key, obj))
}
}
output.push("}; ");
}
inlineObjectHelper(n, d, r);
this.write("%s\n", output.join('').trim());
}
module.exports = pbxWriter;