rcee_precompiled 0.1.0-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 07ee801da8b64f612aee78f3c51ac5b083a62d49c68992e3a089e33eb31dadf4
4
+ data.tar.gz: 733e1652eae9fd74d98fd184c562c160ee2508f694134b790384be47a0bf810d
5
+ SHA512:
6
+ metadata.gz: 51a35bc755af82e00cd3050ed5fbfe49cd83f03f6184eb9edb2a216e6176d2b27eba34fcdf3a8f635856e8fdc5f50345e30bd786dffef3daabdf2a0211b61815
7
+ data.tar.gz: 5d601a193c724b65788728a8ecc47a3ef84073575ed06bd1df4ae73475a1d8dfbea2b20c63a3d07b5bd4a3db10e66b67cd747874d57e07feef59dfd6adab2ea4
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.bundle
10
+ *.so
11
+ *.o
12
+ *.a
13
+ mkmf.log
14
+ ports
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in precompiled.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rake-compiler"
11
+ gem "rake-compiler-dock"
12
+
13
+ gem "minitest", "~> 5.0"
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+
2
+ This gem is part of the Ruby C Extensions Explained project at https://github.com/flavorjones/ruby-c-extensions-explained
data/Rakefile ADDED
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ rcee_precompiled_spec = Bundler.load_gemspec("rcee_precompiled.gemspec")
7
+
8
+ Rake::TestTask.new(:test) do |t|
9
+ t.libs << "test"
10
+ t.libs << "lib"
11
+ t.test_files = FileList["test/**/*_test.rb"]
12
+ end
13
+
14
+ # "gem" task for vanilla packaged (tarball)
15
+ require "rubygems/package_task"
16
+ Gem::PackageTask.new(rcee_precompiled_spec).define
17
+
18
+ require "rake/extensiontask"
19
+ require "rake_compiler_dock"
20
+
21
+ cross_rubies = ["3.0.0", "2.7.0", "2.6.0", "2.5.0"]
22
+ cross_platforms = ["x64-mingw32", "x86_64-linux", "x86_64-darwin", "arm64-darwin"]
23
+
24
+ ENV["RUBY_CC_VERSION"] = cross_rubies.join(":")
25
+
26
+
27
+ Rake::ExtensionTask.new("precompiled", rcee_precompiled_spec) do |ext|
28
+ ext.lib_dir = "lib/rcee/precompiled"
29
+ ext.cross_compile = true
30
+ ext.cross_platform = cross_platforms
31
+ ext.cross_config_options << "--enable-cross-build" # so extconf.rb knows we're cross-compiling
32
+ ext.cross_compiling do |spec|
33
+ # remove things not needed for precompiled gems
34
+ spec.dependencies.reject! { |dep| dep.name == 'mini_portile2' }
35
+ spec.files.reject! { |file| File.fnmatch?("*.tar.gz", file) }
36
+ end
37
+ end
38
+
39
+ namespace "gem" do
40
+ cross_platforms.each do |platform|
41
+ desc "build native gem for #{platform}"
42
+ task platform do
43
+ RakeCompilerDock.sh(<<~EOF, platform: platform)
44
+ gem install bundler --no-document &&
45
+ bundle &&
46
+ bundle exec rake gem:#{platform}:buildit
47
+ EOF
48
+ end
49
+
50
+ namespace platform do
51
+ # this runs in the rake-compiler-dock docker container
52
+ task "buildit" do
53
+ # use Task#invoke because the pkg/*gem task is defined at runtime
54
+ Rake::Task["native:#{platform}"].invoke
55
+ Rake::Task["pkg/#{rcee_precompiled_spec.full_name}-#{Gem::Platform.new(platform).to_s}.gem"].invoke
56
+ end
57
+ end
58
+ end
59
+
60
+ desc "build native gem for all platforms"
61
+ multitask "all" => [cross_platforms, "gem"].flatten
62
+ end
63
+
64
+
65
+ CLOBBER.add("ports")
66
+ CLEAN.add("{ext,lib}/**/*.{o,so}")
67
+
68
+ task build: :compile
69
+ task default: %i[clobber compile test]
@@ -0,0 +1,40 @@
1
+ require "mkmf"
2
+ require "mini_portile2"
3
+
4
+ package_root_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
5
+
6
+ RbConfig::CONFIG["CC"] = RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"] if ENV["CC"]
7
+ ENV["CC"] = RbConfig::CONFIG["CC"]
8
+
9
+ # not needed for libyaml, but generally useful to know whether we're cross-compiling
10
+ cross_build_p = enable_config("cross-build")
11
+
12
+ MiniPortile.new("yaml", "0.2.5").tap do |recipe|
13
+ recipe.files = [{
14
+ url: "https://github.com/yaml/libyaml/releases/download/0.2.5/yaml-0.2.5.tar.gz",
15
+ sha256: "c642ae9b75fee120b2d96c712538bd2cf283228d2337df2cf2988e3c02678ef4",
16
+ }]
17
+ recipe.target = File.join(package_root_dir, "ports")
18
+
19
+ # configure the environment that MiniPortile will use for subshells
20
+ ENV.to_h.dup.tap do |env|
21
+ # -fPIC is necessary for linking into a shared library
22
+ env["CFLAGS"] = [env["CFLAGS"], "-fPIC"].join(" ")
23
+ env["SUBDIRS"] = "include src" # libyaml: skip tests
24
+
25
+ recipe.configure_options += env.map { |key, value| "#{key}=#{value.strip}" }
26
+ end
27
+
28
+ unless File.exist?(File.join(recipe.target, recipe.host, recipe.name, recipe.version))
29
+ recipe.cook
30
+ end
31
+
32
+ recipe.activate
33
+ pkg_config(File.join(recipe.path, "lib", "pkgconfig", "yaml-0.1.pc"))
34
+ end
35
+
36
+ unless have_library("yaml", "yaml_get_version", "yaml.h")
37
+ abort("\nERROR: *** could not find libyaml development environment ***\n\n")
38
+ end
39
+
40
+ create_makefile("rcee/precompiled/precompiled")
@@ -0,0 +1,25 @@
1
+ #include "precompiled.h"
2
+
3
+ VALUE rb_mRCEE;
4
+ VALUE rb_mPrecompiled;
5
+ VALUE rb_cPrecompiledExtension;
6
+
7
+ static VALUE
8
+ rb_precompiled_extension_class_do_something(VALUE self)
9
+ {
10
+ int major, minor, patch;
11
+
12
+ yaml_get_version(&major, &minor, &patch);
13
+
14
+ return rb_sprintf("libyaml version %d.%d.%d", major, minor, patch);
15
+ }
16
+
17
+ void
18
+ Init_precompiled(void)
19
+ {
20
+ rb_mRCEE = rb_define_module("RCEE");
21
+ rb_mPrecompiled = rb_define_module_under(rb_mRCEE, "Precompiled");
22
+ rb_cPrecompiledExtension = rb_define_class_under(rb_mPrecompiled, "Extension", rb_cObject);
23
+ rb_define_singleton_method(rb_cPrecompiledExtension, "do_something",
24
+ rb_precompiled_extension_class_do_something, 0);
25
+ }
@@ -0,0 +1,7 @@
1
+ #ifndef PRECOMPILED_H
2
+ #define PRECOMPILED_H 1
3
+
4
+ #include "ruby.h"
5
+ #include "yaml.h"
6
+
7
+ #endif /* PRECOMPILED_H */
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RCEE
4
+ module Precompiled
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "precompiled/version"
4
+
5
+ begin
6
+ # load the precompiled extension file
7
+ ruby_version = /(\d+\.\d+)/.match(::RUBY_VERSION)
8
+ require_relative "precompiled/#{ruby_version}/precompiled"
9
+ rescue LoadError
10
+ # fall back to the extension compiled upon installation.
11
+ # use "require" instead of "require_relative" because non-native gems will place C extension files
12
+ # in Gem::BasicSpecification#extension_dir after compilation (during normal installation), which
13
+ # is in $LOAD_PATH but not necessarily relative to this file
14
+ # (see https://github.com/sparklemotion/nokogiri/issues/2300 for more)
15
+ require "rcee/precompiled/precompiled"
16
+ end
17
+
18
+ module RCEE
19
+ module Precompiled
20
+ class Error < StandardError; end
21
+ # Your code goes here...
22
+ end
23
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/rcee/precompiled/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rcee_precompiled"
7
+ spec.version = RCEE::Precompiled::VERSION
8
+ spec.authors = ["Mike Dalessio"]
9
+ spec.email = ["mike.dalessio@gmail.com"]
10
+
11
+ spec.summary = "Example gem demonstrating a basic C extension."
12
+ spec.description = "Part of a project to explain how Ruby C extensions work."
13
+ spec.homepage = "https://github.com/flavorjones/ruby-c-extensions-explained"
14
+ spec.required_ruby_version = ">= 2.5.0"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = [
20
+ ".gitignore",
21
+ "Gemfile",
22
+ "README.md",
23
+ "Rakefile",
24
+ "ext/precompiled/extconf.rb",
25
+ "ext/precompiled/precompiled.c",
26
+ "ext/precompiled/precompiled.h",
27
+ "lib/rcee/precompiled.rb",
28
+ "lib/rcee/precompiled/version.rb",
29
+ "ports/archives/yaml-0.2.5.tar.gz",
30
+ "rcee_precompiled.gemspec",
31
+ ]
32
+
33
+ spec.bindir = "exe"
34
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
35
+ spec.require_paths = ["lib"]
36
+ spec.extensions = ["ext/precompiled/extconf.rb"]
37
+
38
+ spec.add_dependency "mini_portile2"
39
+
40
+ # For more information and examples about making a new gem, checkout our
41
+ # guide at: https://bundler.io/guides/creating_gem.html
42
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rcee_precompiled
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: x86_64-linux
6
+ authors:
7
+ - Mike Dalessio
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-09-02 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Part of a project to explain how Ruby C extensions work.
14
+ email:
15
+ - mike.dalessio@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - Gemfile
22
+ - README.md
23
+ - Rakefile
24
+ - ext/precompiled/extconf.rb
25
+ - ext/precompiled/precompiled.c
26
+ - ext/precompiled/precompiled.h
27
+ - lib/rcee/precompiled.rb
28
+ - lib/rcee/precompiled/2.5/precompiled.so
29
+ - lib/rcee/precompiled/2.6/precompiled.so
30
+ - lib/rcee/precompiled/2.7/precompiled.so
31
+ - lib/rcee/precompiled/3.0/precompiled.so
32
+ - lib/rcee/precompiled/version.rb
33
+ - rcee_precompiled.gemspec
34
+ homepage: https://github.com/flavorjones/ruby-c-extensions-explained
35
+ licenses:
36
+ - MIT
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '2.5'
47
+ - - "<"
48
+ - !ruby/object:Gem::Version
49
+ version: 3.1.dev
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ requirements: []
56
+ rubygems_version: 3.2.3
57
+ signing_key:
58
+ specification_version: 4
59
+ summary: Example gem demonstrating a basic C extension.
60
+ test_files: []