laag 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7fc52971d2115cc524c37687915f4ebc6d1c4634a4daa33949428fd17262d687
4
+ data.tar.gz: 62300ed74edd656f990c4ea48aba64f6405251a49db719f4e4f74d853e018848
5
+ SHA512:
6
+ metadata.gz: e3a6054e746b3f91f18643b217e565ae2fdabc67f1bf337c89d744ec039f96fe4157e542c8c4b04f08c214312c7d69ac33d6c2da40260e0935b2e611e518214b
7
+ data.tar.gz: f2a66b281ea07b95ad7b42dd9d310393844caaf21d6535b0b5be364435fd4a56936f4a2721051f06c4a859491d8f1cc0adfa926968c162130d61f6634fe38afb
@@ -0,0 +1 @@
1
+ *.gem
@@ -0,0 +1,22 @@
1
+
2
+ The MIT License (MIT)
3
+ Copyright © 2018 Chris Olstrom <chris@olstrom.com>
4
+ Copyright © 2018 SUSE LLC
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the “Software”), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
@@ -0,0 +1,23 @@
1
+ #+TITLE: laag - Library as a Gem
2
+ #+LATEX: \pagebreak
3
+
4
+ * Overview
5
+
6
+ ~laag~ is a library to support packaging libraries as Ruby Gems.
7
+
8
+ * Why does this exist?
9
+
10
+ Ruby is portable and readily available on all significant platforms. It has
11
+ solid tools for dependency management, versioning, and vendoring.
12
+
13
+ ~laag~ leverages these tools to provide platform-native libraries, so that
14
+ other Gems that need those libraries can be easier to install.
15
+
16
+ * License
17
+
18
+ ~laag~ is available under the [[https://tldrlegal.com/license/mit-license][MIT License]]. See ~LICENSE.txt~ for the full
19
+ text.
20
+
21
+ * Contributors
22
+
23
+ - [[https://colstrom.github.io/][Chris Olstrom]] | [[mailto:chris@olstrom.com][e-mail]] | [[https://twitter.com/ChrisOlstrom][Twitter]]
@@ -0,0 +1,16 @@
1
+
2
+ # -*- ruby -*-
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'laag'
6
+ gem.version = `git describe --tags --abbrev=0`.chomp
7
+ gem.licenses = 'MIT'
8
+ gem.authors = ['Chris Olstrom']
9
+ gem.email = 'chris@olstrom.com'
10
+ gem.homepage = 'http://colstrom.github.io/laag/'
11
+ gem.summary = 'Library as a Gem'
12
+ gem.description = 'Simplifies platform-native dependency management'
13
+
14
+ gem.files = `git ls-files -z`.split("\x0")
15
+ gem.executables = `git ls-files -z -- bin/*`.split("\x0").map { |f| File.basename(f) }
16
+ end
@@ -0,0 +1,7 @@
1
+
2
+ # -*- ruby -*-
3
+
4
+ require_relative 'laag/build_environment'
5
+ require_relative 'laag/library'
6
+ require_relative 'laag/platform'
7
+ require_relative 'laag/version'
@@ -0,0 +1,143 @@
1
+
2
+ # -*- ruby -*-
3
+
4
+ require 'set' # Ruby Standard Library
5
+
6
+ module LAAG
7
+ class BuildEnvironment
8
+ DEFAULT_FEATURES = Set.new %w[autoconf autoreconf configure make]
9
+
10
+ def initialize(library, **options)
11
+ @library = library
12
+ @options = options
13
+ @enabled = Set.new
14
+ @disabled = Set.new
15
+ %i[enable disable].each { |s| [*options[s]].each { |f| send s, f } }
16
+ self
17
+ end
18
+
19
+ def script(&block)
20
+ instance_eval(&block) if block_given?
21
+ end
22
+
23
+ def execute!(command, *arguments)
24
+ STDOUT.puts ' -- ' + (commandline = [command, *arguments].flatten.map(&:to_s).join(' '))
25
+
26
+ Dir.chdir(@library.source_path) do
27
+ system(commandline).tap do |success|
28
+ raise "Error: '#{commandline}' failed" unless success
29
+ end
30
+ end
31
+ end
32
+
33
+ def autoreconf!
34
+ return unless enabled?(:autoreconf) and file?('configure.ac')
35
+ execute! 'autoreconf', '--install'
36
+ end
37
+
38
+ def autogen!
39
+ return unless enabled?(:autogen) and file?('autogen.sh')
40
+ execute! './autogen.sh'
41
+ end
42
+
43
+ def configure!(*arguments)
44
+ return unless enabled?(:configure)
45
+ autogen! unless file?('configure')
46
+ autoreconf! unless file?('configure')
47
+ return unless file?('configure')
48
+ execute! './configure', configure_options(arguments)
49
+ end
50
+
51
+ def make!(*arguments, make: ENV['MAKE'] || ENV['make'] || 'make')
52
+ configure! unless file?(makefile)
53
+ return unless file?(makefile)
54
+ execute! make, "-j#{make_jobs}", arguments
55
+ end
56
+
57
+ def configure_options(arguments)
58
+ [
59
+ ("--prefix=#{@library.install_path}" unless disabled?(:prefix)),
60
+ ('--disable-dependency-tracking' unless enabled?('dependency-tracking')),
61
+ ('--enable-shared' unless disabled?(:shared)),
62
+ ('--enable-static' unless disabled?(:static)),
63
+ ('--with-pic' unless disabled?(:pic)),
64
+ *arguments
65
+ ].compact.uniq
66
+ end
67
+
68
+ def default!
69
+ make! :clean
70
+ configure!
71
+ make!
72
+ make! :install
73
+ make! :clean
74
+ end
75
+
76
+ #############
77
+ # Detection #
78
+ #############
79
+
80
+ def file?(filename)
81
+ return unless filename
82
+ File.exist? File.join(@library.source_path, filename.split('/'))
83
+ end
84
+
85
+ def makefile
86
+ RbConfig::CONFIG['MAKEFILES'].split.find { |makefile| file? makefile } || 'Makefile'
87
+ end
88
+
89
+ def make_jobs
90
+ @options.fetch(:make_jobs) do
91
+ Etc.respond_to?(:nprocessors) ? Etc.nprocessors : ''
92
+ end
93
+ end
94
+
95
+ #################
96
+ # Feature Flags #
97
+ #################
98
+
99
+ def features
100
+ DEFAULT_FEATURES
101
+ end
102
+
103
+ def disabled
104
+ @disabled - @enabled
105
+ end
106
+
107
+ def enabled
108
+ features - disabled
109
+ end
110
+
111
+ ######################
112
+ # Flag State Queries #
113
+ ######################
114
+
115
+ def enabled?(feature)
116
+ enabled.include? feature.to_s
117
+ end
118
+
119
+ def disabled?(feature)
120
+ disabled.include? feature.to_s
121
+ end
122
+
123
+ ###########################
124
+ # Flag State Manipulation #
125
+ ###########################
126
+
127
+ def enable(feature)
128
+ feature.tap { @enabled << feature.to_s }
129
+ end
130
+
131
+ def unenable(feature)
132
+ feature.tap { @enabled.delete feature.to_s }
133
+ end
134
+
135
+ def disable(feature)
136
+ feature.tap { @disabled << feature.to_s }
137
+ end
138
+
139
+ def undisable(feature)
140
+ feature.tap { @disabled.delete feature.to_s }
141
+ end
142
+ end
143
+ end
@@ -0,0 +1,44 @@
1
+
2
+ # -*- ruby -*-
3
+
4
+ require 'rbconfig' # Ruby Standard Library
5
+
6
+ module LAAG
7
+ class Library
8
+ def initialize(gem_root:, origin:, version:, **options)
9
+ @gem_root = gem_root
10
+ @origin = origin
11
+ @version = version
12
+ @options = options
13
+ self
14
+ end
15
+
16
+ attr_reader :gem_root, :origin, :version
17
+
18
+ def name
19
+ @name ||= @options.fetch(:name) { origin.split('/').last.downcase }
20
+ end
21
+
22
+ def package_prefix
23
+ @package_prefix ||= @options.fetch(:package_prefix) { 'package' }
24
+ end
25
+
26
+ def install_prefix
27
+ @install_prefix ||= @options.fetch(:install_prefix) do
28
+ File.join package_prefix, ".#{name}", version
29
+ end
30
+ end
31
+
32
+ def vendor_prefix
33
+ @vendor_prefix ||= @options.fetch(:vendor_prefix) { 'vendor' }
34
+ end
35
+
36
+ def install_path
37
+ @install_path ||= File.join(gem_root, install_prefix)
38
+ end
39
+
40
+ def source_path
41
+ @source_path ||= File.join(gem_root, vendor_prefix, @origin)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,12 @@
1
+
2
+ # -*- ruby -*-
3
+
4
+ require 'rbconfig' # Ruby Standard Library
5
+
6
+ module LAAG
7
+ module Platform
8
+ HOST_OS = RbConfig::CONFIG['host_os'].downcase
9
+ SOEXT = RbConfig::CONFIG['SOEXT'] || RbConfig::CONFIG['DLEXT']
10
+ SOGLOB = (HOST_OS =~ /darwin/) ? "*.#{SOEXT}" : "#{SOEXT}.*"
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+
2
+ # -*- ruby -*-
3
+
4
+ module LAAG
5
+ VERSION = $LOADED_FEATURES
6
+ .map { |f| f.match %r{laag-(?<version>[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+(\.pre)?)} }
7
+ .compact
8
+ .map { |gem| gem['version'] }
9
+ .uniq
10
+ .first
11
+ end
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: laag
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.4
5
+ platform: ruby
6
+ authors:
7
+ - Chris Olstrom
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-03-07 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Simplifies platform-native dependency management
14
+ email: chris@olstrom.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".gitignore"
20
+ - LICENSE.txt
21
+ - README.org
22
+ - laag.gemspec
23
+ - lib/laag.rb
24
+ - lib/laag/build_environment.rb
25
+ - lib/laag/library.rb
26
+ - lib/laag/platform.rb
27
+ - lib/laag/version.rb
28
+ homepage: http://colstrom.github.io/laag/
29
+ licenses:
30
+ - MIT
31
+ metadata: {}
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubyforge_project:
48
+ rubygems_version: 2.7.6
49
+ signing_key:
50
+ specification_version: 4
51
+ summary: Library as a Gem
52
+ test_files: []