Skip to content

Commit d5373b7

Browse files
committed
Introduce infrastructure for several Ruby versions
1 parent 97eed19 commit d5373b7

File tree

3 files changed

+67
-8
lines changed

3 files changed

+67
-8
lines changed

make-rules/gem.mk

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,66 @@ VENDOR_GEM_DIR=/usr/ruby/$(RUBY_VERSION)/lib/ruby/vendor_ruby/gems/$(RUBY_LIB_VE
3030
# <component_name>.gemspec
3131
GEMSPEC=$(COMPONENT_NAME).gemspec
3232

33-
3433
# Some gems projects have to be built using rake
3534
# Allow GEM build/install commands to be overwritten
3635
# to account for possible differences
3736
GEM_BUILD_ACTION=(cd $(@D); $(GEM) build $(GEM_BUILD_ARGS) $(GEMSPEC))
3837

38+
define ruby-rule
39+
$(BUILD_DIR)/%-$(1)/.built: RUBY_VERSION=$(1)
40+
$(BUILD_DIR)/%-$(1)/.built: RUBY_LIB_VERSION=$(RUBY_LIB_VERSION.$(1))
41+
$(BUILD_DIR)/%-$(1)/.installed: RUBY_VERSION=$(1)
42+
$(BUILD_DIR)/%-$(1)/.installed: RUBY_LIB_VERSION=$(RUBY_LIB_VERSION.$(1))
43+
$(BUILD_DIR)/%-$(1)/.tested: RUBY_VERSION=$(1)
44+
$(BUILD_DIR)/%-$(1)/.tested: RUBY_LIB_VERSION=$(RUBY_LIB_VERSION.$(1))
45+
$(BUILD_DIR)/%-$(1)/.tested-and-compared: RUBY_VERSION=$(1)
46+
$(BUILD_DIR)/%-$(1)/.tested-and-compared: RUBY_LIB_VERSION=$(RUBY_LIB_VERSION.$(1))
47+
endef
48+
49+
$(foreach rbver, $(RUBY_VERSIONS), $(eval $(call ruby-rule,$(rbver))))
50+
51+
$(BUILD_DIR)/$(MACH32)-%/.built: BITS=32
52+
$(BUILD_DIR)/$(MACH64)-%/.built: BITS=64
53+
$(BUILD_DIR)/$(MACH32)-%/.installed: BITS=32
54+
$(BUILD_DIR)/$(MACH64)-%/.installed: BITS=64
55+
$(BUILD_DIR)/$(MACH32)-%/.tested: BITS=32
56+
$(BUILD_DIR)/$(MACH64)-%/.tested: BITS=64
57+
$(BUILD_DIR)/$(MACH32)-%/.tested-and-compared: BITS=32
58+
$(BUILD_DIR)/$(MACH64)-%/.tested-and-compared: BITS=64
59+
60+
BUILD_32 = $(RUBY_32_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.built)
61+
BUILD_64 = $(RUBY_64_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.built)
62+
BUILD_NO_ARCH = $(RUBY_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.built)
63+
64+
ifeq ($(filter-out $(RUBY_64_ONLY_VERSIONS), $(RUBY_VERSION)),)
65+
BUILD_32_and_64 = $(BUILD_64)
66+
endif
67+
68+
ifeq ($(filter-out $(RUBY_32_ONLY_VERSIONS), $(RUBY_VERSION)),)
69+
BUILD_32_and_64 = $(BUILD_32)
70+
endif
71+
72+
INSTALL_32 = $(RUBY_32_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.installed)
73+
INSTALL_64 = $(RUBY_64_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.installed)
74+
INSTALL_NO_ARCH = $(RUBY_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.installed)
75+
76+
# If we are building Ruby 2.6 support, build it and install it
77+
# before Ruby 2.3, so 2.3 is installed last and is the canonical version.
78+
# When we change the default, the new default should go last.
79+
ifneq ($(findstring 2.6,$(RUBY_VERSIONS)),)
80+
$(BUILD_DIR)/%-2.3/.built: $(BUILD_DIR)/%-2.6/.built
81+
$(BUILD_DIR)/%-2.3/.installed: $(BUILD_DIR)/%-2.6/.installed
82+
endif
83+
84+
ifeq ($(strip $(RUBY_BUILD_DOCS)),yes)
3985
# Build install args in a more readable fashion
4086
ifeq ($(firstword $(subst .,$(space),$(RUBY_VERSION))),2)
4187
# gem install 2.x does docs differently. Continue to generate both types
4288
GEM_INSTALL_ARGS += --document rdoc,ri
4389
endif
90+
else
91+
GEM_INSTALL_ARGS += --no-document
92+
endif
4493

4594
GEM_INSTALL_ARGS += -V --local --force
4695
GEM_INSTALL_ARGS += --install-dir $(PROTO_DIR)/$(VENDOR_GEM_DIR)

make-rules/ips.mk

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ $(foreach ver,$(PYTHON_VERSIONS),$(eval $(call python-generate-macros,$(ver))))
147147

148148
PKG_MACROS += PYTHON_32_ONLY=
149149

150+
define ruby-generate-macros
151+
PKG_MACROS += RUBY_$(1)_ONLY=\#
152+
PKG_MACROS += RUBY_$(1)_EXCL=
153+
endef
154+
$(foreach ver,$(RUBY_VERSIONS),$(eval $(call ruby-generate-macros,$(ver))))
155+
150156
MANGLED_DIR = $(PROTO_DIR)/mangled
151157

152158
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
400406
# the version number.
401407
define ruby-manifest-rule
402408
$(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).mogrified: \
403-
PKG_MACROS += RUBY_VERSION=$(1) RUBY_LIB_VERSION=$(2) \
409+
PKG_MACROS += RUBY_VERSION=$(1) RUBY_LIB_VERSION=$(2) RUBY_$(1)_ONLY= RUBY_$(1)_EXCL=\# \
404410
RUBYV=$(subst .,,$(1))
405411

406412
$(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).p5m: %-RUBYVER.p5m
407-
if [ -f $$*-$(shell echo $(1) | tr -d .)GENFRAG.p5m ]; then \
408-
cat $$*-$(shell echo $(1) | tr -d .)GENFRAG.p5m >> $$@; \
413+
if [ -f $$*-$(shell echo $(1) | tr -d .)-GENFRAG.p5m ]; then \
414+
cat $$*-$(shell echo $(1) | tr -d .)-GENFRAG.p5m >> $$@; \
409415
fi
410416
$(PKGMOGRIFY) -D RUBY_VERSION=$(1) -D RUBY_LIB_VERSION=$(2) \
411417
-D RUBYV=$(shell echo $(1) | tr -d .) $$< > $$@
412418
endef
413419
$(foreach ver,$(RUBY_VERSIONS),\
414420
$(eval $(call ruby-manifest-rule,$(shell echo $(ver) | \
415-
cut -d. -f1,2),$(ver))))
421+
cut -d. -f1,2),$(RUBY_LIB_VERSION.$(ver)))))
416422

417423
# A rule to create a helper transform package for ruby, that will insert the
418424
# appropriate conditional dependencies into a ruby library's

make-rules/shared-macros.mk

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,10 +732,10 @@ F77 = $(F77.$(COMPILER).$(BITS))
732732
FC = $(FC.$(COMPILER).$(BITS))
733733

734734
RUBY_VERSION = 2.3
735-
RUBY_LIB_VERSION.2.2 = 2.2.0
736735
RUBY_LIB_VERSION.2.3 = 2.3.0
737-
RUBY.2.2 = /usr/ruby/2.2/bin/ruby
736+
RUBY_LIB_VERSION.2.6 = 2.6.0
738737
RUBY.2.3 = /usr/ruby/2.3/bin/ruby
738+
RUBY.2.6 = /usr/ruby/2.6/bin/ruby
739739
RUBY = $(RUBY.$(RUBY_VERSION))
740740
RUBY_LIB_VERSION = $(RUBY_LIB_VERSION.$(RUBY_VERSION))
741741

@@ -750,7 +750,11 @@ RUBY_SCRIPT_FIX_FUNC = \
750750
# Use the ruby lib versions to represent the RUBY_VERSIONS that
751751
# need to get built. This is done because during package transformations
752752
# both the ruby version and the ruby library version are needed.
753-
RUBY_VERSIONS = $(RUBY_LIB_VERSION)
753+
RUBY_VERSIONS = 2.3
754+
RUBY_32_VERSIONS = 2.3
755+
RUBY_64_VERSIONS = 2.6
756+
757+
RUBY_BUILD_DOCS = yes
754758

755759
PYTHON_VENDOR_PACKAGES.32 = $(PYTHON.$(PYTHON_VERSION).VENDOR_PACKAGES.32)
756760
PYTHON_VENDOR_PACKAGES.64 = $(PYTHON.$(PYTHON_VERSION).VENDOR_PACKAGES.64)

0 commit comments

Comments
 (0)