Class: Tebako::ScenarioManagerBase

Inherits:
Object
  • Object
show all
Defined in:
lib/tebako/scenario_manager.rb

Overview

A couple of static Scenario definitions

Direct Known Subclasses

ScenarioManager

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ostype = RUBY_PLATFORM) ⇒ ScenarioManagerBase

Returns a new instance of ScenarioManagerBase.



43
44
45
46
47
48
49
50
51
52
# File 'lib/tebako/scenario_manager.rb', line 43

def initialize(ostype = RUBY_PLATFORM)
  @ostype = ostype
  @linux = @ostype =~ /linux/ ? true : false
  @musl = @ostype =~ /linux-musl/ ? true : false
  @macos = @ostype =~ /darwin/ ? true : false
  @msys  = @ostype =~ /msys|mingw|cygwin/ ? true : false

  @fs_mount_point = @msys ? "A:/__tebako_memfs__" : "/__tebako_memfs__"
  @exe_suffix = @msys ? ".exe" : ""
end

Instance Attribute Details

#exe_suffixObject (readonly)

Returns the value of attribute exe_suffix.



54
55
56
# File 'lib/tebako/scenario_manager.rb', line 54

def exe_suffix
  @exe_suffix
end

#fs_mount_pointObject (readonly)

Returns the value of attribute fs_mount_point.



54
55
56
# File 'lib/tebako/scenario_manager.rb', line 54

def fs_mount_point
  @fs_mount_point
end

Instance Method Details

#b_envObject



56
57
58
59
60
61
62
63
64
65
# File 'lib/tebako/scenario_manager.rb', line 56

def b_env
  u_flags = if @macos
              "-DTARGET_OS_SIMULATOR=0 -DTARGET_OS_IPHONE=0  #{ENV.fetch("CXXFLAGS", nil)}"
            elsif @msys
              "-DGFLAGS_IS_A_DLL=0   #{ENV.fetch("CXXFLAGS", nil)}"
            else
              ENV.fetch("CXXFLAGS", nil)
            end
  @b_env ||= { "CXXFLAGS" => u_flags }
end

#linux?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/tebako/scenario_manager.rb', line 67

def linux?
  @linux
end

#linux_gnu?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/tebako/scenario_manager.rb', line 71

def linux_gnu?
  @linux && !@musl
end

#linux_musl?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/tebako/scenario_manager.rb', line 75

def linux_musl?
  @linux && @musl
end

#m_filesObject



79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/tebako/scenario_manager.rb', line 79

def m_files
  # [TODO]
  # Ninja generates incorrect script for tebako press target -- gets lost in a chain custom targets
  # Using makefiles has negative performance impact so it needs to be fixed

  @m_files ||= if @linux || @macos
                 "Unix Makefiles"
               elsif @msys
                 "MinGW Makefiles"
               else
                 raise Tebako::Error.new("#{RUBY_PLATFORM} is not supported.", 112)
               end
end

#macos?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/tebako/scenario_manager.rb', line 93

def macos?
  @macos
end

#msys?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'lib/tebako/scenario_manager.rb', line 97

def msys?
  @msys
end

#musl?Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/tebako/scenario_manager.rb', line 101

def musl?
  @musl
end

#ncoresObject



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/tebako/scenario_manager.rb', line 105

def ncores
  if @ncores.nil?
    if @macos
      out, st = Open3.capture2e("sysctl", "-n", "hw.ncpu")
    else
      out, st = Open3.capture2e("nproc", "--all")
    end

    @ncores = !st.signaled? && st.exitstatus.zero? ? out.strip.to_i : 4
  end
  @ncores
end