autoproj 1.0.0

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.
@@ -0,0 +1,30 @@
1
+ # This is the YAML configuration file for webgen used to set configuration options.
2
+ #
3
+ # The general syntax is:
4
+ #
5
+ # configuration.option.name: value
6
+ #
7
+ # For example, to set a different default language, you would do:
8
+ #
9
+ # website.lang: de
10
+ #
11
+ # Have a look at the documentation of the individual configuration options to see
12
+ # the allowed format of the values. Since this is a YAML file, you can easily set
13
+ # configuration options to strings, integers, dates, arrays, hashes and more.
14
+ #
15
+ # The available configuration options can be listed using the `webgen config`
16
+ # command, for example: `webgen config sourcehandler` will list all options starting
17
+ # with sourcehandler.
18
+ default_processing_pipeline:
19
+ Page: tags,maruku,blocks
20
+
21
+ default_meta_info:
22
+ Webgen::SourceHandler::Page:
23
+ in_menu: true
24
+
25
+ tag.menu.nested: false
26
+
27
+ tag.breadcrumbtrail.omit_index_path: true
28
+
29
+ tag.coderay.line_numbers: false
30
+ tag.coderay.lang: ruby
@@ -0,0 +1,17 @@
1
+ # = webgen extensions directory
2
+ #
3
+ # All init.rb files anywhere under this directory get automatically loaded on a webgen run. This
4
+ # allows you to add your own extensions to webgen or to modify webgen's core!
5
+ #
6
+ # If you don't need this feature you can savely delete this file and the directory in which it is!
7
+ #
8
+ # The +config+ variable below can be used to access the Webgen::Configuration object for the current
9
+ # website.
10
+ config = Webgen::WebsiteAccess.website.config
11
+
12
+ config = Webgen::WebsiteAccess.website.config
13
+ config['sourcehandler.patterns']['Webgen::SourceHandler::Copy'] << '**/autoproj_bootstrap'
14
+
15
+ $LOAD_PATH.unshift File.expand_path('..', File.dirname(__FILE__))
16
+ require 'ext/rdoc_links'
17
+ require 'ext/previous_next'
@@ -0,0 +1,40 @@
1
+ require 'webgen/tag'
2
+ class PrevNextTag
3
+ include Webgen::Tag::Base
4
+
5
+ def call(tag, body, context)
6
+ node = context.content_node
7
+ while !node.is_file?
8
+ node = node.parent
9
+ end
10
+
11
+ siblings = node.parent.children.sort
12
+ siblings.delete_if { |n| !n.meta_info['in_menu'] }
13
+ prev, _ = siblings.
14
+ enum_for(:each_cons, 2).
15
+ find { |prev, this| this == node }
16
+ _, nxt = siblings.
17
+ enum_for(:each_cons, 2).
18
+ find { |this, nxt| this == node }
19
+
20
+ content = if tag == "next" && nxt
21
+ node.link_to(nxt)
22
+ elsif tag == "previous" && prev
23
+ node.link_to(prev)
24
+ end
25
+
26
+ if content
27
+ if !body.empty?
28
+ body.gsub '%', content
29
+ else
30
+ content
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ config = Webgen::WebsiteAccess.website.config
37
+ config['contentprocessor.tags.map']['previous'] = 'PrevNextTag'
38
+ config['contentprocessor.tags.map']['next'] = 'PrevNextTag'
39
+
40
+
@@ -0,0 +1,33 @@
1
+ require 'webgen/tag'
2
+ class RdocLinks
3
+ include Webgen::Tag::Base
4
+
5
+ def call(tag, body, context)
6
+ name = param('rdoclinks.name')
7
+ if base_module = param('rdoclinks.base_module')
8
+ name = base_module + "::" + name
9
+ end
10
+
11
+ if name =~ /(?:\.|#)(\w+)$/
12
+ class_name = $`
13
+ method_name = $1
14
+ else
15
+ class_name = name
16
+ end
17
+
18
+ path = class_name.split('::')
19
+ path[-1] += ".html"
20
+ url = "#{param('rdoclinks.base_url')}/#{path.join("/")}"
21
+
22
+ "<a href=\"#{context.ref_node.route_to(url)}\">#{param('rdoclinks.name')}</a>"
23
+ end
24
+ end
25
+
26
+ config = Webgen::WebsiteAccess.website.config
27
+ config.rdoclinks.name "", :mandatory => 'default'
28
+ config.rdoclinks.base_webgen "", :mandatory => false
29
+ config.rdoclinks.base_url "", :mandatory => false
30
+ config.rdoclinks.base_module nil, :mandatory => false
31
+ config.rdoclinks.full_name false, :mandatory => false
32
+ config['contentprocessor.tags.map']['rdoc_class'] = 'RdocLinks'
33
+
@@ -0,0 +1,111 @@
1
+ ---
2
+ title: Writing autobuild scripts
3
+ sort_info: 200
4
+ ---
5
+
6
+ Defining CMake packages
7
+ -----------------------
8
+ A simple cmake package is defined with
9
+
10
+ {coderay:: ruby}
11
+ cmake_package "package_name"
12
+ {coderay}
13
+
14
+ More complex tweaking is achieved with
15
+
16
+ {coderay:: ruby}
17
+ cmake_package "package_name" do |pkg|
18
+ [modify the pkg object]
19
+ end
20
+ {coderay}
21
+
22
+ In particular, cmake build options can be given with
23
+
24
+ {coderay:: ruby}
25
+ cmake_package "package_name" do |pkg|
26
+ pkg.define "VAR", "VALUE"
27
+ end
28
+ {coderay}
29
+
30
+ The above snippet being equivalent to calling <tt>cmake -DVAR=VALUE</tt>
31
+
32
+ <b>Note to advanced users</b>
33
+ <br />
34
+ The "pkg" variable holds an object that represents the package. This
35
+ object is an instance of the Autobuild::CMake. See [the autobuild
36
+ API](http://doudou.github.com/autobuild/Autobuild/CMake.html) for more
37
+ details.
38
+ {.note}
39
+
40
+ Defining autotools packages
41
+ ---------------------------
42
+ TBD
43
+
44
+ Declaring documentation targets
45
+ -------------------------------
46
+ Both autotools and cmake packages use <tt>make</tt> as the low-level build tool.
47
+ For both packages, you can declare a documentation target that will be used
48
+ during the call to <tt>autoproj doc</tt> to generate documentation:
49
+
50
+ {coderay:: ruby}
51
+ cmake_package "package_name" do |pkg|
52
+ pkg.with_doc 'doc'
53
+ pkg.doc_dir = "doc/html"
54
+ end
55
+ {coderay}
56
+
57
+ The doc\_dir assignment above is needed if the package installs its documentation
58
+ elsewhere than "doc".
59
+
60
+ Defining dependencies
61
+ ---------------------
62
+ Inter-package dependencies can be defined with
63
+
64
+ {coderay:: ruby}
65
+ pkg.depends_on "package_name"
66
+ {coderay}
67
+
68
+ In the same way, if the source package depends on an OS package (see
69
+ [Prepackaged dependencies](os_deps.html) for details), you can use
70
+
71
+ {coderay:: ruby}
72
+ pkg.depends_on_os_package "package_name"
73
+ {coderay}
74
+
75
+ Both methods should be used only for dynamic dependencies, i.e. dependencies
76
+ that are dependent on build options (see below). Static dependencies should be
77
+ defined in the package's manifest.xml
78
+ {.warning}
79
+
80
+ Defining and using options
81
+ --------------------------
82
+
83
+ It is possible to define configuration options which are set by your user at
84
+ build time. These options can then be used in the autobuild scripts to
85
+ parametrize the build.
86
+
87
+ The general form of an option declaration is:
88
+
89
+ {coderay:: ruby}
90
+ configuration_option "option_name", "option_type",
91
+ :default => "default_value",
92
+ :values => ["set", "of", "possible", "values"],
93
+ :doc => "description of the option"
94
+ {coderay}
95
+
96
+ Once declared, it can be used in autobuild scripts with:
97
+
98
+ {coderay:: ruby}
99
+ user_config("option_name")
100
+ {coderay}
101
+
102
+ Options are saved in <tt>autoproj/config.yml</tt> after the build. Options that
103
+ are already set won't be asked again unless the <tt>--reconfigure</tt> option is
104
+ given to <tt>autoproj build</tt>.
105
+
106
+ Do not try to have too many options, that is in general bad policy as
107
+ non-advanced users won't be able to know what to answer. Advanced users will
108
+ always have the option to override your autobuild definitions to tweak the
109
+ builds to their needs.
110
+ {.warning}
111
+
@@ -0,0 +1,218 @@
1
+ #! /usr/bin/ruby
2
+
3
+ require 'yaml'
4
+ require 'set'
5
+ require 'rubygems'
6
+
7
+ module Autoproj
8
+ class << self
9
+ attr_reader :verbose
10
+ end
11
+ end
12
+
13
+ module Autobuild
14
+ module Subprocess
15
+ def self.run(name, phase, *cmd)
16
+ `#{cmd.join(" ")}`
17
+ if $?.exitstatus != 0
18
+ STDERR.puts "ERROR: failed to run #{cmd.join(" ")}"
19
+ exit 1
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ require 'tempfile'
26
+ module Autoproj
27
+ class OSDependencies
28
+ def self.load(file)
29
+ OSDependencies.new(YAML.load(File.read(file)))
30
+ end
31
+
32
+ attr_reader :definitions
33
+ def initialize(defs = Hash.new)
34
+ @definitions = defs.to_hash
35
+ end
36
+
37
+ def merge(info)
38
+ @definitions = definitions.merge(info.definitions)
39
+ end
40
+
41
+ def operating_system
42
+ if File.exists?('/etc/debian_version')
43
+ codename = File.read('/etc/debian_version').chomp
44
+ ['debian', codename]
45
+ else
46
+ raise ConfigError, "Unknown operating system"
47
+ end
48
+ end
49
+
50
+ GAIN_ROOT_ACCESS = <<-EOSCRIPT
51
+ if test `id -u` != "0"; then
52
+ exec sudo /bin/bash $0 "$@"
53
+
54
+ fi
55
+ EOSCRIPT
56
+
57
+ OS_PACKAGE_INSTALL = {
58
+ 'debian' => 'apt-get install -y %s'
59
+ }
60
+
61
+ def generate_os_script(dependencies)
62
+ os_name, os_version = operating_system
63
+ shell_snippets = ""
64
+ os_packages = []
65
+ dependencies.each do |name|
66
+ dep_def = definitions[name]
67
+ if !dep_def
68
+ raise ConfigError, "I don't know how to install '#{name}'"
69
+ elsif !dep_def[os_name]
70
+ raise ConfigError, "I don't know how to install '#{name}' on #{os_name}"
71
+ end
72
+
73
+ data = dep_def[os_name]
74
+ if data.kind_of?(Hash)
75
+ data = data[os_version]
76
+ if !data
77
+ raise ConfigError, "I don't know how to install '#{name}' on this specific version of #{os_name} (#{os_version})"
78
+ end
79
+ end
80
+
81
+ if data.respond_to?(:to_ary)
82
+ os_packages.concat data.to_ary
83
+ elsif data.to_str =~ /\w+/
84
+ os_packages << data.to_str
85
+ else
86
+ shell_snippets << "\n" << data << "\n"
87
+ end
88
+ end
89
+
90
+ "#! /bin/bash\n" +
91
+ GAIN_ROOT_ACCESS + "\n" +
92
+ (OS_PACKAGE_INSTALL[os_name] % [os_packages.join(" ")]) +
93
+ "\n" + shell_snippets
94
+ end
95
+
96
+ def partition_packages(package_set)
97
+ package_set = package_set.to_set
98
+ osdeps, gems = [], []
99
+ package_set.to_set.each do |name|
100
+ pkg_def = definitions[name]
101
+ if !pkg_def
102
+ raise ConfigError, "I know nothing about a prepackaged '#{name}' software"
103
+ end
104
+
105
+ if pkg_def.respond_to?(:to_str)
106
+ case(pkg_def.to_str)
107
+ when "gem" then
108
+ gems << name
109
+ else
110
+ raise ConfigError, "unknown OS-independent package management type #{pkg_def}"
111
+ end
112
+ else
113
+ osdeps << name
114
+ end
115
+ end
116
+ return osdeps, gems
117
+ end
118
+
119
+ def install(packages)
120
+ osdeps, gems = partition_packages(packages)
121
+
122
+ # Ideally, we would feed the OS dependencies to rosdep.
123
+ # Unfortunately, this is C++ code and I don't want to install the
124
+ # whole ROS stack just for rosdep ...
125
+ #
126
+ # So, for now, reimplement rosdep by ourselves. Given how things
127
+ # are done, this is actually not so hard.
128
+ shell_script = generate_os_script(osdeps)
129
+ if Autoproj.verbose
130
+ STDERR.puts "Installing non-ruby OS dependencies with"
131
+ STDERR.puts shell_script
132
+ end
133
+
134
+ File.open('osdeps.sh', 'w') do |file|
135
+ file.write shell_script
136
+ end
137
+ Autobuild::Subprocess.run 'autoproj', 'osdeps', 'bash', './osdeps.sh'
138
+ FileUtils.rm_f 'osdeps.sh'
139
+
140
+ # Don't install gems that are already there ...
141
+ gems.delete_if do |name|
142
+ version_requirements = Gem::Requirement.default
143
+ available = Gem.source_index.find_name(name, version_requirements)
144
+ !available.empty?
145
+ end
146
+
147
+ # Now install what is left
148
+ if !gems.empty?
149
+ if Autoproj.verbose
150
+ STDERR.puts "Installing rubygems dependencies with"
151
+ STDERR.puts "gem install #{gems.join(" ")}"
152
+ end
153
+ Autobuild::Subprocess.run 'autoproj', 'osdeps', 'gem', 'install', *gems
154
+ end
155
+ end
156
+ end
157
+ end
158
+
159
+
160
+
161
+ DEFS = <<EODEFS
162
+ ruby:
163
+ debian:
164
+ - ruby1.8-dev
165
+ - ruby1.8
166
+ - libopenssl-ruby1.8
167
+
168
+ build-essential:
169
+ debian: build-essential
170
+
171
+ libxml2:
172
+ debian:
173
+ - libxml2-dev
174
+ libxslt:
175
+ debian:
176
+ - libxslt1-dev
177
+ autoproj: gem
178
+ EODEFS
179
+
180
+ PACKAGES = %w{ruby libxml2 libxslt build-essential}
181
+ USER_PACKAGES = %w{autoproj}
182
+
183
+ packages = PACKAGES.dup
184
+ if ARGV.first != "dev"
185
+ packages += USER_PACKAGES
186
+ end
187
+
188
+ osdeps_management = Autoproj::OSDependencies.new(YAML.load(DEFS))
189
+ STDERR.puts "autoproj: installing autoproj and its dependencies (this can take a long time)"
190
+ osdeps_management.install(packages)
191
+
192
+ if ARGV.first != "dev"
193
+ ENV['RUBYOPT'] = "-rubygems"
194
+ ENV['GEM_HOME'] = "#{Dir.pwd}/autoproj/gems"
195
+ ENV['PATH'] = "#{ENV['GEM_HOME']}/bin:$PATH"
196
+ Autobuild::Subprocess.run('bootstrap', 'post', 'autoproj', 'bootstrap')
197
+ end
198
+
199
+ File.open('env.sh', 'w') do |io|
200
+ io.write <<-EOSHELL
201
+ export RUBYOPT=-rubygems
202
+ export GEM_HOME=#{Dir.pwd}/autoproj/gems
203
+ export PATH=$GEM_HOME/bin:$PATH
204
+ EOSHELL
205
+ end
206
+
207
+ STDERR.puts <<EOTEXT
208
+
209
+
210
+ add the following line at the bottom of your .bashrc:
211
+ source #{Dir.pwd}/env.sh
212
+
213
+ WARNING: autoproj will not work until your restart all
214
+ your consoles, or run the following in them:
215
+ $ source #{Dir.pwd}/env.sh
216
+
217
+ EOTEXT
218
+