rcee_packaged_tarball 0.4.0 → 0.5.1

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: 77ace21c823e931cb6e7d7feeed01351e8f8c67240c362868d948bb2933afff6
4
- data.tar.gz: 16ca21fe014c181139dd5a0af35ee0720544c6e50c44238985ccd9e782ef2473
3
+ metadata.gz: 012f184b015f99d0eef695227f07b59d078bb6dc2ff4fca845819b0e14c79d6a
4
+ data.tar.gz: c989226ac5a3016918f2250053bbfb3045bdb39e508b2ee541e587962d51a81e
5
5
  SHA512:
6
- metadata.gz: 817725162179cd2ec67413d5eebae0bc5281113fce750d5bf0c1a635f71a87d79d3d9fec9c26f735f90a4febd2b2bd03621b906f65c51439279c842db29d5257
7
- data.tar.gz: 9a778aba66c002986cea504b81621f1ba727be16f8a4ee8b729f72fc1018403479b2a44162a1e014b46c0af38f9f0d04ed053249333eba0528f8e8c19ce68ce4
6
+ metadata.gz: bda72ad435dd4fed4f7d9bd52c999f6ab991d0971bca6bdaa4143763cad0a27341cab4bd07670f217768cdc22bfb2fe51fb39a0cc1d9de6e0476e679b718fd3e
7
+ data.tar.gz: 3c621a89c8185147feae5bf656e62bb8bc6fba58d39b50883b398b6349e2f0c3c7da04de1bb4b55f1e52ec72f2b9c47100df3f4e46d02a32cf07553d2be3cfa0
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.4.0"
5
+ VERSION = "0.5.1"
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.4.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Dalessio
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-19 00:00:00.000000000 Z
11
+ date: 2024-01-28 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.3.5
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.