2019-04-28 05:35:14 +03:00
|
|
|
# -*- mode: makefile-gmake; indent-tabs-mode: t -*-
|
|
|
|
|
2020-05-10 18:17:02 +03:00
|
|
|
reconfig config.status: export MAKE:=$(MAKE)
|
2017-02-13 02:37:28 +03:00
|
|
|
override gnumake_recursive := $(if $(findstring n,$(firstword $(MFLAGS))),,+)
|
2017-02-15 13:51:58 +03:00
|
|
|
override mflags := $(filter-out -j%,$(MFLAGS))
|
2017-03-26 04:21:57 +03:00
|
|
|
MSPECOPT += $(if $(filter -j%,$(MFLAGS)),-j)
|
2020-06-05 18:35:45 +03:00
|
|
|
nproc = $(subst -j,,$(filter -j%,$(MFLAGS)))
|
2014-07-03 07:38:13 +04:00
|
|
|
|
2021-08-07 12:32:24 +03:00
|
|
|
ifeq ($(GITHUB_ACTIONS),true)
|
2022-01-01 16:17:14 +03:00
|
|
|
override ACTIONS_GROUP = @echo "\#\#[group]$(patsubst yes-%,%,$@)"
|
2021-08-07 12:32:24 +03:00
|
|
|
override ACTIONS_ENDGROUP = @echo "\#\#[endgroup]"
|
|
|
|
endif
|
|
|
|
|
2022-06-27 11:30:47 +03:00
|
|
|
ifneq ($(filter darwin%,$(target_os)),)
|
|
|
|
# Remove debug option not to generate thousands of .dSYM
|
|
|
|
MJIT_DEBUGFLAGS := $(filter-out -g%,$(MJIT_DEBUGFLAGS))
|
|
|
|
|
2022-07-05 18:30:21 +03:00
|
|
|
INSTRUBY_ENV += SDKROOT=
|
2021-04-10 05:57:45 +03:00
|
|
|
endif
|
2021-05-21 04:34:28 +03:00
|
|
|
INSTRUBY_ARGS += --gnumake
|
2021-04-10 05:57:45 +03:00
|
|
|
|
2018-10-06 18:14:19 +03:00
|
|
|
CHECK_TARGETS := great exam love check test check% test% btest%
|
|
|
|
# expand test targets, and those dependents
|
|
|
|
TEST_TARGETS := $(filter $(CHECK_TARGETS),$(MAKECMDGOALS))
|
|
|
|
TEST_DEPENDS := $(filter-out commit $(TEST_TARGETS),$(MAKECMDGOALS))
|
|
|
|
TEST_TARGETS := $(patsubst great,exam,$(TEST_TARGETS))
|
|
|
|
TEST_DEPENDS := $(filter-out great $(TEST_TARGETS),$(TEST_DEPENDS))
|
|
|
|
TEST_TARGETS := $(patsubst exam,check,$(TEST_TARGETS))
|
2019-07-22 04:10:28 +03:00
|
|
|
TEST_TARGETS := $(patsubst check,test-spec test-all test-tool test-short,$(TEST_TARGETS))
|
2018-10-06 18:14:19 +03:00
|
|
|
TEST_TARGETS := $(patsubst test-rubyspec,test-spec,$(TEST_TARGETS))
|
|
|
|
TEST_DEPENDS := $(filter-out exam check test-spec $(TEST_TARGETS),$(TEST_DEPENDS))
|
|
|
|
TEST_TARGETS := $(patsubst love,check,$(TEST_TARGETS))
|
|
|
|
TEST_DEPENDS := $(filter-out love $(TEST_TARGETS),$(TEST_DEPENDS))
|
2019-07-02 09:22:22 +03:00
|
|
|
TEST_TARGETS := $(patsubst test-almost,test-all,$(patsubst check-%,test test-%,$(TEST_TARGETS)))
|
2018-10-06 18:14:19 +03:00
|
|
|
TEST_DEPENDS := $(filter-out test-all $(TEST_TARGETS),$(TEST_DEPENDS))
|
|
|
|
TEST_TARGETS := $(patsubst test,test-short,$(TEST_TARGETS))
|
|
|
|
TEST_DEPENDS := $(filter-out test $(TEST_TARGETS),$(TEST_DEPENDS))
|
|
|
|
TEST_TARGETS := $(patsubst test-short,btest-ruby test-knownbug test-basic,$(TEST_TARGETS))
|
2022-01-01 16:17:14 +03:00
|
|
|
TEST_TARGETS := $(patsubst test-bundled-gems,test-bundled-gems-run,$(TEST_TARGETS))
|
|
|
|
TEST_TARGETS := $(patsubst test-bundled-gems-run,test-bundled-gems-run $(PREPARE_BUNDLED_GEMS),$(TEST_TARGETS))
|
2022-01-01 19:25:33 +03:00
|
|
|
TEST_TARGETS := $(patsubst test-bundled-gems-prepare,test-bundled-gems-prepare $(PRECHECK_BUNDLED_GEMS) test-bundled-gems-fetch,$(TEST_TARGETS))
|
2018-10-06 18:14:19 +03:00
|
|
|
TEST_DEPENDS := $(filter-out test-short $(TEST_TARGETS),$(TEST_DEPENDS))
|
|
|
|
TEST_DEPENDS += $(if $(filter great exam love check,$(MAKECMDGOALS)),all exts)
|
2013-03-06 15:59:23 +04:00
|
|
|
|
2019-08-26 07:09:48 +03:00
|
|
|
in-srcdir := $(if $(filter-out .,$(srcdir)),$(CHDIR) $(srcdir) &&)
|
|
|
|
|
2014-03-25 05:30:07 +04:00
|
|
|
ifneq ($(filter -O0 -Od,$(optflags)),)
|
|
|
|
override XCFLAGS := $(filter-out -D_FORTIFY_SOURCE=%,$(XCFLAGS))
|
|
|
|
endif
|
|
|
|
|
2015-03-13 11:29:26 +03:00
|
|
|
ifeq ($(if $(filter all main exts enc trans libencs libenc libtrans \
|
2015-03-18 11:08:31 +03:00
|
|
|
prog program ruby ruby$(EXEEXT) \
|
|
|
|
wprogram rubyw rubyw$(EXEEXT) \
|
|
|
|
miniruby$(EXEEXT) mini,\
|
2015-03-12 19:15:07 +03:00
|
|
|
$(MAKECMDGOALS)),,$(MAKECMDGOALS)),)
|
2015-10-22 17:56:37 +03:00
|
|
|
-include $(SHOWFLAGS)
|
2015-03-12 19:15:07 +03:00
|
|
|
endif
|
|
|
|
|
2014-06-01 23:32:15 +04:00
|
|
|
ifneq ($(filter universal-%,$(arch)),)
|
|
|
|
define archcmd
|
2014-06-01 23:32:17 +04:00
|
|
|
%.$(1).S: %.c
|
|
|
|
@$$(ECHO) translating $$< with $(2)
|
|
|
|
$$(Q) $$(CC) $$(CFLAGS_NO_ARCH) $(2) $$(XCFLAGS) $$(CPPFLAGS) $$(COUTFLAG)$$@ -S $$<
|
|
|
|
|
|
|
|
%.S: %.$(1).S
|
|
|
|
|
2014-06-01 23:32:15 +04:00
|
|
|
%.$(1).i: %.c
|
|
|
|
@$$(ECHO) preprocessing $$< with $(2)
|
|
|
|
$$(Q) $$(CPP) $$(warnflags) $(2) $$(XCFLAGS) $$(CPPFLAGS) $$(COUTFLAG)$$@ -E $$< > $$@
|
|
|
|
|
|
|
|
%.i: %.$(1).i
|
|
|
|
endef
|
|
|
|
|
2018-02-06 06:19:42 +03:00
|
|
|
$(foreach arch,$(arch_flags),\
|
2014-06-01 23:32:15 +04:00
|
|
|
$(eval $(call archcmd,$(patsubst -arch=%,%,$(value arch)),$(patsubst -arch=%,-arch %,$(value arch)))))
|
|
|
|
endif
|
|
|
|
|
2017-02-13 08:11:14 +03:00
|
|
|
.PHONY: $(addprefix yes-,$(TEST_TARGETS))
|
|
|
|
|
|
|
|
ifneq ($(filter-out btest%,$(TEST_TARGETS)),)
|
|
|
|
$(addprefix yes-,$(TEST_TARGETS)): $(TEST_DEPENDS)
|
2013-03-27 07:42:19 +04:00
|
|
|
endif
|
2013-03-06 15:59:23 +04:00
|
|
|
|
2017-02-13 08:11:14 +03:00
|
|
|
ORDERED_TEST_TARGETS := $(filter $(TEST_TARGETS), \
|
|
|
|
btest-ruby test-knownbug test-basic \
|
2019-07-22 04:10:28 +03:00
|
|
|
test-testframework test-tool test-ruby test-all \
|
2020-06-05 15:54:39 +03:00
|
|
|
test-spec test-bundler-prepare test-bundler test-bundler-parallel \
|
2022-01-01 16:17:14 +03:00
|
|
|
test-bundled-gems-precheck test-bundled-gems-fetch \
|
|
|
|
test-bundled-gems-prepare test-bundled-gems-run \
|
2017-02-13 08:11:14 +03:00
|
|
|
)
|
2017-05-16 16:15:12 +03:00
|
|
|
prev_test := $(if $(filter test-spec,$(ORDERED_TEST_TARGETS)),test-spec-precheck)
|
2017-03-02 07:54:18 +03:00
|
|
|
$(foreach test,$(ORDERED_TEST_TARGETS), \
|
|
|
|
$(eval yes-$(value test) no-$(value test): $(value prev_test)); \
|
2017-02-13 08:11:14 +03:00
|
|
|
$(eval prev_test := $(value test)))
|
2013-03-07 05:39:10 +04:00
|
|
|
|
|
|
|
ifneq ($(if $(filter install,$(MAKECMDGOALS)),$(filter uninstall,$(MAKECMDGOALS))),)
|
|
|
|
install-targets := $(filter install uninstall,$(MAKECMDGOALS))
|
|
|
|
$(word 1,$(install-targets)): $(word 0,$(install-targets))
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(filter reinstall,$(MAKECMDGOALS)),)
|
2014-06-19 18:11:52 +04:00
|
|
|
install-prereq: uninstall
|
|
|
|
uninstall sudo-precheck: all $(if $(filter all,$(INSTALLDOC)),docs)
|
2013-03-07 05:39:10 +04:00
|
|
|
endif
|
2014-06-20 08:20:26 +04:00
|
|
|
|
|
|
|
ifneq ($(filter love,$(MAKECMDGOALS)),)
|
|
|
|
showflags: up
|
2016-07-26 19:03:51 +03:00
|
|
|
sudo-precheck: test yes-test-testframework no-test-testframework
|
2014-06-20 08:20:26 +04:00
|
|
|
install-prereq: sudo-precheck
|
|
|
|
yes-test-all no-test-all: install
|
|
|
|
endif
|
2020-06-05 18:35:45 +03:00
|
|
|
yes-test-bundler-parallel: PARALLELRSPECOPTS += $(if $(nproc),-n$(shell expr $(nproc) + $(nproc) / 2))
|
|
|
|
|
2019-12-20 03:19:39 +03:00
|
|
|
# Cross reference needs to parse all files at once
|
2019-09-08 18:21:40 +03:00
|
|
|
love install reinstall: RDOCFLAGS = --force-update
|
2016-06-04 05:40:04 +03:00
|
|
|
|
2021-08-12 06:33:37 +03:00
|
|
|
ifneq ($(if $(filter -flto%,$(CFLAGS)),$(subst darwin,,$(arch)),$(arch)),$(arch))
|
|
|
|
override EXE_LDFLAGS = $(filter-out -g%,$(LDFLAGS))
|
|
|
|
endif
|
|
|
|
|
2016-06-04 05:40:04 +03:00
|
|
|
$(srcdir)/missing/des_tables.c: $(srcdir)/missing/crypt.c
|
2016-06-04 06:46:06 +03:00
|
|
|
ifeq ($(if $(filter yes,$(CROSS_COMPILING)),,$(CC)),)
|
2016-06-04 05:40:04 +03:00
|
|
|
touch $@
|
|
|
|
else
|
|
|
|
@$(ECHO) building make_des_table
|
2021-08-12 06:33:37 +03:00
|
|
|
$(CC) $(INCFLAGS) $(CPPFLAGS) -DDUMP $(EXE_LDFLAGS) $(XLDFLAGS) $(LIBS) -omake_des_table $(srcdir)/missing/crypt.c
|
2016-06-04 06:46:06 +03:00
|
|
|
@[ -x ./make_des_table ]
|
2016-06-04 05:40:04 +03:00
|
|
|
@$(ECHO) generating $@
|
|
|
|
$(Q) $(MAKEDIRS) $(@D)
|
2016-06-04 13:58:14 +03:00
|
|
|
$(Q) ./make_des_table > $@.new
|
|
|
|
$(Q) mv $@.new $@
|
2016-06-04 05:40:04 +03:00
|
|
|
$(Q) $(RMALL) make_des_table*
|
|
|
|
endif
|
2016-08-20 05:20:34 +03:00
|
|
|
|
2020-01-08 12:35:21 +03:00
|
|
|
config.status: $(wildcard config.cache)
|
|
|
|
|
2016-08-20 05:20:34 +03:00
|
|
|
STUBPROGRAM = rubystub$(EXEEXT)
|
|
|
|
IGNOREDPATTERNS = %~ .% %.orig %.rej \#%\#
|
|
|
|
SCRIPTBINDIR := $(if $(EXEEXT),,exec/)
|
2018-11-28 17:56:19 +03:00
|
|
|
SCRIPTPROGRAMS = $(addprefix $(SCRIPTBINDIR),$(addsuffix $(EXEEXT),$(filter-out $(IGNOREDPATTERNS),$(notdir $(wildcard $(srcdir)/libexec/*)))))
|
2016-08-20 05:20:34 +03:00
|
|
|
|
|
|
|
stub: $(STUBPROGRAM)
|
|
|
|
scriptbin: $(SCRIPTPROGRAMS)
|
|
|
|
ifneq ($(STUBPROGRAM),rubystub)
|
|
|
|
rubystub: $(STUBPROGRAM)
|
|
|
|
endif
|
|
|
|
|
|
|
|
$(SCRIPTPROGRAMS): $(STUBPROGRAM)
|
|
|
|
|
|
|
|
$(STUBPROGRAM): rubystub.$(OBJEXT) $(LIBRUBY) $(MAINOBJ) $(OBJS) $(EXTOBJS) $(SETUP) $(PREP)
|
|
|
|
|
|
|
|
rubystub$(EXEEXT):
|
|
|
|
@rm -f $@
|
|
|
|
$(ECHO) linking $@
|
2021-08-12 06:33:37 +03:00
|
|
|
$(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) rubystub.$(OBJEXT) $(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@
|
2016-08-20 05:20:34 +03:00
|
|
|
$(Q) $(POSTLINK)
|
|
|
|
$(if $(STRIP),$(Q) $(STRIP) $@)
|
|
|
|
|
|
|
|
$(SCRIPTBINDIR)%$(EXEEXT): bin/% $(STUBPROGRAM) \
|
|
|
|
$(if $(SCRIPTBINDIR),$(TIMESTAMPDIR)/.exec.time)
|
|
|
|
$(ECHO) generating $@
|
|
|
|
$(Q) { cat $(STUBPROGRAM); echo; sed -e '1{' -e '/^#!.*ruby/!i\' -e '#!/bin/ruby' -e '}' $<; } > $@
|
|
|
|
$(Q) chmod +x $@
|
|
|
|
$(Q) $(POSTLINK)
|
|
|
|
|
|
|
|
$(TIMESTAMPDIR)/.exec.time:
|
|
|
|
$(Q) mkdir exec
|
|
|
|
$(Q) exit > $@
|
2017-03-09 04:06:09 +03:00
|
|
|
|
|
|
|
.PHONY: commit
|
2019-07-19 01:51:48 +03:00
|
|
|
commit: $(if $(filter commit,$(MAKECMDGOALS)),$(filter-out commit,$(MAKECMDGOALS))) up
|
2019-07-16 02:25:39 +03:00
|
|
|
@$(BASERUBY) -C "$(srcdir)" -I./tool/lib -rvcs -e 'VCS.detect(".").commit'
|
2018-06-02 15:17:16 +03:00
|
|
|
+$(Q) \
|
|
|
|
{ \
|
2019-08-26 07:09:48 +03:00
|
|
|
$(in-srcdir) \
|
2019-08-10 17:45:49 +03:00
|
|
|
exec sed -f tool/prereq.status defs/gmake.mk template/Makefile.in common.mk; \
|
2018-06-02 15:17:16 +03:00
|
|
|
} | \
|
2019-02-14 17:21:14 +03:00
|
|
|
$(MAKE) $(mflags) Q=$(Q) ECHO=$(ECHO) srcdir="$(srcdir)" srcs_vpath="" CHDIR="$(CHDIR)" \
|
2018-06-02 15:17:16 +03:00
|
|
|
BOOTSTRAPRUBY="$(BOOTSTRAPRUBY)" MINIRUBY="$(BASERUBY)" BASERUBY="$(BASERUBY)" \
|
2018-11-13 06:24:18 +03:00
|
|
|
VCSUP="" ENC_MK=.top-enc.mk REVISION_FORCE=PHONY CONFIGURE="$(CONFIGURE)" -f - \
|
2018-06-02 15:17:16 +03:00
|
|
|
update-src srcs all-incs
|
2017-07-17 04:16:07 +03:00
|
|
|
|
2019-04-24 16:40:54 +03:00
|
|
|
GITHUB_RUBY_URL = https://github.com/ruby/ruby
|
2019-04-24 17:26:56 +03:00
|
|
|
PR =
|
2019-04-24 16:40:54 +03:00
|
|
|
|
2022-08-04 20:40:49 +03:00
|
|
|
COMMIT_GPG_SIGN = $(shell $(GIT) -C "$(srcdir)" config commit.gpgsign)
|
|
|
|
REMOTE_GITHUB_URL = $(shell $(GIT) -C "$(srcdir)" config remote.github.url)
|
2019-08-15 15:34:34 +03:00
|
|
|
COMMITS_NOTES = commits
|
2019-04-25 12:27:16 +03:00
|
|
|
|
2019-04-24 16:40:54 +03:00
|
|
|
.PHONY: fetch-github
|
|
|
|
fetch-github:
|
2019-04-25 12:54:43 +03:00
|
|
|
$(call fetch-github,$(PR))
|
2019-04-25 12:29:58 +03:00
|
|
|
|
|
|
|
define fetch-github
|
|
|
|
$(if $(1),,\
|
2019-04-24 16:40:54 +03:00
|
|
|
echo "usage:"; echo " make $@ PR=1234"; \
|
|
|
|
exit 1; \
|
2019-04-25 12:27:16 +03:00
|
|
|
)
|
2019-05-08 10:59:37 +03:00
|
|
|
$(eval REMOTE_GITHUB_URL := $(REMOTE_GITHUB_URL))
|
2022-08-04 20:40:49 +03:00
|
|
|
$(if $(REMOTE_GITHUB_URL),,
|
|
|
|
echo adding $(GITHUB_RUBY_URL) as remote github
|
|
|
|
$(GIT) -C "$(srcdir)" remote add github $(GITHUB_RUBY_URL)
|
|
|
|
$(GIT) -C "$(srcdir)" config --add remote.github.fetch +refs/notes/$(COMMITS_NOTES):refs/notes/$(COMMITS_NOTES)
|
|
|
|
$(eval REMOTE_GITHUB_URL := $(GITHUB_RUBY_URL))
|
2019-04-25 12:27:16 +03:00
|
|
|
)
|
2022-08-04 20:40:49 +03:00
|
|
|
$(if $(shell $(GIT) -C "$(srcdir)" rev-parse "github/pull/$(1)/head" -- 2> /dev/null),
|
|
|
|
$(GIT) -C "$(srcdir)" branch -f "gh-$(1)" "github/pull/$(1)/head",
|
|
|
|
$(GIT) -C "$(srcdir)" fetch -f github "pull/$(1)/head:gh-$(1)"
|
2019-08-11 09:42:16 +03:00
|
|
|
)
|
2019-04-25 12:29:58 +03:00
|
|
|
endef
|
2019-04-24 16:40:54 +03:00
|
|
|
|
2019-04-25 12:05:51 +03:00
|
|
|
.PHONY: checkout-github
|
|
|
|
checkout-github: fetch-github
|
2022-08-04 20:40:49 +03:00
|
|
|
$(GIT) -C "$(srcdir)" checkout "gh-$(PR)"
|
2019-04-25 12:05:51 +03:00
|
|
|
|
2019-08-14 19:00:26 +03:00
|
|
|
.PHONY: update-github
|
2019-08-15 19:34:51 +03:00
|
|
|
update-github: fetch-github
|
2019-08-14 19:00:26 +03:00
|
|
|
$(eval PULL_REQUEST_API := https://api.github.com/repos/ruby/ruby/pulls/$(PR))
|
2019-08-15 19:11:18 +03:00
|
|
|
$(eval PULL_REQUEST_FORK_BRANCH := $(shell \
|
|
|
|
curl -s $(if $(GITHUB_TOKEN),-H "Authorization: bearer $(GITHUB_TOKEN)") $(PULL_REQUEST_API) | \
|
|
|
|
$(BASERUBY) -rjson -e 'JSON.parse(STDIN.read)["head"].tap { |h| print "#{h["repo"]["full_name"]} #{h["ref"]}" }' \
|
|
|
|
))
|
2019-08-15 20:08:02 +03:00
|
|
|
$(eval FORK_REPO := $(word 1,$(PULL_REQUEST_FORK_BRANCH)))
|
|
|
|
$(eval PR_BRANCH := $(word 2,$(PULL_REQUEST_FORK_BRANCH)))
|
2019-08-15 19:34:51 +03:00
|
|
|
|
|
|
|
$(eval GITHUB_UPDATE_WORKTREE := $(shell mktemp -d "$(srcdir)/gh-$(PR)-XXXXXX"))
|
2022-08-04 20:40:49 +03:00
|
|
|
$(GIT) -C "$(srcdir)" worktree add $(notdir $(GITHUB_UPDATE_WORKTREE)) "gh-$(PR)"
|
|
|
|
$(GIT) -C "$(GITHUB_UPDATE_WORKTREE)" merge master --no-edit
|
2019-08-15 20:08:40 +03:00
|
|
|
@$(BASERUBY) -e 'print "Are you sure to push this to PR=$(PR)? [Y/n]: "; exit(gets.chomp != "n")'
|
2022-08-04 20:40:49 +03:00
|
|
|
$(GIT) -C "$(srcdir)" remote add fork-$(PR) git@github.com:$(FORK_REPO).git
|
|
|
|
$(GIT) -C "$(GITHUB_UPDATE_WORKTREE)" push fork-$(PR) gh-$(PR):$(PR_BRANCH)
|
|
|
|
$(GIT) -C "$(srcdir)" remote rm fork-$(PR)
|
|
|
|
$(GIT) -C "$(srcdir)" worktree remove $(notdir $(GITHUB_UPDATE_WORKTREE))
|
|
|
|
$(GIT) -C "$(srcdir)" branch -D gh-$(PR)
|
2019-08-14 19:00:26 +03:00
|
|
|
|
2019-07-17 05:56:40 +03:00
|
|
|
.PHONY: pull-github
|
|
|
|
pull-github: fetch-github
|
|
|
|
$(call pull-github,$(PR))
|
|
|
|
|
|
|
|
define pull-github
|
2022-08-04 20:40:49 +03:00
|
|
|
$(eval GITHUB_MERGE_BASE := $(shell $(GIT) -C "$(srcdir)" log -1 --format=format:%H))
|
|
|
|
$(eval GITHUB_MERGE_BRANCH := $(shell $(GIT) -C "$(srcdir)" symbolic-ref --short HEAD))
|
2019-04-25 13:37:10 +03:00
|
|
|
$(eval GITHUB_MERGE_WORKTREE := $(shell mktemp -d "$(srcdir)/gh-$(1)-XXXXXX"))
|
2022-08-04 20:40:49 +03:00
|
|
|
$(GIT) -C "$(srcdir)" worktree prune
|
|
|
|
$(GIT) -C "$(srcdir)" worktree add $(notdir $(GITHUB_MERGE_WORKTREE)) "gh-$(1)"
|
|
|
|
$(GIT) -C "$(GITHUB_MERGE_WORKTREE)" rebase $(GITHUB_MERGE_BRANCH)
|
2019-04-25 12:27:16 +03:00
|
|
|
$(eval COMMIT_GPG_SIGN := $(COMMIT_GPG_SIGN))
|
|
|
|
$(if $(filter true,$(COMMIT_GPG_SIGN)), \
|
2022-08-04 20:40:49 +03:00
|
|
|
$(GIT) -C "$(GITHUB_MERGE_WORKTREE)" rebase --exec "$(GIT) commit --amend --no-edit -S" "$(GITHUB_MERGE_BASE)"; \
|
2019-04-25 12:27:16 +03:00
|
|
|
)
|
2022-08-04 20:40:49 +03:00
|
|
|
$(GIT) -C "$(GITHUB_MERGE_WORKTREE)" rebase --exec "$(GIT) notes add --message 'Merged: $(GITHUB_RUBY_URL)/pull/$(1)'" "$(GITHUB_MERGE_BASE)"
|
2019-04-25 12:29:58 +03:00
|
|
|
endef
|
|
|
|
|
2019-07-17 05:56:40 +03:00
|
|
|
.PHONY: fetch-github-%
|
2019-04-25 12:29:58 +03:00
|
|
|
fetch-github-%:
|
|
|
|
$(call fetch-github,$*)
|
|
|
|
|
2019-07-17 05:56:40 +03:00
|
|
|
.PHONY: checkout-github-%
|
|
|
|
checkout-github-%: fetch-github-%
|
2022-08-04 20:40:49 +03:00
|
|
|
$(GIT) -C "$(srcdir)" checkout "gh-$*"
|
2019-07-17 05:56:40 +03:00
|
|
|
|
|
|
|
.PHONY: pr-% pull-github-%
|
|
|
|
pr-% pull-github-%: fetch-github-%
|
|
|
|
$(call pull-github,$*)
|
|
|
|
|
2019-04-25 13:24:56 +03:00
|
|
|
HELP_EXTRA_TASKS = \
|
|
|
|
" checkout-github: checkout GitHub Pull Request [PR=1234]" \
|
2019-07-17 05:56:40 +03:00
|
|
|
" pull-github: rebase GitHub Pull Request to new worktree [PR=1234]" \
|
2019-08-14 19:00:26 +03:00
|
|
|
" update-github: merge master branch and push it to Pull Request [PR=1234]" \
|
2019-04-25 13:24:56 +03:00
|
|
|
""
|
|
|
|
|
2020-09-29 07:41:59 +03:00
|
|
|
extract-gems: $(HAVE_BASERUBY:yes=update-gems)
|
2020-03-13 09:31:21 +03:00
|
|
|
|
2022-08-04 11:03:15 +03:00
|
|
|
# 1. squeeze spaces
|
|
|
|
# 2. strip and skip comment/empty lines
|
2022-08-04 19:03:54 +03:00
|
|
|
# 3. "gem x.y.z URL xxxxxx" -> "gem|x.y.z|xxxxxx|URL"
|
2022-08-04 11:03:15 +03:00
|
|
|
# 4. "gem x.y.z URL" -> "gem-x.y.z"
|
|
|
|
bundled-gems := $(shell sed \
|
|
|
|
-e 's/[ ][ ]*/ /g' \
|
|
|
|
-e 's/^ //;/\#/d;s/ *$$//;/^$$/d' \
|
2022-08-05 03:55:49 +03:00
|
|
|
$(if $(filter yes,$(HAVE_GIT)), \
|
2022-08-04 19:03:54 +03:00
|
|
|
-e 's/^\(.*\) \(.*\) \(.*\) \(.*\)/\1|\2|\4|\3/' \
|
2022-08-05 03:55:49 +03:00
|
|
|
) \
|
2022-08-04 11:03:15 +03:00
|
|
|
-e 's/ /-/;s/ .*//' \
|
|
|
|
$(srcdir)/gems/bundled_gems)
|
|
|
|
|
2022-08-04 19:03:54 +03:00
|
|
|
bundled-gems-rev := $(filter-out $(subst |,,$(bundled-gems)),$(bundled-gems))
|
2022-08-04 11:03:15 +03:00
|
|
|
bundled-gems := $(filter-out $(bundled-gems-rev),$(bundled-gems))
|
|
|
|
|
|
|
|
update-gems: | $(patsubst %,$(srcdir)/gems/%.gem,$(bundled-gems))
|
2022-08-04 19:03:54 +03:00
|
|
|
update-gems: | $(foreach g,$(bundled-gems-rev),$(srcdir)/gems/src/$(word 1,$(subst |, ,$(value g))))
|
2020-03-13 09:31:21 +03:00
|
|
|
|
2020-03-31 11:36:52 +03:00
|
|
|
test-bundler-precheck: | $(srcdir)/.bundle/cache
|
|
|
|
|
|
|
|
$(srcdir)/.bundle/cache:
|
2020-04-02 16:30:17 +03:00
|
|
|
$(MAKEDIRS) $(@D) $(CACHE_DIR)
|
2020-03-31 11:36:52 +03:00
|
|
|
$(LN_S) ../.downloaded-cache $@
|
|
|
|
|
2022-08-04 11:03:15 +03:00
|
|
|
$(srcdir)/gems/%.gem:
|
2020-03-13 09:31:21 +03:00
|
|
|
$(ECHO) Downloading bundled gem $*...
|
|
|
|
$(Q) $(BASERUBY) -C "$(srcdir)" \
|
|
|
|
-I./tool -rdownloader \
|
|
|
|
-e 'gem = "$(@F)"' \
|
|
|
|
-e 'old = Dir.glob("gems/"+gem.sub(/-[^-]*$$/, "-*.gem"))' \
|
|
|
|
-e 'Downloader::RubyGems.download(gem, "gems", nil) and' \
|
|
|
|
-e '(old.delete("gems/#{gem}"); !old.empty?) and' \
|
|
|
|
-e 'File.unlink(*old) and' \
|
|
|
|
-e 'FileUtils.rm_rf(old.map{'"|n|"'n.chomp(".gem")})'
|
|
|
|
|
2022-08-04 11:03:15 +03:00
|
|
|
extract-gems: | $(patsubst %,$(srcdir)/.bundle/gems/%,$(bundled-gems))
|
|
|
|
extract-gems: | $(foreach g,$(bundled-gems-rev), \
|
2022-08-04 19:03:54 +03:00
|
|
|
$(srcdir)/.bundle/gems/$(word 1,$(subst |, ,$(value g)))-$(word 2,$(subst |, ,$(value g))))
|
2020-03-13 09:31:21 +03:00
|
|
|
|
2022-08-04 11:03:15 +03:00
|
|
|
$(srcdir)/.bundle/gems/%: $(srcdir)/gems/%.gem | .bundle/gems
|
2020-03-13 09:31:21 +03:00
|
|
|
$(ECHO) Extracting bundle gem $*...
|
2020-03-28 11:24:59 +03:00
|
|
|
$(Q) $(BASERUBY) -C "$(srcdir)" \
|
2022-07-30 18:04:16 +03:00
|
|
|
-Itool/lib -rbundled_gem \
|
|
|
|
-e 'BundledGem.unpack("gems/$(@F).gem", ".bundle")'
|
2020-03-13 09:31:21 +03:00
|
|
|
|
2022-08-04 11:03:15 +03:00
|
|
|
define copy-gem
|
2022-08-04 19:03:54 +03:00
|
|
|
$(srcdir)/gems/src/$(1): | $(srcdir)/gems/src
|
|
|
|
$(ECHO) Cloning $(4)
|
|
|
|
$(Q) $(GIT) clone $(4) $$(@)
|
|
|
|
|
2022-08-04 11:03:15 +03:00
|
|
|
$(srcdir)/.bundle/gems/$(1)-$(2): | $(srcdir)/gems/src/$(1) .bundle/gems
|
|
|
|
$(ECHO) Copying $(1)@$(3) to $$(@F)
|
2022-08-18 05:05:34 +03:00
|
|
|
$(Q) $(CHDIR) "$(srcdir)/gems/src/$(1)" && \
|
|
|
|
$(GIT) fetch origin $(3) && \
|
|
|
|
$(GIT) checkout --detach $(3) && \
|
|
|
|
:
|
2022-08-04 11:03:15 +03:00
|
|
|
$(Q) $(BASERUBY) -C "$(srcdir)" \
|
|
|
|
-Itool/lib -rbundled_gem \
|
|
|
|
-e 'BundledGem.copy("gems/src/$(1)/$(1).gemspec", ".bundle")'
|
|
|
|
|
|
|
|
endef
|
|
|
|
define copy-gem-0
|
2022-08-04 19:03:54 +03:00
|
|
|
$(call copy-gem,$(word 1,$(1)),$(word 2,$(1)),$(word 3,$(1)),$(word 4,$(1)))
|
2022-08-04 11:03:15 +03:00
|
|
|
endef
|
|
|
|
|
2022-08-04 19:03:54 +03:00
|
|
|
$(foreach g,$(bundled-gems-rev),$(eval $(call copy-gem-0,$(subst |, ,$(value g)))))
|
|
|
|
|
|
|
|
$(srcdir)/gems/src:
|
|
|
|
$(MAKEDIRS) $@
|
2022-08-04 11:03:15 +03:00
|
|
|
|
2020-03-13 09:31:21 +03:00
|
|
|
$(srcdir)/.bundle/gems:
|
|
|
|
$(MAKEDIRS) $@
|
|
|
|
|
2020-03-12 17:38:14 +03:00
|
|
|
ifneq ($(filter update-bundled_gems refresh-gems,$(MAKECMDGOALS)),)
|
2020-03-12 16:58:04 +03:00
|
|
|
update-gems: update-bundled_gems
|
2019-10-23 19:42:31 +03:00
|
|
|
endif
|
2018-02-06 06:19:42 +03:00
|
|
|
|
|
|
|
ifeq ($(filter 0 1,$(words $(arch_flags))),)
|
|
|
|
$(foreach x,$(patsubst -arch=%,%,$(arch_flags)), \
|
|
|
|
$(eval $$(MJIT_HEADER:.h=)-$(value x).h \
|
|
|
|
$$(MJIT_MIN_HEADER:.h=)-$(value x).h \
|
2018-03-16 05:07:43 +03:00
|
|
|
$$(TIMESTAMPDIR)/$$(MJIT_HEADER:.h=)-$(value x).time \
|
2018-02-06 06:19:42 +03:00
|
|
|
: ARCH_FLAG := -arch $(value x)))
|
|
|
|
|
2018-03-16 05:07:43 +03:00
|
|
|
$(foreach x,$(patsubst -arch=%,%,$(arch_flags)), \
|
|
|
|
$(eval $$(MJIT_HEADER:.h=)-$(value x).h: \
|
|
|
|
$$(TIMESTAMPDIR)/$$(MJIT_HEADER:.h=)-$(value x).time))
|
|
|
|
|
2018-02-06 06:19:42 +03:00
|
|
|
mjit_min_headers := $(patsubst -arch=%,$(MJIT_MIN_HEADER:.h=-%.h),$(arch_flags))
|
2018-02-08 17:59:31 +03:00
|
|
|
$(MJIT_MIN_HEADER): $(mjit_min_headers) $(PREP)
|
2018-02-06 06:19:42 +03:00
|
|
|
@ set -e; set $(patsubst -arch=%,%,$(arch_flags)); \
|
2018-02-10 09:38:18 +03:00
|
|
|
cd $(@D); h=$(@F:.h=); \
|
|
|
|
exec > $(@F).new; \
|
|
|
|
echo '#if 0'; \
|
|
|
|
for arch; do\
|
|
|
|
echo "#elif defined __$${arch}__"; \
|
|
|
|
echo "# include \"$$h-$$arch.h\""; \
|
|
|
|
done; \
|
|
|
|
echo "#else"; echo "# error unsupported platform"; echo "#endif"
|
2018-02-06 06:19:42 +03:00
|
|
|
$(IFCHANGE) $@ $@.new
|
2018-02-07 16:45:14 +03:00
|
|
|
$(Q) $(MAKEDIRS) $(MJIT_HEADER_INSTALL_DIR)
|
|
|
|
$(Q) $(MAKE_LINK) $@ $(MJIT_HEADER_INSTALL_DIR)/$(@F)
|
2018-02-06 06:19:42 +03:00
|
|
|
|
|
|
|
endif
|
2018-11-20 06:07:46 +03:00
|
|
|
|
2019-07-09 07:10:08 +03:00
|
|
|
ifeq ($(if $(wildcard $(filter-out .,$(UNICODE_FILES) $(UNICODE_PROPERTY_FILES))),,\
|
2019-04-04 15:11:53 +03:00
|
|
|
$(wildcard $(srcdir)/lib/unicode_normalize/tables.rb)),)
|
|
|
|
# Needs the dependency when any Unicode data file exists, or
|
|
|
|
# normalization tables script doesn't. Otherwise, when the target
|
|
|
|
# only exists, use it as-is.
|
2019-04-04 08:10:26 +03:00
|
|
|
.PHONY: $(UNICODE_SRC_DATA_DIR)/.unicode-tables.time
|
2019-04-04 15:11:53 +03:00
|
|
|
UNICODE_TABLES_TIMESTAMP =
|
2019-04-04 08:10:26 +03:00
|
|
|
$(UNICODE_SRC_DATA_DIR)/.unicode-tables.time: \
|
|
|
|
$(UNICODE_FILES) $(UNICODE_PROPERTY_FILES)
|
|
|
|
endif
|
|
|
|
|
2021-12-02 06:20:53 +03:00
|
|
|
ifeq ($(wildcard $(srcdir)/revision.h),)
|
|
|
|
REVISION_IN_HEADER := none
|
|
|
|
REVISION_LATEST := update
|
|
|
|
else
|
2019-11-21 09:17:34 +03:00
|
|
|
REVISION_IN_HEADER := $(shell sed -n 's/^\#define RUBY_FULL_REVISION "\(.*\)"/\1/p' $(srcdir)/revision.h 2>/dev/null)
|
2022-08-04 20:40:49 +03:00
|
|
|
REVISION_LATEST := $(shell $(CHDIR) $(srcdir) && $(GIT) log -1 --format=%H 2>/dev/null)
|
2021-12-02 06:20:53 +03:00
|
|
|
endif
|
2019-11-21 04:57:36 +03:00
|
|
|
ifneq ($(REVISION_IN_HEADER),$(REVISION_LATEST))
|
2018-11-29 10:07:40 +03:00
|
|
|
# GNU make treat the target as unmodified when its dependents get
|
|
|
|
# updated but it is not updated, while others may not.
|
|
|
|
$(srcdir)/revision.h: $(REVISION_H)
|
2019-11-21 04:57:36 +03:00
|
|
|
endif
|
2018-11-29 10:07:40 +03:00
|
|
|
|
2022-05-27 05:27:15 +03:00
|
|
|
include $(top_srcdir)/yjit/yjit.mk
|
Rust YJIT
In December 2021, we opened an [issue] to solicit feedback regarding the
porting of the YJIT codebase from C99 to Rust. There were some
reservations, but this project was given the go ahead by Ruby core
developers and Matz. Since then, we have successfully completed the port
of YJIT to Rust.
The new Rust version of YJIT has reached parity with the C version, in
that it passes all the CRuby tests, is able to run all of the YJIT
benchmarks, and performs similarly to the C version (because it works
the same way and largely generates the same machine code). We've even
incorporated some design improvements, such as a more fine-grained
constant invalidation mechanism which we expect will make a big
difference in Ruby on Rails applications.
Because we want to be careful, YJIT is guarded behind a configure
option:
```shell
./configure --enable-yjit # Build YJIT in release mode
./configure --enable-yjit=dev # Build YJIT in dev/debug mode
```
By default, YJIT does not get compiled and cargo/rustc is not required.
If YJIT is built in dev mode, then `cargo` is used to fetch development
dependencies, but when building in release, `cargo` is not required,
only `rustc`. At the moment YJIT requires Rust 1.60.0 or newer.
The YJIT command-line options remain mostly unchanged, and more details
about the build process are documented in `doc/yjit/yjit.md`.
The CI tests have been updated and do not take any more resources than
before.
The development history of the Rust port is available at the following
commit for interested parties:
https://github.com/Shopify/ruby/commit/1fd9573d8b4b65219f1c2407f30a0a60e537f8be
Our hope is that Rust YJIT will be compiled and included as a part of
system packages and compiled binaries of the Ruby 3.2 release. We do not
anticipate any major problems as Rust is well supported on every
platform which YJIT supports, but to make sure that this process works
smoothly, we would like to reach out to those who take care of building
systems packages before the 3.2 release is shipped and resolve any
issues that may come up.
[issue]: https://bugs.ruby-lang.org/issues/18481
Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
Co-authored-by: Noah Gibbs <the.codefolio.guy@gmail.com>
Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2022-04-19 21:40:21 +03:00
|
|
|
|
2018-11-20 06:07:46 +03:00
|
|
|
# Query on the generated rdoc
|
|
|
|
#
|
|
|
|
# $ make rdoc:Integer#+
|
|
|
|
rdoc\:%: PHONY
|
2018-11-28 17:56:19 +03:00
|
|
|
$(Q)$(RUNRUBY) $(srcdir)/libexec/ri --no-standard-docs --doc-dir=$(RDOCOUT) $(patsubst rdoc:%,%,$@)
|
2018-11-20 09:13:42 +03:00
|
|
|
|
|
|
|
test_%.rb test/%: programs PHONY
|
2020-06-09 12:47:16 +03:00
|
|
|
$(Q)$(exec) $(RUNRUBY) "$(TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) -- $(patsubst test/%,%,$@)
|
2018-11-24 07:34:00 +03:00
|
|
|
|
2019-08-13 15:11:58 +03:00
|
|
|
spec/bundler/%: PHONY
|
2020-06-09 12:47:16 +03:00
|
|
|
$(Q)$(exec) $(XRUBY) -C $(srcdir) -Ispec/bundler .bundle/bin/rspec --require spec_helper $(RSPECOPTS) $@
|
2019-08-13 15:11:58 +03:00
|
|
|
|
2020-06-25 12:21:41 +03:00
|
|
|
spec/bundler: test-bundler-parallel
|
2020-06-10 15:59:30 +03:00
|
|
|
$(Q)$(NULLCMD)
|
2020-06-10 13:59:52 +03:00
|
|
|
|
2021-08-25 10:24:25 +03:00
|
|
|
# workaround to avoid matching non ruby files with "spec/%/" under GNU make 3.81
|
2021-12-04 04:40:15 +03:00
|
|
|
spec/%_spec.c:
|
|
|
|
$(empty)
|
|
|
|
$(srcdir)/$(RUBYSPEC_CAPIEXT)/rubyspec.h:
|
2021-08-25 11:50:49 +03:00
|
|
|
$(empty)
|
2019-07-31 14:46:01 +03:00
|
|
|
|
2019-09-20 03:31:55 +03:00
|
|
|
benchmark/%: miniruby$(EXEEXT) update-benchmark-driver PHONY
|
|
|
|
$(Q)$(BASERUBY) -rrubygems -I$(srcdir)/benchmark/lib $(srcdir)/benchmark/benchmark-driver/exe/benchmark-driver \
|
|
|
|
--executables="compare-ruby::$(COMPARE_RUBY) -I$(EXTOUT)/common --disable-gem" \
|
|
|
|
--executables="built-ruby::$(BENCH_RUBY) --disable-gem" \
|
2020-06-08 03:25:22 +03:00
|
|
|
$(srcdir)/$@ $(BENCH_OPTS) $(OPTS)
|
2019-09-20 03:31:55 +03:00
|
|
|
|
2018-11-24 07:34:00 +03:00
|
|
|
clean-srcs-ext::
|
|
|
|
$(Q)$(RM) $(patsubst $(srcdir)/%,%,$(EXT_SRCS))
|
|
|
|
|
|
|
|
clean-srcs-extra::
|
|
|
|
$(Q)$(RM) $(patsubst $(srcdir)/%,%,$(EXTRA_SRCS))
|
2019-04-21 06:30:38 +03:00
|
|
|
|
|
|
|
ifneq ($(filter $(VCS),git),)
|
|
|
|
update-src::
|
2020-04-04 21:57:05 +03:00
|
|
|
@$(BASERUBY) $(tooldir)/lib/colorize.rb pass "Latest commit hash = $(shell $(filter-out svn,$(VCS)) -C $(srcdir) rev-parse --short=10 HEAD)"
|
2019-04-21 06:30:38 +03:00
|
|
|
endif
|
2019-07-15 11:06:35 +03:00
|
|
|
|
|
|
|
# Update dependencies and commit the updates to the current branch.
|
|
|
|
update-deps:
|
|
|
|
$(eval update_deps := $(shell date +update-deps-%Y%m%d))
|
|
|
|
$(eval deps_dir := $(shell mktemp -d)/$(update_deps))
|
2022-08-04 20:40:49 +03:00
|
|
|
$(eval GIT_DIR := $(shell $(GIT) -C $(srcdir) rev-parse --absolute-git-dir))
|
|
|
|
$(GIT) --git-dir=$(GIT_DIR) worktree add $(deps_dir)
|
2020-04-04 21:57:05 +03:00
|
|
|
cp $(tooldir)/config.guess $(tooldir)/config.sub $(deps_dir)/tool
|
2019-07-15 11:06:35 +03:00
|
|
|
[ -f config.status ] && cp config.status $(deps_dir)
|
|
|
|
cd $(deps_dir) && autoconf && \
|
|
|
|
exec ./configure -q -C --enable-load-relative --disable-install-doc --disable-rubygems 'optflags=-O0' 'debugflags=-save-temps=obj -g'
|
|
|
|
$(RUNRUBY) -C $(deps_dir) tool/update-deps --fix
|
2022-08-04 20:40:49 +03:00
|
|
|
$(GIT) -C $(deps_dir) diff --no-ext-diff --ignore-submodules --exit-code || \
|
|
|
|
$(GIT) -C $(deps_dir) commit --all --message='Update dependencies'
|
|
|
|
$(GIT) --git-dir=$(GIT_DIR) worktree remove $(deps_dir)
|
2019-08-08 16:40:09 +03:00
|
|
|
$(RMDIR) $(dir $(deps_dir))
|
2022-08-04 20:40:49 +03:00
|
|
|
$(GIT) --git-dir=$(GIT_DIR) merge --no-edit --ff-only $(update_deps)
|
|
|
|
$(GIT) --git-dir=$(GIT_DIR) branch --delete $(update_deps)
|
2020-11-21 17:15:26 +03:00
|
|
|
|
|
|
|
# order-only-prerequisites doesn't work for $(RUBYSPEC_CAPIEXT)
|
|
|
|
# because the same named directory exists in the source tree.
|
2021-08-30 06:03:44 +03:00
|
|
|
$(RUBYSPEC_CAPIEXT)/%.$(DLEXT): $(srcdir)/$(RUBYSPEC_CAPIEXT)/%.c $(srcdir)/$(RUBYSPEC_CAPIEXT)/rubyspec.h $(RUBY_H_INCLUDES) $(LIBRUBY)
|
2020-11-21 17:15:26 +03:00
|
|
|
$(ECHO) building $@
|
|
|
|
$(Q) $(MAKEDIRS) $(@D)
|
2021-08-30 06:03:44 +03:00
|
|
|
$(Q) $(DLDSHARED) $(XDLDFLAGS) $(XLDFLAGS) $(LDFLAGS) $(INCFLAGS) $(CPPFLAGS) $(OUTFLAG)$@ $< $(LIBRUBYARG)
|
2020-11-21 17:15:26 +03:00
|
|
|
$(Q) $(RMALL) $@.*
|
2020-11-22 13:09:58 +03:00
|
|
|
|
2020-11-21 17:15:26 +03:00
|
|
|
rubyspec-capiext: $(patsubst %.c,$(RUBYSPEC_CAPIEXT)/%.$(DLEXT),$(notdir $(wildcard $(srcdir)/$(RUBYSPEC_CAPIEXT)/*.c)))
|
|
|
|
@ $(NULLCMD)
|
2021-08-05 16:30:48 +03:00
|
|
|
|
|
|
|
ifeq ($(ENABLE_SHARED),yes)
|
|
|
|
exts: rubyspec-capiext
|
|
|
|
endif
|
2021-12-04 04:40:15 +03:00
|
|
|
|
|
|
|
spec/%/ spec/%_spec.rb: programs exts PHONY
|
|
|
|
+$(RUNRUBY) -r./$(arch)-fake $(srcdir)/spec/mspec/bin/mspec-run -B $(srcdir)/spec/default.mspec $(SPECOPTS) $(patsubst %,$(srcdir)/%,$@)
|
2021-12-04 10:20:30 +03:00
|
|
|
|
|
|
|
ruby.pc: $(filter-out ruby.pc,$(ruby_pc))
|