Created
July 30, 2016 19:41
-
-
Save Constellation/8b39602f5504abb02d17cb146a5a2d78 to your computer and use it in GitHub Desktop.
xcode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Copyright (C) 2016 Yusuke Suzuki <utatane.tea@gmail.com> | |
| Redistribution and use in source and binary forms, with or without | |
| modification, are permitted provided that the following conditions are met: | |
| * Redistributions of source code must retain the above copyright | |
| notice, this list of conditions and the following disclaimer. | |
| * Redistributions in binary form must reproduce the above copyright | |
| notice, this list of conditions and the following disclaimer in the | |
| documentation and/or other materials provided with the distribution. | |
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY | |
| DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
| ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
| THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| */ | |
| // API is a bit wonky right now | |
| var xcode = require('xcode'), | |
| fs = require('fs'), | |
| util = require('util'); | |
| var projectPath = 'JavaScriptCore.xcodeproj/project.pbxproj'; | |
| var project = xcode.project(projectPath); | |
| function longComment(file) { | |
| return util.format("%s in %s", file.basename, file.group); | |
| } | |
| function pbxBuildPhaseObj(file) { | |
| var obj = Object.create(null); | |
| obj.value = file.uuid; | |
| obj.comment = longComment(file); | |
| return obj; | |
| } | |
| xcode.project.prototype.pbxHeadersBuildPhaseObj = function(target) { | |
| return this.buildPhaseObject('PBXHeadersBuildPhase', 'Headers', target); | |
| }; | |
| xcode.project.prototype.addToPbxHeadersBuildPhase = function(file) { | |
| var sources = this.pbxHeadersBuildPhaseObj(file.target); | |
| sources.files.push(pbxBuildPhaseObj(file)); | |
| }; | |
| // parsing is async, in a different process | |
| project.parse(function (err) { | |
| var group = project.pbxGroupByName('parser'); | |
| var groupKey = project.findPBXGroupKey({ path: 'parser' }); | |
| var target = project.pbxTargetByName('JavaScriptCore'); | |
| var targetKey = project.findTargetKey('JavaScriptCore'); | |
| var file = project.addHeaderFile('parser/ModuleScopeData.h', { | |
| target: targetKey | |
| }, groupKey); | |
| file.settings = { | |
| ATTRIBUTES: [ 'Private' ] | |
| }; | |
| file.group = 'Headers'; | |
| console.log(file); | |
| file.target = targetKey; | |
| file.uuid = project.generateUuid(); | |
| project.addToPbxBuildFileSection(file); | |
| project.addToPbxHeadersBuildPhase(file); | |
| fs.writeFileSync(projectPath, project.writeSync()); | |
| console.log('new project written'); | |
| }); | |
| /* vim: set sw=4 ts=4 et tw=80 : */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment