Last active
September 28, 2019 08:16
-
-
Save ssnickolay/6740a1187055b892f8186e91191db9e1 to your computer and use it in GitHub Desktop.
Build Ruby via gg Framework. https://github.com/StanfordSNR/gg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on https://github.com/StanfordSNR/gg/blob/master/docker/README.md | |
# install deps | |
apt-get install -y ruby bison | |
# clone Ruby | |
git clone --single-branch --branch ruby_2_6 https://github.com/ruby/ruby.git | |
cd ruby | |
# build configuration files | |
touch config.status | |
sed -f tool/prereq.status Makefile.in common.mk > Makefile | |
make -s -j$(nproc) update-download | |
make -s -j$(nproc) srcs | |
cd ../ | |
# execute fixups | |
wget https://gist.githubusercontent.com/ssnickolay/6740a1187055b892f8186e91191db9e1/raw/c30e9e1f231dd7bf253221a028d4aaae328cc606/fixup.rb | |
chmod +x fixup.rb | |
./fixup.rb ruby/configure | |
mkdir build | |
# use gg | |
CC="$GG_MODELPATH/gcc" CXX="$GG_MODELPATH/g++" GG_BYPASS=1 ../ruby/configure --prefix=$PWD/../install -C --disable-install-doc --disable-jit-support | |
# STEP 1 | |
gg init | |
gg infer make -j$(nproc) miniruby | |
cat ./miniruby | |
# #!/usr/bin/env gg-force-and-run | |
# TM20oOJnybvjKBPY_YJVHo9e06R_pcDq4lLfbbYidhyo000023eb | |
# STEP 2 | |
gg force --jobs 500 --engine lambda miniruby | |
./miniruby -e "puts 'Hello, RubyRussia!'" | |
# Hello, RubyRussia! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'fileutils' | |
def backup(file) | |
name = File.basename(file) | |
folder = File.expand_path("..", File.absolute_path(file)) | |
FileUtils.cp( | |
"#{ folder }/#{ name }", | |
"#{ folder }/#{ name }_backup", | |
) | |
end | |
EXP = /if ac_fn_c_try/ | |
ERROR1 = /something wrong with CFLAGS=/ # 7844 | |
ERROR2 = /something wrong with LDFLAGS=/ # 7878 | |
THEN = /; then/ | |
THEN_REPLACE = ' || true; then' | |
GCC_FLAG1 = /-E -xc/ | |
GCC_FLAG1_FIX = '-E -x c' | |
def fixup(file) | |
lines = [] | |
File.foreach(file).with_index do |line, line_num| | |
if line.match?(ERROR1) || line.match?(ERROR2) | |
lines.reverse_each.with_index do |r_line, r_line_num| | |
if r_line.match?(EXP) | |
# skip config rule | |
lines[line_num - r_line_num - 1] = r_line.gsub!(THEN, THEN_REPLACE) | |
break | |
end | |
end | |
end | |
if line.match?(GCC_FLAG1) | |
lines << line.gsub!(GCC_FLAG1, GCC_FLAG1_FIX) | |
else | |
lines << line | |
end | |
end | |
File.open(File.path(file), 'w') { |f| f.puts lines } | |
end | |
path = ARGV[0] | |
abort('Wrong configuration file path') unless File.exists?(path) | |
config = File.new(path) | |
backup(config) | |
puts 'Backup was created' | |
fixup(config) | |
puts 'Congig was fixed!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment