From 80770252983a73930bd39dafb645a2350a3cf317 Mon Sep 17 00:00:00 2001 From: Alexander Pyhalov Date: Fri, 17 Sep 2021 18:55:39 +0300 Subject: [PATCH] Introduce infrastructure for several Ruby versions --- make-rules/gem.mk | 62 +++++++++++++++++++++++++++++++- make-rules/ips.mk | 18 ++++++---- make-rules/shared-macros.mk | 15 ++++++-- tools/python/pkglint/userland.py | 3 +- 4 files changed, 87 insertions(+), 11 deletions(-) diff --git a/make-rules/gem.mk b/make-rules/gem.mk index 0b2882495fc..7b8e5b7aa5f 100644 --- a/make-rules/gem.mk +++ b/make-rules/gem.mk @@ -30,17 +30,66 @@ VENDOR_GEM_DIR=/usr/ruby/$(RUBY_VERSION)/lib/ruby/vendor_ruby/gems/$(RUBY_LIB_VE # .gemspec GEMSPEC=$(COMPONENT_NAME).gemspec - # Some gems projects have to be built using rake # Allow GEM build/install commands to be overwritten # to account for possible differences GEM_BUILD_ACTION=(cd $(@D); $(GEM) build $(GEM_BUILD_ARGS) $(GEMSPEC)) +define ruby-rule +$(BUILD_DIR)/%-$(1)/.built: RUBY_VERSION=$(1) +$(BUILD_DIR)/%-$(1)/.built: RUBY_LIB_VERSION=$(RUBY_LIB_VERSION.$(1)) +$(BUILD_DIR)/%-$(1)/.installed: RUBY_VERSION=$(1) +$(BUILD_DIR)/%-$(1)/.installed: RUBY_LIB_VERSION=$(RUBY_LIB_VERSION.$(1)) +$(BUILD_DIR)/%-$(1)/.tested: RUBY_VERSION=$(1) +$(BUILD_DIR)/%-$(1)/.tested: RUBY_LIB_VERSION=$(RUBY_LIB_VERSION.$(1)) +$(BUILD_DIR)/%-$(1)/.tested-and-compared: RUBY_VERSION=$(1) +$(BUILD_DIR)/%-$(1)/.tested-and-compared: RUBY_LIB_VERSION=$(RUBY_LIB_VERSION.$(1)) +endef + +$(foreach rbver, $(RUBY_VERSIONS), $(eval $(call ruby-rule,$(rbver)))) + +$(BUILD_DIR)/$(MACH32)-%/.built: BITS=32 +$(BUILD_DIR)/$(MACH64)-%/.built: BITS=64 +$(BUILD_DIR)/$(MACH32)-%/.installed: BITS=32 +$(BUILD_DIR)/$(MACH64)-%/.installed: BITS=64 +$(BUILD_DIR)/$(MACH32)-%/.tested: BITS=32 +$(BUILD_DIR)/$(MACH64)-%/.tested: BITS=64 +$(BUILD_DIR)/$(MACH32)-%/.tested-and-compared: BITS=32 +$(BUILD_DIR)/$(MACH64)-%/.tested-and-compared: BITS=64 + +BUILD_32 = $(RUBY_32_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.built) +BUILD_64 = $(RUBY_64_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.built) +BUILD_NO_ARCH = $(RUBY_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.built) + +ifeq ($(filter-out $(RUBY_64_ONLY_VERSIONS), $(RUBY_VERSION)),) +BUILD_32_and_64 = $(BUILD_64) +endif + +ifeq ($(filter-out $(RUBY_32_ONLY_VERSIONS), $(RUBY_VERSION)),) +BUILD_32_and_64 = $(BUILD_32) +endif + +INSTALL_32 = $(RUBY_32_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.installed) +INSTALL_64 = $(RUBY_64_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.installed) +INSTALL_NO_ARCH = $(RUBY_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.installed) + +# If we are building Ruby 2.6 support, build it and install it +# before Ruby 2.3, so 2.3 is installed last and is the canonical version. +# When we change the default, the new default should go last. +ifneq ($(findstring 2.6,$(RUBY_VERSIONS)),) +$(BUILD_DIR)/%-2.3/.built: $(BUILD_DIR)/%-2.6/.built +$(BUILD_DIR)/%-2.3/.installed: $(BUILD_DIR)/%-2.6/.installed +endif + +ifeq ($(strip $(RUBY_BUILD_DOCS)),yes) # Build install args in a more readable fashion ifeq ($(firstword $(subst .,$(space),$(RUBY_VERSION))),2) # gem install 2.x does docs differently. Continue to generate both types GEM_INSTALL_ARGS += --document rdoc,ri endif +else +GEM_INSTALL_ARGS += --no-document +endif GEM_INSTALL_ARGS += -V --local --force GEM_INSTALL_ARGS += --install-dir $(PROTO_DIR)/$(VENDOR_GEM_DIR) @@ -72,6 +121,17 @@ $(BUILD_DIR)/%/.installed: $(BUILD_DIR)/%/.built COMPONENT_TEST_TARGETS = +# determine the type of tests we want to run. +ifeq ($(strip $(wildcard $(COMPONENT_TEST_RESULTS_DIR)/results-*.master)),) +TEST_32 = $(RUBY_32_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.tested) +TEST_64 = $(RUBY_64_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.tested) +TEST_NO_ARCH = $(RUBY_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.tested) +else +TEST_32 = $(RUBY_32_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.tested-and-compared) +TEST_64 = $(RUBY_64_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.tested-and-compared) +TEST_NO_ARCH = $(RUBY_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.tested-and-compared) +endif + # Test the built source. If the output file shows up in the environment or # arguments, don't redirect stdout/stderr to it. $(BUILD_DIR)/%/.tested-and-compared: $(BUILD_DIR)/%/.built diff --git a/make-rules/ips.mk b/make-rules/ips.mk index 0847f9b647d..33a17168f69 100644 --- a/make-rules/ips.mk +++ b/make-rules/ips.mk @@ -147,6 +147,12 @@ $(foreach ver,$(PYTHON_VERSIONS),$(eval $(call python-generate-macros,$(ver)))) PKG_MACROS += PYTHON_32_ONLY= +define ruby-generate-macros +PKG_MACROS += RUBY_$(1)_ONLY=\# +PKG_MACROS += RUBY_$(1)_EXCL= +endef +$(foreach ver,$(RUBY_VERSIONS),$(eval $(call ruby-generate-macros,$(ver)))) + MANGLED_DIR = $(PROTO_DIR)/mangled PKG_PROTO_DIRS += $(MANGLED_DIR) $(PROTO_DIR) $(@D) $(COMPONENT_DIR) $(COMPONENT_SRC) @@ -400,19 +406,19 @@ $(foreach mfst,$(HISTORICAL_MANIFESTS),$(eval $(call history-manifest-rule,$(mfs # the version number. define ruby-manifest-rule $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).mogrified: \ - PKG_MACROS += RUBY_VERSION=$(1) RUBY_LIB_VERSION=$(2) \ - RUBYV=$(subst .,,$(1)) + PKG_MACROS += RUBY_VERSION=$(1) RUBY_LIB_VERSION=$(2) RUBY_$(1)_ONLY= RUBY_$(1)_EXCL=\# \ + RUBYV=$(subst .,,$(1) RUBY_ARCH=$(3)) $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).p5m: %-RUBYVER.p5m - if [ -f $$*-$(shell echo $(1) | tr -d .)GENFRAG.p5m ]; then \ - cat $$*-$(shell echo $(1) | tr -d .)GENFRAG.p5m >> $$@; \ + if [ -f $$*-$(shell echo $(1) | tr -d .)-GENFRAG.p5m ]; then \ + cat $$*-$(shell echo $(1) | tr -d .)-GENFRAG.p5m >> $$@; \ fi $(PKGMOGRIFY) -D RUBY_VERSION=$(1) -D RUBY_LIB_VERSION=$(2) \ - -D RUBYV=$(shell echo $(1) | tr -d .) $$< > $$@ + -D RUBYV=$(shell echo $(1) | tr -d .) -D RUBY_ARCH=$(3) $$< > $$@ endef $(foreach ver,$(RUBY_VERSIONS),\ $(eval $(call ruby-manifest-rule,$(shell echo $(ver) | \ - cut -d. -f1,2),$(ver)))) + cut -d. -f1,2),$(RUBY_LIB_VERSION.$(ver)),$(RUBY_ARCH.$(ver))))) # A rule to create a helper transform package for ruby, that will insert the # appropriate conditional dependencies into a ruby library's diff --git a/make-rules/shared-macros.mk b/make-rules/shared-macros.mk index 5b8ef66eb8f..830f052a2bc 100644 --- a/make-rules/shared-macros.mk +++ b/make-rules/shared-macros.mk @@ -732,10 +732,13 @@ F77 = $(F77.$(COMPILER).$(BITS)) FC = $(FC.$(COMPILER).$(BITS)) RUBY_VERSION = 2.3 -RUBY_LIB_VERSION.2.2 = 2.2.0 +RUBY_ARCH.2.3 = $(MACH)-solaris$(SOLARIS_VERSION) +RUBY_ARCH.2.6 = $(MACH64)-solaris$(SOLARIS_VERSION) +RUBY_ARCH = $(RUBY_ARCH.$(RUBY_VERSION)) RUBY_LIB_VERSION.2.3 = 2.3.0 -RUBY.2.2 = /usr/ruby/2.2/bin/ruby +RUBY_LIB_VERSION.2.6 = 2.6.0 RUBY.2.3 = /usr/ruby/2.3/bin/ruby +RUBY.2.6 = /usr/ruby/2.6/bin/ruby RUBY = $(RUBY.$(RUBY_VERSION)) RUBY_LIB_VERSION = $(RUBY_LIB_VERSION.$(RUBY_VERSION)) @@ -750,7 +753,13 @@ RUBY_SCRIPT_FIX_FUNC = \ # Use the ruby lib versions to represent the RUBY_VERSIONS that # need to get built. This is done because during package transformations # both the ruby version and the ruby library version are needed. -RUBY_VERSIONS = $(RUBY_LIB_VERSION) +RUBY_VERSIONS = 2.3 +RUBY_32_VERSIONS = 2.3 +RUBY_64_VERSIONS = 2.6 + +RUBY_BUILD_DOCS = yes + +PKG_MACROS += RUBY_ARCH=$(RUBY_ARCH) PYTHON_VENDOR_PACKAGES.32 = $(PYTHON.$(PYTHON_VERSION).VENDOR_PACKAGES.32) PYTHON_VENDOR_PACKAGES.64 = $(PYTHON.$(PYTHON_VERSION).VENDOR_PACKAGES.64) diff --git a/tools/python/pkglint/userland.py b/tools/python/pkglint/userland.py index 68caa441151..064666e5845 100644 --- a/tools/python/pkglint/userland.py +++ b/tools/python/pkglint/userland.py @@ -66,7 +66,8 @@ def __init__(self, config): "sparcv9", "64", "i86pc-solaris-thread-multi-64", # perl path - "sun4-solaris-thread-multi-64" # perl path + "sun4-solaris-thread-multi-64", # perl path + "amd64-solaris2.11" # ruby path ] self.runpath_re = [ re.compile('^/lib(/.*)?$'),