Module: Tebako::CliHelpers
- Defined in:
- lib/tebako/cli_helpers.rb
Overview
Cli helpers
Constant Summary collapse
- WARN =
<<~WARN ****************************************************************************************************************** * * * WARNING: You are packaging in-place, i.e.: tebako package will be placed inside application root. * * It is not an error but we do not recommend it because it is a way to keep packaging old versions recrsively. * * * * For example, ensure that `--root=` differs from `--output=` as described in README.adoc: * * tebako press --root='~/projects/myproject' --entry=start.rb --output=/temp/myproject.tebako * * * ****************************************************************************************************************** WARN
- WARN2 =
<<~WARN ****************************************************************************************************************** * * * WARNING: You are creating packaging environment inside application root. * * It is not an error but it means that all build-time artifacts will ne included in tebako package. * * You do not need it unless under very special circumstances like tebako packaging tebako itself. * * * * Please consider removing your exisitng `--prefix` folder abd use another one that points outside of `--root` * * like tebako press --r ~/projects/myproject -e start.rb -o /temp/myproject.tebako -p ~/.tebako * * * ****************************************************************************************************************** WARN
Instance Method Summary collapse
- #check_warnings(options_manager) ⇒ Object
- #do_press(options_manager) ⇒ Object
- #do_press_application(options_manager, scenario_manager) ⇒ Object
- #do_press_runtime(options_manager, scenario_manager) ⇒ Object
- #do_setup(options_manager) ⇒ Object
- #finalize(options_manager, scenario_manager) ⇒ Object
- #generate_files(options_manager, scenario_manager) ⇒ Object
- #options_from_tebafile(tebafile) ⇒ Object
- #press_build_cmd(options_manager) ⇒ Object
- #press_cfg_cmd(options_manager) ⇒ Object
- #setup_build_cmd(options_manager) ⇒ Object
- #setup_cfg_cmd(options_manager) ⇒ Object
Instance Method Details
#check_warnings(options_manager) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/tebako/cli_helpers.rb', line 73 def check_warnings() return unless .mode != "runtime" puts WARN if .package_within_root? puts WARN2 if .prefix_within_root? sleep 5 end |
#do_press(options_manager) ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/tebako/cli_helpers.rb', line 81 def do_press() scenario_manager = Tebako::ScenarioManager.new(.root, .fs_entrance) scenario_manager.configure_scenario .process_gemfile(scenario_manager.gemfile_path) if scenario_manager.with_gemfile check_warnings() puts .press_announce(scenario_manager.msys?) do_press_runtime(, scenario_manager) do_press_application(, scenario_manager) end |
#do_press_application(options_manager, scenario_manager) ⇒ Object
92 93 94 95 96 97 |
# File 'lib/tebako/cli_helpers.rb', line 92 def do_press_application(, scenario_manager) return unless %w[both application].include?(.mode) packager = Tebako::PackagerLite.new(, scenario_manager) packager.create_package end |
#do_press_runtime(options_manager, scenario_manager) ⇒ Object
99 100 101 102 103 104 105 106 107 |
# File 'lib/tebako/cli_helpers.rb', line 99 def do_press_runtime(, scenario_manager) return unless %w[both runtime bundle].include?(.mode) generate_files(, scenario_manager) merged_env = ENV.to_h.merge(scenario_manager.b_env) Tebako.packaging_error(103) unless system(merged_env, press_cfg_cmd()) Tebako.packaging_error(104) unless system(merged_env, press_build_cmd()) finalize(, scenario_manager) end |
#do_setup(options_manager) ⇒ Object
109 110 111 112 113 114 115 |
# File 'lib/tebako/cli_helpers.rb', line 109 def do_setup() puts "Setting up tebako packaging environment" merged_env = ENV.to_h.merge(Tebako::ScenarioManagerBase.new.b_env) Tebako.packaging_error(101) unless system(merged_env, setup_cfg_cmd()) Tebako.packaging_error(102) unless system(merged_env, setup_build_cmd()) end |
#finalize(options_manager, scenario_manager) ⇒ Object
130 131 132 133 134 135 |
# File 'lib/tebako/cli_helpers.rb', line 130 def finalize(, scenario_manager) use_patchelf = .patchelf? && scenario_manager.linux_gnu? patchelf = use_patchelf ? "#{.deps_bin_dir}/patchelf" : nil Tebako::Packager.finalize(.ruby_src_dir, .package, .rv, patchelf, .output_type_first) end |
#generate_files(options_manager, scenario_manager) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/tebako/cli_helpers.rb', line 117 def generate_files(, scenario_manager) puts "-- Generating files" v_parts = Tebako::VERSION.split(".") Tebako::Codegen.generate_tebako_version_h(, v_parts) Tebako::Codegen.generate_tebako_fs_cpp(, scenario_manager) Tebako::Codegen.generate_deploy_rb(, scenario_manager) return unless %w[both runtime].include?(.mode) Tebako::Codegen.generate_stub_rb() end |
#options_from_tebafile(tebafile) ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/tebako/cli_helpers.rb', line 137 def (tebafile) ::YAML.load_file(tebafile)["options"] || {} rescue Psych::SyntaxError => e puts "Warning: The tebafile '#{tebafile}' contains invalid YAML syntax." puts e. {} rescue StandardError => e puts "An unexpected error occurred while loading the tebafile '#{tebafile}'." puts e. {} end |
#press_build_cmd(options_manager) ⇒ Object
149 150 151 |
# File 'lib/tebako/cli_helpers.rb', line 149 def press_build_cmd() "cmake --build #{.output_folder} --target tebako --parallel #{Etc.nprocessors}" end |
#press_cfg_cmd(options_manager) ⇒ Object
153 154 155 |
# File 'lib/tebako/cli_helpers.rb', line 153 def press_cfg_cmd() "cmake -DSETUP_MODE:BOOLEAN=OFF #{.} #{.}" end |
#setup_build_cmd(options_manager) ⇒ Object
157 158 159 |
# File 'lib/tebako/cli_helpers.rb', line 157 def setup_build_cmd() "cmake --build \"#{.output_folder}\" --target setup --parallel #{Etc.nprocessors}" end |
#setup_cfg_cmd(options_manager) ⇒ Object
161 162 163 |
# File 'lib/tebako/cli_helpers.rb', line 161 def setup_cfg_cmd() "cmake -DSETUP_MODE:BOOLEAN=ON #{.}" end |