Skip to content

Commit

Permalink
Introduce infrastructure for several Ruby versions
Browse files Browse the repository at this point in the history
  • Loading branch information
pyhalov committed Sep 18, 2021
1 parent 97eed19 commit 8077025
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 11 deletions.
62 changes: 61 additions & 1 deletion make-rules/gem.mk
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,66 @@ VENDOR_GEM_DIR=/usr/ruby/$(RUBY_VERSION)/lib/ruby/vendor_ruby/gems/$(RUBY_LIB_VE
# <component_name>.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)
Expand Down Expand Up @@ -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
Expand Down
18 changes: 12 additions & 6 deletions make-rules/ips.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions make-rules/shared-macros.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion tools/python/pkglint/userland.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(/.*)?$'),
Expand Down

0 comments on commit 8077025

Please sign in to comment.