CB-10085 Implement and expose PlatformApi for OS X
Project: http://git-wip-us.apache.org/repos/asf/cordova-osx/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-osx/commit/2803ddce Tree: http://git-wip-us.apache.org/repos/asf/cordova-osx/tree/2803ddce Diff: http://git-wip-us.apache.org/repos/asf/cordova-osx/diff/2803ddce Branch: refs/heads/master Commit: 2803ddceee4df7324d1af035cd5a79426273d20d Parents: 4f8d066 Author: Tobias Bocanegra <[email protected]> Authored: Tue Dec 15 13:01:06 2015 -0800 Committer: Tobias Bocanegra <[email protected]> Committed: Tue Dec 15 13:01:06 2015 -0800 ---------------------------------------------------------------------- bin/autotest | 22 -- bin/cordova_plist_to_config_xml | 127 ----------- bin/diagnose_project | 217 ------------------- .../__PROJECT_NAME__-Info.plist | 2 - bin/tests/autotest.coffee | 24 -- bin/tests/create.coffee | 34 --- bin/tests/debug.coffee | 18 -- bin/tests/test.coffee | 18 -- bin/tests_old | 27 --- 9 files changed, 489 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/2803ddce/bin/autotest ---------------------------------------------------------------------- diff --git a/bin/autotest b/bin/autotest deleted file mode 100755 index 9d039ff..0000000 --- a/bin/autotest +++ /dev/null @@ -1,22 +0,0 @@ -#! /usr/bin/env node - -/* - 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. - */ - -require('nodeunit').reporters.default.run(['bin/tests']); http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/2803ddce/bin/cordova_plist_to_config_xml ---------------------------------------------------------------------- diff --git a/bin/cordova_plist_to_config_xml b/bin/cordova_plist_to_config_xml deleted file mode 100755 index e781c63..0000000 --- a/bin/cordova_plist_to_config_xml +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/python -# -# 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. -# -""" -Converts a project's Cordova.plist file into a config.xml one. This conversion is required for Cordova 2.3. - -Usage: - plist2xml.py path/to/project -""" - -import StringIO -import fileinput -import plistlib -import os -import re -import sys -from xml.dom import minidom -from xml.etree import ElementTree - - -def Usage(): - sys.stderr.write(__doc__) - sys.exit(1) - - -def ValueToElement(node_name, key, value): - if isinstance(value, bool): - value = str(value).lower() - return ElementTree.Element(node_name, attrib={'name':key, 'value':str(value)}) - - -def AppendDict(d, node, name, ignore=()): - for key in sorted(d): - if key not in ignore: - node.append(ValueToElement(name, key, d[key])) - - -def FindProjectFile(path): - # Do an extra abspath here to strip off trailing / if present. - path = os.path.abspath(path) - if path.endswith('.pbxproj'): - return path - elif path.endswith('.xcodeproj'): - return os.path.join(path, 'project.pbxproj') - for f in os.listdir(path): - if f.endswith('.xcodeproj'): - return os.path.join(path, f, 'project.pbxproj') - raise Exception('Invalid project path. Please provide the path to your .xcodeproj directory') - - -def FindPlistFile(search_path): - for root, unused_dirnames, file_names in os.walk(search_path): - for file_name in file_names: - if file_name == 'Cordova.plist': - return os.path.join(root, file_name) - raise Exception('Could not find a file named "Cordova.plist" within ' + search_path) - - -def ConvertPlist(src_path, dst_path): - # Run it through plutil to ensure it's not a binary plist. - os.system("plutil -convert xml1 '%s'" % src_path) - plist = plistlib.readPlist(src_path) - root = ElementTree.Element('cordova') - - AppendDict(plist, root, 'preference', ignore=('Plugins', 'ExternalHosts')) - - plugins = ElementTree.Element('plugins') - root.append(plugins) - AppendDict(plist['Plugins'], plugins, 'plugin') - - for value in sorted(plist['ExternalHosts']): - root.append(ElementTree.Element('access', attrib={'origin':value})) - - tree = ElementTree.ElementTree(root) - s = StringIO.StringIO() - tree.write(s, encoding='UTF-8') - mini_dom = minidom.parseString(s.getvalue()) - with open(dst_path, 'w') as out: - out.write(mini_dom.toprettyxml(encoding='UTF-8')) - - -def UpdateProjectFile(path): - file_handle = fileinput.input(path, inplace=1) - for line in file_handle: - if 'Cordova.plist' in line: - line = line.replace('Cordova.plist', 'config.xml') - line = line.replace('lastKnownFileType = text.plist.xml', 'lastKnownFileType = text.xml') - print line, - file_handle.close() - - -def main(argv): - if len(argv) != 1: - Usage(); - - project_file = FindProjectFile(argv[0]) - plist_file = FindPlistFile(os.path.dirname(os.path.dirname(project_file))) - - config_file = os.path.join(os.path.dirname(plist_file), 'config.xml') - sys.stdout.write('Converting %s to %s.\n' % (plist_file, config_file)) - ConvertPlist(plist_file, config_file) - - sys.stdout.write('Updating references in %s\n' % project_file) - UpdateProjectFile(project_file) - - os.unlink(plist_file) - sys.stdout.write('Updates Complete.\n') - - -if __name__ == '__main__': - main(sys.argv[1:]) http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/2803ddce/bin/diagnose_project ---------------------------------------------------------------------- diff --git a/bin/diagnose_project b/bin/diagnose_project deleted file mode 100755 index 1879fe1..0000000 --- a/bin/diagnose_project +++ /dev/null @@ -1,217 +0,0 @@ -#!/usr/bin/python -""" -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. -""" -""" -Prints out information regarding a Cordova project for diagnostic purposes. -Currently this only reports information but does not give any recommendations yet. - -Usage: CordovaVersion/bin/diagnose_project path/to/your/app.xcodeproj -""" - -import os -import sys -import plistlib -import shutil -import tempfile -import pprint - -def Usage(): - print __doc__ - sys.exit(1) - -def AbsParentPath(path): - return os.path.abspath(os.path.join(path, os.path.pardir)) - -def AbsProjectPath(relative_path): - # Do an extra abspath here to strip off trailing / if present. - project_path = os.path.abspath(relative_path) - if project_path.endswith('.pbxproj'): - project_path = AbsParentPath(project_path) - elif project_path.endswith('.xcodeproj'): - pass - else: - raise Exception('The following is not a valid path to an XCode project: %s' % project_path) - return project_path - -def getXcodePlist(pbxPath): - tmpfile = tempfile.mktemp (".xml") - os.system("plutil -convert xml1 -o %s %s" % (tmpfile, pbxPath)) - - return plistlib.readPlist( tmpfile ) - -def getTargetBuildSettings(diagKeys, xcodePlist): - allObjects = xcodePlist['objects'] - rootObj = allObjects[ xcodePlist['rootObject'] ] - - buildSettings = {}; - - targetguids = rootObj['targets'] - for targetguid in targetguids: - target = allObjects[ targetguid ] - targetname = target['name'] - targetSettings = {} - bclist = allObjects[ target['buildConfigurationList'] ]['buildConfigurations'] - for conflist in bclist: - cl = allObjects[conflist]; - clname = cl.get("name", 'no name') - targetSettings[clname] = {} - for key in diagKeys: - val = cl['buildSettings'].get(key, '(not found)') - targetSettings[clname][key] = val - buildSettings[targetname] = targetSettings - - return buildSettings - -def getProjectBuildSettings(diagKeys, xcodePlist): - allObjects = xcodePlist['objects'] - rootObj = allObjects[ xcodePlist['rootObject'] ] - - buildSettings = {}; - - bclist = allObjects[ rootObj['buildConfigurationList'] ]['buildConfigurations'] - for conflist in bclist: - cl = allObjects[conflist]; - clname = cl.get("name", 'no name') - buildSettings[clname] = {} - for key in diagKeys: - val = cl['buildSettings'].get(key, '(not found)') - buildSettings[clname][key] = val - - return buildSettings - -def getXcodeBuildSettings(diagKeys, xcodePlist): - projectSettings = getProjectBuildSettings(diagKeys, xcodePlist) - targetSettings = getTargetBuildSettings(diagKeys, xcodePlist) - - settings = {} - settings['Project'] = projectSettings - settings['Targets'] = targetSettings - - return settings - -def main(argv): - if len(argv) != 2: - Usage() - - project_path = AbsProjectPath(argv[1]) - parent_project_path = AbsParentPath(project_path) - - projPbx = os.path.join(project_path, 'project.pbxproj') - - buildSettingsKeys = ['HEADER_SEARCH_PATHS', 'ARCHS', 'USER_HEADER_SEARCH_PATHS', 'IPHONEOS_DEPLOYMENT_TARGET', 'OTHER_LDFLAGS', 'GCC_VERSION'] - - projPlist = getXcodePlist(projPbx) - allObjects = projPlist['objects'] - rootObj = allObjects[ projPlist['rootObject'] ] - - print "\n\n-------------------------------------BEGIN--------------------------------------" - print "Inspecting project: %s" % (projPbx) - - print "\n\n--------------------------------------------------------------------------------" - print "Finding your project's sub-projects...\n" - - subprojKeys = ['name', 'path', 'sourceTree'] - subprojValues = [] - - subprojRef = rootObj['projectReferences'] - for subproj in subprojRef: - sp = {} - subprojGroup = allObjects[ subproj['ProjectRef'] ] - for key in subprojKeys: - val = subprojGroup.get(key, "(not found)") - sp[key] = val; - print "Sub-project:", sp - subprojValues.append(sp) - - - print "\n\n--------------------------------------------------------------------------------" - print "Inspecting your project's Build Settings...\n" - - buildSettings = getXcodeBuildSettings(buildSettingsKeys, projPlist) - pp = pprint.PrettyPrinter(indent=4) - - for key in buildSettings: - print key, ":" - pp.pprint(buildSettings[key]) - - print "\n\n--------------------------------------------------------------------------------" - print "Inspecting Xcode Preferences...\n" - - xcodeBinaryPrefsPath = os.path.join( os.path.expanduser("~"), "Library", "Preferences", "com.apple.dt.Xcode.plist" ); - xcodePrefsPlist = getXcodePlist(xcodeBinaryPrefsPath) - - ideSetting = xcodePrefsPlist.get('IDEApplicationwideBuildSettings', {}) - xcodeCordovaLib = ideSetting.get("CORDOVALIB", "(not found)") - print "CORDOVALIB:", xcodeCordovaLib - print "Build Location Style:", xcodePrefsPlist.get('IDEBuildLocationStyle', "(unknown)") - - print "\n\n--------------------------------------------------------------------------------" - print "Inspecting your CordovaLib's Build Settings...\n" - - cdvlibPath = None - cdvlibProjName = 'CordovaLib.xcodeproj' - - for sp in subprojValues: - if cdvlibProjName in sp['path']: - if 'CORDOVALIB' in sp['sourceTree']: - print "Your project *IS* using the CORDOVALIB Xcode variable (source tree)." - cdvlibPath = os.path.join( xcodeCordovaLib, cdvlibProjName) - else: - print "Your project is *NOT* using the CORDOVALIB Xcode variable (source tree)." - cdvlibPath = sp['path'] - - cdvlibNormalizedPath = os.path.normpath( os.path.join(parent_project_path, cdvlibPath) ) - cdvlibPbx = os.path.join( cdvlibNormalizedPath , 'project.pbxproj' ) - - print "Path is:", cdvlibNormalizedPath, "\n" - - cdvPlist = getXcodePlist(cdvlibPbx) - cdvBuildSettingsKeys = ['PUBLIC_HEADERS_FOLDER_PATH', 'ARCHS', 'ARCHS[sdk=iphoneos*]', 'ARCHS[sdk=iphoneos6.*]', 'ARCHS[sdk=iphonesimulator*]', 'USER_HEADER_SEARCH_PATHS', 'IPHONEOS_DEPLOYMENT_TARGET', 'OTHER_LDFLAGS', 'GCC_VERSION'] - - cdvBuildSettings = getXcodeBuildSettings(cdvBuildSettingsKeys, cdvPlist) - pp.pprint( cdvBuildSettings ) - - print "\n\n--------------------------------------------------------------------------------" - print "Inspecting CordovaLib Version...\n" - - cdvlibFolder = AbsParentPath(cdvlibNormalizedPath) - cdvlibVersionFile = os.path.join( cdvlibFolder, "VERSION") - - try: - vf = open(cdvlibVersionFile, 'r') - print "VERSION file:", vf.readline() - vf.close() - except: - print "VERSION file not found at:", cdvlibVersionFile - - cdvlibAvailabilityFile = os.path.join( cdvlibFolder, "Classes", "CDVAvailability.h" ) - try: - af = open(cdvlibAvailabilityFile, 'r') - match = "#define CORDOVA_VERSION_MIN_REQUIRED" - for line in af: - if match in line: - print "CDVAvailability.h version:", line.strip().replace(match, ""), - af.close() - except: - print "CDVAvailability.h file not found at:", cdvlibAvailabilityFile, - - print "\n\n--------------------------------------END---------------------------------------" - -if __name__ == '__main__': - main(sys.argv) http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/2803ddce/bin/templates/project/__PROJECT_NAME__/__PROJECT_NAME__-Info.plist ---------------------------------------------------------------------- diff --git a/bin/templates/project/__PROJECT_NAME__/__PROJECT_NAME__-Info.plist b/bin/templates/project/__PROJECT_NAME__/__PROJECT_NAME__-Info.plist index 8d5d59b..7a2c897 100644 --- a/bin/templates/project/__PROJECT_NAME__/__PROJECT_NAME__-Info.plist +++ b/bin/templates/project/__PROJECT_NAME__/__PROJECT_NAME__-Info.plist @@ -24,8 +24,6 @@ <string>1</string> <key>LSMinimumSystemVersion</key> <string>${MACOSX_DEPLOYMENT_TARGET}</string> - <key>NSHumanReadableCopyright</key> - <string>Copyright © 2015 --AUTHOR--. All rights reserved.</string> <key>NSMainNibFile</key> <string>MainViewController</string> <key>NSPrincipalClass</key> http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/2803ddce/bin/tests/autotest.coffee ---------------------------------------------------------------------- diff --git a/bin/tests/autotest.coffee b/bin/tests/autotest.coffee deleted file mode 100644 index da8abbe..0000000 --- a/bin/tests/autotest.coffee +++ /dev/null @@ -1,24 +0,0 @@ -# -# 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. -# - - -exports['you are sane'] = (test) -> - test.expect 1 - test.ok true, "this assertion should always pass" - test.done() http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/2803ddce/bin/tests/create.coffee ---------------------------------------------------------------------- diff --git a/bin/tests/create.coffee b/bin/tests/create.coffee deleted file mode 100644 index 12fe61e..0000000 --- a/bin/tests/create.coffee +++ /dev/null @@ -1,34 +0,0 @@ -# -# 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. -# - -util = require 'util' -exec = require('child_process').exec -path = require 'path' - -exports['default example project is generated'] = (test) -> - test.expect 1 - exec './bin/create', (error, stdout, stderr) -> - test.ok true, "this assertion should pass" unless error? - test.done() - -exports['default example project has a /phonegap folder'] = (test) -> - test.expect 1 - path.exists './example/phonegap', (exists) -> - test.ok exists, 'the other phonegap folder exists' - test.done() http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/2803ddce/bin/tests/debug.coffee ---------------------------------------------------------------------- diff --git a/bin/tests/debug.coffee b/bin/tests/debug.coffee deleted file mode 100644 index b72aa93..0000000 --- a/bin/tests/debug.coffee +++ /dev/null @@ -1,18 +0,0 @@ -# -# 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. -# http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/2803ddce/bin/tests/test.coffee ---------------------------------------------------------------------- diff --git a/bin/tests/test.coffee b/bin/tests/test.coffee deleted file mode 100644 index b72aa93..0000000 --- a/bin/tests/test.coffee +++ /dev/null @@ -1,18 +0,0 @@ -# -# 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. -# http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/2803ddce/bin/tests_old ---------------------------------------------------------------------- diff --git a/bin/tests_old b/bin/tests_old deleted file mode 100755 index 2bc4715..0000000 --- a/bin/tests_old +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -# -# 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. -# -cd $(dirname $0)/.. -xcodebuild \ - -scheme "TestApp" \ - -project "CordovaLibTests/CordovaLibTests.xcodeproj" \ - -configuration "Debug" \ - clean build test - --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
