From 914caac235ddc15dabcc1f2d0e9cbd382d9bc94b Mon Sep 17 00:00:00 2001 From: "Maxim [maxirmx] Samsonov" Date: Thu, 16 Jan 2025 13:02:32 +0300 Subject: [PATCH] fix: reorganize dependencies (another attempt to fix https://github.com/tamatebako/tebako-ci-containers/issues/39 --- CMakeLists.txt | 28 +++++++++++++++++----------- lib/tebako/cli.rb | 1 + lib/tebako/cli_helpers.rb | 1 - lib/tebako/options_manager.rb | 4 ++++ lib/tebako/version.rb | 2 +- spec/options_manager_spec.rb | 30 ++++++++++++++++++++++++++++++ 6 files changed, 53 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 788fc323..cd31e976 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 [Ribose Inc](https://www.ribose.com). +# Copyright (c) 2021-2025 [Ribose Inc](https://www.ribose.com). # All rights reserved. # This file is a part of tebako # @@ -361,8 +361,10 @@ ExternalProject_Add(${RUBY_PRJ} DOWNLOAD_NO_PROGRESS true SOURCE_DIR ${RUBY_SOURCE_DIR} BUILD_IN_SOURCE true - PATCH_COMMAND ruby ${EXE}/tebako-packager pass1 ${OSTYPE_TXT} ${RUBY_SOURCE_DIR} ${FS_MOUNT_POINT} ${DATA_SRC_DIR} ${RUBY_VER} - CONFIGURE_COMMAND ${GNU_BASH} -c "${RUBY_SOURCE_DIR}/configure ${OPENSSL_RUBY_OPTION} ${LIBYAML_RUBY_OPTION} \ + CONFIGURE_COMMAND ruby ${EXE}/tebako-packager pass1 ${OSTYPE_TXT} ${RUBY_SOURCE_DIR} ${FS_MOUNT_POINT} ${DATA_SRC_DIR} ${RUBY_VER} + # Make it for MacOS otherwise LDFLAGS are invalid + COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_LIB_DIR} + COMMAND ${GNU_BASH} -c "${RUBY_SOURCE_DIR}/configure ${OPENSSL_RUBY_OPTION} ${LIBYAML_RUBY_OPTION} \ --without-gmp \ --disable-dtrace \ --disable-debug-env \ @@ -379,23 +381,27 @@ ExternalProject_Add(${RUBY_PRJ} 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}" ) -add_dependencies(${RUBY_PRJ} ${DWARFS_WR_PRJ} ${LIBDWARFS_WR_PRJ}) - -if(IS_GNU) - add_dependencies(${RUBY_PRJ} ${PATCHELF_PRJ}) -endif(IS_GNU) - +# add_dependencies(${RUBY_PRJ} ${DWARFS_WR_PRJ}) if (${SETUP_MODE}) add_custom_target(setup ${CMAKE_COMMAND} -E echo "Tebako setup has completed" DEPENDS ${DWARFS_WR_PRJ} ${RUBY_PRJ} ) -else (${SETUP_MODE}) + if(IS_GNU) + add_dependencies(setup ${PATCHELF_PRJ}) + endif(IS_GNU) + + else (${SETUP_MODE}) add_custom_target(setup ${CMAKE_COMMAND} -E echo "Tebako setup has been verified" DEPENDS ${DWARFS_WR_PRJ} ${RUBY_PRJ} ) + if(IS_GNU) + add_dependencies(setup ${PATCHELF_PRJ}) + endif(IS_GNU) + + set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -406,7 +412,7 @@ else (${SETUP_MODE}) add_custom_target(packaged_filesystem COMMAND ruby ${DEPS_BIN_DIR}/deploy.rb - DEPENDS ${RUBY_PRJ} + DEPENDS setup BYPRODUCTS ${DATA_BIN_FILE} ) diff --git a/lib/tebako/cli.rb b/lib/tebako/cli.rb index ff1dcaa0..94ed539f 100755 --- a/lib/tebako/cli.rb +++ b/lib/tebako/cli.rb @@ -141,6 +141,7 @@ def self.exit_on_failure? no_commands do def bootstrap(clean: false) options_manager = Tebako::OptionsManager.new(options) + # creating it for MacOs environment where it want to have all lib folders exiting at configuration stage cache_manager = Tebako::CacheManager.new(options_manager.deps, options_manager.source, options_manager.output_folder) cache_manager.version_cache_check unless options[:devmode] || clean diff --git a/lib/tebako/cli_helpers.rb b/lib/tebako/cli_helpers.rb index 9132954a..2d1c8d07 100644 --- a/lib/tebako/cli_helpers.rb +++ b/lib/tebako/cli_helpers.rb @@ -83,7 +83,6 @@ def do_press_runtime(options_manager, scenario_manager) def do_setup(options_manager) puts "Setting up tebako packaging environment" - merged_env = ENV.to_h.merge(options_manager.b_env) Tebako.packaging_error(101) unless system(merged_env, setup_cfg_cmd(options_manager)) Tebako.packaging_error(102) unless system(merged_env, setup_build_cmd(options_manager)) diff --git a/lib/tebako/options_manager.rb b/lib/tebako/options_manager.rb index 95fef6ea..ce2d2ce1 100644 --- a/lib/tebako/options_manager.rb +++ b/lib/tebako/options_manager.rb @@ -121,6 +121,10 @@ def deps_bin_dir @deps_bin_dir ||= File.join(deps, "bin") end + def deps_lib_dir + @deps_lib_dir ||= File.join(deps, "lib") + end + def fs_current fs_current = Dir.pwd if RUBY_PLATFORM =~ /msys|mingw|cygwin/ diff --git a/lib/tebako/version.rb b/lib/tebako/version.rb index 8df71fee..af4cb8c1 100644 --- a/lib/tebako/version.rb +++ b/lib/tebako/version.rb @@ -26,5 +26,5 @@ # POSSIBILITY OF SUCH DAMAGE. module Tebako - VERSION = "0.12.2" + VERSION = "0.12.3" end diff --git a/spec/options_manager_spec.rb b/spec/options_manager_spec.rb index 149462f4..0789b1d8 100644 --- a/spec/options_manager_spec.rb +++ b/spec/options_manager_spec.rb @@ -652,6 +652,36 @@ end end end + + describe "#deps_lib_dir" do + let(:options_manager) { Tebako::OptionsManager.new({}) } + it "returns the correct lib directory path" do + allow(options_manager).to receive(:prefix).and_return("/fake/prefix") + expect(options_manager.deps_lib_dir).to eq("/fake/prefix/deps/lib") + end + end + + describe "#press_announce_ref" do + let(:options_manager) { Tebako::OptionsManager.new({}) } + it "returns the announce reference string" do + allow(options_manager).to receive(:ref).and_return("ref") + expect(options_manager.press_announce_ref(true)).to eq(" referencing runtime at 'ref'") + expect(options_manager.press_announce_ref(false)).to eq("") + end + end + + describe "#ref" do + it "returns 'tebako-runtime' if no ref is specified" do + options_manager = described_class.new({}) + expect(options_manager.ref).to eq("tebako-runtime") + end + + it "returns the given ref, converting backslashes to forward slashes" do + options = { "ref" => "some\\path\\ref" } + options_manager = described_class.new(options) + expect(options_manager.ref).to eq("some/path/ref") + end + end end # rubocop:enable Metrics/BlockLength