Skip to content

Commit

Permalink
Initial Plugin Release
Browse files Browse the repository at this point in the history
* Added initial README
* Added initial Plugin code
  • Loading branch information
mattrayner committed Aug 2, 2016
1 parent cf3e9a5 commit 09411c1
Show file tree
Hide file tree
Showing 73 changed files with 4,702 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- '4.4'
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016 Matthew Rayner

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
# Cordova Vuforia SDK Plugin
# ![Cordova-Plugin-Vuforia-SDK][logo]
Cordova Vuforia SDK plugin is designed to inject the Vuforia SDK into any Cordova project. It was specifically created to be used with [Cordova-Plugin-Vuforia][cordova-plugin-vuforia].

[![NPM Version][shield-npm]][info-npm]
[![Build Status][shield-travis]][info-travis]
[![License][shield-license]][info-license]

## Note
This 'plugin' simply a way of injecting the Vuforia SDK code into a Cordova project. It offers no JavaScript interface or additional functionality.

## Contributing
If you wish to submit a bug fix or feature, you can create a pull request and it will be merged pending a code review.

1. Clone it
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request

## License
Cordova-Plugin-Vuforia-SDK is licensed under the [MIT License][info-license].


[logo]: https://cdn.rawgit.com/mattrayner/cordova-plugin-vuforia-sdk/cf3e9a58f18e2eabf2a6b9a91c75fadd1cf0a118/docs/logo.svg

[info-npm]: https://www.npmjs.com/package/cordova-plugin-vuforia-sdk
[info-travis]: https://travis-ci.org/mattrayner/cordova-plugin-vuforia-sdk
[info-license]: LICENSE

[shield-npm]: https://img.shields.io/npm/v/cordova-plugin-vuforia-sdk.svg
[shield-travis]: https://img.shields.io/travis/mattrayner/cordova-plugin-vuforia-sdk.svg
[shield-license]: https://img.shields.io/badge/license-MIT-blue.svg

[cordova-plugin-vuforia]: https://github.com/mattrayner/cordova-plugin-vuforia
73 changes: 73 additions & 0 deletions hooks/AfterPluginInstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env node
'use strict';

module.exports = function(context) {

let cwd = process.cwd();
let fs = require('fs');
let path = require('path');
let hookData = require('./hook_data.json');

// Modify the xcconfig build path and pass the resulting file path to the addHeaderSearchPaths function.
const modifyBuildConfig = function() {
let xcConfigBuildFilePath = path.join(cwd, 'platforms', 'ios', 'cordova', 'build.xcconfig');

try {
let xcConfigBuildFileExists = fs.accessSync(xcConfigBuildFilePath);
}
catch(e) {
console.log('Could not locate build.xcconfig, you will need to set HEADER_SEARCH_PATHS manually');
return;
}

console.log(`xcConfigBuildFilePath: ${xcConfigBuildFilePath}`);

addHeaderSearchPaths(xcConfigBuildFilePath);
};

// Read the build config, add the correct Header Search Paths to the config before calling modifyAppDelegate.
const addHeaderSearchPaths = function(xcConfigBuildFilePath) {
let lines = fs.readFileSync(xcConfigBuildFilePath, 'utf8').split('\n');
let paths = hookData.headerPaths;

let headerSearchPathLineNumber;

lines.forEach((l, i) => {
if (l.indexOf('HEADER_SEARCH_PATHS') > -1) {
headerSearchPathLineNumber = i;
}
});

if (headerSearchPathLineNumber) {
for(let actualPath of paths) {
if (lines[headerSearchPathLineNumber].indexOf(actualPath) == -1) {
lines[headerSearchPathLineNumber] += ` ${actualPath}`;
console.log(`${actualPath} was added to the search paths`);
}
else {
console.log(`${actualPath} was already setup in build.xcconfig`);
}
}
}
else {
lines[lines.length - 1] = 'HEADER_SEARCH_PATHS = ';
for(let actualPath of paths) {
lines[lines.length - 1] += actualPath;
}
}

let newConfig = lines.join('\n');

fs.writeFile(xcConfigBuildFilePath, newConfig, function (err) {
if (err) {
console.log(`Error updating build.xcconfig: ${err}`);
return;
}
console.log('Successfully updated HEADER_SEARCH_PATHS in build.xcconfig');
});

};


modifyBuildConfig();
};
60 changes: 60 additions & 0 deletions hooks/BeforePluginUninstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env node
'use strict';

module.exports = function(context) {
let cwd = process.cwd();
let fs = require('fs');
let path = require('path');
let hookData = require('./hook_data.json');

let xcConfigBuildFilePath = path.join(cwd, 'platforms', 'ios', 'cordova', 'build.xcconfig');

console.log('Vuforia BeforePluginUninstall.js, attempting to modify build.xcconfig');

try {
let xcConfigBuildFileExists = fs.accessSync(xcConfigBuildFilePath);
}
catch(e) {
console.log('Could not locate build.xcconfig.');
return;
}

console.log('xcConfigBuildFilePath: ', xcConfigBuildFilePath);

let lines = fs.readFileSync(xcConfigBuildFilePath, 'utf8').split('\n');

let headerSearchPathLineNumber;
lines.forEach((l, i) => {
if (l.indexOf('HEADER_SEARCH_PATHS') > -1) {
headerSearchPathLineNumber = i;
}
});

if (!headerSearchPathLineNumber) {
console.log('build.xcconfig does not have HEADER_SEARCH_PATHS');
return;
}


let paths = hookData.headerPaths;

for(let actualPath of paths){
if (lines[headerSearchPathLineNumber].indexOf(actualPath) === -1) {
console.log('build.xcconfig does not have header path for Instagram Assets Picker');
continue;
}
let line = lines[headerSearchPathLineNumber];
lines[headerSearchPathLineNumber] = line.replace(' '+actualPath, '');
}
let newConfig = lines.join('\n');

fs.writeFile(xcConfigBuildFilePath, newConfig, function (err) {
if (err) {
console.log('error updating build.xcconfig, err: ', err);
return;
}
console.log('successfully updated HEADER_SEARCH_PATHS in build.xcconfig');
});


};
6 changes: 6 additions & 0 deletions hooks/hook_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"headerPaths": [
"\"../../plugins/cordova-plugin-vuforia-sdk/src/vuforia/include\"",
"\"$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include\""
]
}
29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "cordova-plugin-vuforia-sdk",
"version": "0.0.1",
"description": "A Cordova wrapper for the Vuforia SDK",
"repository": {
"type": "git",
"url": "git+https://github.com/mattrayner/cordova-plugin-vuforia-sdk.git"
},
"cordova": {
"id": "cordova-plugin-vuforia-sdk",
"platforms": [
"android",
"ios"
]
},
"keywords": [
"cordova",
"vuforia",
"ecosystem:cordova",
"cordova-android",
"cordova-ios"
],
"author": "Matt Rayner",
"license": "MIT",
"bugs": {
"url": "https://github.com/mattrayner/cordova-plugin-vuforia-sdk/issues"
},
"homepage": "https://github.com/mattrayner/cordova-plugin-vuforia-sdk#readme"
}
64 changes: 64 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>

<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-vuforia-sdk"
version="0.0.1">
<name>Vuforia SDK</name>
<description>Cordova Vuforia SDK Plugin</description>
<license>MIT</license>
<keywords>cordova,vuforia,sdk</keywords>
<repo>[email protected]:mattrayner/cordova-plugin-vuforia-sdk.git</repo>
<issue>https://github.com/mattrayner/cordova-plugin-vuforia-sdk/issues</issue>

<author>Matthew Rayner</author>

<info>
Cordova Vuforia SDK Plugin version 0.0.2, Copyright (C) 2016 Matthew Rayner
Cordova Vuforia SDK Plugin comes with ABSOLUTELY NO WARRANTY; see the
LICENSE file for more information.
This is free software, and you are welcome to redistribute it
under certain conditions; see the LICENSE file for more information.
</info>

<!-- android -->
<platform name="android">
<!-- Libraries -->
<source-file src="src/vuforia/jniLibs/armeabi/libVuforia.so" target-dir="libs/armeabi-v7a" />
<source-file src="src/vuforia/Vuforia.jar" target-dir="libs" />

<!-- Add our permissions to the Android Manifest -->
<config-file target="AndroidManifest.xml" parent="/*">
<uses-feature android:glEsVersion="0x00020000" />
<uses-feature android:name="android.hardware.camera" />

<uses-permission android:name="android.permission.CAMERA" />

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
</config-file>
</platform>

<!-- ios -->
<platform name="ios">
<hook type="after_plugin_install" src="hooks/AfterPluginInstall.js" />
<hook type="before_plugin_uninstall" src="hooks/BeforePluginUninstall.js" />

<framework src="AVFoundation.framework" weak="true" />
<framework src="CoreGraphics.framework" weak="true" />
<framework src="CoreMedia.framework" weak="true" />
<framework src="CoreMotion.framework" weak="true" />
<framework src="CoreVideo.framework" weak="true" />
<framework src="Foundation.framework" weak="true" />
<framework src="OpenGLES.framework" weak="true" />
<framework src="QuartzCore.framework" weak="true" />
<framework src="Security.framework" weak="true" />
<framework src="SystemConfiguration.framework" weak="true" />
<framework src="UIKit.framework" weak="true" />

<source-file src="src/vuforia/lib/arm/libVuforia.a" target-dir="libs" framework="true" />
</platform>
</plugin>
Binary file added src/vuforia/Vuforia.jar
Binary file not shown.
43 changes: 43 additions & 0 deletions src/vuforia/include/QCAR/Area.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*===============================================================================
Copyright (c) 2010-2014 Qualcomm Connected Experiences, Inc. All Rights Reserved.
Vuforia is a trademark of QUALCOMM Incorporated, registered in the United States
and other countries. Trademarks of QUALCOMM Incorporated are used with permission.
@file
Area.h
@brief
Header file for Area class.
===============================================================================*/

#ifndef _QCAR_AREA_H_
#define _QCAR_AREA_H_

#include <QCAR/QCAR.h>

namespace QCAR
{

/// Area is the base class for 2D shapes used in Vuforia
class QCAR_API Area
{
public:
enum TYPE {
RECTANGLE,
RECTANGLE_INT,
INVALID
};

virtual TYPE getType() const = 0;

virtual ~Area();

private:
Area& operator=(const Area& other);
};

} // namespace QCAR


#endif // _QCAR_AREA_H_
Loading

0 comments on commit 09411c1

Please sign in to comment.