Class: Pik::Devkit

Inherits:
Command show all
Defined in:
lib/pik/commands/devkit_command.rb

Instance Attribute Summary

Attributes inherited from Command

#config, #debug, #options, #output, #version

Instance Method Summary collapse

Methods inherited from Command

#actual_gem_home, #add_sigint_handler, aka, choose_from, #close, cmd_name, #cmd_name, #create, #current_gem_bin_path, #current_version?, #default_gem_home, #delete_old_pik_script, description, #editors, #find_config_from_path, #gem_path, #get_version, hl, inherited, #initialize, it, names, #parse_options, #pik_version, #sh, summary

Constructor Details

This class inherits a constructor from Pik::Command

Instance Method Details

#command_optionsObject



59
60
61
62
63
64
# File 'lib/pik/commands/devkit_command.rb', line 59

def command_options
  super
  sep =<<SEP
SEP
  options.separator sep  
end

#executeObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/pik/commands/devkit_command.rb', line 7

def execute
  if @args.include? 'update'
    puts "Updating devkit batch files for:"
    config.each{|ruby_version, ruby_config|
         ver = Pik::VersionParser.parse(ruby_version)
         if ver.platform =~ /mingw/
           puts "   #{ver.full_version}"
           write_batch_files(ruby_config[:path])
         end
        config.global[:devkit]
      }
  else
    help
  end
end

#write_batch_files(path) ⇒ Object



23
24
25
26
27
# File 'lib/pik/commands/devkit_command.rb', line 23

def write_batch_files(path)
  write_make(path)
  write_sh(path)
  write_gcc(path)
end

#write_gcc(path) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/pik/commands/devkit_command.rb', line 49

def write_gcc(path)
  Pik::BatchFile.new(path + 'gcc.bat') do |b|
    b.file_data << 'setlocal'
    b.set(:DEVKIT => config.global[:devkit])
    b.set(:PATH => "%DEVKIT%\\gcc\\3.4.5\\bin;%PATH%")
    b.file_data << "gcc.exe %*"
    b.write
  end
end

#write_make(path) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/pik/commands/devkit_command.rb', line 29

def write_make(path)
  Pik::BatchFile.new(path + 'make.bat') do |b|
    b.file_data << 'setlocal'
    b.set(:DEVKIT => config.global[:devkit])
    b.set(:PATH => "%DEVKIT%\\gcc\\3.4.5\\bin;%DEVKIT%\\msys\\1.0.11\\bin")
    b.file_data << "bash.exe --login -i -c \"make %*\""
    b.write
  end
end

#write_sh(path) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/pik/commands/devkit_command.rb', line 39

def write_sh(path)
  Pik::BatchFile.new(path + 'sh.bat') do |b|
    b.file_data << 'setlocal'
    b.set(:DEVKIT => config.global[:devkit])
    b.set(:PATH => "%DEVKIT%\\gcc\\3.4.5\\bin;%DEVKIT%\\msys\\1.0.11\\bin")
    b.file_data << "bash.exe --login -i -c \"sh %*\""
    b.write
  end
end