Class: Xezat::Generator::Pkgconfig
- Inherits:
-
Object
- Object
- Xezat::Generator::Pkgconfig
show all
- Includes:
- Xezat
- Defined in:
- lib/xezat/generator/pkgconfig.rb
Constant Summary
Constants included
from Xezat
DATA_DIR, INI_FILE, LOG, REPOSITORY_DIR, ROOT_DIR, TEMPLATE_DIR, VERSION
Instance Method Summary
collapse
Methods included from Xezat
#config, #packages, #variables
Constructor Details
#initialize(options, cygport) ⇒ Pkgconfig
Returns a new instance of Pkgconfig.
17
18
19
20
|
# File 'lib/xezat/generator/pkgconfig.rb', line 17
def initialize(options, cygport)
@options = options
@cygport = cygport
end
|
Instance Method Details
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/xezat/generator/pkgconfig.rb', line 63
def append_commands_to_autotools(variables)
srcdir = variables[:CYGCONF_SOURCE] || variables[:S]
pn = variables[:PN]
configure_ac = File.expand_path(File.join(srcdir, 'configure.ac'))
configure_ac = File.expand_path(File.join(srcdir, 'configure.in')) unless File.exist?(configure_ac)
raise AutotoolsFileNotFoundError unless File.exist?(configure_ac)
original_ac = File.read(configure_ac)
unless original_ac =~ /#{pn}.pc/
original_ac.gsub!(/(AC_CONFIG_FILES\(\[)/, '\1' + "#{pn}.pc ")
File.atomic_write(configure_ac) do |fa|
fa.write(original_ac)
makefile_am = File.expand_path(File.join(srcdir, 'Makefile.am'))
raise AutotoolsFileNotFoundError unless File.exist?(makefile_am)
unless File.read(makefile_am) =~ /pkgconfig_DATA/
commands_am = File.read(File.expand_path(File.join(TEMPLATE_DIR, 'Makefile.am')))
File.atomic_open(makefile_am, 'a') do |fm|
fm.write(commands_am)
end
end
end
end
end
|
#append_commands_to_cmakelists(variables) ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'lib/xezat/generator/pkgconfig.rb', line 48
def append_commands_to_cmakelists(variables)
srcdir = variables[:CYGCMAKE_SOURCE] || variables[:S]
cmakelists = File.expand_path(File.join(srcdir, 'CMakeLists.txt'))
unless File.read(cmakelists) =~ /DESTINATION \$\{CMAKE_INSTALL_PREFIX\}\/lib\/pkgconfig/
File.atomic_open(cmakelists, 'a') do |f|
f.write(get_cmakelists(variables))
end
end
end
|
#generate ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/xezat/generator/pkgconfig.rb', line 22
def generate
vars = variables(@cygport)
generate_pkg_config(vars, @options)
if vars[:_cmake_CYGCLASS_]
append_commands_to_cmakelists(vars)
else
append_commands_to_autotools(vars)
end
end
|
#generate_pkg_config(variables, options) ⇒ Object
33
34
35
36
37
38
39
40
41
|
# File 'lib/xezat/generator/pkgconfig.rb', line 33
def generate_pkg_config(variables, options)
srcdir = variables[:CYGCMAKE_SOURCE] || variables[:S]
pn = variables[:PN]
pc = File.expand_path(File.join(srcdir, "#{pn}.pc.in"))
raise UnregeneratableConfigurationError, "#{pn}.pc.in already exists" if (File.exist?(pc) && !options['overwrite'])
File.atomic_write(pc) do |f|
f.write(get_pkg_config(variables))
end
end
|
#get_cmakelists(variables) ⇒ Object
58
59
60
61
|
# File 'lib/xezat/generator/pkgconfig.rb', line 58
def get_cmakelists(variables)
erb = File.expand_path(File.join(TEMPLATE_DIR, 'cmake.erb'))
ERB.new(File.readlines(erb).join(nil), nil, '%-').result(binding)
end
|
#get_pkg_config(variables) ⇒ Object
43
44
45
46
|
# File 'lib/xezat/generator/pkgconfig.rb', line 43
def get_pkg_config(variables)
erb = File.expand_path(File.join(TEMPLATE_DIR, 'pkgconfig.erb'))
ERB.new(File.readlines(erb).join(nil), nil, '%-').result(binding)
end
|