Skip to content

Commit 52baafa

Browse files
committed
GNUmakefile: Swap uname -s with rustc --print host-tuple for cross-build and MSYS
1 parent 5a912a7 commit 52baafa

2 files changed

Lines changed: 42 additions & 11 deletions

File tree

.github/workflows/make.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,40 @@ jobs:
271271
# 2. the makefile doesn't try to install libstdbuf even though stdbuf is skipped
272272
DESTDIR=/tmp/ make SKIP_UTILS="stdbuf" install
273273
274+
# keep this job minimal to avoid have many duplicated build with CICD
275+
build_makefile-other:
276+
name: Build/Makefile
277+
runs-on: ${{ matrix.job.os }}
278+
env:
279+
CARGO_INCREMENTAL: 0
280+
strategy:
281+
fail-fast: false
282+
matrix:
283+
job:
284+
- { os: windows-latest , features: feat_os_windows }
285+
steps:
286+
- uses: actions/checkout@v6
287+
with:
288+
persist-credentials: false
289+
- uses: Swatinem/rust-cache@v2
290+
- name: Run sccache-cache
291+
id: sccache-setup
292+
uses: mozilla-actions/sccache-action@v0.0.9
293+
continue-on-error: true
294+
- name: Export sccache
295+
if: steps.sccache-setup.outcome == 'success'
296+
run: |
297+
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
298+
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
299+
- name: "`make build`"
300+
shell: bash
301+
run: |
302+
set -x
303+
# Check that we exclude unix programs to avoid build failure
304+
make PREFIX=/tmp/usr MULTICALL=y COMPLETIONS=n MANPAGES=n LOCALES=n \
305+
SKIP_UTILS="arch b2sum base32 base64 basename basenc cat cksum comm cp csplit cut date dd df dir dircolors dirname du echo env expand expr factor false fmt fold head hostname join link ln ls md5sum mkdir mktemp more mv nl nproc numfmt od paste pr printenv printf ptx pwd readlink realpath rm rmdir seq sha1sum sha224sum sha256sum sha384sum sha512sum shred shuf sleep sort split sum sync tac tail tee test touch tr truncate tsort uname unexpand uniq unlink vdir wc whoami yes"
306+
target/debug/coreutils.exe true
307+
274308
test_busybox:
275309
name: Tests/BusyBox test suite
276310
runs-on: ${{ matrix.job.os }}

GNUmakefile

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,14 @@ TOYBOX_ROOT := $(BASEDIR)/tmp
6262
TOYBOX_VER := 0.8.12
6363
TOYBOX_SRC := $(TOYBOX_ROOT)/toybox-$(TOYBOX_VER)
6464

65-
#------------------------------------------------------------------------
66-
# Detect the host system.
67-
# On Windows uname -s might return MINGW_NT-* or CYGWIN_NT-*.
68-
# Otherwise let it default to the kernel name returned by uname -s
69-
# (Linux, Darwin, FreeBSD, …).
70-
#------------------------------------------------------------------------
71-
OS ?= $(shell uname -s)
65+
# Detect the target system
66+
# See https://doc.rust-lang.org/beta/rustc/platform-support.html
67+
# todo: support building wasm
68+
OS := $(or $(CARGO_BUILD_TARGET),$(shell rustc --print host-tuple))
7269

7370
# Windows does not allow symlink by default.
7471
# Allow to override LN for AppArmor.
75-
ifneq (,$(findstring _NT,$(OS)))
72+
ifneq (,$(findstring windows,$(OS)))
7673
LN ?= ln -f
7774
endif
7875
LN ?= ln -sf
@@ -97,7 +94,7 @@ SELINUX_PROGS := \
9794

9895
$(info Detected OS = $(OS))
9996

100-
ifeq (,$(findstring MINGW,$(OS)))
97+
ifeq (,$(findstring windows,$(OS)))
10198
PROGS += $(UNIX_PROGS)
10299
endif
103100
ifeq ($(SELINUX_ENABLED),1)
@@ -288,7 +285,7 @@ install: build install-manpages install-completions install-locales
288285
mkdir -p $(INSTALLDIR_BIN)
289286
ifneq (,$(and $(findstring stdbuf,$(UTILS)),$(findstring feat_external_libstdbuf,$(CARGOFLAGS))))
290287
mkdir -p $(DESTDIR)$(LIBSTDBUF_DIR)
291-
ifneq (,$(findstring CYGWIN,$(OS)))
288+
ifneq (,$(findstring cygwin,$(OS)))
292289
$(INSTALL) -m 755 $(BUILDDIR)/deps/stdbuf.dll $(DESTDIR)$(LIBSTDBUF_DIR)/libstdbuf.dll
293290
else
294291
$(INSTALL) -m 755 $(BUILDDIR)/deps/libstdbuf.* $(DESTDIR)$(LIBSTDBUF_DIR)/
@@ -308,7 +305,7 @@ else
308305
endif
309306

310307
uninstall:
311-
ifeq (,$(findstring MINGW,$(OS)))
308+
ifeq (,$(findstring windows,$(OS)))
312309
rm -f $(DESTDIR)$(LIBSTDBUF_DIR)/libstdbuf.*
313310
-rm -d $(DESTDIR)$(LIBSTDBUF_DIR) 2>/dev/null || true
314311
endif

0 commit comments

Comments
 (0)