gear 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 9ff4a42d8882485107f6cd2276dc24e6d74c4b11
4
- data.tar.gz: 2cdd3cce719513f2e8b38f394366b5c2314ae64b
3
+ metadata.gz: 97e26787777b28a03c1a1293077cc855cb998e56
4
+ data.tar.gz: 4fd29a9e4c0948802cc6226dd29256a9dee0406f
5
5
  SHA512:
6
- metadata.gz: 532fbc434c6eb50279b425087a3698c3bba358cc457bed986ffc465544f741c1576a239b8efe2eea3bfbc7d2e354df4a121e2b8d1816315e6187ee17465b025c
7
- data.tar.gz: d663bc3f3d05ca9b8fa1a47f4818c7972f3cb9c3d8aa793ce89368982444c87489f0befa07d27219484836d816acd005dc24809cd7f87423cb72147525eda09f
6
+ metadata.gz: 06646f36476fcf108f0bb4c8247d90e528b751aec5f4e1c2ee8a0139af3eddf94d38ff394c119c619c7508a92d8c8de46912c19c0ee1e5fbc127e0d9b468af89
7
+ data.tar.gz: ac8b6b443779b00bfc4fac4d5935122dd1a029ef3ae20a6ad240a575ccb32173b9805b0449c10cb3aa0a07958789fae6c395c1b6847c7d613bb972ab15c298ef
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'gear'
3
- s.version = '0.0.1'
3
+ s.version = '0.0.2'
4
4
  s.license = 'GPL-3'
5
5
  s.summary = 'modular dependency build system for native extensions'
6
6
  s.description = 'gear provides a modular framework to encapsulate build tasks for native ' +
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
8
8
  s.authors = ['Rei Kagetsuki']
9
9
  s.email = 'zero@genshin.org'
10
10
  s.files = ['gear.gemspec'] +
11
- Dir.glob("lib")
12
- s.require_path = 'lib'
11
+ Dir.glob("lib/**/*.rb")
12
+ s.require_paths = ['lib']
13
13
  s.homepage = 'https://github.com/Kagetsuki/gear'
14
14
 
15
15
  s.add_dependency 'git'
@@ -0,0 +1,174 @@
1
+ require 'git'
2
+
3
+ class Gear
4
+ #======== attribute list ========#
5
+ # obtained: tracking flag indicating if sources have been obtained
6
+ # built: tracking flag indicating if the build has been completed
7
+ # installed: tracking flag indicating if installation/vendorization completed
8
+ # checked: tracking flag indicating if an installation check succeeded
9
+ # headers: an array of headers to check for (in include path)
10
+ # libs: an array of libs to check for
11
+ # build_path: the path where the build will occur
12
+ attr_reader :obtained, :built, :installed, :checked,
13
+ :headers, :libs, :build_path
14
+
15
+ @@install_path = "#{Dir.pwd}/vendor"
16
+ @@initialized = false
17
+
18
+ @headers = []
19
+ @libs = []
20
+
21
+ class << self
22
+ attr_accessor :gear_name
23
+ end
24
+
25
+ def self.install_path(new_path = nil)
26
+ @@install_path = new_path unless new_path.nil?
27
+ @@install_path
28
+ end
29
+
30
+ def self.initialized?
31
+ @@initialized
32
+ end
33
+
34
+ # define the default name
35
+ # *OVERRIDE* with the name of the Gear/repo/project
36
+ @gear_name = 'Gear'
37
+
38
+ def name()
39
+ self.class.gear_name
40
+ end
41
+
42
+ def target(new_target = nil)
43
+ @@install_path = new_target unless new_target.nil?
44
+ @@install_path
45
+ end
46
+
47
+ def initialize()
48
+ @obtained = @built = @installed = @checked = false
49
+ @build_path = _root_dir() + "/build/#{name()}"
50
+ _setup_paths()
51
+
52
+ @@initialized = true
53
+ end
54
+
55
+ def obtain()
56
+ STDERR.puts "WARNING: Gear did not override obtain method. No sources were obtained."
57
+ @obtained = false
58
+ return false
59
+ end
60
+
61
+ def build()
62
+ STDERR.puts "WARNING: Gear did not override build method. Nothing was built."
63
+ @built = false
64
+ return false
65
+ end
66
+
67
+ def install()
68
+ STDERR.puts "WARNING: Gear did not override install method. Nothing has been installed."
69
+ @installed = false
70
+ return false
71
+ end
72
+
73
+ def check()
74
+ STDERR.puts "WARNING: Gear did not override check method. Status is unknown."
75
+ @checked = false
76
+ return false
77
+ end
78
+
79
+ def engage()
80
+ !check && # bail if already installed
81
+ obtain &
82
+ build &&
83
+ install &&
84
+ check
85
+ end
86
+
87
+ def remove()
88
+ FileUtils.rm_rf("#{@build_path}")
89
+ @obtained = false
90
+ return true
91
+ end
92
+
93
+ def uninstall()
94
+ # set @installed to false on a succesfully uninstall
95
+ STDERR.puts "WARNING: Gear did not override uninstall method."
96
+ return false
97
+ end
98
+
99
+ def disengage()
100
+ uninstall &&
101
+ remove
102
+ end
103
+
104
+ #======== obtain helpers ========#
105
+ def git_obtain(repository, branch)
106
+ begin
107
+ if Dir.exist? build_path
108
+ @git = Git.open(build_path)
109
+ @git.reset("HEAD", hard: true)
110
+ @git.clean(force: true, d: true, x:true)
111
+ else
112
+ @git = Git.clone(repository, build_path)
113
+ end
114
+ rescue e
115
+ STDERR.puts "Could not obtain repository #{repository}.\n#{e}"
116
+ @obtained = false
117
+ return false
118
+ end
119
+
120
+ @git.checkout(branch)
121
+ @git.pull
122
+
123
+ Dir.chdir(@build_path)
124
+ `git submodule update --init --recursive`
125
+
126
+ @obtained = true
127
+ return true
128
+ end
129
+
130
+ def github_obtain(user, repository, branch = 'master')
131
+ git_obtain("https://github.com/#{user}/#{repository}.git", branch)
132
+ end
133
+
134
+ def std_config_make(flags = "")
135
+ Dir.chdir(@build_path)
136
+ `autoconf` if !File.exist? 'configure'
137
+ `./confirgure --prefix#{@@install_path}`
138
+ `make`
139
+ end
140
+
141
+ def std_make_install()
142
+ `make install`
143
+ @installed = true
144
+ return true
145
+ end
146
+
147
+ # Prefixes a command with the gearbox prefixed in the load path
148
+ def gear_exec(command = "")
149
+ `LD_LIBRARY_PATH=#{@@install_path}/lib:$LD_LIBRARY_PATH C_INCLUDE_PATH=#{@@install_path}/include:$C_INCLUDE_PATH PATH=#{@@install_path}/bin:$PATH #{command}`
150
+ end
151
+
152
+ private
153
+ def _root_dir()
154
+ File.expand_path('../..', __FILE__)
155
+ end
156
+
157
+ # sets up vendor/sub directories
158
+ def _setup_paths()
159
+ #puts "⚙Preparing directory structure in #{@@install_path}"
160
+ return if @@initialized
161
+ FileUtils.mkdir_p("#{@@install_path}/bin")
162
+ FileUtils.mkdir_p("#{@@install_path}/include")
163
+ FileUtils.mkdir_p("#{@@install_path}/lib")
164
+
165
+ ENV['PATH'] = (ENV['PATH'].nil? ?
166
+ "#{@@install_path}/bin" : ENV['PATH'] + ":#{@@install_path}/bin")
167
+ #ENV['C_INCLUDE_PATH'] = ENV['C_INCLUDE_PATH'].to_s + ":#{@@install_path}/include"
168
+ #ENV['CPLUS_INCLUDE_PATH'] = ENV['CPLUS_INCLUDE_PATH'].to_s + ":#{@@install_path}/include"
169
+ ENV['CPATH'] = (ENV['CPATH'].nil? ?
170
+ "#{@@install_path}/include" : ENV['CPATH'] + ":#{@@install_path}/include")
171
+ ENV['LD_LIBRARY_PATH'] = (ENV['LD_LIBRARY_PATH'].nil? ?
172
+ "#{@@install_path}/lib" : ENV['LD_LIBRARY_PATH'] + ":#{@@install_path}/lib")
173
+ end
174
+ end
@@ -0,0 +1,37 @@
1
+ require "gear"
2
+
3
+ module Gears
4
+ class APNGAsm < Gear
5
+ @gear_name = "APNGAsm"
6
+
7
+ def check()
8
+ gear_exec 'ldconfig -p | grep libapngasm'
9
+ if $?.exitstatus == 0
10
+ @checked = true
11
+ return true
12
+ end
13
+ @checked = false
14
+ return false
15
+ end
16
+
17
+ def obtain()
18
+ github_obtain('apngasm', 'apngasm')
19
+ end
20
+
21
+ def build()
22
+ Dir.chdir(@build_path)
23
+ FileUtils.mkdir_p('build') # `mkdir build`
24
+ Dir.chdir('build') # `cd build`
25
+ gear_exec 'cmake -DCMAKE_INSTALL_PREFIX:PATH=#{@@install_path} ..'
26
+ gear_exec 'make'
27
+ @built = true
28
+ return true
29
+ end
30
+
31
+ def install()
32
+ std_make_install
33
+ end
34
+
35
+ #TODO uninstall
36
+ end
37
+ end
@@ -0,0 +1,39 @@
1
+ require "gear"
2
+
3
+ module Gears
4
+ class Boost < Gear
5
+ @gear_name = "Boost"
6
+
7
+ def check()
8
+ gear_exec 'ldconfig -p | grep libboost'
9
+ if $?.exitstatus == 0
10
+ @checked = true
11
+ return true
12
+ end
13
+ @checked = false
14
+ return false
15
+ end
16
+
17
+ def obtain()
18
+ github_obtain('boostorg', 'boost')
19
+ end
20
+
21
+ def build()
22
+ Dir.chdir(@build_path)
23
+ `sh bootstrap.sh --without-libraries=python --prefix=#{@@install_path}`
24
+ `sh b2 headers`
25
+ `sh b2`
26
+ `sh b2 install --prefix=#{@@install_path}`
27
+ @built = true
28
+ return true
29
+ end
30
+
31
+ def install()
32
+ std_make_install
33
+ end
34
+
35
+ def uninstall()
36
+ #TODO
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,43 @@
1
+ require "gear"
2
+
3
+ module Gears
4
+ class SWIG < Gear
5
+ @gear_name = "SWIG"
6
+
7
+ def check()
8
+ gear_exec 'swig -version'
9
+ if $?.exitstatus == 0
10
+ @checked = true
11
+ return true
12
+ end
13
+ @checked = false
14
+ return false
15
+ end
16
+
17
+ def obtain()
18
+ github_obtain('swig', 'swig')
19
+ end
20
+
21
+ def build()
22
+ Dir.chdir(@build_path)
23
+ `sh autogen.sh`
24
+ `sh configure --prefix=#{@@install_path}`
25
+ `make`
26
+ @built = true
27
+ return true
28
+ end
29
+
30
+ def install()
31
+ std_make_install
32
+ end
33
+
34
+ def uninstall()
35
+ FileUtils.rm_f("#{@@install_path}/bin/swig")
36
+ FileUtils.rm_f("#{@@install_path}/bin/ccache-swig")
37
+ FileUtils.rm_rf("#{@@install_path}/share/swig")
38
+ FileUtils.rm_f("#{@@install_path}/share/man/man1/ccache-swig.1")
39
+ @installed = false
40
+ return true
41
+ end
42
+ end
43
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gear
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rei Kagetsuki
@@ -32,6 +32,10 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - gear.gemspec
35
+ - lib/gear.rb
36
+ - lib/gears/apngasm.rb
37
+ - lib/gears/boost.rb
38
+ - lib/gears/swig.rb
35
39
  homepage: https://github.com/Kagetsuki/gear
36
40
  licenses:
37
41
  - GPL-3