1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

tool/mjit_archflag.sh: separated, too many escapes

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-11-15 05:22:44 +00:00
parent 2212c1dc16
commit 3dac8eda41
2 changed files with 43 additions and 36 deletions

View file

@ -583,31 +583,8 @@ un-runnable:
mjit_config.h:
$(ECHO) making $@
@{ \
quote() { \
printf "#define $$1"; shift; \
$${1+printf} $${1+' "%s"'$$sep} $${1+"$$@"}; \
echo; \
}; \
parse_arch_flag() { \
while [ "$$#" -gt 0 ]; do \
case "$$1" in \
-arch) \
shift; \
archs="$${archs:+$$archs }$$1"; \
shift; \
;; \
*) \
arch_flag="$${arch_flag:+$${arch_flag} }$$1"; \
shift; \
;; \
esac; \
done; \
}; \
. $(srcdir)/tool/mjit_archflag.sh "$(UNIVERSAL_ARCHNAMES)" $(ARCH_FLAG); \
test "$(Q)" = @ || set -x; \
archs="$(UNIVERSAL_ARCHNAMES)"; \
arch_flag=""; \
parse_arch_flag $(ARCH_FLAG); \
need_mjit_archflag="$${archs}$${arch_flag}"; \
echo '#ifndef RUBY_MJIT_CONFIG_H'; \
echo '#define RUBY_MJIT_CONFIG_H 1'; \
echo; \
@ -615,23 +592,14 @@ mjit_config.h:
quote MJIT_MIN_HEADER_NAME "/$(MJIT_HEADER_INSTALL_DIR)/$(MJIT_MIN_HEADER_NAME)"; \
sep=,; \
quote "MJIT_CC_COMMON " $(MJIT_CC); \
quote "MJIT_CFLAGS $${need_mjit_archflag:+ MJIT_ARCHFLAG}" $(MJIT_CFLAGS); \
quote "MJIT_CFLAGS MJIT_ARCHFLAG" $(MJIT_CFLAGS); \
quote "MJIT_OPTFLAGS " $(MJIT_OPTFLAGS); \
quote "MJIT_DEBUGFLAGS " $(MJIT_DEBUGFLAGS); \
quote "MJIT_LDSHARED " $(MJIT_LDSHARED); \
quote "MJIT_DLDFLAGS $${need_mjit_archflag:+ MJIT_ARCHFLAG}" $(MJIT_DLDFLAGS); \
quote "MJIT_DLDFLAGS MJIT_ARCHFLAG" $(MJIT_DLDFLAGS); \
quote "MJIT_LIBS " $(LIBRUBYARG_SHARED); \
quote 'PRELOADENV "@PRELOADENV@"'; \
$${archs:+echo} $${archs:+'#if 0'}; \
for arch in $$archs; do \
echo "#elif defined __$${arch%=*}__"; \
quote " MJIT_ARCHFLAG " -arch $${arch%=*}; \
done; \
$${archs:+echo} $${archs:+'#else'}; \
if [ "$${arch_flag}" != "" ]; then \
quote " MJIT_ARCHFLAG " $${arch_flag}; \
fi; \
$${archs:+echo} $${archs:+'#endif'}; \
indent=$${archs+ } define_arch_flags; \
echo; \
echo '#endif /* RUBY_MJIT_CONFIG_H */'; \
} > $@

39
tool/mjit_archflag.sh Normal file
View file

@ -0,0 +1,39 @@
# -*- sh -*-
quote() {
printf "#${indent}define $1"
shift
${1+printf} ${1+' "%s"'$sep} ${1+"$@"}
echo
}
archs=""
arch_flag=""
for arch in $1; do
archs="${archs:+$archs }${arch%=*}"
done
while shift && [ "$#" -gt 0 ]; do
case "$1" in
-arch)
shift
archs="${archs:+$archs }$1"
;;
*)
arch_flag="${arch_flag:+${arch_flag} }$1"
;;
esac
done
define_arch_flags() {
local indent=${archs:+ }
${archs:+echo} ${archs:+'#if 0'}
for arch in $archs; do
echo "#elif defined __${arch}__"
quote "MJIT_ARCHFLAG " -arch "${arch}"
done
${archs:+echo} ${archs:+'#else'}
quote "MJIT_ARCHFLAG ${arch_flag:- /* no flag */}" ${arch_flag}
${archs:+echo} ${archs:+'#endif'}
}