Skip to content

Commit

Permalink
chore: move 'chmod +x mkdwarfs' call to Ruby from CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
maxirmx committed Jan 9, 2025
1 parent f0625e4 commit 68aff35
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/alpine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ concurrency:
cancel-in-progress: true

env:
CACHE_VER: 11
CACHE_VER: 16
TZ: "Etc/UTC"
VERBOSE: no

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gem-test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ concurrency:
cancel-in-progress: true

env:
CACHE_VER: 15
CACHE_VER: 16
DEBIAN_FRONTEND: "noninteractive"
TZ: "Etc/UTC"
# show cmake output
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ concurrency:
cancel-in-progress: true

env:
CACHE_VER: 15
CACHE_VER: 16
VERBOSE: no

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ concurrency:
cancel-in-progress: true

env:
CACHE_VER: 11
CACHE_VER: 16
DEBIAN_FRONTEND: "noninteractive"
TZ: "Etc/UTC"
# show cmake output (yes/no)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-msys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ concurrency:
cancel-in-progress: true

env:
CACHE_VER: 11
CACHE_VER: 16
VERBOSE: no

jobs:
Expand Down
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ set(IS_MSYS OFF)
set(IS_DARWIN OFF)
set(RB_W32 OFF)
set(RUBY_WITHOUT_EXT "dbm,win32,win32ole,-test-/*")
set(RUBY_NAME "ruby")
set(EXE_SUFFIX "")
set(DWARFS_PRELOAD OFF)
set(WITH_PATCHELF OFF)

Expand All @@ -108,7 +106,6 @@ elseif("${OSTYPE_TXT}" MATCHES "^msys*")
# set(DWARFS_PRELOAD ON)
set(RB_W32 ON)
set(RUBY_WITHOUT_EXT "dbm,syslog,pty,gdbm,readline,-test-/*")
set(EXE_SUFFIX ".exe")
elseif("${OSTYPE_TXT}" MATCHES "^darwin.*")
set(IS_DARWIN ON)
if(${RUBY_VER} VERSION_LESS "3.1.0")
Expand Down Expand Up @@ -162,7 +159,6 @@ if ("-${RUBY_VER}" STREQUAL "-" OR "-${RUBY_HASH}" STREQUAL "-")
message(FATAL_ERROR "Ruby version is not specified")
endif()

set(RUBY_NAME ruby)
set(RUBY_PRJ _ruby_${RUBY_VER})
set(RUBY_SOURCE_DIR ${DEPS}/src/${RUBY_PRJ})
set(RUBY_BINARY_DIR ${DEPS}/src/${RUBY_PRJ})
Expand Down Expand Up @@ -380,7 +376,6 @@ ExternalProject_Add(${RUBY_PRJ}
COMMAND ruby ${EXE}/tebako-packager pass1a ${RUBY_SOURCE_DIR}
BUILD_COMMAND make -j${NCORES}
INSTALL_COMMAND make install -j${NCORES}
COMMAND ${GNU_BASH} -c "chmod +x ${DEPS_BIN_DIR}/mkdwarfs${EXE_SUFFIX}"
COMMAND ${GNU_BASH} -c "ruby ${EXE}/tebako-packager pass2 ${OSTYPE_TXT} ${RUBY_SOURCE_DIR} ${DEPS_LIB_DIR} ${DATA_SRC_DIR} ${RUBY_STASH_DIR} ${RUBY_VER}"
)

Expand Down
2 changes: 1 addition & 1 deletion lib/tebako/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def press
def setup
(om, cm) = bootstrap

do_setup(om)
do_setup(om, cm)
cm.ensure_version_file
rescue Tebako::Error => e
puts "Tebako script failed: #{e.message} [#{e.error_code}]"
Expand Down
4 changes: 3 additions & 1 deletion lib/tebako/cli_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ def do_press_runtime(options_manager, scenario_manager)
true
end

def do_setup(options_manager)
def do_setup(options_manager, scenario_manager)
puts "Setting up tebako packaging environment"

cfg_cmd = "cmake -DSETUP_MODE:BOOLEAN=ON #{options_manager.cfg_options}"
build_cmd = "cmake --build \"#{options_manager.output_folder}\" --target setup --parallel #{Etc.nprocessors}"
merged_env = ENV.to_h.merge(options_manager.b_env)
Tebako.packaging_error(101) unless system(merged_env, cfg_cmd)
Tebako.packaging_error(102) unless system(merged_env, build_cmd)

FileUtils.chmod("+x", File.join(options_manager.deps_bin_dir, "mkdwarfs#{scenario_manager.exe_suffix}"))
true
end

Expand Down
5 changes: 3 additions & 2 deletions spec/cli_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@

describe "#do_setup" do
let(:options_manager) { Tebako::OptionsManager.new(options) }
let(:scenario_manager) { double("ScenarioManager", exe_suffix: "") }

context "when running on Gnu Linux" do
before do
Expand All @@ -125,13 +126,13 @@
it "executes the setup command successfully" do
allow(FileUtils).to receive(:rm_rf)
allow(self).to receive(:system).and_return(true)
expect(do_setup(options_manager)).to be_truthy
expect(do_setup(options_manager, scenario_manager)).to be_truthy
end

it "raises an error if the setup command fails" do
allow(FileUtils).to receive(:rm_rf)
allow(self).to receive(:system).and_return(false)
expect { do_setup(options_manager) }.to raise_error(Tebako::Error)
expect { do_setup(options_manager, scenario_manager) }.to raise_error(Tebako::Error)
end
end
end
Expand Down

0 comments on commit 68aff35

Please sign in to comment.