Skip to content

Commit a142602

Browse files
committed
Extract setup/baseruby
1 parent b2db5a9 commit a142602

3 files changed

Lines changed: 83 additions & 19 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Setup directories etc.
2+
description: >-
3+
Build baseruby for cross-compiling
4+
5+
inputs:
6+
srcdir:
7+
required: true
8+
default: ${{ github.workspace }}
9+
description: >-
10+
Directory of source codes.
11+
12+
builddir:
13+
required: false
14+
default: ${{ github.workspace }}/baseruby
15+
description: >-
16+
Where baseruby will be built.
17+
18+
installdir:
19+
required: false
20+
default: install
21+
description: >-
22+
The path where the baseruby will be installed to.
23+
This is relative from the workspace.
24+
25+
outputs:
26+
ruby:
27+
value: ${{ steps.build.outputs.installdir }}/bin/ruby
28+
description: >-
29+
The path of the executable baseruby.
30+
dump_ast:
31+
value: ${{ steps.build.outputs.installdir }}/bin/dump_ast
32+
description: >-
33+
The path of the executable dump_ast.
34+
35+
runs:
36+
using: composite
37+
38+
steps:
39+
- name: Build baseruby
40+
shell: bash
41+
id: build
42+
run: |
43+
case "$installdir" in /*) ;; *) installdir="$PWD/$installdir";; esac
44+
mkdir "$builddir"
45+
ln -sr "$srcdir" "$builddir/.src"
46+
pushd "$builddir"
47+
.src/configure "--prefix=${installdir}" --disable-install-doc
48+
CONFIGURE_ARGS=--with-out-ext=-test- make install
49+
install dump_ast "${installdir}/bin"
50+
{
51+
echo "${installdir}/bin/dump_ast"
52+
echo "${installdir}/.installed.list"
53+
echo "${installdir}/"
54+
} >> .installed.list
55+
cp .installed.list "${installdir}/"
56+
make distclean
57+
rm .src
58+
popd
59+
rmdir "$builddir"
60+
{
61+
echo "installdir=${installdir}"
62+
} | tee -a "$GITHUB_OUTPUT"
63+
env:
64+
srcdir: ${{ inputs.srcdir }}
65+
builddir: ${{ inputs.builddir }}
66+
installdir: ${{ inputs.installdir }}
67+
68+
- name: clean
69+
uses: gacts/run-and-post-run@598d7a875d5620e0457490555b5e18e46082aa47 # v1.4.4
70+
with:
71+
working-directory: ${{ inputs.srcdir }}
72+
post: |
73+
ruby tool/rbuninstall.rb "${{ steps.build.outputs.installdir }}/.installed.list" > /dev/null

.github/workflows/crosscompile.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,21 +95,20 @@ jobs:
9595
libncurses-dev:${{ matrix.arch }} \
9696
autoconf ruby
9797
98-
- name: Build baseruby
99-
run: |
100-
mkdir ../baseruby
101-
cd ../baseruby
102-
../src/configure --prefix=$PWD/install --disable-install-doc
103-
make
104-
make install
98+
- uses: ./.github/actions/setup/baseruby
99+
id: baseruby
100+
with:
101+
srcdir: src
105102

106103
- name: Run configure
107104
run: >-
108105
../src/configure -C --disable-install-doc
109106
--prefix=/usr
110107
--build=${{ matrix.build }}
111108
--host=${{ matrix.host }}
112-
--with-baseruby=$PWD/../baseruby/install/bin/ruby
109+
--with-baseruby="$baseruby"
110+
env:
111+
baseruby: ${{ steps.baseruby.outputs.ruby }}
113112

114113
- run: make
115114

.github/workflows/wasm.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,10 @@ jobs:
104104
run: |
105105
echo "WASI_SDK_PATH=/opt/wasi-sdk" >> $GITHUB_ENV
106106
107-
- name: Build baseruby
107+
- uses: ./.github/actions/setup/baseruby
108108
id: baseruby
109-
run: |
110-
set -ex
111-
mkdir ../baseruby
112-
pushd ../baseruby
113-
echo "ruby=$PWD/install/bin/ruby" >> $GITHUB_OUTPUT
114-
echo "dump_ast=$PWD/dump_ast" >> $GITHUB_OUTPUT
115-
../src/configure --prefix=$PWD/install --disable-install-doc
116-
export CONFIGURE_ARGS=--with-out-ext=-test-
117-
make
118-
make install
109+
with:
110+
srcdir: src
119111

120112
- name: Download config.guess with wasi version
121113
run: |

0 commit comments

Comments
 (0)