Unverified Commit 1cc1ade6 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #5263 from shuujii/use-namespaces-according-to-Rake-conventions

Use namespaces according to Rake conventions
parents 76241a96 0dfcaaed
desc 'generate document' desc 'generate document'
task :doc => [:api_doc, :capi_doc] do task :doc => %w[doc:api doc:capi]
end namespace :doc do
desc 'generate yard docs'
desc 'generate yard docs' task :api do
task :api_doc do begin
begin sh "mrbdoc"
sh "mrbdoc" rescue
rescue puts "ERROR: To generate yard documentation, you should install yard-mruby gem."
puts "ERROR: To generate yard documentation, you should install yard-mruby gem." puts " $ gem install yard-mruby yard-coderay"
puts " $ gem install yard-mruby yard-coderay" end
end end
end
desc 'generate doxygen docs' desc 'generate doxygen docs'
task :capi_doc do task :capi do
begin begin
sh "doxygen Doxyfile" sh "doxygen Doxyfile"
rescue rescue
puts "ERROR: To generate C API documents, you need Doxygen." puts "ERROR: To generate C API documents, you need Doxygen."
puts " $ sudo apt-get install doxygen" puts " $ sudo apt-get install doxygen"
end
end end
end
desc 'clean all built docs' desc 'clean all built docs'
task :clean_api_doc do task :clean => %w[clean:api clean:capi]
rm_rf 'doc/api'
end
desc 'clean all built docs' namespace :clean do
task :clean_capi_doc do desc 'clean yard docs'
rm_rf 'doc/capi' task :api do
end rm_rf 'doc/api'
end
desc 'clean all built docs' desc 'clean doxygen docs'
task :clean_doc => [:clean_api_doc, :clean_capi_doc] do task :capi do
end rm_rf 'doc/capi'
end
end
desc 'clean all built docs' namespace :view do
task :view_api => [:api_doc] do desc 'open yard docs'
sh 'xdg-open doc/api/index.html' task :api do
end sh 'xdg-open doc/api/index.html'
end
desc 'clean all built docs' desc 'open doxygen docs'
task :view_capi => [:capi_doc] do task :capi do
sh 'xdg-open doc/capi/html/index.html' sh 'xdg-open doc/capi/html/index.html'
end
end
end end
# deprecated
task "api_doc" => "doc:api"
task "capi_doc" => "doc:capi"
task "clean_doc" => "doc:clean"
task "clean_api_doc" => "doc:clean:api"
task "clean_capi_doc" => "doc:clean:capi"
task "view_api" => "doc:view:api"
task "view_capi" => "doc:view:capi"
...@@ -25,91 +25,97 @@ def run_cmd(cmd) ...@@ -25,91 +25,97 @@ def run_cmd(cmd)
raise 'error' unless system cmd raise 'error' unless system cmd
end end
desc 'recreate docker images for GitLab builds' namespace :gitlab do
task :gitlab_dockers do desc 'recreate docker images for GitLab builds'
CI_COMPILERS.each do |compiler| task :dockers do
tag = ci_image_tag(compiler) CI_COMPILERS.each do |compiler|
filename = "Dockerfile.#{tag}" tag = ci_image_tag(compiler)
File.open(filename, 'wb') do |f| filename = "Dockerfile.#{tag}"
f << "# #{compiler} - #{tag}\n" File.open(filename, 'wb') do |f|
f << "FROM #{CI_BASE}\n" f << "# #{compiler} - #{tag}\n"
f << "RUN apt-get update && apt-get install -y git ruby2.3 ruby2.3-dev bison\n" f << "FROM #{CI_BASE}\n"
f << "RUN apt-get update && apt-get install -y binutils manpages\n" f << "RUN apt-get update && apt-get install -y git ruby2.3 ruby2.3-dev bison\n"
f << "RUN apt-get update && apt-get install -y #{compiler}\n" f << "RUN apt-get update && apt-get install -y binutils manpages\n"
if compiler['gcc'] f << "RUN apt-get update && apt-get install -y #{compiler}\n"
f << "RUN apt-get update && apt-get install -y libx32#{compiler}-dev\n" if compiler['gcc']
f << "RUN apt-get update && apt-get install --no-install-recommends -y #{compiler}-multilib\n" f << "RUN apt-get update && apt-get install -y libx32#{compiler}-dev\n"
end f << "RUN apt-get update && apt-get install --no-install-recommends -y #{compiler}-multilib\n"
f << "RUN dpkg --add-architecture i386\n" end
f << "RUN apt-get update && apt-get install -y linux-libc-dev:i386\n" f << "RUN dpkg --add-architecture i386\n"
if compiler['clang'] f << "RUN apt-get update && apt-get install -y linux-libc-dev:i386\n"
f << "RUN apt-get update && apt-get install --no-install-recommends -y libc6-dev-i386\n" if compiler['clang']
f << "RUN apt-get update && apt-get install -y gcc gcc-multilib\n" f << "RUN apt-get update && apt-get install --no-install-recommends -y libc6-dev-i386\n"
f << "RUN apt-get update && apt-get install -y gcc gcc-multilib\n"
end
end end
docker_tag = ci_docker_tag(compiler)
cmd1 = "docker build -t #{docker_tag} -f #{filename} ."
cmd2 = "docker push #{docker_tag}"
run_cmd cmd1
run_cmd cmd2
File.delete(filename)
end end
docker_tag = ci_docker_tag(compiler)
cmd1 = "docker build -t #{docker_tag} -f #{filename} ."
cmd2 = "docker push #{docker_tag}"
run_cmd cmd1
run_cmd cmd2
File.delete(filename)
end end
end
desc 'create build configurations and update .gitlab-ci.yml' desc 'create build configurations and update .gitlab-ci.yml'
task :gitlab_config do task :config do
require 'yaml' require 'yaml'
configs = [] configs = []
[true, false].each do |mode_32| [true, false].each do |mode_32|
['', 'MRB_USE_FLOAT32'].each do |float_conf| ['', 'MRB_USE_FLOAT32'].each do |float_conf|
['', 'MRB_NAN_BOXING', 'MRB_WORD_BOXING'].each do |boxing_conf| ['', 'MRB_NAN_BOXING', 'MRB_WORD_BOXING'].each do |boxing_conf|
['', 'MRB_UTF8_STRING'].each do |utf8_conf| ['', 'MRB_UTF8_STRING'].each do |utf8_conf|
next if (float_conf == 'MRB_USE_FLOAT32') && (boxing_conf == 'MRB_NAN_BOXING') next if (float_conf == 'MRB_USE_FLOAT32') && (boxing_conf == 'MRB_NAN_BOXING')
next if (int_conf == 'MRB_INT64') && (boxing_conf == 'MRB_NAN_BOXING') next if (int_conf == 'MRB_INT64') && (boxing_conf == 'MRB_NAN_BOXING')
next if (int_conf == 'MRB_INT64') && (boxing_conf == 'MRB_WORD_BOXING') && mode_32 next if (int_conf == 'MRB_INT64') && (boxing_conf == 'MRB_WORD_BOXING') && mode_32
env = [float_conf, int_conf, boxing_conf, utf8_conf].map do |conf| env = [float_conf, int_conf, boxing_conf, utf8_conf].map do |conf|
conf == '' ? nil : "-D#{conf}=1" conf == '' ? nil : "-D#{conf}=1"
end.compact.join(' ') end.compact.join(' ')
bit = mode_32 ? '-m32 ' : '' bit = mode_32 ? '-m32 ' : ''
_info = '' _info = ''
_info += mode_32 ? '32bit ' : '64bit ' _info += mode_32 ? '32bit ' : '64bit '
_info += float_conf['USE'] ? 'float ' : '' _info += float_conf['USE'] ? 'float ' : ''
_info += int_conf['16'] ? 'int16 ' : '' _info += int_conf['16'] ? 'int16 ' : ''
_info += int_conf['64'] ? 'int64 ' : '' _info += int_conf['64'] ? 'int64 ' : ''
_info += boxing_conf['NAN'] ? 'nan ' : '' _info += boxing_conf['NAN'] ? 'nan ' : ''
_info += boxing_conf['WORD'] ? 'word ' : '' _info += boxing_conf['WORD'] ? 'word ' : ''
_info += utf8_conf['UTF8'] ? 'utf8 ' : '' _info += utf8_conf['UTF8'] ? 'utf8 ' : ''
_info = _info.gsub(/ +/, ' ').strip.tr(' ', '_') _info = _info.gsub(/ +/, ' ').strip.tr(' ', '_')
configs << { '_info' => _info, 'CFLAGS' => "#{bit}#{env}", 'LDFLAGS' => bit.strip.to_s } configs << { '_info' => _info, 'CFLAGS' => "#{bit}#{env}", 'LDFLAGS' => bit.strip.to_s }
end
end end
end end
end end
end path = './.gitlab-ci.yml'
path = './.gitlab-ci.yml' data = YAML.load_file(path)
data = YAML.load_file(path) data.keys.select do |key|
data.keys.select do |key| key.start_with? 'Test'
key.start_with? 'Test' end.each do |key|
end.each do |key| data.delete(key)
data.delete(key) end
end CI_COMPILERS.each do |compiler|
CI_COMPILERS.each do |compiler| configs.each do |config|
configs.each do |config| name = "Test #{compiler} #{config['_info']}"
name = "Test #{compiler} #{config['_info']}" hash = {
hash = { 'CC' => compiler,
'CC' => compiler, 'CXX' => compiler.gsub('gcc', 'g++').gsub('clang', 'clang++'),
'CXX' => compiler.gsub('gcc', 'g++').gsub('clang', 'clang++'), 'LD' => compiler
'LD' => compiler }
} hash = hash.merge(config)
hash = hash.merge(config) hash.delete('_info')
hash.delete('_info') data[name] = {
data[name] = { 'stage' => 'test',
'stage' => 'test', 'image' => ci_docker_tag(compiler),
'image' => ci_docker_tag(compiler), 'variables' => hash,
'variables' => hash, 'script' => 'env; rake --verbose all test'
'script' => 'env; rake --verbose all test' }
} end
end end
File.open(path, 'w') { |f| YAML.dump(data, f) }
end end
File.open(path, 'w') { |f| YAML.dump(data, f) }
end end
# deprecated
task "gitlab_config" => "gitlab:config"
task "gitlab_dockers" => "gitlab:dockers"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment