Module: Orchid

Defined in:
lib/orchid.rb

Defined Under Namespace

Classes: App, Compiler, Library, Package, PackageDoesNotExistError, Project, Version

Constant Summary collapse

CC =
Config::CONFIG["CC"]
VALAC =
"valac"
DIRS =
{ :bindir  => Config::CONFIG["bindir"],
:datadir => Config::CONFIG["datadir"],
:libdir  => Config::CONFIG["libdir"],
:vapidir => discover_global_vapidir() }
LIBARGS =
[Config::CONFIG["CCDLFLAGS"]].flatten.freeze
INFO =
{ :version => discover_compiler_version(),
:compiler_opts => discover_compiler_options(),
:vapidir => DIRS[:vapidir] }
true
PROJECTS =
{}
CHECKED_PACKAGES =
{}

Class Method Summary collapse

Class Method Details

.discover_compiler_optionsObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/orchid.rb', line 65

def self.discover_compiler_options
  exclude = ["disable-warnings", "symbols", "save-temps"]
  
  options = []
  valac_help = `#{VALAC} --help`
  valac_help = valac_help.split(/[\t\r\n]+/).compact.map do |string|
    string = string.gsub(/[\t\r\n]+/, '').gsub(/\ +/, ' ') if string
  end
  
  in_options = false
  
  valac_help.each do |string|      
    if in_options
      extract = string.scan(/\s+-{1,2}([\w-]+)(=([\w-]+)(\.{3,})?)?/i)
      
      option = {}
      
      option[:name] = [extract.first.first, extract.last.first].uniq
      option[:multiple] = extract.last[3] == "..." ? true : false
      option[:bool] = extract.last[2] ? false : true
      
      options << option if (option[:name] & exclude).empty?
    end
    
    in_options = true if string.match(/Application Options\:/)
  end
  
  return options.uniq
end

.discover_compiler_versionObject



95
96
97
98
99
100
# File 'lib/orchid.rb', line 95

def self.discover_compiler_version
  valac_version = `#{VALAC} --version`.split
  valac_version = valac_version.last.gsub(/[\t\n\r]+/, '')
  
  return Orchid::Version.new(valac_version)
end

.discover_global_vapidirObject



102
103
104
105
106
# File 'lib/orchid.rb', line 102

def self.discover_global_vapidir
  glib20 = `locate -b glib-2.0.vapi`
  
  return File.dirname(glib20.strip)
end

.register_project(project) ⇒ Object



124
125
126
# File 'lib/orchid.rb', line 124

def self.register_project(project)
  PROJECTS[project.name] = project
end