motion.h 0.0.2 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +16 -4
  3. data/Rakefile +6 -0
  4. data/lib/motion.h.rb +68 -11
  5. data/motion.h.gemspec +3 -3
  6. metadata +16 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be4b20cc5a9df900392e473d3bffcc51f5e3a52d
4
- data.tar.gz: 409003301af6fdc598cad5d2120568ab8791aefa
3
+ metadata.gz: 511528c649ad4a3843b64b4a92f5a8f4894d6210
4
+ data.tar.gz: 3ea00c01f5388e197681382011cf57f5413a358d
5
5
  SHA512:
6
- metadata.gz: a8a11705edb6e7749d15e559d836faf5134ca7c9a22815ea6337248aca3370f34ecc3bfe572bc915d6d61e346d4b81b72dcf16067c0dc7a15a453df6694b3188
7
- data.tar.gz: dd945be80a47f5c4880725ad978c58817ccaf37dbb4a8a80b2f6a2b80b2c7d01d91b58e8a0c539f5d46d2c46d79dfeb76f1d3b1b7d60df98992b03b351b14b7e
6
+ metadata.gz: 1d4bc836006f18b002eb46f4879b8f9361ac3f8f202cc3797f7492242cbb6d0f716d8937259450c9225b3c15748359128b3005d6841042af9ca3a3542cacb3ac
7
+ data.tar.gz: d28c3f961aa804f253b4dd143b3c3f2e1bff62e0bb0cfa8f3fa8ec8be49a2dda7a233c48e1f1cdbe7336c3d62d997721edc20b76d5d9714eea685a41b7980c6c
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # motion.h
2
2
 
3
- Expose iOS system C libraries in RubyMotion.
3
+ Expose iOS and OS X system libraries in RubyMotion.
4
4
 
5
- Outside of the usual Apple frameworks, iOS includes many system C libraries,
5
+ Outside of the usual Apple frameworks, iOS and OS X include many system libraries,
6
6
  with the most well known examples being [SQLite](http://www.sqlite.org/), and
7
7
  [Libxml2](http://www.xmlsoft.org/). RubyMotion provides the ability to directly
8
8
  call into C libraries through a mechanism called BridgeSupport, which takes us
@@ -49,8 +49,20 @@ end
49
49
  Example: Creating an in-memory database:
50
50
 
51
51
  ```ruby
52
- db = Pointer.new(Sqlite3.type)
53
- sqlite3_open(':memory', db)
52
+ dbptr_out = Pointer.new(Sqlite3.type) # => sqlite3 **
53
+ sqlite3_open(':memory:', dbptr_out)
54
+ dbptr = dbptr_out.value # => sqlite3 *
55
+ sqlite3_exec(dbptr, 'create table gems (name text)', nil, nil, nil)
56
+ sqlite3_exec(dbptr, 'insert into gems values ("motion.h")', nil, nil, nil)
57
+ callback = ->(_context, count, values_array_ptr, column_names_array_ptr) {
58
+ count.times do |column_number|
59
+ column_name = column_names_array_ptr[column_number]
60
+ value = values_array_ptr[column_number]
61
+ puts "#{column_name}: #{value.inspect}"
62
+ end
63
+ 0 # sqlite3_exec requires 0 to continue
64
+ }
65
+ sqlite3_exec(dbptr, 'select * from gems', callback, nil, nil)
54
66
  ```
55
67
 
56
68
  ### Objective-C Runtime
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ task :default do
4
+ system 'gem uninstall -ax motion.h'
5
+ system 'gem build motion.h.gemspec'
6
+ system 'gem install ./motion.h-0.0.7.gem'
7
+ end
@@ -2,13 +2,31 @@ unless defined? Motion::Project::Config
2
2
  raise '"motion.h" must be required within a RubyMotion project Rakefile.'
3
3
  end
4
4
 
5
- class Motion::Project::Config
6
- # @param [String] header_file Requested C header file.
7
- # @param [Hash] options Options for customizing BridgeSupport file generation
8
- # @option options [String] :prefix Subdirectory of /usr/include used for root of included header files.
9
- # @option options [String] :bridgesupport_dir Path where the generated bridgesupport file is saved. Defaults to ./build
10
- def include(header_file, options={})
11
- MotionHeader.new(header_file, self, options).integrate
5
+ module Motion::Project
6
+ class Config
7
+ # @param [String] header_file Requested C header file.
8
+ # @param [Hash] options Options for customizing BridgeSupport file generation
9
+ # @option options [String] :prefix Subdirectory of /usr/include used for root of included header files.
10
+ # @option options [String] :bridgesupport_dir Path where the generated bridgesupport file is saved. Defaults to ./build
11
+ def include(header_file, options={})
12
+ motion_h << MotionHeader.new(header_file, self, options).integrate
13
+ end
14
+
15
+ def motion_h
16
+ @motion_h ||= []
17
+ end
18
+ end
19
+
20
+ class App
21
+ class << self
22
+ def build_with_motion_h(platform, opts = {})
23
+ config.bridgesupport_files.concat(config.motion_h)
24
+ build_without_motion_h(platform, opts)
25
+ end
26
+
27
+ alias_method "build_without_motion_h", "build"
28
+ alias_method "build", "build_with_motion_h"
29
+ end
12
30
  end
13
31
  end
14
32
 
@@ -31,7 +49,7 @@ class MotionHeader
31
49
  def integrate
32
50
  verify_header_file
33
51
  generate_bridgesupport_file
34
- @config.bridgesupport_files << bridgesupport_file
52
+ bridgesupport_file
35
53
  end
36
54
 
37
55
  def verify_header_file
@@ -42,16 +60,52 @@ class MotionHeader
42
60
  def generate_bridgesupport_file
43
61
  return if File.exist?(bridgesupport_file)
44
62
  Dir.mkdir(@bridgesupport_dir) unless Dir.exist?(@bridgesupport_dir)
45
- `/usr/bin/gen_bridge_metadata --format complete --no-64-bit --cflags '-I#{include_path}' #{@header_file} > #{bridgesupport_file}`
63
+ cflags = [
64
+ "-I#{include_path}",
65
+ "-F#{frameworks_path}"
66
+ ]
67
+ if product_version >= catalina_version
68
+ cflags << "--isysroot #{isysroot_dir}"
69
+ end
70
+ Bundler.with_unbundled_env do
71
+ `/Library/RubyMotion/bin/gen_bridge_metadata --format complete --64-bit --cflags '#{cflags.join(' ')}' #{@header_file} > #{bridgesupport_file}`
72
+ end
73
+ end
74
+
75
+ def catalina_version
76
+ Gem::Version.new('10.15')
77
+ end
78
+
79
+ def product_version
80
+ Gem::Version.new(`sw_vers -productVersion`)
46
81
  end
47
82
 
48
83
  def include_path
49
- path_components = [@config.xcode_dir, *sdk_dir(@config.sdk_version), 'usr', 'include', @prefix].compact
84
+ sdk_dir = sdk_dir(@config.sdk_version)
85
+ path_components = [@config.xcode_dir, *sdk_dir, 'usr', 'include', @prefix].compact
50
86
  File.join(*path_components)
51
87
  end
52
88
 
89
+ def frameworks_path
90
+ sdk_dir = sdk_dir(@config.sdk_version)
91
+ path_components = [@config.xcode_dir, *sdk_dir, 'System', 'Library', 'Frameworks'].compact
92
+ File.join(*path_components)
93
+ end
94
+
95
+ def isysroot_dir
96
+ case platform
97
+ when :ios then 'iPhoneOS'
98
+ when :osx then 'MacOSX'
99
+ end
100
+ end
101
+
53
102
  def sdk_dir(sdk_version)
54
- ['Platforms', 'iPhoneOS.platform', 'Developer', 'SDKs', "iPhoneOS#{sdk_version}.sdk"]
103
+ case platform
104
+ when :ios
105
+ ['Platforms', 'iPhoneOS.platform', 'Developer', 'SDKs', "iPhoneOS#{sdk_version}.sdk"]
106
+ when :osx
107
+ ['Platforms', 'MacOSX.platform', 'Developer', 'SDKs', "MacOSX#{sdk_version}.sdk"]
108
+ end
55
109
  end
56
110
 
57
111
  def bridgesupport_file
@@ -59,4 +113,7 @@ class MotionHeader
59
113
  "#{@bridgesupport_dir}/#{file_name}.bridgesupport"
60
114
  end
61
115
 
116
+ def platform
117
+ Motion::Project::App.respond_to?(:template) ? Motion::Project::App.template : :ios
118
+ end
62
119
  end
@@ -1,11 +1,11 @@
1
1
  # coding: utf-8
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = "motion.h"
4
- spec.version = '0.0.2'
4
+ spec.version = '0.0.7'
5
5
  spec.authors = ["Dave Lee"]
6
6
  spec.email = ['dave@kastiglione.com']
7
- spec.description = 'Expose iOS system C libraries in RubyMotion'
8
- spec.summary = 'Expose iOS system C libraries in RubyMotion'
7
+ spec.description = 'Expose iOS system C libraries in RubyMotion.'
8
+ spec.summary = 'Expose iOS system C libraries in RubyMotion.'
9
9
  spec.homepage = 'https://github.com/kastiglione/motion.h'
10
10
  spec.license = "MIT"
11
11
 
metadata CHANGED
@@ -1,51 +1,51 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion.h
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Lee
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-11 00:00:00.000000000 Z
11
+ date: 2021-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description: Expose iOS system C libraries in RubyMotion
41
+ description: Expose iOS system C libraries in RubyMotion.
42
42
  email:
43
43
  - dave@kastiglione.com
44
44
  executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - .gitignore
48
+ - ".gitignore"
49
49
  - Gemfile
50
50
  - LICENSE.txt
51
51
  - README.md
@@ -56,25 +56,24 @@ homepage: https://github.com/kastiglione/motion.h
56
56
  licenses:
57
57
  - MIT
58
58
  metadata: {}
59
- post_install_message:
59
+ post_install_message:
60
60
  rdoc_options: []
61
61
  require_paths:
62
62
  - lib
63
63
  required_ruby_version: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - '>='
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  requirements:
70
- - - '>='
70
+ - - ">="
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0'
73
73
  requirements: []
74
- rubyforge_project:
75
- rubygems_version: 2.0.3
76
- signing_key:
74
+ rubyforge_project:
75
+ rubygems_version: 2.5.2.3
76
+ signing_key:
77
77
  specification_version: 4
78
- summary: Expose iOS system C libraries in RubyMotion
78
+ summary: Expose iOS system C libraries in RubyMotion.
79
79
  test_files: []
80
- has_rdoc: