nix-rpg-build 0.5.0
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 +7 -0
- data/lib/build.rb +94 -0
- data/lib/config_build.rb +125 -0
- data/lib/header.rb +39 -0
- data/lib/nix_rpg_build.rb +5 -0
- data/lib/scanner.rb +26 -0
- data/lib/version.rb +3 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 583655e080ef092848f7d83ec2e6e85ef625eb9e
|
4
|
+
data.tar.gz: c5361914e7642e2e649422d345b5ac7566c96e55
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a0ab119a8dc723f0fe0a75901517fc32d567d25e3b74aea806fda801e158dfcb5e3dd03b0ab8ab2fac8177f7ecd9a481e099a42021c6e58888c3022e49006271
|
7
|
+
data.tar.gz: 46ed43169b98bd761482103f671188e0ad04b018bc731c4f2a5eddb9dc2e07f3915bf027be9c37b8069a0bb3c27dfdadfc4dfefc3f7cb9efe230f85251c27f2a
|
data/lib/build.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module NixRPGBuild
|
4
|
+
class Build
|
5
|
+
# Returns a hash read in from the configuration YAML file.
|
6
|
+
attr_reader :hash
|
7
|
+
# Returns a hash for the YAML key config_out used to get data for
|
8
|
+
# configuration output data such as binaries, version numbers, package URLs,
|
9
|
+
# and bug report URLs.
|
10
|
+
attr_reader :config_out
|
11
|
+
# Returns an array for the YAML key c_flags used to get data for compiler flags.
|
12
|
+
attr_reader :c_flags
|
13
|
+
# Returns an array for the YAML key pkg_config used to get data for packages that
|
14
|
+
# the software depends.
|
15
|
+
attr_reader :pkg_config
|
16
|
+
# Returns a string with the name of the header file with the configuration macros.
|
17
|
+
attr_reader :config_header
|
18
|
+
# Returns a hash for the YAML key complier_opts used to get data for compiler options.
|
19
|
+
# including the complier being used(gcc, clang etc.).
|
20
|
+
attr_reader :complier_opts
|
21
|
+
|
22
|
+
# A hash with a value that is an array to binaries.
|
23
|
+
# @see Build#config_out
|
24
|
+
attr_reader :bins
|
25
|
+
# A hash with a value that is an array to versions numbers of the binaries.
|
26
|
+
# @see Build#config_out
|
27
|
+
attr_reader :versions
|
28
|
+
# A hash with a value that is an array to package urls of the binaries.
|
29
|
+
# @see Build#config_out
|
30
|
+
attr_reader :package_urls
|
31
|
+
# A hash with a value that is an array to issues urls of the binaries.
|
32
|
+
# @see Build#config_out
|
33
|
+
attr_reader :issues_urls
|
34
|
+
|
35
|
+
# A hash with a value that is an array to pkg-config libs & flags.
|
36
|
+
# @see Build#complier_opts
|
37
|
+
attr_reader :pkgc
|
38
|
+
# A hash with a value that is an array to include header files.
|
39
|
+
# @see Build#complier_opts
|
40
|
+
attr_reader :include
|
41
|
+
# A hash with a value that is an array to libs.
|
42
|
+
# @see Build#complier_opts
|
43
|
+
attr_reader :libs
|
44
|
+
# A hash with a value that is an array to source code path.
|
45
|
+
# @see Build#complier_opts
|
46
|
+
attr_reader :src
|
47
|
+
|
48
|
+
# Executes a system command. It returns true if the command is succesful.
|
49
|
+
# It returns false if the command execution fails or gets a non zero exit
|
50
|
+
# status. If the former is true then the exit status in the built in global
|
51
|
+
# variable $? is printed to stdout. $? is either nil or Process::Status and
|
52
|
+
# in this case it will be Process::Status so it can used as needed following
|
53
|
+
# a failed execution.
|
54
|
+
#
|
55
|
+
# @param exec_str [String] the system command string.
|
56
|
+
# @return [Bool] true or false.
|
57
|
+
def self.exec(exec_str)
|
58
|
+
status = system(exec_str)
|
59
|
+
|
60
|
+
case status
|
61
|
+
when nil
|
62
|
+
puts $?
|
63
|
+
return false
|
64
|
+
when false
|
65
|
+
return status
|
66
|
+
else
|
67
|
+
return true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def initialize(config_yml)
|
72
|
+
output = File.new(config_yml, 'r')
|
73
|
+
@hash = YAML.load(output.read)
|
74
|
+
output.close
|
75
|
+
|
76
|
+
@config_out = @hash["config_out"]
|
77
|
+
@c_flags = @hash["c_flags"]
|
78
|
+
@config_header = @hash["config_header"]
|
79
|
+
@pkg_config = @hash["pkg_config"]
|
80
|
+
@config_files = @hash["config_files"]
|
81
|
+
@complier_opts = @hash["complier_opts"]
|
82
|
+
|
83
|
+
@bins = @config_out["bins"]
|
84
|
+
@versions = @config_out["versions"]
|
85
|
+
@package_urls = @config_out["package_urls"]
|
86
|
+
@issues_urls = @config_out["issues_urls"]
|
87
|
+
|
88
|
+
@pkgc = @complier_opts["pkg_config"]
|
89
|
+
@include = @complier_opts["include"]
|
90
|
+
@libs = @complier_opts["libs"]
|
91
|
+
@src = @complier_opts["src"]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
data/lib/config_build.rb
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
module NixRPGBuild
|
2
|
+
class Config_Build < Build
|
3
|
+
# The string with the compiler options.
|
4
|
+
attr_reader :build_str
|
5
|
+
# If true(default) then -g is passed into #build_str to include debuging data.
|
6
|
+
# So it can be used with GDB for debugging.
|
7
|
+
attr_accessor :debug_mode
|
8
|
+
def initialize(config_yml)
|
9
|
+
super(config_yml)
|
10
|
+
|
11
|
+
@build_str = "gcc "
|
12
|
+
@debug_mode = true
|
13
|
+
end
|
14
|
+
|
15
|
+
# If complier_opts includes the the passed in key than is yields what
|
16
|
+
# whatever is in the code block.
|
17
|
+
#
|
18
|
+
# @param key [String] complier_opts key to test.
|
19
|
+
# @yield [] Actions to follow .
|
20
|
+
# @return [Nil]
|
21
|
+
def if_include(key)
|
22
|
+
yield if @complier_opts.keys.include?(key)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Sets each C flag to build_str from c_flags.
|
26
|
+
#
|
27
|
+
# @return [Nil]
|
28
|
+
# @see Build#c_flags
|
29
|
+
# @see #build_str
|
30
|
+
def set_c_flags
|
31
|
+
@c_flags.each do |i|
|
32
|
+
build_str.concat("#{i}\s")
|
33
|
+
end
|
34
|
+
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
|
38
|
+
# Sets each include path to build_str from c_flags.
|
39
|
+
#
|
40
|
+
# @return [Nil]
|
41
|
+
# @see Build#include
|
42
|
+
# @see #build_str
|
43
|
+
def set_include_paths
|
44
|
+
if_include("include") do
|
45
|
+
inc = 0
|
46
|
+
|
47
|
+
@include.each do |l|
|
48
|
+
build_str.concat("-I"+@include[inc] + "\s")
|
49
|
+
inc += 1
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
|
56
|
+
# Sets a source path to build_str from src.
|
57
|
+
#
|
58
|
+
# @param src_index [Fixnum] the source in the src array.
|
59
|
+
# @return [Nil]
|
60
|
+
# @see Build#src
|
61
|
+
# @see #build_str
|
62
|
+
def set_src_path(src_index)
|
63
|
+
if debug_mode
|
64
|
+
build_str.concat("-g #{@src[src_index]} -o\s")
|
65
|
+
else
|
66
|
+
build_str.concat("#{@src[src_index]} -o\s")
|
67
|
+
end
|
68
|
+
|
69
|
+
nil
|
70
|
+
end
|
71
|
+
|
72
|
+
# Sets an output(executable/binary) to build_str from @bins.
|
73
|
+
#
|
74
|
+
# @param bins_index [Fixnum] the binary in the bins array.
|
75
|
+
# @return [Nil]
|
76
|
+
# @see Build#bins
|
77
|
+
# @see #build_str
|
78
|
+
def set_output(bins_index)
|
79
|
+
build_str.concat("#{@bins[bins_index]}\s")
|
80
|
+
|
81
|
+
nil
|
82
|
+
end
|
83
|
+
|
84
|
+
# Sets each library to build_str from libs.
|
85
|
+
#
|
86
|
+
# @return [Nil]
|
87
|
+
# @see Build#libs
|
88
|
+
# @see #build_str
|
89
|
+
def set_libs
|
90
|
+
if_include("libs") do
|
91
|
+
inc = 0
|
92
|
+
|
93
|
+
@libs.each do |l|
|
94
|
+
if l.include?(".a") || l.include?(".so")
|
95
|
+
build_str.concat(@libs[inc] + "\s")
|
96
|
+
else
|
97
|
+
build_str.concat("-l"+@libs[inc] + "\s")
|
98
|
+
end
|
99
|
+
inc += 1
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
nil
|
104
|
+
end
|
105
|
+
|
106
|
+
# Sets each package to build_str from pkgc.
|
107
|
+
#
|
108
|
+
# @return [Nil]
|
109
|
+
# @see Build#pkgc
|
110
|
+
# @see #build_str
|
111
|
+
def set_pkg_config
|
112
|
+
if_include("pkg_config") do
|
113
|
+
build_str.concat("`pkg-config --cflags --libs ")
|
114
|
+
|
115
|
+
@pkgc.each do |p|
|
116
|
+
build_str.concat("#{p}" + "\s")
|
117
|
+
end
|
118
|
+
|
119
|
+
build_str.concat "`"
|
120
|
+
end
|
121
|
+
|
122
|
+
nil
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
data/lib/header.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module NixRPGBuild
|
2
|
+
class Header < Build
|
3
|
+
# An array of macros to write to the configuration header file.
|
4
|
+
attr_accessor :macros
|
5
|
+
def initialize(config_yml)
|
6
|
+
super(config_yml)
|
7
|
+
@macros = []
|
8
|
+
end
|
9
|
+
|
10
|
+
# Writes a configuration header file.
|
11
|
+
#
|
12
|
+
# @return [Nil]
|
13
|
+
def write
|
14
|
+
@header = File.new(@config_header, 'w')
|
15
|
+
|
16
|
+
@bins.each_index do |i|
|
17
|
+
@header.puts "/* Name of package */"
|
18
|
+
@header.puts "#define " + @macros[i] + "\s" + "\"#{@bins[i]}\"\n\n"
|
19
|
+
end
|
20
|
+
|
21
|
+
@versions.each_index do |i|
|
22
|
+
@header.puts "/* Version number of package */"
|
23
|
+
@header.puts "#define " + @macros[i] + "_VERSION" + "\s" + "\"#{@versions[i]}\"\n\n"
|
24
|
+
end
|
25
|
+
|
26
|
+
@package_urls.each_index do |i|
|
27
|
+
@header.puts "/* The home page for this package. */"
|
28
|
+
@header.puts "#define " + @macros[i] + "_PKG_URL" + "\s" + "\"#{@package_urls[i]}\"\n\n"
|
29
|
+
end
|
30
|
+
|
31
|
+
@issues_urls.each_index do |i|
|
32
|
+
@header.puts "/* The address where bug reports for this package should be sent. */"
|
33
|
+
@header.puts "#define " + @macros[i] + "_ISSUES_URL" + "\s" + "\"#{@issues_urls[i]}\"\n\n"
|
34
|
+
end
|
35
|
+
|
36
|
+
@header.close
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/scanner.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module NixRPGBuild
|
2
|
+
class Scanner < Build
|
3
|
+
def initialize(config_yml)
|
4
|
+
super(config_yml)
|
5
|
+
|
6
|
+
@pkg_name = []
|
7
|
+
end
|
8
|
+
|
9
|
+
# Checks the system for packages needed as dependencies. It uses pkg-config
|
10
|
+
# to do this.
|
11
|
+
#
|
12
|
+
# @return [Nil]
|
13
|
+
def scan
|
14
|
+
@pkg_config.each do |i|
|
15
|
+
puts "checking for #{i}"
|
16
|
+
@pkg_name.push(i)
|
17
|
+
end
|
18
|
+
|
19
|
+
@pkg_name.each do |i|
|
20
|
+
Build.exec("pkg-config --print-errors --exists '#{i}'")
|
21
|
+
end
|
22
|
+
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nix-rpg-build
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ralph Desir(Mav7)
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.9'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 5.9.1
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '5.9'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 5.9.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
description: A gem for implementing A build system for nix-rpg.
|
48
|
+
email: gehirnmav7@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- lib/build.rb
|
54
|
+
- lib/config_build.rb
|
55
|
+
- lib/header.rb
|
56
|
+
- lib/nix_rpg_build.rb
|
57
|
+
- lib/scanner.rb
|
58
|
+
- lib/version.rb
|
59
|
+
homepage:
|
60
|
+
licenses:
|
61
|
+
- GPL-2.0
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.5.1
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: A build system for nix-rpg.
|
83
|
+
test_files: []
|