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_build(options_manager, scenario_manager) ⇒ Object
-
#do_press_runtime(options_manager, scenario_manager) ⇒ Object
rubocop:disable Metrics/MethodLength.
-
#do_setup(options_manager) ⇒ Object
rubocop:enable Metrics/MethodLength.
- #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
78 79 80 81 82 83 84 85 86 |
# File 'lib/tebako/cli_helpers.rb', line 78 def check_warnings() return if .mode == "runtime" package_warning = .package_within_root? prefix_warning = .prefix_within_root? puts WARN if package_warning puts WARN2 if prefix_warning sleep 5 if package_warning || prefix_warning end |
#do_press(options_manager) ⇒ Object
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/tebako/cli_helpers.rb', line 88 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_build(, scenario_manager) do_press_application(, scenario_manager) end |
#do_press_application(options_manager, scenario_manager) ⇒ Object
112 113 114 115 116 |
# File 'lib/tebako/cli_helpers.rb', line 112 def do_press_application(, scenario_manager) return unless %w[both application].include?(.mode) Tebako::ApplicationBuilder.new(, scenario_manager).build end |
#do_press_build(options_manager, scenario_manager) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/tebako/cli_helpers.rb', line 99 def do_press_build(, scenario_manager) return do_press_runtime(, scenario_manager) unless .mode == "bundle" if .bundle_format == "layered" Tebako::SingleFileBundleBuilder.new(, scenario_manager).build return end Tebako::BundleBuilder.new(, scenario_manager).build do do_press_runtime(, scenario_manager) end end |
#do_press_runtime(options_manager, scenario_manager) ⇒ Object
rubocop:disable Metrics/MethodLength
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/tebako/cli_helpers.rb', line 118 def do_press_runtime(, scenario_manager) # rubocop:disable Metrics/MethodLength return unless %w[both runtime bundle].include?(.mode) runner = ->(environment, command) { system(environment, command) } file_generator = -> { generate_files(, scenario_manager) } finalizer = -> { finalize(, scenario_manager) } Tebako::RuntimeBuilder.new( , scenario_manager, command_runner: runner, file_generator: file_generator, finalizer: finalizer, configure_command: press_cfg_cmd(), build_command: press_build_cmd() ).build end |
#do_setup(options_manager) ⇒ Object
rubocop:enable Metrics/MethodLength
135 136 137 138 139 140 141 |
# File 'lib/tebako/cli_helpers.rb', line 135 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
154 155 156 157 158 159 |
# File 'lib/tebako/cli_helpers.rb', line 154 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
143 144 145 146 147 148 149 150 151 152 |
# File 'lib/tebako/cli_helpers.rb', line 143 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) Tebako::Codegen.generate_stub_rb() if %w[both runtime].include?(.mode) Tebako::Codegen.generate_package_manifest(, scenario_manager) end |
#options_from_tebafile(tebafile) ⇒ Object
161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/tebako/cli_helpers.rb', line 161 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
173 174 175 |
# File 'lib/tebako/cli_helpers.rb', line 173 def press_build_cmd() "cmake --build #{.output_folder} --target tebako --parallel #{Etc.nprocessors}" end |
#press_cfg_cmd(options_manager) ⇒ Object
177 178 179 |
# File 'lib/tebako/cli_helpers.rb', line 177 def press_cfg_cmd() "cmake -DSETUP_MODE:BOOLEAN=OFF #{.} #{.}" end |
#setup_build_cmd(options_manager) ⇒ Object
181 182 183 |
# File 'lib/tebako/cli_helpers.rb', line 181 def setup_build_cmd() "cmake --build \"#{.output_folder}\" --target setup --parallel #{Etc.nprocessors}" end |
#setup_cfg_cmd(options_manager) ⇒ Object
185 186 187 |
# File 'lib/tebako/cli_helpers.rb', line 185 def setup_cfg_cmd() "cmake -DSETUP_MODE:BOOLEAN=ON #{.}" end |