Skip to content

Commit 6ccfd3a

Browse files
oech3sylvestre
authored andcommitted
GNUmakefile: Swap uname -s with rustc --print host-tuple for cross-build and MSYS
1 parent d830e84 commit 6ccfd3a

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
@@ -266,6 +266,40 @@ jobs:
266266
# 2. the makefile doesn't try to install libstdbuf even though stdbuf is skipped
267267
DESTDIR=/tmp/ make SKIP_UTILS="stdbuf" install
268268
269+
# keep this job minimal to avoid have many duplicated build with CICD
270+
build_makefile-other:
271+
name: Build/Makefile
272+
runs-on: ${{ matrix.job.os }}
273+
env:
274+
CARGO_INCREMENTAL: 0
275+
strategy:
276+
fail-fast: false
277+
matrix:
278+
job:
279+
- { os: windows-latest , features: feat_os_windows }
280+
steps:
281+
- uses: actions/checkout@v6
282+
with:
283+
persist-credentials: false
284+
- uses: Swatinem/rust-cache@v2
285+
- name: Run sccache-cache
286+
id: sccache-setup
287+
uses: mozilla-actions/sccache-action@v0.0.9
288+
continue-on-error: true
289+
- name: Export sccache
290+
if: steps.sccache-setup.outcome == 'success'
291+
run: |
292+
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
293+
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
294+
- name: "`make build`"
295+
shell: bash
296+
run: |
297+
set -x
298+
# Check that we exclude unix programs to avoid build failure
299+
make PREFIX=/tmp/usr MULTICALL=y COMPLETIONS=n MANPAGES=n LOCALES=n \
300+
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"
301+
target/debug/coreutils.exe true
302+
269303
test_busybox:
270304
name: Tests/BusyBox test suite
271305
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)