class Gdlc::GDLC

Constants

GDLC_PATH
OUTDIR_PATH

Public Class Methods

add_flag(flg) click to toggle source

Add a compiler flag

Duplicate flags are discarded.

flg - Flag to set.

# File lib/gdlc/gdlc.rb, line 50
def GDLC.add_flag(flg)
  @@flags << flg unless @@flags.include? flg
end
add_include_dirs(dirs) click to toggle source

Add include dir(s)

dirName - Name of directory

# File lib/gdlc/gdlc.rb, line 73
def GDLC.add_include_dirs(dirs)
  if(dirs.class == Array)
    dirs.each do |d|
      @@incdirs << d unless @@incdirs.include? d
    end
  else
    @@incdirs << dirs unless @@incdirs.include? dirs
  end
end
app_path() click to toggle source

Class methods

# File lib/gdlc/gdlc.rb, line 30
def GDLC.app_path
  @@app_path
end
app_path=(apppath) click to toggle source
# File lib/gdlc/gdlc.rb, line 34
def GDLC.app_path=(apppath)
  @@app_path = apppath
end
clear_flags() click to toggle source

clear all flags

# File lib/gdlc/gdlc.rb, line 40
def GDLC.clear_flags
  @@flags = []
end
clear_include_dirs() click to toggle source

Clear out the include directory list

# File lib/gdlc/gdlc.rb, line 96
def GDLC.clear_include_dirs
  @@incdirs.clear

end
compile(srcfile, outname) click to toggle source

Compile a guideline

srcfile - Name of source file to compile outname - Name of output file

# File lib/gdlc/gdlc.rb, line 106
def GDLC.compile(srcfile, outname)
  GDLC.execute_GDLC("#{GDLC.get_flags} #{GDLC.get_include_dirs} #{srcfile} #{outname}")
end
get_flags() click to toggle source

Return a string containing all flags as input parameters

returns params - string containing all flags separated with space

# File lib/gdlc/gdlc.rb, line 59
def GDLC.get_flags
  return @@flags.join " "
end
get_include_dirs() click to toggle source

Return a string containing all include dirs as input parameters Formats string as ‘/Isome/dir/name /Isome/other/dir’

returns params - Parameter string

# File lib/gdlc/gdlc.rb, line 88
def GDLC.get_include_dirs
  @@incdirs
  params = @@incdirs.map { |d| "--I#{d}" }
  params.join ' '
end
incdirs() click to toggle source

Return compiler include dirs array

# File lib/gdlc/gdlc.rb, line 65
def GDLC.incdirs
  @@incdirs
end

Private Class Methods

execute_GDLC(cmdLine) click to toggle source

Execute GDLC application

cmdLine - Command line to pass to the application

# File lib/gdlc/gdlc.rb, line 116
def GDLC.execute_GDLC(cmdLine)
  app_cmd = "#{@@app_path} #{cmdLine}"
  puts "Executing: #{app_cmd}"

  output = `#{app_cmd}`
  exitcode = $?.exitstatus

  # Currently unable to retrieve exit code from java jar execution.
  # May be because 'system' executes a sub-process which is executing
  # the JVM which returns the exit code.
  # Regardless of the JVM exit code, the sub-process returns 0.
  #
  # For now, we'll look for a specific message in the output and fail if
  # its not found.
  puts output
  fail 'compile failed' unless output.include?('XML written to file')
end