pkg-config 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/NEWS +5 -0
  2. data/Rakefile +5 -0
  3. data/lib/pkg-config.rb +33 -8
  4. metadata +4 -4
data/NEWS CHANGED
@@ -1,5 +1,10 @@
1
1
  = NEWS
2
2
 
3
+ == 1.0.3 - 2010/09/07
4
+
5
+ * add path and override_variable customize API.
6
+ * support description.
7
+
3
8
  == 1.0.2 - 2010/09/02
4
9
 
5
10
  * fix packaing miss.
data/Rakefile CHANGED
@@ -48,3 +48,8 @@ project = Hoe.spec('pkg-config') do |project|
48
48
  project.changes = news.read.split(/^== .*$/)[1].strip
49
49
  project.description = "A pkg-cofnig implementation by Ruby"
50
50
  end
51
+
52
+ desc "tag the current veresion"
53
+ task :tag do
54
+ sh("git", "tag", "-a", version.to_s, "-m", "release #{version}!!!")
55
+ end
data/lib/pkg-config.rb CHANGED
@@ -23,14 +23,17 @@ require 'pathname'
23
23
 
24
24
  class PackageConfig
25
25
  attr_accessor :msvc_syntax
26
- def initialize(name, path=nil, msvc_syntax=false)
26
+ def initialize(name, options={})
27
27
  @name = name
28
- @path = path || ENV["PKG_CONFIG_PATH"]
28
+ @options = options
29
+ @path = @options[:path] || ENV["PKG_CONFIG_PATH"]
29
30
  @path = [@path, guess_default_path].compact.join(separator)
30
- @msvc_syntax = msvc_syntax
31
+ @msvc_syntax = @options[:msvc_syntax]
31
32
  @variables = @declarations = nil
32
33
  override_variables = with_config("override-variables", "")
33
34
  @override_variables = parse_override_variables(override_variables)
35
+ default_override_variables = @options[:override_variables] || {}
36
+ @override_variables = default_override_variables.merge(@override_variables)
34
37
  end
35
38
 
36
39
  def exist?
@@ -73,6 +76,10 @@ class PackageConfig
73
76
  declaration("Version")
74
77
  end
75
78
 
79
+ def description
80
+ declaration("Description")
81
+ end
82
+
76
83
  def variable(name)
77
84
  parse_pc if @variables.nil?
78
85
  expand_value(@override_variables[name] || @variables[name])
@@ -93,12 +100,12 @@ class PackageConfig
93
100
  end
94
101
 
95
102
  def separator
96
- File.expand_path(".").index(":") ? ";" : ":"
103
+ File::PATH_SEPARATOR
97
104
  end
98
105
 
99
106
  def collect_cflags
100
107
  all_cflags = (requires_private + requires.reverse).collect do |package|
101
- self.class.new(package, @path, @msvc_syntax).cflags
108
+ self.class.new(package, @options).cflags
102
109
  end
103
110
  all_cflags = [declaration("Cflags")] + all_cflags
104
111
  all_cflags = all_cflags.join(" ").gsub(/-I /, '-I').split.uniq
@@ -116,7 +123,7 @@ class PackageConfig
116
123
 
117
124
  def collect_libs
118
125
  all_libs = requires.collect do |package|
119
- self.class.new(package, @path, @msvc_syntax).libs
126
+ self.class.new(package, @options).libs
120
127
  end
121
128
  all_libs = [declaration("Libs")] + all_libs
122
129
  all_libs = all_libs.join(" ").gsub(/-([Ll]) /, '\1').split.uniq
@@ -251,15 +258,29 @@ class PackageConfig
251
258
  end
252
259
 
253
260
  module PKGConfig
254
- VERSION = "1.0.2"
261
+ VERSION = "1.0.3"
262
+
263
+ @@path = nil
264
+ @@override_variables = {}
255
265
 
256
266
  module_function
267
+ def add_path(path)
268
+ @@path = [path, @@path || ''].join(File::PATH_SEPARATOR)
269
+ end
270
+
271
+ def set_override_variable(key, value)
272
+ @@override_variables[key] = value
273
+ end
274
+
257
275
  def msvc?
258
276
  /mswin32/.match(RUBY_PLATFORM) and /^cl\b/.match(Config::CONFIG['CC'])
259
277
  end
260
278
 
261
279
  def package_config(package)
262
- PackageConfig.new(package, nil, msvc?)
280
+ PackageConfig.new(package,
281
+ :path => @@path,
282
+ :msvc_syntax => msvc?,
283
+ :override_variables => @@override_variables)
263
284
  end
264
285
 
265
286
  def exist?(pkg)
@@ -286,6 +307,10 @@ module PKGConfig
286
307
  package_config(pkg).version
287
308
  end
288
309
 
310
+ def description(pkg)
311
+ package_config(pkg).description
312
+ end
313
+
289
314
  def check_version?(pkg, major = 0, minor = 0, micro = 0)
290
315
  return false unless exist?(pkg)
291
316
  ver = modversion(pkg).split(".").collect{|item| item.to_i}
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pkg-config
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 2
10
- version: 1.0.2
9
+ - 3
10
+ version: 1.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kouhei Sutou
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-02 00:00:00 +09:00
18
+ date: 2010-09-07 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency