holywyvern/carbuncle

View on GitHub
build_configs/utils/gems.rb

Summary

Maintainability
A
0 mins
Test Coverage
CARBUNCLE_GEMS = %w[
  dependencies support core audio doc-ext graphics
  input math scene tilemap
].freeze

STDLIB_GEMS = %w[
  mruby-compar-ext mruby-enum-ext mruby-string-ext mruby-numeric-ext
  mruby-array-ext mruby-hash-ext mruby-range-ext mruby-proc-ext
  mruby-symbol-ext mruby-object-ext mruby-objectspace mruby-set
  mruby-fiber mruby-enumerator mruby-enum-lazy mruby-toplevel-ext
  mruby-kernel-ext mruby-class-ext mruby-struct mruby-catch mruby-data
  mruby-enum-chain mruby-pack mruby-proc-binding
  mruby-print
].freeze

MATH_GEMS = %w[
  mruby-math mruby-rational mruby-complex mruby-cmath mruby-bigint
  mruby-random
].freeze

METAPROG_GEMS = %w[
  mruby-metaprog mruby-method mruby-eval mruby-compiler
].freeze

MRUBY_BINARIES = %w[
  mruby-bin-mrbc mruby-bin-mirb
].freeze

CORE_GEMS = (STDLIB_GEMS + MATH_GEMS + METAPROG_GEMS + MRUBY_BINARIES).freeze
  
GITHUB_GEMS = %w[
  iij/mruby-regexp-pcre mattn/mruby-json
].freeze

def add_core_gems(conf)
  CORE_GEMS.each do |gem|
    conf.gem core: gem
  end
end
  
def add_external_gems(conf)
  GITHUB_GEMS.each do |gem|
    conf.gem github: gem
  end
end
  
def add_carbuncle_gems(conf)
  root_dir = File.join(__dir__, '..', '..', 'gems')
  CARBUNCLE_GEMS.each do |name|
    conf.gem File.expand_path(File.join(root_dir, "carbuncle-#{name}"))
  end
  conf.gem File.expand_path(File.join(root_dir, 'mruby-bin-carbuncle'))
end

def setup_carbuncle(conf)
  add_core_gems(conf)
  add_external_gems(conf)
  add_carbuncle_gems(conf)
end

def setup_carbuncle_debug(conf)
  return if ENV['DEBUG'] != 'true'

  conf.enable_test
  conf.enable_debug
  conf.cc.defines += %w[MRB_ENABLE_DEBUG_HOOK]
  conf.gem core: 'mruby-bin-debugger'
end