rcee_packaged_tarball 0.3.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1673f44de3fda83fea04201db8dd99de09d5ea6a444773440926e3b3c141637
4
- data.tar.gz: b89775e45e1fdf472033bd619344da4c915006d67523ea1046520d7d27983111
3
+ metadata.gz: 58b32d8f933c8d02d0e2aa6d39b9a5b5e64458d8546b2a9b069f46f1c1055370
4
+ data.tar.gz: cf54f67265b8b057a376514dda97df9908c19e2d22747e3c861a393bd69c223f
5
5
  SHA512:
6
- metadata.gz: 1613088409f875bd9ef95ba11761d9ab0b99cbddbecc1b8b362c7a66f611938b1be49e6c2270e2db32a61b48a1d0f29b05cf23cb411ab878bbe41652a5816da2
7
- data.tar.gz: 85d8781d291ff0c307ca0fbff0e59ffecdcc7b9b31acdfe14161bbabea3f182a9bab132a41278d7a76aa4d7b16fe6d34639f0fbba7893bf43534430ec3b35067
6
+ metadata.gz: d5db9bc2768d02496f6bd42fba01e82e0d8f311eb2c63333e61751fe9b4848b05afee9f693d93fe802f25e1dfac0f54275ad5ee05e3d1f5c6288f57eb6c17e03
7
+ data.tar.gz: f1c868c5ebd9f6713f3eac704a07fd02d49d80721f49e049a9ff5ebeaede19524b2da3799106f21fd666ee49d739f64d45dacc5c48c34031c6913ef0d2f6185d
data/README.md CHANGED
@@ -21,38 +21,60 @@ Gem::Specification.new do |spec|
21
21
  end
22
22
  ```
23
23
 
24
- The `extconf.rb` contains a new block:
24
+ The `extconf.rb` is about to get more complicated. To help manage the complexity, we'll use a module with a `.configure` method:
25
25
 
26
26
  ``` ruby
27
- MiniPortile.new("yaml", "0.2.5").tap do |recipe|
28
- recipe.target = File.join(package_root_dir, "ports")
29
- recipe.files = [{
30
- url: "https://github.com/yaml/libyaml/releases/download/0.2.5/yaml-0.2.5.tar.gz",
31
- sha256: "c642ae9b75fee120b2d96c712538bd2cf283228d2337df2cf2988e3c02678ef4",
32
- }]
27
+ module RCEE
28
+ module PackagedTarball
29
+ module ExtConf
30
+ class << self
31
+ def configure
32
+ configure_packaged_libraries
33
+ create_makefile("rcee/packaged_tarball/packaged_tarball")
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ RCEE::PackagedTarball::ExtConf.configure
41
+ ```
42
+
43
+ The `ExtConf` contains a method `configure_packaged_libraries` which uses `mini_portile` to download the library (if necessary); verify the checksum; extract the files; configure, compile, and link it; and finally configure `MakeMakefile` to find the headers and the library:
44
+
45
+ ``` ruby
46
+ def configure_packaged_libraries
47
+ recipe = libyaml_recipe
33
48
 
49
+ # ensure libyaml has already been unpacked, configured, and compiled
34
50
  unless File.exist?(File.join(recipe.target, recipe.host, recipe.name, recipe.version))
35
51
  recipe.cook
36
52
  end
37
53
 
54
+ # use the packaged libyaml
38
55
  recipe.activate
39
56
  pkg_config(File.join(recipe.path, "lib", "pkgconfig", "yaml-0.1.pc"))
40
- end
41
- ```
42
57
 
43
- This block:
58
+ # assert that we can build against the packaged libyaml
59
+ unless have_library("yaml", "yaml_get_version", "yaml.h")
60
+ abort("\nERROR: *** could not find libyaml development environment ***\n\n")
61
+ end
62
+ end
44
63
 
45
- - downloads the libyaml tarball if necessary (note that the packaged gem includes the tarball and so this is skipped by end users during `gem install`)
46
- - verifies the checksum of the tarball
47
- - extracts the tarball
48
- - configures the build system (for libyaml, this is "autoconf")
49
- - compile libyaml's source code into object files
50
- - link the object files together into a library we can use
51
- - configure `MakeMakefile` to find the headers and the library
64
+ def libyaml_recipe
65
+ MiniPortile.new("yaml", "0.2.5").tap do |recipe|
66
+ recipe.files = [{
67
+ url: "https://github.com/yaml/libyaml/releases/download/0.2.5/yaml-0.2.5.tar.gz",
68
+ sha256: "c642ae9b75fee120b2d96c712538bd2cf283228d2337df2cf2988e3c02678ef4"
69
+ }]
70
+ recipe.target = File.join(PACKAGE_ROOT_DIR, "ports")
71
+ end
72
+ end
73
+ ```
52
74
 
53
- (Of special note, we're able to use `pkgconfig` to do much of our extension configuration, which allows us to have a pretty clean configuration. This is one advantage to using upstream distributions.)
75
+ Of special note, we're able to use `pkgconfig` to do much of our extension configuration, which allows us to have a pretty clean configuration. This is one advantage to using upstream distributions.
54
76
 
55
- Note that all of those steps happen *before* the Makefile is created -- it's run by `extconf.rb` so that the Makefile will know where to find our libyaml files.
77
+ Note that all of those steps happen *before* the Makefile is created, so that the Makefile will contain the appropriate paths and flags to build our extension against libyaml.
56
78
 
57
79
 
58
80
  ## Testing
@@ -1,24 +1,58 @@
1
1
  require "mkmf"
2
2
  require "mini_portile2"
3
3
 
4
- package_root_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
4
+ module RCEE
5
+ module PackagedTarball
6
+ module ExtConf
7
+ PACKAGE_ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
5
8
 
6
- MiniPortile.new("yaml", "0.2.5").tap do |recipe|
7
- recipe.files = [{
8
- url: "https://github.com/yaml/libyaml/releases/download/0.2.5/yaml-0.2.5.tar.gz",
9
- sha256: "c642ae9b75fee120b2d96c712538bd2cf283228d2337df2cf2988e3c02678ef4",
10
- }]
9
+ class << self
10
+ def configure
11
+ configure_packaged_libraries
11
12
 
12
- recipe.target = File.join(package_root_dir, "ports")
13
- unless File.exist?(File.join(recipe.target, recipe.host, recipe.name, recipe.version))
14
- recipe.cook
13
+ create_makefile("rcee/packaged_tarball/packaged_tarball")
14
+ end
15
+
16
+ def configure_packaged_libraries
17
+ recipe = libyaml_recipe
18
+
19
+ # ensure libyaml has already been unpacked, configured, and compiled
20
+ unless File.exist?(File.join(recipe.target, recipe.host, recipe.name, recipe.version))
21
+ recipe.cook
22
+ end
23
+
24
+ # use the packaged libyaml
25
+ recipe.activate
26
+ pkg_config(File.join(recipe.path, "lib", "pkgconfig", "yaml-0.1.pc"))
27
+
28
+ # assert that we can build against the packaged libyaml
29
+ unless have_library("yaml", "yaml_get_version", "yaml.h")
30
+ abort("\nERROR: *** could not find libyaml development environment ***\n\n")
31
+ end
32
+ end
33
+
34
+ def download
35
+ libyaml_recipe.download
36
+ end
37
+
38
+ def libyaml_recipe
39
+ MiniPortile.new("yaml", "0.2.5").tap do |recipe|
40
+ recipe.files = [{
41
+ url: "https://github.com/yaml/libyaml/releases/download/0.2.5/yaml-0.2.5.tar.gz",
42
+ sha256: "c642ae9b75fee120b2d96c712538bd2cf283228d2337df2cf2988e3c02678ef4"
43
+ }]
44
+ recipe.target = File.join(PACKAGE_ROOT_DIR, "ports")
45
+ end
46
+ end
47
+ end
48
+ end
15
49
  end
16
- recipe.activate
17
- pkg_config(File.join(recipe.path, "lib", "pkgconfig", "yaml-0.1.pc"))
18
50
  end
19
51
 
20
- unless have_library("yaml", "yaml_get_version", "yaml.h")
21
- abort("\nERROR: *** could not find libyaml development environment ***\n\n")
52
+ # run "ruby ./ext/packaged_tarball/extconf.rb -- --download-dependencies" to download the tarball
53
+ if arg_config("--download-dependencies")
54
+ RCEE::PackagedTarball::ExtConf.download
55
+ exit!(0)
22
56
  end
23
57
 
24
- create_makefile("rcee/packaged_tarball/packaged_tarball")
58
+ RCEE::PackagedTarball::ExtConf.configure
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RCEE
4
4
  module PackagedTarball
5
- VERSION = "0.3.0"
5
+ VERSION = "0.5.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcee_packaged_tarball
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Dalessio
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-08 00:00:00.000000000 Z
11
+ date: 2024-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_portile2
@@ -62,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0'
64
64
  requirements: []
65
- rubygems_version: 3.2.22
65
+ rubygems_version: 3.4.19
66
66
  signing_key:
67
67
  specification_version: 4
68
68
  summary: Example gem demonstrating a basic C extension.