cosmo0920
null+****@clear*****
Sat Sep 13 23:45:54 JST 2014
cosmo0920 2014-09-13 23:45:54 +0900 (Sat, 13 Sep 2014) New Revision: c4d049981e894f21a2fe9e87dc5856d39d9ee37a https://github.com/ranguba/rroonga/commit/c4d049981e894f21a2fe9e87dc5856d39d9ee37a Message: windows: Import Vagrantfile and scripts for cross build Added files: build/windows/README.md build/windows/Vagrantfile build/windows/build-functions.sh build/windows/cross-build-rroonga.sh build/windows/user-build.sh Added: build/windows/README.md (+19 -0) 100644 =================================================================== --- /dev/null +++ build/windows/README.md 2014-09-13 23:45:54 +0900 (aaaebca) @@ -0,0 +1,19 @@ +Vagrant box for Cross compiling Rroonga +=== + +Vagrant box for cross compiling Rroonga. + +```bash +$ cd build/windows +$ vagrant up +``` + +or simply execute in Rroonga root directory: + +```bash +$ rake build:windows +``` + +Then, cross compiling for a long time.... + +Cross compiled gems are copied under \<rroonga\_base\_dir\>/pkg when it executes via `rake build:windows`. Added: build/windows/Vagrantfile (+40 -0) 100644 =================================================================== --- /dev/null +++ build/windows/Vagrantfile 2014-09-13 23:45:54 +0900 (18e187d) @@ -0,0 +1,40 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +def use_cpu_nums + proc_file = "/proc/cpuinfo" + use_cpus = 1 + if File.exist?(proc_file) + cpu_nums = `cat #{proc_file} |grep processor|wc -l` + elsif RUBY_PLATFORM =~ /darwin/ + cpu_nums = `sysctl -n hw.ncpu` + elsif RUBY_PLATFORM =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/ + cpu_nums = `echo %NUMBER_OF_PROCESSORS%` + end + use_cpus = cpu_nums.to_i / 2 if cpu_nums.to_i >=2 + use_cpus +end + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + config.vm.box = "ubuntu-14.04-x86_64" + config.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box" + + config.vm.network "forwarded_port", guest: 80, host: 8080 + config.vm.network "private_network", ip: "192.168.33.107" + config.ssh.forward_agent = true + + config.vm.provider("virtualbox") do |vb| + vb.gui = false + use_cpus = use_cpu_nums + vb.customize ["modifyvm", :id, "--cpus", "#{use_cpus.to_s}"] + vb.customize ["modifyvm", :id, "--memory", "2048"] + vb.customize ["modifyvm", :id, "--ioapic", "on"] + vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] + vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] + end + + config.vm.provision :shell, path: "cross-build-rroonga.sh", privileged: false +end Added: build/windows/build-functions.sh (+42 -0) 100755 =================================================================== --- /dev/null +++ build/windows/build-functions.sh 2014-09-13 23:45:54 +0900 (bff180a) @@ -0,0 +1,42 @@ +#!/bin/bash + +function old_ruby_install_with_bundler() { + ruby_version=$1 + rbenv install $ruby_version + rbenv global $ruby_version + gem update --system + gem install bundler +} + +function ruby_install_with_bundler() { + ruby_version=$1 + rbenv install $ruby_version + rbenv global $ruby_version + gem install bundler +} + +function bundle_install() { + ruby_version=$1 + rbenv local $ruby_version + bundle install --path vendor/bundle +} + +function install_rake_compiler_cross_ruby() { + ruby_version=$1 + rbenv local $ruby_version + bundle exec rake-compiler cross-ruby HOST=i686-w64-mingw32 VERSION=$ruby_version + bundle exec rake-compiler cross-ruby HOST=x86_64-w64-mingw32 VERSION=$ruby_version +} + +function cross_compile() { + bundle exec rake clean:groonga + rbenv local $RUBY19 + bundle exec rake RUBY_CC_VERSION=$CROSS_TERGET MAKE_N_JOBS=$CPU_NUMS cross clean native gem + bundle exec rake clean:groonga + bundle exec rake RUBY_CC_VERSION=$CROSS_TERGET MAKE_N_JOBS=$CPU_NUMS RROONGA_USE_GROONGA_X64=true cross clean native gem +} + +function cp_pkg_gems() { + mkdir -p $PKG_GEMS + cp pkg/*.gem $PKG_GEMS +} Added: build/windows/cross-build-rroonga.sh (+8 -0) 100755 =================================================================== --- /dev/null +++ build/windows/cross-build-rroonga.sh 2014-09-13 23:45:54 +0900 (5486ba8) @@ -0,0 +1,8 @@ +#!/bin/bash + +export DEBIAN_FRONTEND=noninteractive +sudo apt-get update +sudo apt-get -y install libssl-dev libreadline-dev +sudo apt-get -y install git build-essential ruby mingw-w64 + +/vagrant/user-build.sh Added: build/windows/user-build.sh (+52 -0) 100755 =================================================================== --- /dev/null +++ build/windows/user-build.sh 2014-09-13 23:45:54 +0900 (483112a) @@ -0,0 +1,52 @@ +#!/bin/bash -x + +readonly RUBY19="1.9.3-p547" +readonly RUBY20="2.0.0-p481" +readonly RUBY21="2.1.2" +readonly CROSS_TERGET="1.9.3:2.0.0:2.1.2" +readonly PKG_GEMS="/vagrant/pkg" +readonly CPU_NUMS=`cat /proc/cpuinfo |grep processor|wc -l` + +if [ ! -d ~/.rbenv ]; then + git clone https://github.com/sstephenson/rbenv.git ~/.rbenv + echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc + echo 'eval "$(rbenv init -)"' >> ~/.bashrc +fi + +if [ ! -d ~/.rbenv/plugins/ruby-build ]; then + git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build +fi + +# setting PATH +export PATH="$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH" +bash -l -c 'source ~/.bashrc' +. /vagrant/build-functions.sh + +# Ruby 1.9.3 +old_ruby_install_with_bundler $RUBY19 +# Ruby 2.0.0 +ruby_install_with_bundler $RUBY20 +# Ruby 2.1.2 +ruby_install_with_bundler $RUBY21 + +if [ ! -d ~/rroonga ]; then + git clone https://github.com/ranguba/rroonga.git ~/rroonga +fi + +cd ~/rroonga + +# bundle install +bundle_install $RUBY19 +bundle_install $RUBY20 +bundle_install $RUBY21 + +# install cross ruby with rake-compiler +install_rake_compiler_cross_ruby $RUBY19 +install_rake_compiler_cross_ruby $RUBY20 +install_rake_compiler_cross_ruby $RUBY21 + +# cross-compile +cross_compile + +# copy pkg/*.gem to /vagrant/pkgs +cp_pkg_gems -------------- next part -------------- HTML����������������������������...Download