gccxml_gem 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/Rakefile +107 -0
  2. data/gccxml.rb +60 -0
  3. metadata +52 -0
@@ -0,0 +1,107 @@
1
+ require 'rake/testtask'
2
+ require 'rdoc/task'
3
+ require 'rubygems/package_task'
4
+
5
+ PROJECT_NAME = "gccxml_gem"
6
+ GCCXML_VERSION = "0.9.3"
7
+ RUBYFORGE_USERNAME = "jameskilton"
8
+
9
+ desc "Build gccxml for this system"
10
+ task :build_gccxml => [:clean, :unpack, :build, :install]
11
+
12
+ def make_cmd
13
+ RUBY_PLATFORM =~ /mswin/ ? "mingw32-make" : "make"
14
+ end
15
+
16
+ task :unpack do
17
+ cd "ext" do
18
+ sh "tar xzvf gccxml.tar.gz"
19
+ mkdir "gccxml-build"
20
+ end
21
+ end
22
+
23
+ task :build do
24
+ install_path = File.expand_path(File.dirname(__FILE__))
25
+
26
+ platform = RUBY_PLATFORM =~ /mswin/ ? "-G \"MinGW Makefiles\"" : ""
27
+
28
+ cd "ext/gccxml-build" do
29
+ sh "cmake -DCMAKE_INSTALL_PREFIX:PATH=#{install_path} -DCMAKE_BUILD_TYPE=None #{platform} ../gccxml"
30
+ sh make_cmd
31
+ end
32
+ end
33
+
34
+ task :install do
35
+ cd "ext/gccxml-build" do
36
+ sh "#{make_cmd} install"
37
+ end
38
+
39
+ sh "chmod a+x bin/*"
40
+ sh "chmod -R a+rx share/"
41
+
42
+ cd "bin" do
43
+ `cp gccxml_cc1plus.exe gccxml_cc1plus` if File.exists?("gccxml_cc1plus.exe")
44
+ end
45
+ end
46
+
47
+ desc "Clean up everything"
48
+ task :clean do
49
+ rm_rf "ext/gccxml"
50
+ rm_rf "ext/gccxml-build"
51
+ rm_rf "bin"
52
+ rm_rf "share"
53
+ end
54
+
55
+ base_spec = lambda do |s|
56
+ s.name = PROJECT_NAME
57
+ s.version = GCCXML_VERSION
58
+ s.summary = 'Easy install for GCCXML'
59
+ s.homepage = 'http://rbplusplus.rubyforge.org/'
60
+ s.rubyforge_project = "rbplusplus"
61
+ s.author = 'Jason Roelofs'
62
+ s.email = 'jameskilton@gmail.com'
63
+
64
+ s.description = <<-END
65
+ Because GCCXML is difficult to install on all platforms,
66
+ this binary gem is provided for ease of installing
67
+ and using RbGCCXML.
68
+ END
69
+
70
+ s.require_paths = ['.']
71
+ end
72
+
73
+ binary_spec = Gem::Specification.new do |s|
74
+ base_spec.call(s)
75
+ s.platform = Gem::Platform::CURRENT
76
+
77
+ patterns = [
78
+ 'Rakefile',
79
+ '*.rb',
80
+ 'bin/*',
81
+ 'share/**/*'
82
+ ]
83
+
84
+ s.files = patterns.map {|p| Dir.glob(p) }.flatten
85
+ end
86
+
87
+ pure_ruby_spec = Gem::Specification.new do |s|
88
+ base_spec.call(s)
89
+ s.platform = Gem::Platform::RUBY
90
+
91
+ patterns = [
92
+ 'Rakefile',
93
+ '*.rb'
94
+ ]
95
+
96
+ s.files = patterns.map {|p| Dir.glob(p) }.flatten
97
+ end
98
+
99
+ desc "Build binary build of the gem"
100
+ task :binary_gem do
101
+ Gem::Builder.new(binary_spec).build
102
+ end
103
+
104
+ desc "Build pure ruby build of the gem"
105
+ task :pure_ruby_gem do
106
+ Gem::Builder.new(pure_ruby_spec).build
107
+ end
@@ -0,0 +1,60 @@
1
+ require 'rbconfig'
2
+
3
+ # This class takes care of finding and actually calling the gccxml executable,
4
+ # setting up certain use flags according to what was specified.
5
+ class GCCXML
6
+
7
+ def initialize()
8
+ @exe = find_exe.strip.chomp
9
+ @includes = []
10
+ @flags = []
11
+ end
12
+
13
+ # Add an include path for parsing
14
+ def add_include(path)
15
+ @includes << path
16
+ end
17
+
18
+ # Add extra CXXFLAGS to the command line
19
+ def add_cxxflags(flags)
20
+ @flags << flags
21
+ end
22
+
23
+ # Run gccxml on the header file(s), sending the output to the passed in
24
+ # file.
25
+ def parse(header_file, to_file)
26
+ includes = @includes.flatten.uniq.map {|i| "-I#{i.chomp}"}.join(" ").chomp
27
+ flags = @flags.flatten.join(" ").chomp
28
+ cmd = "#{@exe} #{includes} #{flags} #{header_file} -fxml=#{to_file}"
29
+ raise "Error executing gccxml command line: #{cmd}" unless system(cmd)
30
+ end
31
+
32
+ private
33
+
34
+ def windows?
35
+ RUBY_PLATFORM =~ /(mswin|cygwin)/
36
+ end
37
+
38
+ def find_exe
39
+ ext = windows? ? ".exe" : ""
40
+ binary = "gccxml#{ext}"
41
+
42
+ path = File.expand_path(File.join(File.dirname(__FILE__), "bin", binary))
43
+ path.chomp!
44
+
45
+ if `#{path} --version 2>&1` =~ /GCC-XML/
46
+ path
47
+ elsif `#{binary} --version 2>&1` =~ /GCC-XML/
48
+ binary
49
+ else
50
+ if File.exists?(path)
51
+ # This is the Rubygems <= 1.1.1 bug of not setting file attributes properly
52
+ dir = File.expand_path(File.dirname(__FILE__))
53
+ raise "Unable to execute gccxml. Please run 'sudo chmod -R a+x #{dir}'"
54
+ else
55
+ raise "Unable to find gccxml executable locally or on your PATH."
56
+ end
57
+ end
58
+ end
59
+
60
+ end
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gccxml_gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jason Roelofs
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-16 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: ! 'Because GCCXML is difficult to install on all platforms,
15
+
16
+ this binary gem is provided for ease of installing
17
+
18
+ and using RbGCCXML.
19
+
20
+ '
21
+ email: jameskilton@gmail.com
22
+ executables: []
23
+ extensions: []
24
+ extra_rdoc_files: []
25
+ files:
26
+ - Rakefile
27
+ - gccxml.rb
28
+ homepage: http://rbplusplus.rubyforge.org/
29
+ licenses: []
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - .
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubyforge_project: rbplusplus
48
+ rubygems_version: 1.8.6
49
+ signing_key:
50
+ specification_version: 3
51
+ summary: Easy install for GCCXML
52
+ test_files: []