Skip to content

Commit

Permalink
Build kernel with gemified build tools.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Aug 3, 2013
1 parent e63e30e commit f7b40e2
Showing 1 changed file with 14 additions and 68 deletions.
82 changes: 14 additions & 68 deletions rakelib/kernel.rake
Expand Up @@ -22,44 +22,18 @@ def kernel_clean
:verbose => $verbose
end

require 'kernel/bootstrap/iseq.rb'

# So that the compiler can try and use the config
module Rubinius
Config = { 'eval.cache' => false }
end

# TODO: Build this functionality into the compiler
class KernelCompiler
def self.compile(file, output, line, transforms)
compiler = Rubinius::Compiler.new :file, :compiled_file
compiler = Rubinius::ToolSet::Build::Compiler.new :file, :compiled_file

parser = compiler.parser
parser.root Rubinius::AST::Script

writer = compiler.writer

# Not ready to enable them yet
case BUILD_CONFIG[:language_version]
when "18"
parser.processor Rubinius::Melbourne
writer.version = 18
when "19"
parser.processor Rubinius::Melbourne19
writer.version = 19
when "20"
parser.processor Rubinius::Melbourne20
writer.version = 20
end

if transforms.kind_of? Array
transforms.each { |t| parser.enable_category t }
else
parser.enable_category transforms
end

parser.root Rubinius::ToolSet::Build::AST::Script
parser.input file, line

generator = compiler.generator
generator.processor Rubinius::ToolSet::Build::Generator

writer = compiler.writer
writer.name = output

Expand Down Expand Up @@ -108,24 +82,6 @@ opcodes = "lib/compiler/opcodes.rb"
# Generate a digest of the Rubinius runtime files
signature_file = "kernel/signature.rb"

compiler_files = FileList[
"lib/compiler.rb",
"lib/compiler/**/*.rb",
opcodes,
"lib/compiler/generator_methods.rb",
"lib/melbourne.rb",
"lib/melbourne/**/*.rb",
"vm/marshal.[ch]pp"
]

parser_files = FileList[
"lib/ext/melbourne/**/*.{c,h}pp",
"lib/ext/melbourne/grammar18.y",
"lib/ext/melbourne/grammar19.y",
"lib/ext/melbourne/lex.c.tab",
"lib/ext/melbourne/lex.c.blt"
]

kernel_files = FileList[
"kernel/**/*.txt",
"kernel/**/*.rb"
Expand Down Expand Up @@ -226,34 +182,24 @@ end
kernel_file_task runtime, signature_file, name
end

compiler_files.map { |f| File.dirname f }.uniq.each do |dir|
directory dir
end

compiler_files.each do |name|
compiler_file_task runtime, signature_file, name
end

namespace :compiler do
signature_path = File.expand_path("../../kernel/signature", __FILE__)

Rubinius::COMPILER_PATH = libprefixdir
Rubinius::PARSER_PATH = "#{libprefixdir}/melbourne"
Rubinius::PARSER_EXT_PATH = "#{libprefixdir}/ext/melbourne/build/melbourne20"

melbourne = "lib/ext/melbourne/build/melbourne.#{$dlext}"

file melbourne => "extensions:melbourne_build"
task :load => ['compiler:generate'] do
require "rubinius/bridge"
require "rubinius/toolset"

task :load => ['compiler:generate', melbourne] + compiler_files do

if BUILD_CONFIG[:which_ruby] == :ruby
require "#{Rubinius::COMPILER_PATH}/mri_bridge"
elsif BUILD_CONFIG[:which_ruby] == :rbx && RUBY_VERSION =~ /^1\.8/
require "#{Rubinius::COMPILER_PATH}/rbx_bridge"
end
Rubinius::ToolSet.start
require "rubinius/melbourne"
require "rubinius/processor"
require "rubinius/compiler"
require "rubinius/ast"
Rubinius::ToolSet.finish :build

require "#{Rubinius::COMPILER_PATH}/compiler"
require signature_path
end

Expand Down

0 comments on commit f7b40e2

Please sign in to comment.