File: Rakefile

package info (click to toggle)
ruby-libxml 3.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 3,040 kB
  • sloc: xml: 18,263; ansic: 8,344; ruby: 6,987; makefile: 3
file content (91 lines) | stat: -rw-r--r-- 2,474 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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
88
89
90
91
#!/usr/bin/env ruby

require "rubygems"
require "rake/extensiontask"
require "rake/testtask"
require "rubygems/package_task"
require "rdoc/task"
require "yaml"

GEM_NAME = "libxml-ruby"
SO_NAME  = "libxml_ruby"

# Read the spec file
spec = Gem::Specification.load("#{GEM_NAME}.gemspec")

task :default => [:test]

# Setup compile tasks
if RUBY_PLATFORM.match(/mswin32|mswin64|mingw32/)
  Rake::ExtensionTask.new do |ext|
    ext.gem_spec = spec
    ext.name = SO_NAME
    ext.ext_dir = "ext/libxml"
    ext.lib_dir = "lib/#{RUBY_VERSION.sub(/\.\d$/, '')}"
    ext.config_options << "--with-xml2-include=C:/msys64/mingw64/include/libxml2"
  end
else
  Rake::ExtensionTask.new do |ext|
    ext.gem_spec = spec
    ext.name = SO_NAME
    ext.ext_dir = "ext/libxml"
    ext.lib_dir = "lib/#{RUBY_VERSION.sub(/\.\d$/, '')}"
    ext.config_options << "--with-xml2-include=/usr/include/libxml2"
  end
end

# Setup generic gem
Gem::PackageTask.new(spec) do |pkg|
  pkg.package_dir = 'pkg'
  pkg.need_tar    = false
end

# Setup Windows Gem
if RUBY_PLATFORM.match(/mswin32|mswin64|mingw32/)
  binaries = (FileList['lib/**/*.so',
                       'lib/**/*dll'])

  # Windows specification
  win_spec = spec.clone
  win_spec.platform = Gem::Platform::CURRENT
  win_spec.files += binaries.to_a
  win_spec.instance_variable_set(:@cache_file, nil)

  # Unset extensions
  win_spec.extensions = nil

  # Rake task to build the windows package
  Gem::PackageTask.new(win_spec) do |pkg|
    pkg.package_dir = 'pkg'
    pkg.need_tar = false
  end
end

# RDoc Task
desc 'Generate rdoc documentation'
RDoc::Task.new("rdoc") do |rdoc|
  rdoc.rdoc_dir = 'rdoc'
  rdoc.title    = 'LibXML'
  rdoc.generator = 'hanna'

  # Show source inline with line numbers
  rdoc.options << '--line-numbers'
  rdoc.options << '--charset=utf-8'
  # Make the readme file the start page for the generated html
  rdoc.main = 'README.rdoc'
  rdoc.rdoc_files.include('doc/*.rdoc',
                          'ext/**/libxml.c',
                          'ext/**/ruby_xml.c',
                          'ext/**/*.c',
                          'lib/**/*.rb',
                          'README.rdoc',
                          'HISTORY',
                          'LICENSE')
end

# Test Task
Rake::TestTask.new do |t|
  t.libs << "test"
  t.test_files = FileList['test/test*.rb'] - ['test/test_suite.rb']
  t.verbose = true
end