xref: /OK3568_Linux_fs/yocto/poky/meta/recipes-devtools/ruby/ruby_3.1.3.bb (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunSUMMARY = "An interpreter of object-oriented scripting language"
2*4882a593SmuzhiyunDESCRIPTION = "Ruby is an interpreted scripting language for quick \
3*4882a593Smuzhiyunand easy object-oriented programming. It has many features to process \
4*4882a593Smuzhiyuntext files and to do system management tasks (as in Perl). \
5*4882a593SmuzhiyunIt is simple, straight-forward, and extensible. \
6*4882a593Smuzhiyun"
7*4882a593SmuzhiyunHOMEPAGE = "http://www.ruby-lang.org/"
8*4882a593SmuzhiyunSECTION = "devel/ruby"
9*4882a593SmuzhiyunLICENSE = "Ruby | BSD-2-Clause | BSD-3-Clause | GPL-2.0-only | ISC | MIT"
10*4882a593SmuzhiyunLIC_FILES_CHKSUM = "file://COPYING;md5=5b8c87559868796979806100db3f3805 \
11*4882a593Smuzhiyun                    file://BSDL;md5=8b50bc6de8f586dc66790ba11d064d75 \
12*4882a593Smuzhiyun                    file://GPL;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
13*4882a593Smuzhiyun                    file://LEGAL;md5=f260190bc1e92e363f0ee3c0463d4c7c \
14*4882a593Smuzhiyun                    "
15*4882a593Smuzhiyun
16*4882a593SmuzhiyunDEPENDS = "zlib openssl libyaml gdbm readline libffi"
17*4882a593SmuzhiyunDEPENDS:append:class-target = " ruby-native"
18*4882a593Smuzhiyun
19*4882a593SmuzhiyunSHRT_VER = "${@oe.utils.trim_version("${PV}", 2)}"
20*4882a593SmuzhiyunSRC_URI = "http://cache.ruby-lang.org/pub/ruby/${SHRT_VER}/ruby-${PV}.tar.gz \
21*4882a593Smuzhiyun           file://0001-extmk-fix-cross-compilation-of-external-gems.patch \
22*4882a593Smuzhiyun           file://0002-Obey-LDFLAGS-for-the-link-of-libruby.patch \
23*4882a593Smuzhiyun           file://remove_has_include_macros.patch \
24*4882a593Smuzhiyun           file://run-ptest \
25*4882a593Smuzhiyun           file://0001-template-Makefile.in-do-not-write-host-cross-cc-item.patch \
26*4882a593Smuzhiyun           file://0002-template-Makefile.in-filter-out-f-prefix-map.patch \
27*4882a593Smuzhiyun           file://0003-rdoc-build-reproducible-documentation.patch \
28*4882a593Smuzhiyun           file://0004-lib-mkmf.rb-sort-list-of-object-files-in-generated-M.patch \
29*4882a593Smuzhiyun           file://0005-Mark-Gemspec-reproducible-change-fixing-784225-too.patch \
30*4882a593Smuzhiyun           file://0006-Make-gemspecs-reproducible.patch \
31*4882a593Smuzhiyun           file://0001-vm_dump.c-Define-REG_S1-and-REG_S2-for-musl-riscv.patch \
32*4882a593Smuzhiyun           "
33*4882a593SmuzhiyunUPSTREAM_CHECK_URI = "https://www.ruby-lang.org/en/downloads/"
34*4882a593Smuzhiyun
35*4882a593Smuzhiyuninherit autotools ptest pkgconfig
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun# This snippet lets compiled extensions which rely on external libraries,
39*4882a593Smuzhiyun# such as zlib, compile properly.  If we don't do this, then when extmk.rb
40*4882a593Smuzhiyun# runs, it uses the native libraries instead of the target libraries, and so
41*4882a593Smuzhiyun# none of the linking operations succeed -- which makes extconf.rb think
42*4882a593Smuzhiyun# that the libraries aren't available and hence that the extension can't be
43*4882a593Smuzhiyun# built.
44*4882a593Smuzhiyun
45*4882a593Smuzhiyundo_configure:prepend() {
46*4882a593Smuzhiyun    sed -i "s#%%TARGET_CFLAGS%%#$CFLAGS#; s#%%TARGET_LDFLAGS%%#$LDFLAGS#" ${S}/common.mk
47*4882a593Smuzhiyun    rm -rf ${S}/ruby/
48*4882a593Smuzhiyun}
49*4882a593Smuzhiyun
50*4882a593SmuzhiyunDEPENDS:append:libc-musl = " libucontext"
51*4882a593Smuzhiyun
52*4882a593SmuzhiyunSRC_URI[sha256sum] = "5ea498a35f4cd15875200a52dde42b6eb179e1264e17d78732c3a57cd1c6ab9e"
53*4882a593Smuzhiyun
54*4882a593SmuzhiyunPACKAGECONFIG ??= ""
55*4882a593SmuzhiyunPACKAGECONFIG += "${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)}"
56*4882a593Smuzhiyun
57*4882a593SmuzhiyunPACKAGECONFIG[valgrind] = "--with-valgrind=yes, --with-valgrind=no, valgrind"
58*4882a593SmuzhiyunPACKAGECONFIG[gmp] = "--with-gmp=yes, --with-gmp=no, gmp"
59*4882a593SmuzhiyunPACKAGECONFIG[ipv6] = "--enable-ipv6, --disable-ipv6,"
60*4882a593Smuzhiyun# rdoc is off by default due to non-reproducibility reported in
61*4882a593Smuzhiyun# https://bugs.ruby-lang.org/issues/18456
62*4882a593SmuzhiyunPACKAGECONFIG[rdoc] = "--enable-install-rdoc,--disable-install-rdoc,"
63*4882a593Smuzhiyun
64*4882a593SmuzhiyunEXTRA_OECONF = "\
65*4882a593Smuzhiyun    --disable-versioned-paths \
66*4882a593Smuzhiyun    --disable-rpath \
67*4882a593Smuzhiyun    --disable-dtrace \
68*4882a593Smuzhiyun    --enable-shared \
69*4882a593Smuzhiyun    --enable-load-relative \
70*4882a593Smuzhiyun    --with-pkg-config=pkg-config \
71*4882a593Smuzhiyun    --with-static-linked-ext \
72*4882a593Smuzhiyun"
73*4882a593Smuzhiyun
74*4882a593SmuzhiyunEXTRA_OECONF:append:libc-musl = "\
75*4882a593Smuzhiyun    ac_cv_func_isnan=yes \
76*4882a593Smuzhiyun    ac_cv_func_isinf=yes \
77*4882a593Smuzhiyun"
78*4882a593Smuzhiyun
79*4882a593SmuzhiyunPARALLEL_MAKEINST = ""
80*4882a593Smuzhiyun
81*4882a593Smuzhiyundo_install:append:class-target () {
82*4882a593Smuzhiyun    # Find out rbconfig.rb from .installed.list
83*4882a593Smuzhiyun    rbconfig_rb=`grep rbconfig.rb ${B}/.installed.list`
84*4882a593Smuzhiyun    # Remove build host directories
85*4882a593Smuzhiyun    sed -i -e 's:--sysroot=${STAGING_DIR_TARGET}::g' \
86*4882a593Smuzhiyun           -e s:'--with-libtool-sysroot=${STAGING_DIR_TARGET}'::g \
87*4882a593Smuzhiyun           -e 's|${DEBUG_PREFIX_MAP}||g' \
88*4882a593Smuzhiyun           -e 's:${HOSTTOOLS_DIR}/::g' \
89*4882a593Smuzhiyun           -e 's:${RECIPE_SYSROOT_NATIVE}::g' \
90*4882a593Smuzhiyun           -e 's:${RECIPE_SYSROOT}::g' \
91*4882a593Smuzhiyun           -e 's:${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}::g' \
92*4882a593Smuzhiyun        ${D}$rbconfig_rb
93*4882a593Smuzhiyun
94*4882a593Smuzhiyun    sed -i -e 's|${DEBUG_PREFIX_MAP}||g' \
95*4882a593Smuzhiyun        ${D}${libdir}/pkgconfig/*.pc
96*4882a593Smuzhiyun
97*4882a593Smuzhiyun    # logs that may contain host-specific paths
98*4882a593Smuzhiyun    find ${D} -name gem_make.out -delete
99*4882a593Smuzhiyun}
100*4882a593Smuzhiyun
101*4882a593Smuzhiyundo_install_ptest () {
102*4882a593Smuzhiyun    cp -rf ${S}/test ${D}${PTEST_PATH}/
103*4882a593Smuzhiyun
104*4882a593Smuzhiyun    install -D ${S}/tool/test/runner.rb ${D}${PTEST_PATH}/tool/test/runner.rb
105*4882a593Smuzhiyun    cp -r ${S}/tool/lib ${D}${PTEST_PATH}/tool/
106*4882a593Smuzhiyun    mkdir -p ${D}${PTEST_PATH}/lib
107*4882a593Smuzhiyun    cp -r ${S}/lib/did_you_mean ${S}/lib/rdoc ${D}${PTEST_PATH}/lib
108*4882a593Smuzhiyun
109*4882a593Smuzhiyun    # install test-binaries
110*4882a593Smuzhiyun    # These .so files have sporadic reproducibility fails as seen here:
111*4882a593Smuzhiyun    # https://autobuilder.yocto.io/pub/repro-fail/oe-reproducible-20220107-rm1diuww/packages/diff-html/
112*4882a593Smuzhiyun    # As they are needed only in ruby-ptest, and that is currently altogether disabled, let's take them out.
113*4882a593Smuzhiyun    # If someone wants to look at where the non-determinism comes from, one possible reason is use of
114*4882a593Smuzhiyun    # -rdynamic -Wl,-export-dynamic
115*4882a593Smuzhiyun    #find $(find ./.ext -path '*/-test-') -name '*.so' -print0 \
116*4882a593Smuzhiyun    #    | tar --no-recursion --null -T - --no-same-owner --preserve-permissions -cf - \
117*4882a593Smuzhiyun    #    | tar -C ${D}${libdir}/ruby/${SHRT_VER}.0/ --no-same-owner --preserve-permissions --strip-components=2 -xf -
118*4882a593Smuzhiyun    # adjust path to not assume build directory layout
119*4882a593Smuzhiyun    sed -e 's|File.expand_path(.*\.\./bin/erb[^)]*|File.expand_path("${bindir}/erb"|g' \
120*4882a593Smuzhiyun        -i ${D}${PTEST_PATH}/test/erb/test_erb_command.rb
121*4882a593Smuzhiyun
122*4882a593Smuzhiyun    cp -r ${S}/include ${D}/${libdir}/ruby/
123*4882a593Smuzhiyun}
124*4882a593Smuzhiyun
125*4882a593SmuzhiyunPACKAGES =+ "${PN}-ri-docs ${PN}-rdoc"
126*4882a593Smuzhiyun
127*4882a593SmuzhiyunSUMMARY:${PN}-ri-docs = "ri (Ruby Interactive) documentation for the Ruby standard library"
128*4882a593SmuzhiyunRDEPENDS:${PN}-ri-docs = "${PN}"
129*4882a593SmuzhiyunFILES:${PN}-ri-docs += "${datadir}/ri"
130*4882a593Smuzhiyun
131*4882a593SmuzhiyunSUMMARY:${PN}-rdoc = "RDoc documentation generator from Ruby source"
132*4882a593SmuzhiyunRDEPENDS:${PN}-rdoc = "${PN}"
133*4882a593SmuzhiyunFILES:${PN}-rdoc += "${libdir}/ruby/*/rdoc ${bindir}/rdoc"
134*4882a593Smuzhiyun
135*4882a593SmuzhiyunFILES:${PN} += "${datadir}/rubygems"
136*4882a593Smuzhiyun
137*4882a593SmuzhiyunFILES:${PN}-ptest:append:class-target = "\
138*4882a593Smuzhiyun    ${libdir}/ruby/include \
139*4882a593Smuzhiyun    ${libdir}/ruby/${SHRT_VER}.0/*/-test- \
140*4882a593Smuzhiyun"
141*4882a593Smuzhiyun
142*4882a593SmuzhiyunBBCLASSEXTEND = "native"
143