rcee_packaged_tarball 0.4.0 → 0.5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77ace21c823e931cb6e7d7feeed01351e8f8c67240c362868d948bb2933afff6
4
- data.tar.gz: 16ca21fe014c181139dd5a0af35ee0720544c6e50c44238985ccd9e782ef2473
3
+ metadata.gz: 0da8858fe1db654ad45d08b4bf96556d2b3011ffa56f9e349a8f3917535e51d2
4
+ data.tar.gz: bb85f6a25b082ba6c7eca2438ce74d41cfd16b46b4432d6bf81879c0f6541dbe
5
5
  SHA512:
6
- metadata.gz: 817725162179cd2ec67413d5eebae0bc5281113fce750d5bf0c1a635f71a87d79d3d9fec9c26f735f90a4febd2b2bd03621b906f65c51439279c842db29d5257
7
- data.tar.gz: 9a778aba66c002986cea504b81621f1ba727be16f8a4ee8b729f72fc1018403479b2a44162a1e014b46c0af38f9f0d04ed053249333eba0528f8e8c19ce68ce4
6
+ metadata.gz: 0452403775630f08cdf2a4c49e573062681313185cf6770ab8072ed8bd0b0175b254f5d6b1ea4a8bd1044ce836fb8158302fe1157aaadc893e9cf31f4232b5bb
7
+ data.tar.gz: 78fb2ec8784343b967f3d1adcfb8dcd4a4f30a5aba0ff165ddd164efd0944c7b04f827021089f17bb64cc7d2bf4f8ded74b7e351aa1b36064fd59af77fc46978
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.0.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.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Dalessio
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-19 00:00:00.000000000 Z
11
+ date: 2024-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_portile2
@@ -47,7 +47,7 @@ homepage: https://github.com/flavorjones/ruby-c-extensions-explained
47
47
  licenses:
48
48
  - MIT
49
49
  metadata: {}
50
- post_install_message:
50
+ post_install_message:
51
51
  rdoc_options: []
52
52
  require_paths:
53
53
  - lib
@@ -62,8 +62,8 @@ 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
66
- signing_key:
65
+ rubygems_version: 3.4.19
66
+ signing_key:
67
67
  specification_version: 4
68
68
  summary: Example gem demonstrating a basic C extension.
69
69
  test_files: []