motion.h 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +56 -0
- data/Rakefile +1 -0
- data/lib/motion.h.rb +50 -0
- data/motion.h.gemspec +19 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f3563f032b9abc0292b0a360b3c7314fc6eb8334
|
4
|
+
data.tar.gz: dda1f773593647d5588514b5a625368c7595072a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 250a6333b2536b6bab308c0dbbe58cb970e78593f08de68ad4c5bc0b146cc762c1f8b79b57cbc75f23107fd249a51c13e5c8bd95362bd97e28d893aa3194328d
|
7
|
+
data.tar.gz: 6059442158529d4a6b50e9313de1c83740a16d30aceeec7dd5f6c84fce5aea39f533f620656b23e6e0c98995d3241a50c119ccb106839cf81306476431e84dee
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Dave Lee
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# motion.h
|
2
|
+
|
3
|
+
Include iOS system libraries in RubyMotion.
|
4
|
+
|
5
|
+
Outside of the usual Apple frameworks, iOS includes many system C libraries,
|
6
|
+
with the most well known examples being [SQLite](http://www.sqlite.org/), and
|
7
|
+
[Libxml2](http://www.xmlsoft.org/). RubyMotion provides the ability to directly
|
8
|
+
call into C libraries through a mechanism called BridgeSupport, which takes us
|
9
|
+
to the point in the story where `motion.h` is introduced. In order to use
|
10
|
+
BridgeSupport, the compiler must be fed an XML file that describes a library's
|
11
|
+
C API, and this is what `motion.h` takes care of. Simply declare the header
|
12
|
+
files needed, just like in C, and now RubyMotion code can call directly into
|
13
|
+
the specified system library, without having to write an Objective-C wrapper.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Add this line to your application's Gemfile:
|
18
|
+
|
19
|
+
gem 'motion.h'
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install motion.h
|
28
|
+
|
29
|
+
## Examples
|
30
|
+
|
31
|
+
In your `Rakefile`:
|
32
|
+
|
33
|
+
### SQLite
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
Motion::Project::App.setup do |config|
|
37
|
+
config.libs << '/usr/lib/libsqlite3.dylib'
|
38
|
+
config.include 'sqlite3.h'
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
### Objective-C Runtime
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
Motion::Project::App.setup do |config|
|
46
|
+
config.include 'objc/runtime.h'
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
1. Fork it
|
53
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
54
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
55
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
56
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/motion.h.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
unless defined? Motion::Project::Config
|
2
|
+
raise '"motion.h" must be required within a RubyMotion project Rakefile.'
|
3
|
+
end
|
4
|
+
|
5
|
+
class Motion::Project::Config
|
6
|
+
def include(header_file, output_dir=nil)
|
7
|
+
MotionHeader.new(header_file, self, output_dir).integrate
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class MotionHeader
|
12
|
+
|
13
|
+
BRIDGESUPPORT_DIR = 'build'
|
14
|
+
|
15
|
+
# @param [String] header_file Requested C header file.
|
16
|
+
# @param [Motion::Project::Config] config RubyMotion config provided in App.setup.
|
17
|
+
# @param [String] bridgesupport_dir Path where the generated bridgesupport file is saved. Defaults to ./build.
|
18
|
+
def initialize(header_file, config, bridgesupport_dir=BRIDGESUPPORT_DIR)
|
19
|
+
@header_file = header_file
|
20
|
+
@config = config
|
21
|
+
@bridgesupport_dir = bridgesupport_dir || BRIDGESUPPORT_DIR
|
22
|
+
end
|
23
|
+
|
24
|
+
def integrate
|
25
|
+
verify_header_file
|
26
|
+
generate_bridgesupport_file
|
27
|
+
@config.bridgesupport_files << bridgesupport_file
|
28
|
+
end
|
29
|
+
|
30
|
+
def verify_header_file
|
31
|
+
path = "#{include_path}/#{@header_file}"
|
32
|
+
File.exist?(path) or raise "Header file `#{@header_file}' does not exist (#{path})."
|
33
|
+
end
|
34
|
+
|
35
|
+
def generate_bridgesupport_file
|
36
|
+
return if File.exist?(bridgesupport_file)
|
37
|
+
Dir.mkdir(@bridgesupport_dir) unless Dir.exist?(@bridgesupport_dir)
|
38
|
+
`/usr/bin/gen_bridge_metadata --format complete --no-64-bit --cflags '-I#{include_path}' #{@header_file} > #{bridgesupport_file}`
|
39
|
+
end
|
40
|
+
|
41
|
+
def include_path
|
42
|
+
"#{@config.xcode_dir}/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS#{@config.sdk_version}.sdk/usr/include"
|
43
|
+
end
|
44
|
+
|
45
|
+
def bridgesupport_file
|
46
|
+
file_name = @header_file.tr('/', '_').chomp('.h')
|
47
|
+
"#{@bridgesupport_dir}/#{file_name}.bridgesupport"
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
data/motion.h.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
Gem::Specification.new do |spec|
|
3
|
+
spec.name = "motion.h"
|
4
|
+
spec.version = '0.0.1'
|
5
|
+
spec.authors = ["Dave Lee"]
|
6
|
+
spec.email = ['dave@kastiglione.com']
|
7
|
+
spec.description = 'Include iOS system libraries in RubyMotion'
|
8
|
+
spec.summary = 'Include iOS system libraries in RubyMotion'
|
9
|
+
spec.homepage = 'https://github.com/kastiglione/motion.h'
|
10
|
+
spec.license = "MIT"
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split($/)
|
13
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
|
17
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
18
|
+
spec.add_development_dependency "rake"
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motion.h
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dave Lee
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Include iOS system libraries in RubyMotion
|
42
|
+
email:
|
43
|
+
- dave@kastiglione.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/motion.h.rb
|
54
|
+
- motion.h.gemspec
|
55
|
+
homepage: https://github.com/kastiglione/motion.h
|
56
|
+
licenses:
|
57
|
+
- MIT
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.0.3
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: Include iOS system libraries in RubyMotion
|
79
|
+
test_files: []
|
80
|
+
has_rdoc:
|