From 6ccfd3a141cb8b55a9280981067c33ef16473c01 Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Tue, 10 Mar 2026 03:26:18 +0900 Subject: [PATCH] GNUmakefile: Swap uname -s with rustc --print host-tuple for cross-build and MSYS --- .github/workflows/make.yml | 34 ++++++++++++++++++++++++++++++++++ GNUmakefile | 19 ++++++++----------- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index 7fc964612..fb1ed4bd9 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -266,6 +266,40 @@ jobs: # 2. the makefile doesn't try to install libstdbuf even though stdbuf is skipped DESTDIR=/tmp/ make SKIP_UTILS="stdbuf" install + # keep this job minimal to avoid have many duplicated build with CICD + build_makefile-other: + name: Build/Makefile + runs-on: ${{ matrix.job.os }} + env: + CARGO_INCREMENTAL: 0 + strategy: + fail-fast: false + matrix: + job: + - { os: windows-latest , features: feat_os_windows } + steps: + - uses: actions/checkout@v6 + with: + persist-credentials: false + - uses: Swatinem/rust-cache@v2 + - name: Run sccache-cache + id: sccache-setup + uses: mozilla-actions/sccache-action@v0.0.9 + continue-on-error: true + - name: Export sccache + if: steps.sccache-setup.outcome == 'success' + run: | + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV + - name: "`make build`" + shell: bash + run: | + set -x + # Check that we exclude unix programs to avoid build failure + make PREFIX=/tmp/usr MULTICALL=y COMPLETIONS=n MANPAGES=n LOCALES=n \ + 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" + target/debug/coreutils.exe true + test_busybox: name: Tests/BusyBox test suite runs-on: ${{ matrix.job.os }} diff --git a/GNUmakefile b/GNUmakefile index ae266b6c2..d3cfa2f64 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -62,17 +62,14 @@ TOYBOX_ROOT := $(BASEDIR)/tmp TOYBOX_VER := 0.8.12 TOYBOX_SRC := $(TOYBOX_ROOT)/toybox-$(TOYBOX_VER) -#------------------------------------------------------------------------ -# Detect the host system. -# On Windows uname -s might return MINGW_NT-* or CYGWIN_NT-*. -# Otherwise let it default to the kernel name returned by uname -s -# (Linux, Darwin, FreeBSD, …). -#------------------------------------------------------------------------ -OS ?= $(shell uname -s) +# Detect the target system +# See https://doc.rust-lang.org/beta/rustc/platform-support.html +# todo: support building wasm +OS := $(or $(CARGO_BUILD_TARGET),$(shell rustc --print host-tuple)) # Windows does not allow symlink by default. # Allow to override LN for AppArmor. -ifneq (,$(findstring _NT,$(OS))) +ifneq (,$(findstring windows,$(OS))) LN ?= ln -f endif LN ?= ln -sf @@ -97,7 +94,7 @@ SELINUX_PROGS := \ $(info Detected OS = $(OS)) -ifeq (,$(findstring MINGW,$(OS))) +ifeq (,$(findstring windows,$(OS))) PROGS += $(UNIX_PROGS) endif ifeq ($(SELINUX_ENABLED),1) @@ -288,7 +285,7 @@ install: build install-manpages install-completions install-locales mkdir -p $(INSTALLDIR_BIN) ifneq (,$(and $(findstring stdbuf,$(UTILS)),$(findstring feat_external_libstdbuf,$(CARGOFLAGS)))) mkdir -p $(DESTDIR)$(LIBSTDBUF_DIR) -ifneq (,$(findstring CYGWIN,$(OS))) +ifneq (,$(findstring cygwin,$(OS))) $(INSTALL) -m 755 $(BUILDDIR)/deps/stdbuf.dll $(DESTDIR)$(LIBSTDBUF_DIR)/libstdbuf.dll else $(INSTALL) -m 755 $(BUILDDIR)/deps/libstdbuf.* $(DESTDIR)$(LIBSTDBUF_DIR)/ @@ -308,7 +305,7 @@ else endif uninstall: -ifeq (,$(findstring MINGW,$(OS))) +ifeq (,$(findstring windows,$(OS))) rm -f $(DESTDIR)$(LIBSTDBUF_DIR)/libstdbuf.* -rm -d $(DESTDIR)$(LIBSTDBUF_DIR) 2>/dev/null || true endif