orchid 0.0.1
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.
- data/LICENSE +26 -0
- data/Manifest +13 -0
- data/README +92 -0
- data/README.md +90 -0
- data/Rakefile +13 -0
- data/lib/orchid.rb +161 -0
- data/lib/orchid/app.rb +37 -0
- data/lib/orchid/compiler.rb +163 -0
- data/lib/orchid/library.rb +56 -0
- data/lib/orchid/package.rb +153 -0
- data/lib/orchid/pkg-config.rb +126 -0
- data/lib/orchid/project.rb +212 -0
- data/orchid.gemspec +30 -0
- metadata +81 -0
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Copyright (C) 2010 Oiki Yukio, Ruby-GNOME2 Project
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
This program uses software developed as part of the Ruby-GNOME2 Project (http://ruby-gnome2.sourceforge.jp/) which is licensed under the GNU Lesser General Public License version 2.1. You can get the whole license at http://www.gnu.org/licenses/lgpl-2.1.html.
|
25
|
+
|
26
|
+
The GNU Lesser General Public License version 2.1 is compatible with the License used for this program (distribution).
|
data/Manifest
ADDED
data/README
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
-*- markdown -*-
|
2
|
+
|
3
|
+
Orchid
|
4
|
+
======
|
5
|
+
|
6
|
+
Orchid is a build tool for [Vala](http://vala-project.org). Actually, it's a task library for the most amazing build tool on the world: Rake.
|
7
|
+
|
8
|
+
It is fairly simple to use (assuming you have Ruby and Rake installed):
|
9
|
+
|
10
|
+
First, you need to install the Gem.
|
11
|
+
|
12
|
+
sudo gem install orchid
|
13
|
+
|
14
|
+
Then, create a new directory where your project will live, create a beautiful Rakefile and fill it with stuff like this:
|
15
|
+
|
16
|
+
require 'rubygems'
|
17
|
+
require 'orchid'
|
18
|
+
|
19
|
+
Orchid::App.new("app") do |app, compiler|
|
20
|
+
app.src = "./src"
|
21
|
+
app.build = "./build"
|
22
|
+
end
|
23
|
+
|
24
|
+
That's it. Now you can run <code>rake build:[your_project_name_here]</code> or <code>rake build:all</code>. The <code>install:</code> tasks aren't yet finished... so don't run those. :)
|
25
|
+
|
26
|
+
On Dependencies
|
27
|
+
---------------
|
28
|
+
|
29
|
+
Orchid makes a distinction between two types of dependencies: packages and *dependencies*. The idea is that packages are system-installed libraries (a.k.a. the blend of .vapi and .so), and *dependencies* are projects that work together, i.e. a library that is part of a project is used by the Application that is primary to the project.
|
30
|
+
|
31
|
+
Consider this <code>Rakefile</code>:
|
32
|
+
|
33
|
+
require 'rubygems'
|
34
|
+
require 'orchid'
|
35
|
+
|
36
|
+
Orchid::Library("ProjectLibrary").new
|
37
|
+
|
38
|
+
Orchid::App("ProjectApplication").new do |app, compiler|
|
39
|
+
app.packages = "gtk+-2.0 >= 2.16", "gee-2.0"
|
40
|
+
app.dependencies << "ProjectLibrary"
|
41
|
+
end
|
42
|
+
|
43
|
+
This makes <code>ProjectApplication</code> dependant on <code>ProjectLibrary</code>. Also, as you can see versioned packages are also supported. Just add a "=> MAJOR.MINOR[.MICRO]" to the package string and you're all set to go. No version information means use any version.
|
44
|
+
|
45
|
+
On Targets
|
46
|
+
----------
|
47
|
+
|
48
|
+
Orchid distinguishes two types of targets: **debug**, and **release**. You can assign these to any task. For example: <code>rake build:app[debug]</code> will build the "app" project for debugging. **debug** is also the default, so you would only have to use **release** when ready to build it system wide.
|
49
|
+
|
50
|
+
Another thing that one might need to know is that whenever **debug**, Orchid automagically defines a "DEBUG" symbol and turns on the debug valac switch.
|
51
|
+
|
52
|
+
Orchid always defines a "ORCHID" symbol.
|
53
|
+
|
54
|
+
The Common Project Layout
|
55
|
+
-------------------------
|
56
|
+
|
57
|
+
Projects, by default, are layed out like so:
|
58
|
+
|
59
|
+
/ - Project
|
60
|
+
| - INFO # project info files such as README, LICENSE...
|
61
|
+
| - Rakefile
|
62
|
+
| - Orchid::Project
|
63
|
+
| - src
|
64
|
+
| - ProjectSources.vala
|
65
|
+
| - res
|
66
|
+
| - SomeImage.img
|
67
|
+
| - SomeUI.ui
|
68
|
+
| - Orchid::Project
|
69
|
+
| - src
|
70
|
+
| - AnotherSourceFile.vala
|
71
|
+
| - res
|
72
|
+
| - AVeryImportantTextFile.txt
|
73
|
+
| - build
|
74
|
+
| - Orchid::Project
|
75
|
+
| - out.bin
|
76
|
+
| - out.vapi # if it's a library...
|
77
|
+
| - SomeImage.img
|
78
|
+
| - SomeUI.ui
|
79
|
+
| - Orchid::Project
|
80
|
+
| - anotherout.bin
|
81
|
+
| - AVeryImportantTextFile.txt
|
82
|
+
|
83
|
+
[*]: Note that Orchid::Project denotes every subclass of that semi-abstract class.
|
84
|
+
|
85
|
+
This layout can be easily changed by modifying the properties of the Project (the first block argument, <code>app</code>).
|
86
|
+
|
87
|
+
License
|
88
|
+
-------
|
89
|
+
|
90
|
+
Orchid is licensed under the MIT License. Orchid uses <code>pkg-config.rb</code> as part of it's distribution as to remove dependencies on the ruby-gnome2 bindings. The <code>pkg-config.rb</code> file is licensed under the [GNU Lesser General Public License version 2.1](http://www.gnu.org/licenses/lgpl-2.1.html), as is the whole [Ruby-GNOME2 Project](http://ruby-gnome2.sourceforge.jp/). The MIT License is compatible with the GNU LGPL v. 2.1 License.
|
91
|
+
|
92
|
+
Address the <code>LICENSE</code> file included in this distribution for more information.
|
data/README.md
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
Orchid
|
2
|
+
======
|
3
|
+
|
4
|
+
Orchid is a build tool for [Vala](http://vala-project.org). Actually, it's a task library for the most amazing build tool on the world: Rake.
|
5
|
+
|
6
|
+
It is fairly simple to use (assuming you have Ruby and Rake installed):
|
7
|
+
|
8
|
+
First, you need to install the Gem.
|
9
|
+
|
10
|
+
sudo gem install orchid
|
11
|
+
|
12
|
+
Then, create a new directory where your project will live, create a beautiful Rakefile and fill it with stuff like this:
|
13
|
+
|
14
|
+
require 'rubygems'
|
15
|
+
require 'orchid'
|
16
|
+
|
17
|
+
Orchid::App.new("app") do |app, compiler|
|
18
|
+
app.src = "./src"
|
19
|
+
app.build = "./build"
|
20
|
+
end
|
21
|
+
|
22
|
+
That's it. Now you can run <code>rake build:[your_project_name_here]</code> or <code>rake build:all</code>. The <code>install:</code> tasks aren't yet finished... so don't run those. :)
|
23
|
+
|
24
|
+
On Dependencies
|
25
|
+
---------------
|
26
|
+
|
27
|
+
Orchid makes a distinction between two types of dependencies: packages and *dependencies*. The idea is that packages are system-installed libraries (a.k.a. the blend of .vapi and .so), and *dependencies* are projects that work together, i.e. a library that is part of a project is used by the Application that is primary to the project.
|
28
|
+
|
29
|
+
Consider this <code>Rakefile</code>:
|
30
|
+
|
31
|
+
require 'rubygems'
|
32
|
+
require 'orchid'
|
33
|
+
|
34
|
+
Orchid::Library("ProjectLibrary").new
|
35
|
+
|
36
|
+
Orchid::App("ProjectApplication").new do |app, compiler|
|
37
|
+
app.packages = "gtk+-2.0 >= 2.16", "gee-2.0"
|
38
|
+
app.dependencies << "ProjectLibrary"
|
39
|
+
end
|
40
|
+
|
41
|
+
This makes <code>ProjectApplication</code> dependant on <code>ProjectLibrary</code>. Also, as you can see versioned packages are also supported. Just add a "=> MAJOR.MINOR[.MICRO]" to the package string and you're all set to go. No version information means use any version.
|
42
|
+
|
43
|
+
On Targets
|
44
|
+
----------
|
45
|
+
|
46
|
+
Orchid distinguishes two types of targets: **debug**, and **release**. You can assign these to any task. For example: <code>rake build:app[debug]</code> will build the "app" project for debugging. **debug** is also the default, so you would only have to use **release** when ready to build it system wide.
|
47
|
+
|
48
|
+
Another thing that one might need to know is that whenever **debug**, Orchid automagically defines a "DEBUG" symbol and turns on the debug valac switch.
|
49
|
+
|
50
|
+
Orchid always defines a "ORCHID" symbol.
|
51
|
+
|
52
|
+
The Common Project Layout
|
53
|
+
-------------------------
|
54
|
+
|
55
|
+
Projects, by default, are layed out like so:
|
56
|
+
|
57
|
+
/ - Project
|
58
|
+
| - INFO # project info files such as README, LICENSE...
|
59
|
+
| - Rakefile
|
60
|
+
| - Orchid::Project
|
61
|
+
| - src
|
62
|
+
| - ProjectSources.vala
|
63
|
+
| - res
|
64
|
+
| - SomeImage.img
|
65
|
+
| - SomeUI.ui
|
66
|
+
| - Orchid::Project
|
67
|
+
| - src
|
68
|
+
| - AnotherSourceFile.vala
|
69
|
+
| - res
|
70
|
+
| - AVeryImportantTextFile.txt
|
71
|
+
| - build
|
72
|
+
| - Orchid::Project
|
73
|
+
| - out.bin
|
74
|
+
| - out.vapi # if it's a library...
|
75
|
+
| - SomeImage.img
|
76
|
+
| - SomeUI.ui
|
77
|
+
| - Orchid::Project
|
78
|
+
| - anotherout.bin
|
79
|
+
| - AVeryImportantTextFile.txt
|
80
|
+
|
81
|
+
[*]: Note that Orchid::Project denotes every subclass of that semi-abstract class.
|
82
|
+
|
83
|
+
This layout can be easily changed by modifying the properties of the Project (the first block argument, <code>app</code>).
|
84
|
+
|
85
|
+
License
|
86
|
+
-------
|
87
|
+
|
88
|
+
Orchid is licensed under the MIT License. Orchid uses <code>pkg-config.rb</code> as part of it's distribution as to remove dependencies on the ruby-gnome2 bindings. The <code>pkg-config.rb</code> file is licensed under the [GNU Lesser General Public License version 2.1](http://www.gnu.org/licenses/lgpl-2.1.html), as is the whole [Ruby-GNOME2 Project](http://ruby-gnome2.sourceforge.jp/). The MIT License is compatible with the GNU LGPL v. 2.1 License.
|
89
|
+
|
90
|
+
Address the <code>LICENSE</code> file included in this distribution for more information.
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'echoe'
|
2
|
+
|
3
|
+
Echoe.new("orchid") do |orchid|
|
4
|
+
orchid.version = "0.0.1"
|
5
|
+
|
6
|
+
orchid.author = "Oiki Yukio"
|
7
|
+
orchid.email = "oiki.yukio@gmail.com"
|
8
|
+
orchid.summary = "A build tool for Vala."
|
9
|
+
orchid.description = "A task lib for Rake easing the development of Vala applications and libraries."
|
10
|
+
orchid.url = "http://bitbucket.org/oik/orchid"
|
11
|
+
|
12
|
+
# orchid.platform = "UNIX"
|
13
|
+
end
|
data/lib/orchid.rb
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
# orchid.rb
|
2
|
+
# This file is part of Orchid
|
3
|
+
#
|
4
|
+
# Copyright (C) 2010 - Oiki Yukio
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person
|
7
|
+
# obtaining a copy of this software and associated documentation
|
8
|
+
# files (the "Software"), to deal in the Software without
|
9
|
+
# restriction, including without limitation the rights to use,
|
10
|
+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the
|
12
|
+
# Software is furnished to do so, subject to the following
|
13
|
+
# conditions:
|
14
|
+
#
|
15
|
+
# The above copyright notice and this permission notice shall be
|
16
|
+
# included in all copies or substantial portions of the Software.
|
17
|
+
#
|
18
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
20
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
22
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
23
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
24
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
25
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
|
27
|
+
require 'rubygems'
|
28
|
+
require 'rake'
|
29
|
+
require 'pathname'
|
30
|
+
|
31
|
+
module Orchid
|
32
|
+
CC = Config::CONFIG["CC"]
|
33
|
+
VALAC = "valac"
|
34
|
+
|
35
|
+
class Version
|
36
|
+
attr_accessor :major, :minor, :micro
|
37
|
+
|
38
|
+
def initialize(value = nil)
|
39
|
+
if value.class == String
|
40
|
+
value = value.split '.'
|
41
|
+
elsif value.class == Hash
|
42
|
+
value = [value[:major], value[:minor], value[:micro]]
|
43
|
+
elsif value.nil?
|
44
|
+
value = [nil, 0, 0]
|
45
|
+
end
|
46
|
+
|
47
|
+
@major = value.first ? value.first.to_i : nil
|
48
|
+
@minor = value[1] ? value[1].to_i : 0
|
49
|
+
@micro = value.last ? value.last.to_i : 0
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_s
|
53
|
+
return "#{@major}.#{@minor}.#{@micro}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def to_h
|
57
|
+
return {:major => @major, :minor => @minor, :micro => @micro}
|
58
|
+
end
|
59
|
+
|
60
|
+
def to_a
|
61
|
+
return [@major, @minor, @micro]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.discover_compiler_options
|
66
|
+
exclude = ["disable-warnings", "symbols", "save-temps"]
|
67
|
+
|
68
|
+
options = []
|
69
|
+
valac_help = `#{VALAC} --help`
|
70
|
+
valac_help = valac_help.split(/[\t\r\n]+/).compact.map do |string|
|
71
|
+
string = string.gsub(/[\t\r\n]+/, '').gsub(/\ +/, ' ') if string
|
72
|
+
end
|
73
|
+
|
74
|
+
in_options = false
|
75
|
+
|
76
|
+
valac_help.each do |string|
|
77
|
+
if in_options
|
78
|
+
extract = string.scan(/\s+-{1,2}([\w-]+)(=([\w-]+)(\.{3,})?)?/i)
|
79
|
+
|
80
|
+
option = {}
|
81
|
+
|
82
|
+
option[:name] = [extract.first.first, extract.last.first].uniq
|
83
|
+
option[:multiple] = extract.last[3] == "..." ? true : false
|
84
|
+
option[:bool] = extract.last[2] ? false : true
|
85
|
+
|
86
|
+
options << option if (option[:name] & exclude).empty?
|
87
|
+
end
|
88
|
+
|
89
|
+
in_options = true if string.match(/Application Options\:/)
|
90
|
+
end
|
91
|
+
|
92
|
+
return options.uniq
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.discover_compiler_version
|
96
|
+
valac_version = `#{VALAC} --version`.split
|
97
|
+
valac_version = valac_version.last.gsub(/[\t\n\r]+/, '')
|
98
|
+
|
99
|
+
return Orchid::Version.new(valac_version)
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.discover_global_vapidir
|
103
|
+
glib20 = `locate -b glib-2.0.vapi`
|
104
|
+
|
105
|
+
return File.dirname(glib20.strip)
|
106
|
+
end
|
107
|
+
|
108
|
+
DIRS = { :bindir => Config::CONFIG["bindir"],
|
109
|
+
:datadir => Config::CONFIG["datadir"],
|
110
|
+
:libdir => Config::CONFIG["libdir"],
|
111
|
+
:vapidir => discover_global_vapidir() }
|
112
|
+
|
113
|
+
LIBARGS = [Config::CONFIG["CCDLFLAGS"]].flatten.freeze
|
114
|
+
|
115
|
+
INFO = { :version => discover_compiler_version(),
|
116
|
+
:compiler_opts => discover_compiler_options(),
|
117
|
+
:vapidir => DIRS[:vapidir] }
|
118
|
+
|
119
|
+
PRINT = true
|
120
|
+
PROJECTS = {}
|
121
|
+
|
122
|
+
CHECKED_PACKAGES = {}
|
123
|
+
|
124
|
+
def self.register_project(project)
|
125
|
+
PROJECTS[project.name] = project
|
126
|
+
end
|
127
|
+
|
128
|
+
namespace :build do
|
129
|
+
desc "Builds everything as the specified target."
|
130
|
+
task :all, :target do |task, arguments|
|
131
|
+
arguments.with_defaults(:target => :debug)
|
132
|
+
|
133
|
+
Orchid::PROJECTS.keys.each do |project|
|
134
|
+
taskname = "build:#{project.downcase}"
|
135
|
+
Rake::Task[taskname].invoke
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
namespace :install do
|
141
|
+
desc "Installs everything as the specified target."
|
142
|
+
task :all, :target do |task, arguments|
|
143
|
+
arguments.with_defaults(:target => :debug)
|
144
|
+
|
145
|
+
Orchid::PROJECTS.keys.each do |project|
|
146
|
+
taskname = "build:#{project.downcase}"
|
147
|
+
Rake::Task[taskname].invoke
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
dir = Pathname.new(__FILE__).dirname + "orchid"
|
154
|
+
|
155
|
+
load dir + "pkg-config.rb"
|
156
|
+
|
157
|
+
load dir + "package.rb"
|
158
|
+
load dir + "compiler.rb"
|
159
|
+
load dir + "project.rb"
|
160
|
+
load dir + "app.rb"
|
161
|
+
load dir + "library.rb"
|
data/lib/orchid/app.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# app.rb
|
2
|
+
# This file is part of Orchid
|
3
|
+
#
|
4
|
+
# Copyright (C) 2010 - Oiki Yukio
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person
|
7
|
+
# obtaining a copy of this software and associated documentation
|
8
|
+
# files (the "Software"), to deal in the Software without
|
9
|
+
# restriction, including without limitation the rights to use,
|
10
|
+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the
|
12
|
+
# Software is furnished to do so, subject to the following
|
13
|
+
# conditions:
|
14
|
+
#
|
15
|
+
# The above copyright notice and this permission notice shall be
|
16
|
+
# included in all copies or substantial portions of the Software.
|
17
|
+
#
|
18
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
20
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
22
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
23
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
24
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
25
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
|
27
|
+
class Orchid::App < Orchid::Project
|
28
|
+
def initialize(name)
|
29
|
+
super
|
30
|
+
|
31
|
+
if block_given?
|
32
|
+
yield self, @compiler
|
33
|
+
end
|
34
|
+
|
35
|
+
register()
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
# compiler.rb
|
2
|
+
# This file is part of Orchid
|
3
|
+
#
|
4
|
+
# Copyright (C) 2010 - Oiki Yukio
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person
|
7
|
+
# obtaining a copy of this software and associated documentation
|
8
|
+
# files (the "Software"), to deal in the Software without
|
9
|
+
# restriction, including without limitation the rights to use,
|
10
|
+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the
|
12
|
+
# Software is furnished to do so, subject to the following
|
13
|
+
# conditions:
|
14
|
+
#
|
15
|
+
# The above copyright notice and this permission notice shall be
|
16
|
+
# included in all copies or substantial portions of the Software.
|
17
|
+
#
|
18
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
20
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
22
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
23
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
24
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
25
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
|
27
|
+
require 'pathname'
|
28
|
+
require 'shellwords'
|
29
|
+
|
30
|
+
class String
|
31
|
+
def plural?
|
32
|
+
return self.match(/s$/i) ? true : false
|
33
|
+
end
|
34
|
+
|
35
|
+
def pluralize
|
36
|
+
return self.plural? ? self : "#{self}s"
|
37
|
+
end
|
38
|
+
|
39
|
+
def singularize
|
40
|
+
return self.plural? ? self.gsub(/s$/i, '') : self
|
41
|
+
end
|
42
|
+
|
43
|
+
def underscoreize
|
44
|
+
return self.gsub(/\-/, '_')
|
45
|
+
end
|
46
|
+
|
47
|
+
def deunderscoreize
|
48
|
+
return self.gsub(/\_/, '-')
|
49
|
+
end
|
50
|
+
|
51
|
+
def deivize
|
52
|
+
return self.gsub(/\@/, '')
|
53
|
+
end
|
54
|
+
|
55
|
+
def as_iv
|
56
|
+
return "@#{self.strip.underscoreize}"
|
57
|
+
end
|
58
|
+
|
59
|
+
def as_param
|
60
|
+
return (self.length > 1 ? "--" : "-") + self.deunderscoreize.deivize.singularize
|
61
|
+
end
|
62
|
+
|
63
|
+
def as_arg
|
64
|
+
return "'#{self.strip}'"
|
65
|
+
end
|
66
|
+
|
67
|
+
def as_opt
|
68
|
+
return self.deunderscoreize.singularize.deivize
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
class Orchid::Compiler
|
73
|
+
attr_accessor :sources, :symbols_file, :disable_warnings, :save_temps
|
74
|
+
|
75
|
+
def get_option(optname)
|
76
|
+
Orchid::INFO[:compiler_opts].each do |opt|
|
77
|
+
return opt if opt[:name].member? optname
|
78
|
+
end
|
79
|
+
|
80
|
+
return nil
|
81
|
+
end
|
82
|
+
|
83
|
+
def initialize()
|
84
|
+
Orchid::INFO[:compiler_opts].each do |opt|
|
85
|
+
opt[:name].each do |name|
|
86
|
+
name = opt[:multiple] ? name.pluralize.as_iv : name.as_iv
|
87
|
+
|
88
|
+
self.instance_variable_set name, nil
|
89
|
+
self.instance_variable_set name, false if opt[:bool]
|
90
|
+
self.instance_variable_set name, [] if opt[:multiple]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
@symbols_file = nil
|
95
|
+
@disable_warnings = false
|
96
|
+
@save_temps = false
|
97
|
+
|
98
|
+
@sources = []
|
99
|
+
end
|
100
|
+
|
101
|
+
def method_missing(method, *args, &blk)
|
102
|
+
method = method.to_s.scan(/^(\w+)(=)?/i).flatten
|
103
|
+
option = self.get_option(method.first.as_opt)
|
104
|
+
|
105
|
+
if option
|
106
|
+
value = *args.first
|
107
|
+
value = value.to_a.flatten.uniq if option[:multiple]
|
108
|
+
value = value ? true : false if option[:bool]
|
109
|
+
|
110
|
+
if method.last
|
111
|
+
name = option[:name] - (method.first.as_opt.to_a & option[:name])
|
112
|
+
name = name.first
|
113
|
+
name = name.pluralize if option[:multiple]
|
114
|
+
|
115
|
+
self.instance_variable_set(method.first.as_iv, value)
|
116
|
+
self.instance_variable_set(name.as_iv, value) if name
|
117
|
+
|
118
|
+
return value
|
119
|
+
else
|
120
|
+
return self.instance_variable_get(method.first.as_iv)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
raise NoMethodError.new("undefined method `#{method * ''}' for #{self}", (method * ''), args)
|
125
|
+
end
|
126
|
+
|
127
|
+
def parameters
|
128
|
+
params = []
|
129
|
+
|
130
|
+
Orchid::INFO[:compiler_opts].each do |option|
|
131
|
+
iv = option[:multiple] ? option[:name].last.pluralize.as_iv : option[:name].last.as_iv
|
132
|
+
|
133
|
+
value = [self.instance_variable_get(iv)].flatten
|
134
|
+
|
135
|
+
value.each do |val|
|
136
|
+
if [true, false].member? val
|
137
|
+
params << "#{iv.as_param}" if val
|
138
|
+
else
|
139
|
+
params << "#{iv.as_param} #{val.as_arg}" if val
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
params << "--symbols #{File.expand_path(@symbols_file.to_s)}" if (@symbols_file and !@symbols_file.empty?)
|
145
|
+
params << "--save-temps" if @save_temps
|
146
|
+
params << "--disable-warnings" if @disable_warnings
|
147
|
+
|
148
|
+
if @sources
|
149
|
+
@sources.each do |source|
|
150
|
+
params << "#{File.expand_path(source.to_s).as_arg}"
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
return params.compact.uniq
|
155
|
+
end
|
156
|
+
|
157
|
+
def run
|
158
|
+
cmd = "#{Orchid::VALAC} #{parameters() * ' '}"
|
159
|
+
|
160
|
+
puts cmd
|
161
|
+
system(cmd)
|
162
|
+
end
|
163
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# library.rb
|
2
|
+
# This file is part of Orchid
|
3
|
+
#
|
4
|
+
# Copyright (C) 2010 - Oiki Yukio
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person
|
7
|
+
# obtaining a copy of this software and associated documentation
|
8
|
+
# files (the "Software"), to deal in the Software without
|
9
|
+
# restriction, including without limitation the rights to use,
|
10
|
+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the
|
12
|
+
# Software is furnished to do so, subject to the following
|
13
|
+
# conditions:
|
14
|
+
#
|
15
|
+
# The above copyright notice and this permission notice shall be
|
16
|
+
# included in all copies or substantial portions of the Software.
|
17
|
+
#
|
18
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
20
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
22
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
23
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
24
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
25
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
|
27
|
+
class Orchid::Library < Orchid::Project
|
28
|
+
def initialize(name)
|
29
|
+
super
|
30
|
+
|
31
|
+
if block_given?
|
32
|
+
yield self, @compiler
|
33
|
+
end
|
34
|
+
|
35
|
+
@compiler.output = "lib#{@name}.so"
|
36
|
+
@compiler.library = "lib#{@name}"
|
37
|
+
@compiler.vapi = "#{@name}.vapi"
|
38
|
+
@compiler.gir = "#{@name}-#{@version}.gir"
|
39
|
+
@compiler.header = "#{@build + @name}.h"
|
40
|
+
@compiler.Xs = [Orchid::LIBARGS,
|
41
|
+
"-shared",
|
42
|
+
"-Wl,-soname,lib#{@name}.so"].flatten
|
43
|
+
|
44
|
+
register
|
45
|
+
end
|
46
|
+
|
47
|
+
def dependability(compiler)
|
48
|
+
includes = ["-I#{@build}", "-L#{@build}", "-l#{@name}"]
|
49
|
+
|
50
|
+
compiler.Xccs << includes
|
51
|
+
compiler.Xccs.flatten!
|
52
|
+
|
53
|
+
compiler.sources << "#{@build + @name}.vapi"
|
54
|
+
compiler.girdirs << "#{@build}"
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
# package.rb
|
2
|
+
# This file is part of Orchid
|
3
|
+
#
|
4
|
+
# Copyright (C) 2010 - Oiki Yukio
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person
|
7
|
+
# obtaining a copy of this software and associated documentation
|
8
|
+
# files (the "Software"), to deal in the Software without
|
9
|
+
# restriction, including without limitation the rights to use,
|
10
|
+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the
|
12
|
+
# Software is furnished to do so, subject to the following
|
13
|
+
# conditions:
|
14
|
+
#
|
15
|
+
# The above copyright notice and this permission notice shall be
|
16
|
+
# included in all copies or substantial portions of the Software.
|
17
|
+
#
|
18
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
20
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
22
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
23
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
24
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
25
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
|
27
|
+
require 'pathname'
|
28
|
+
|
29
|
+
class Orchid::PackageDoesNotExistError
|
30
|
+
attr_reader :message
|
31
|
+
attr_reader :package
|
32
|
+
attr_reader :vapidirs
|
33
|
+
|
34
|
+
def initialize(msg, package, vapidirs = nil)
|
35
|
+
if vapidirs
|
36
|
+
@vapidirs = vapidirs.to_a.uniq.compact
|
37
|
+
end
|
38
|
+
|
39
|
+
@message = msg
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_s
|
43
|
+
@message
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_str
|
47
|
+
@message
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class Orchid::Package
|
52
|
+
attr_reader :name
|
53
|
+
attr_reader :vapi
|
54
|
+
attr_reader :deps, :dependencies
|
55
|
+
|
56
|
+
def deps=(value)
|
57
|
+
@deps = value.to_s
|
58
|
+
resolve_dependencies()
|
59
|
+
return @deps
|
60
|
+
end
|
61
|
+
|
62
|
+
def initialize(name, vapi = nil, deps = nil)
|
63
|
+
@name = name.to_s
|
64
|
+
@vapi = vapi.to_s if vapi
|
65
|
+
if deps
|
66
|
+
@deps = deps.to_s
|
67
|
+
resolve_dependencies
|
68
|
+
end
|
69
|
+
|
70
|
+
if !@vapi
|
71
|
+
vapifile = Pathname.new(Orchid::DIRS[:vapidir]) + "#{name}.vapi"
|
72
|
+
depsfile = Pathname.new(Orchid::DIRS[:vapidir]) + "#{name}.deps"
|
73
|
+
|
74
|
+
if vapifile.exist? and vapifile.file?
|
75
|
+
@vapi = vapifile.to_s
|
76
|
+
|
77
|
+
if !@deps and (depsfile.exist? and depsfile.file?)
|
78
|
+
@deps = depsfile.to_s
|
79
|
+
resolve_dependencies
|
80
|
+
end
|
81
|
+
else
|
82
|
+
raise Orchid::PackageDoesNotExistError.new("package `#{@name}' doesn't exist in the standard location", @name, Orchid::INFO[:vapidir])
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
Orchid::CHECKED_PACKAGES[name] = self
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.lookup(name, options = {:vapidirs => [], :version => nil})
|
90
|
+
package = nil
|
91
|
+
version = options[:version].to_a
|
92
|
+
vapidirs = options[:vapidirs].to_a
|
93
|
+
vapidirs << Orchid::DIRS[:vapidir]
|
94
|
+
vapidirs.compact!
|
95
|
+
|
96
|
+
vapidirs = vapidirs.to_a.uniq
|
97
|
+
|
98
|
+
if Orchid::CHECKED_PACKAGES[name]
|
99
|
+
return Orchid::CHECKED_PACKAGES[name]
|
100
|
+
end
|
101
|
+
|
102
|
+
vapidirs.each do |vapidir|
|
103
|
+
vapidir = Pathname.new(vapidir).expand_path
|
104
|
+
vapifile = vapidir + "#{name}.vapi"
|
105
|
+
depsfile = vapidir + "#{name}.deps"
|
106
|
+
|
107
|
+
if vapifile.exist? and vapifile.file?
|
108
|
+
begin
|
109
|
+
package = Orchid::Package.new(name, vapifile)
|
110
|
+
|
111
|
+
if depsfile.exist? and depsfile.file?
|
112
|
+
package.deps = depsfile
|
113
|
+
end
|
114
|
+
|
115
|
+
printf "checking for #{name}.vapi... " if Orchid::PRINT
|
116
|
+
|
117
|
+
if package
|
118
|
+
puts "yes" if Orchid::PRINT
|
119
|
+
return package if PKGConfig.have_package(name, *version)
|
120
|
+
end
|
121
|
+
rescue Orchid::PackageDoesNotExistError => e
|
122
|
+
puts "no" if Orchid::PRINT
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
return nil
|
128
|
+
end
|
129
|
+
|
130
|
+
def to_param
|
131
|
+
return "--pkg '#{name}'"
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
135
|
+
def resolve_dependencies
|
136
|
+
depsfile = Pathname.new(@deps)
|
137
|
+
|
138
|
+
if depsfile.exist? and depsfile.file?
|
139
|
+
depsfile = File.open(depsfile.expand_path.to_s)
|
140
|
+
|
141
|
+
@dependencies = depsfile.readlines.map do |dep|
|
142
|
+
dep.gsub! /[\t\n\r]+/, ''
|
143
|
+
dep = Orchid::Package.lookup(dep, :vapidirs => File.dirname(File.expand_path(@vapi.to_s)))
|
144
|
+
end
|
145
|
+
|
146
|
+
@dependencies.compact!.to_a.uniq!
|
147
|
+
|
148
|
+
@dependencies = nil if @dependencies.empty?
|
149
|
+
end
|
150
|
+
|
151
|
+
return nil
|
152
|
+
end
|
153
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
#
|
2
|
+
# pkg-config.rb
|
3
|
+
#
|
4
|
+
# Wrapper of pkg-config tool.
|
5
|
+
#
|
6
|
+
# Copyright(C) 2003-2005 Ruby-GNOME2 Project.
|
7
|
+
#
|
8
|
+
# This program is free software.
|
9
|
+
# You can distribute/modify this program under the terms of
|
10
|
+
# the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
|
11
|
+
|
12
|
+
require 'mkmf'
|
13
|
+
require 'shellwords'
|
14
|
+
|
15
|
+
module PKGConfig
|
16
|
+
@@cmd = with_config('pkg-config', ENV["PKG_CONFIG"] || 'pkg-config')
|
17
|
+
if /mswin32/ =~ RUBY_PLATFORM and /^cl\b/ =~ Config::CONFIG['CC']
|
18
|
+
@@cmd += ' --msvc-syntax'
|
19
|
+
end
|
20
|
+
|
21
|
+
@@list = {}
|
22
|
+
`#{@@cmd} --list-all`.chomp.split(/\n/).each{|v|
|
23
|
+
pkg, name, desc = /(\S+?)\s+(.*?)\s-\s(.*)/.match(v).to_a[1..3]
|
24
|
+
@@list[pkg] = [name, desc]
|
25
|
+
}
|
26
|
+
|
27
|
+
module_function
|
28
|
+
def exist?(pkg)
|
29
|
+
system("#{@@cmd} --exists #{pkg}")
|
30
|
+
end
|
31
|
+
|
32
|
+
def libs(pkg)
|
33
|
+
`#{@@cmd} --libs #{pkg}`.chomp
|
34
|
+
end
|
35
|
+
|
36
|
+
def libs_only_L(pkg)
|
37
|
+
`#{@@cmd} --libs-only-L #{pkg}`.chomp
|
38
|
+
end
|
39
|
+
|
40
|
+
def libs_only_l(pkg)
|
41
|
+
`#{@@cmd} --libs-only-l #{pkg}`.chomp
|
42
|
+
end
|
43
|
+
|
44
|
+
def cflags(pkg)
|
45
|
+
`#{@@cmd} --cflags #{pkg}`.chomp
|
46
|
+
end
|
47
|
+
|
48
|
+
def cflags_only_I(pkg)
|
49
|
+
`#{@@cmd} --cflags-only-I #{pkg}`.chomp
|
50
|
+
end
|
51
|
+
|
52
|
+
def cflags_only_other(pkg)
|
53
|
+
`#{@@cmd} --cflags-only-other #{pkg}`.chomp
|
54
|
+
end
|
55
|
+
|
56
|
+
def variable(pkg, var)
|
57
|
+
`#{@@cmd} --variable=#{var} #{pkg}`.chomp
|
58
|
+
end
|
59
|
+
|
60
|
+
def modversion(pkg)
|
61
|
+
`#{@@cmd} --modversion #{pkg}`.chomp
|
62
|
+
end
|
63
|
+
|
64
|
+
def version
|
65
|
+
`#{@@cmd} --version`.chomp
|
66
|
+
end
|
67
|
+
|
68
|
+
def list_all
|
69
|
+
# Returns [pkg, name, description]
|
70
|
+
@@list.keys.collect{|key| [key] + @@list[key]}.sort
|
71
|
+
end
|
72
|
+
|
73
|
+
def name(pkg)
|
74
|
+
@@list[pkg][0]
|
75
|
+
end
|
76
|
+
|
77
|
+
def description(pkg)
|
78
|
+
@@list[pkg][1]
|
79
|
+
end
|
80
|
+
|
81
|
+
def provides(pkg)
|
82
|
+
`#{@@cmd} --print-provides #{pkg}`.chomp
|
83
|
+
end
|
84
|
+
|
85
|
+
def requires(pkg)
|
86
|
+
`#{@@cmd} --print-requires #{pkg}`.chomp.gsub("\n", ", ")
|
87
|
+
end
|
88
|
+
|
89
|
+
def check_version?(pkg, major = 0, minor = 0, micro = 0)
|
90
|
+
return false unless exist?(pkg)
|
91
|
+
ver = modversion(pkg).split(".").collect{|item| item.to_i}
|
92
|
+
(0..2).each {|i| ver[i] = 0 unless ver[i]}
|
93
|
+
|
94
|
+
(ver[0] > major ||
|
95
|
+
(ver[0] == major && ver[1] > minor) ||
|
96
|
+
(ver[0] == major && ver[1] == minor &&
|
97
|
+
ver[2] >= micro))
|
98
|
+
end
|
99
|
+
|
100
|
+
def have_package(pkg, major = nil, minor = 0, micro = 0)
|
101
|
+
if major.nil?
|
102
|
+
STDOUT.print("checking for #{pkg}... ")
|
103
|
+
else
|
104
|
+
STDOUT.print("checking for #{pkg} version (>= #{major}.#{minor}.#{micro})... ")
|
105
|
+
end
|
106
|
+
major ||= 0
|
107
|
+
STDOUT.flush
|
108
|
+
if check_version?(pkg, major, minor, micro)
|
109
|
+
STDOUT.print "yes\n"
|
110
|
+
libraries = libs_only_l(pkg)
|
111
|
+
dldflags = libs(pkg)
|
112
|
+
dldflags = (Shellwords.shellwords(dldflags) - Shellwords.shellwords(libraries)).map{|s| /\s/ =~ s ? "\"#{s}\"" : s }.join(' ')
|
113
|
+
$libs += ' ' + libraries
|
114
|
+
if /mswin32/ =~ RUBY_PLATFORM
|
115
|
+
$DLDFLAGS += ' ' + dldflags
|
116
|
+
else
|
117
|
+
$LDFLAGS += ' ' + dldflags
|
118
|
+
end
|
119
|
+
$CFLAGS += ' ' + cflags(pkg)
|
120
|
+
true
|
121
|
+
else
|
122
|
+
STDOUT.print "no\n"
|
123
|
+
false
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,212 @@
|
|
1
|
+
# project.rb
|
2
|
+
# This file is part of Orchid
|
3
|
+
#
|
4
|
+
# Copyright (C) 2010 - Oiki Yukio
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person
|
7
|
+
# obtaining a copy of this software and associated documentation
|
8
|
+
# files (the "Software"), to deal in the Software without
|
9
|
+
# restriction, including without limitation the rights to use,
|
10
|
+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the
|
12
|
+
# Software is furnished to do so, subject to the following
|
13
|
+
# conditions:
|
14
|
+
#
|
15
|
+
# The above copyright notice and this permission notice shall be
|
16
|
+
# included in all copies or substantial portions of the Software.
|
17
|
+
#
|
18
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
20
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
22
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
23
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
24
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
25
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
|
27
|
+
require 'rake/tasklib'
|
28
|
+
require 'pathname'
|
29
|
+
|
30
|
+
class Orchid::Project < Rake::TaskLib
|
31
|
+
attr_reader :name, :version
|
32
|
+
attr_reader :src, :res, :build
|
33
|
+
attr_reader :bindir, :libdir, :datadir
|
34
|
+
attr_reader :packages, :dependencies
|
35
|
+
attr_accessor :compiler, :procedures
|
36
|
+
|
37
|
+
attr_reader :sources, :resources
|
38
|
+
|
39
|
+
def name=(val); @name = val.to_s; end
|
40
|
+
def version=(val); @version = Orchid::Version.new(val); end
|
41
|
+
def src=(val); @src = Pathname.new(val.to_s).expand_path; end
|
42
|
+
def res=(val); @res = Pathname.new(val.to_s).expand_path; end
|
43
|
+
def build=(val); @build = Pathname.new(val.to_s).expand_path; end
|
44
|
+
def bindir=(val); @bindir = Pathname.new(val.to_s).expand_path; end
|
45
|
+
def libdir=(val); @libdir = Pathname.new(val.to_s).expand_path; end
|
46
|
+
def datadir=(val); @datadir = Pathname.new(val.to_s).expand_path; end
|
47
|
+
|
48
|
+
def packages=(val, options = {:override => false})
|
49
|
+
return nil if val.nil? or val.to_s.empty?
|
50
|
+
|
51
|
+
if (options[:override] or !@packages)
|
52
|
+
@packages = []
|
53
|
+
end
|
54
|
+
|
55
|
+
val.to_a.flatten.to_a.compact.each do |subval|
|
56
|
+
subval = subval.gsub(/[\(\)]+/, '').gsub(/\s+/, '').split('=>')
|
57
|
+
|
58
|
+
name = subval.first
|
59
|
+
version = nil
|
60
|
+
version = subval.last if subval.length > 1
|
61
|
+
|
62
|
+
@packages << { :name => name, :version => Orchid::Version.new(version) }
|
63
|
+
end
|
64
|
+
|
65
|
+
@packages.uniq!
|
66
|
+
end
|
67
|
+
|
68
|
+
def dependencies=(val, options = {:override => false})
|
69
|
+
return nil if val.nil? or val.to_s.empty?
|
70
|
+
|
71
|
+
if (options[:override] or !@dependencies)
|
72
|
+
@dependencies = val.to_a.flatten.to_a.compact.map do |subval|
|
73
|
+
subval = subval.to_s
|
74
|
+
end
|
75
|
+
|
76
|
+
@dependencies.uniq!
|
77
|
+
else
|
78
|
+
@dependencies << val.to_s
|
79
|
+
@dependencies.flatten!.compact!.uniq!
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
alias :"deps=" :"dependencies="
|
84
|
+
alias :"pkgs=" :"packages="
|
85
|
+
|
86
|
+
def initialize(name)
|
87
|
+
@name = name.to_s
|
88
|
+
@version = "0.0.1"
|
89
|
+
@compiler = Orchid::Compiler.new()
|
90
|
+
|
91
|
+
@src = Pathname.new("./#{@name}/src").expand_path
|
92
|
+
@res = Pathname.new("./#{@name}/res").expand_path
|
93
|
+
@build = Pathname.new("./build/#{@name}").expand_path
|
94
|
+
|
95
|
+
@bindir = Pathname.new(Orchid::DIRS[:bindir]).expand_path
|
96
|
+
@libdir = Pathname.new(Orchid::DIRS[:libdir]).expand_path
|
97
|
+
@datadir = Pathname.new(Orchid::DIRS[:datadir]).expand_path
|
98
|
+
|
99
|
+
@packages = [{:name => "glib-2.0", :version => Orchid::Version.new(nil)}]
|
100
|
+
@dependencies = []
|
101
|
+
|
102
|
+
@procedures = {}
|
103
|
+
end
|
104
|
+
|
105
|
+
def register
|
106
|
+
Orchid.register_project self
|
107
|
+
|
108
|
+
@sources = FileList[@src + "**", "*.vala"].resolve
|
109
|
+
@compiler.output ||= "#{@name}"
|
110
|
+
@compiler.basedir = @src.to_s
|
111
|
+
@compiler.directory = @build.to_s
|
112
|
+
@compiler.sources << @sources
|
113
|
+
@compiler.sources.flatten!
|
114
|
+
|
115
|
+
define_tasks
|
116
|
+
end
|
117
|
+
|
118
|
+
def check_packages
|
119
|
+
@packages.to_a.each do |package|
|
120
|
+
package = Orchid::Package.lookup(package[:name], :version => package[:version].to_a, :vapidirs => @compiler.vapidirs)
|
121
|
+
|
122
|
+
if package
|
123
|
+
@compiler.pkgs << package.name
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def check_dependencies
|
129
|
+
@dependencies.each do |dependency|
|
130
|
+
project = Orchid::PROJECTS[dependency]
|
131
|
+
|
132
|
+
if project
|
133
|
+
project.dependability @compiler
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def define_tasks
|
139
|
+
directory @build.to_s
|
140
|
+
|
141
|
+
debug = "debug:#{@name}"
|
142
|
+
release = "release:#{@name}"
|
143
|
+
|
144
|
+
file debug => [@build.to_s] do
|
145
|
+
check_packages
|
146
|
+
check_dependencies
|
147
|
+
|
148
|
+
@compiler.run()
|
149
|
+
end
|
150
|
+
|
151
|
+
file release => [@build.to_s] do
|
152
|
+
check_packages
|
153
|
+
check_dependencies
|
154
|
+
|
155
|
+
@compiler.run()
|
156
|
+
end
|
157
|
+
|
158
|
+
namespace :build do
|
159
|
+
desc "Builds #{@name}; target is 'debug' or 'release'."
|
160
|
+
task @name.downcase, :target do |task, arguments|
|
161
|
+
arguments.with_defaults(:target => :debug)
|
162
|
+
|
163
|
+
run_dependencies(arguments.target.to_sym)
|
164
|
+
|
165
|
+
if arguments.target.to_sym == :debug
|
166
|
+
@compiler.debug = true
|
167
|
+
@compiler.defines << ["DEBUG", "ORCHID"]
|
168
|
+
|
169
|
+
Rake::Task[debug].reenable
|
170
|
+
Rake::Task[debug].invoke
|
171
|
+
else
|
172
|
+
@compiler.defines << "ORCHID"
|
173
|
+
|
174
|
+
Rake::Task[release].reenable
|
175
|
+
Rake::Task[release].invoke
|
176
|
+
end
|
177
|
+
|
178
|
+
cp_r File.join(@res.to_s, "."), @build.to_s if @res.directory?
|
179
|
+
|
180
|
+
@procedures[:build].call(self) if @procedures[:build]
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
namespace :install do
|
185
|
+
desc "Installs #{@name}; target is 'debug' or 'release'."
|
186
|
+
task @name.downcase, :target do |task, arguments|
|
187
|
+
arguments.with_defaults(:target => :debug)
|
188
|
+
|
189
|
+
Rake::Task["build:#{@name.downcase}"].invoke(arguments.target)
|
190
|
+
|
191
|
+
@procedures[:install].call(self) if @procedures[:install]
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
# abstract method that expresses dependability of a project towards
|
197
|
+
# another project's compiler; see check_dependencies
|
198
|
+
def dependability(compiler)
|
199
|
+
return nil
|
200
|
+
end
|
201
|
+
|
202
|
+
private
|
203
|
+
def run_dependencies(target = :debug)
|
204
|
+
@dependencies.each do |dependency|
|
205
|
+
taskname = "build:#{dependency.downcase}"
|
206
|
+
|
207
|
+
Rake::Task[taskname].invoke
|
208
|
+
end
|
209
|
+
|
210
|
+
return nil
|
211
|
+
end
|
212
|
+
end
|
data/orchid.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{orchid}
|
5
|
+
s.version = "0.0.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Oiki Yukio"]
|
9
|
+
s.date = %q{2010-02-28}
|
10
|
+
s.description = %q{A task lib for Rake easing the development of Vala applications and libraries.}
|
11
|
+
s.email = %q{oiki.yukio@gmail.com}
|
12
|
+
s.extra_rdoc_files = ["LICENSE", "README", "README.md", "lib/orchid.rb", "lib/orchid/app.rb", "lib/orchid/compiler.rb", "lib/orchid/library.rb", "lib/orchid/package.rb", "lib/orchid/pkg-config.rb", "lib/orchid/project.rb"]
|
13
|
+
s.files = ["LICENSE", "Manifest", "README", "README.md", "Rakefile", "lib/orchid.rb", "lib/orchid/app.rb", "lib/orchid/compiler.rb", "lib/orchid/library.rb", "lib/orchid/package.rb", "lib/orchid/pkg-config.rb", "lib/orchid/project.rb", "orchid.gemspec"]
|
14
|
+
s.homepage = %q{http://bitbucket.org/oik/orchid}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Orchid", "--main", "README"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{orchid}
|
18
|
+
s.rubygems_version = %q{1.3.5}
|
19
|
+
s.summary = %q{A build tool for Vala.}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
|
+
else
|
27
|
+
end
|
28
|
+
else
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: orchid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Oiki Yukio
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-28 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: A task lib for Rake easing the development of Vala applications and libraries.
|
17
|
+
email: oiki.yukio@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README
|
25
|
+
- README.md
|
26
|
+
- lib/orchid.rb
|
27
|
+
- lib/orchid/app.rb
|
28
|
+
- lib/orchid/compiler.rb
|
29
|
+
- lib/orchid/library.rb
|
30
|
+
- lib/orchid/package.rb
|
31
|
+
- lib/orchid/pkg-config.rb
|
32
|
+
- lib/orchid/project.rb
|
33
|
+
files:
|
34
|
+
- LICENSE
|
35
|
+
- Manifest
|
36
|
+
- README
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
39
|
+
- lib/orchid.rb
|
40
|
+
- lib/orchid/app.rb
|
41
|
+
- lib/orchid/compiler.rb
|
42
|
+
- lib/orchid/library.rb
|
43
|
+
- lib/orchid/package.rb
|
44
|
+
- lib/orchid/pkg-config.rb
|
45
|
+
- lib/orchid/project.rb
|
46
|
+
- orchid.gemspec
|
47
|
+
has_rdoc: true
|
48
|
+
homepage: http://bitbucket.org/oik/orchid
|
49
|
+
licenses: []
|
50
|
+
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options:
|
53
|
+
- --line-numbers
|
54
|
+
- --inline-source
|
55
|
+
- --title
|
56
|
+
- Orchid
|
57
|
+
- --main
|
58
|
+
- README
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: "0"
|
66
|
+
version:
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: "1.2"
|
72
|
+
version:
|
73
|
+
requirements: []
|
74
|
+
|
75
|
+
rubyforge_project: orchid
|
76
|
+
rubygems_version: 1.3.5
|
77
|
+
signing_key:
|
78
|
+
specification_version: 3
|
79
|
+
summary: A build tool for Vala.
|
80
|
+
test_files: []
|
81
|
+
|