mirror of
https://github.com/uutils/coreutils
synced 2024-11-16 17:58:06 +00:00
Merge pull request #715 from nathanross/cargo-idioms
Use cargo idioms for simple, intuitive builds and flexible tests
This commit is contained in:
commit
072f48f039
343 changed files with 5108 additions and 4181 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,12 +1,7 @@
|
|||
/src/*/gen_table
|
||||
/build/
|
||||
/target/
|
||||
/tmp/
|
||||
/busybox/
|
||||
/deps/regex/
|
||||
/deps/rust-crypto/
|
||||
/deps/target/
|
||||
/deps/time/
|
||||
*~
|
||||
.*.swp
|
||||
.*.swo
|
||||
|
|
22
Cargo.toml
22
Cargo.toml
|
@ -4,6 +4,7 @@ version = "0.0.1"
|
|||
authors = []
|
||||
build = "build.rs"
|
||||
|
||||
|
||||
[features]
|
||||
default = ["all"]
|
||||
all = [
|
||||
|
@ -58,12 +59,13 @@ all = [
|
|||
"sleep",
|
||||
"sort",
|
||||
"split",
|
||||
"stdbuf",
|
||||
"sum",
|
||||
"sync",
|
||||
"tac",
|
||||
"tail",
|
||||
"tee",
|
||||
"test",
|
||||
"test_uu",
|
||||
"timeout",
|
||||
"touch",
|
||||
"tr",
|
||||
|
@ -134,12 +136,13 @@ shuf = { optional=true, path="src/shuf" }
|
|||
sleep = { optional=true, path="src/sleep" }
|
||||
sort = { optional=true, path="src/sort" }
|
||||
split = { optional=true, path="src/split" }
|
||||
stdbuf = { optional=true, path="src/stdbuf" }
|
||||
sum = { optional=true, path="src/sum" }
|
||||
sync = { optional=true, path="src/sync" }
|
||||
tac = { optional=true, path="src/tac" }
|
||||
tail = { optional=true, path="src/tail" }
|
||||
tee = { optional=true, path="src/tee" }
|
||||
test = { optional=true, path="src/test" }
|
||||
test_uu = { optional=true, path="src/test" }
|
||||
timeout = { optional=true, path="src/timeout" }
|
||||
touch = { optional=true, path="src/touch" }
|
||||
tr = { optional=true, path="src/tr" }
|
||||
|
@ -157,8 +160,21 @@ wc = { optional=true, path="src/wc" }
|
|||
whoami = { optional=true, path="src/whoami" }
|
||||
yes = { optional=true, path="src/yes" }
|
||||
|
||||
[dev-dependencies]
|
||||
time = "*"
|
||||
kernel32-sys = "*"
|
||||
winapi = "*"
|
||||
filetime = "*"
|
||||
libc = "*"
|
||||
memchr = "*"
|
||||
primal = "*"
|
||||
aho-corasick= "*"
|
||||
regex-syntax= "*"
|
||||
regex="*"
|
||||
rand="*"
|
||||
tempdir="*"
|
||||
|
||||
[[bin]]
|
||||
name="uutils"
|
||||
path="src/uutils/uutils_cargo.rs"
|
||||
path="src/uutils/uutils.rs"
|
||||
|
||||
|
|
353
Makefile
353
Makefile
|
@ -1,43 +1,30 @@
|
|||
# Config options
|
||||
ENABLE_LTO ?= n
|
||||
ENABLE_STRIP ?= n
|
||||
ENABLE_RELEASE ?= n
|
||||
PROFILE ?= debug
|
||||
MULTICALL ?= n
|
||||
|
||||
PROFILE_CMD :=
|
||||
ifeq (${PROFILE},release)
|
||||
PROFILE_CMD = --release
|
||||
endif
|
||||
|
||||
# Binaries
|
||||
RUSTC ?= rustc
|
||||
CARGO ?= cargo
|
||||
CC ?= gcc
|
||||
RM := rm
|
||||
|
||||
# Install directories
|
||||
PREFIX ?= /usr/local
|
||||
BINDIR ?= /bin
|
||||
LIBDIR ?= /lib
|
||||
|
||||
INSTALLDIR=$(DESTDIR)$(PREFIX)
|
||||
|
||||
# This won't support any directory with spaces in its name, but you can just
|
||||
# make a symlink without spaces that points to the directory.
|
||||
BASEDIR ?= $(shell pwd)
|
||||
SRCDIR := $(BASEDIR)/src
|
||||
BUILDDIR := $(BASEDIR)/build
|
||||
TESTDIR := $(BASEDIR)/test
|
||||
TEMPDIR := $(BASEDIR)/tmp
|
||||
BUILDDIR := $(BASEDIR)/target/${PROFILE}/
|
||||
PKG_BUILDDIR := $(BUILDDIR)/deps/
|
||||
|
||||
# Flags
|
||||
RUSTCFLAGS := -O
|
||||
RMFLAGS :=
|
||||
|
||||
RUSTCLIBFLAGS := $(RUSTCFLAGS) -L $(BUILDDIR)/
|
||||
RUSTCTESTFLAGS := $(RUSTCFLAGS)
|
||||
|
||||
# Handle config setup
|
||||
ifeq ($(ENABLE_LTO),y)
|
||||
RUSTCBINFLAGS := $(RUSTCLIBFLAGS) -C lto
|
||||
else
|
||||
RUSTCBINFLAGS := $(RUSTCLIBFLAGS)
|
||||
endif
|
||||
|
||||
ifneq ($(ENABLE_STRIP),y)
|
||||
ENABLE_STRIP :=
|
||||
endif
|
||||
|
||||
# Possible programs
|
||||
PROGS := \
|
||||
|
@ -83,7 +70,7 @@ PROGS := \
|
|||
sync \
|
||||
tac \
|
||||
tee \
|
||||
test \
|
||||
test_uu \
|
||||
tr \
|
||||
true \
|
||||
truncate \
|
||||
|
@ -132,17 +119,20 @@ ALIASES := \
|
|||
|
||||
BUILD ?= $(PROGS)
|
||||
|
||||
TESTS := \
|
||||
$(filter $(PROGS),$(filter-out $(DONT_TEST),$(filter $(BUILD),$(filter-out $(DONT_BUILD),$(TEST_PROGS)))))
|
||||
|
||||
TEST ?= $(TEST_PROGS)
|
||||
|
||||
# Output names
|
||||
EXES := \
|
||||
$(sort $(filter $(BUILD),$(filter-out $(DONT_BUILD),$(PROGS))))
|
||||
|
||||
CRATE_RLIBS :=
|
||||
|
||||
INSTALL ?= $(EXES)
|
||||
|
||||
INSTALLEES := \
|
||||
$(filter $(INSTALL),$(filter-out $(DONT_INSTALL),$(EXES) uutils))
|
||||
|
||||
INSTALL ?= $(EXES)
|
||||
|
||||
# Shared library extension
|
||||
SYSTEM := $(shell uname)
|
||||
DYLIB_EXT :=
|
||||
|
@ -161,282 +151,57 @@ ifneq (,$(findstring stdbuf, $(INSTALLEES)))
|
|||
LIBS += libstdbuf.$(DYLIB_EXT)
|
||||
endif
|
||||
|
||||
# Programs with usable tests
|
||||
TEST_PROGS := \
|
||||
base64 \
|
||||
basename \
|
||||
cat \
|
||||
cksum \
|
||||
cp \
|
||||
cut \
|
||||
env \
|
||||
dirname \
|
||||
echo \
|
||||
factor \
|
||||
false \
|
||||
fold \
|
||||
hashsum \
|
||||
head \
|
||||
link \
|
||||
ln \
|
||||
mkdir \
|
||||
mv \
|
||||
nl \
|
||||
paste \
|
||||
ptx \
|
||||
pwd \
|
||||
readlink \
|
||||
realpath \
|
||||
rm \
|
||||
rmdir \
|
||||
seq \
|
||||
sort \
|
||||
split \
|
||||
stdbuf \
|
||||
sum \
|
||||
tac \
|
||||
test \
|
||||
touch \
|
||||
tr \
|
||||
true \
|
||||
truncate \
|
||||
tsort \
|
||||
unlink \
|
||||
unexpand \
|
||||
wc
|
||||
|
||||
TEST ?= $(TEST_PROGS)
|
||||
|
||||
TESTS := \
|
||||
$(filter $(TEST),$(filter-out $(DONT_TEST),$(filter $(BUILD),$(filter-out $(DONT_BUILD),$(TEST_PROGS)))))
|
||||
|
||||
# figure out what dependencies we need based on which programs we're building
|
||||
define DEP_INCLUDE
|
||||
-include $(SRCDIR)/$(1)/deps.mk
|
||||
endef
|
||||
# we always depend on libc because common/util does
|
||||
# we also depend on getopts since all utilities support command-line arguments
|
||||
DEPLIBS := libc getopts
|
||||
DEPPLUGS :=
|
||||
# now, add in deps in src/utilname/deps.mk
|
||||
# if we're testing, only consider the TESTS variable,
|
||||
# otherwise consider the EXES variable
|
||||
ifeq ($(MAKECMDGOALS),test)
|
||||
$(foreach build,$(TESTS),$(eval $(call DEP_INCLUDE,$(build))))
|
||||
else
|
||||
$(foreach build,$(sort $(TESTS) $(EXES)),$(eval $(call DEP_INCLUDE,$(build))))
|
||||
endif
|
||||
# uniqify deps
|
||||
DEPLIBS := $(sort $(DEPLIBS))
|
||||
DEPPLUGS := $(sort $(DEPPLUGS))
|
||||
# build --extern commandline for rustc
|
||||
DEP_EXTERN := $(foreach lib,$(subst -,_,$(DEPLIBS)),--extern $(lib)=$(BUILDDIR)/lib$(lib).rlib)
|
||||
DEP_EXTERN += $(foreach plug,$(subst -,_,$(DEPPLUGS)),--extern $(plug)=$(BUILDDIR)/lib$(plug).$(DYLIB_EXT))
|
||||
|
||||
# Setup for building crates
|
||||
define BUILD_SETUP
|
||||
X := $(shell $(RUSTC) --print file-names --crate-type rlib $(SRCDIR)/$(1)/$(1).rs)
|
||||
$(1)_RLIB := $$(X)
|
||||
CRATE_RLIBS += $$(X)
|
||||
endef
|
||||
$(foreach crate,$(EXES),$(eval $(call BUILD_SETUP,$(crate))))
|
||||
|
||||
# Utils stuff
|
||||
EXES_PATHS := $(addprefix $(BUILDDIR)/,$(EXES))
|
||||
RLIB_PATHS := $(addprefix $(BUILDDIR)/,$(CRATE_RLIBS))
|
||||
command = sh -c '$(1)'
|
||||
RESERVED_EXTERNS := --extern uufalse=$(BUILDDIR)/libfalse.rlib --extern uutrue=$(BUILDDIR)/libtrue.rlib --extern uutest=$(BUILDDIR)/libtest.rlib
|
||||
|
||||
# Main exe build rule
|
||||
define EXE_BUILD
|
||||
$(BUILDDIR)/gen/$(1).rs: $(BUILDDIR)/mkmain
|
||||
$(BUILDDIR)/mkmain $(1) $$@
|
||||
|
||||
$(BUILDDIR)/$(1): $(BUILDDIR)/gen/$(1).rs $(BUILDDIR)/$($(1)_RLIB) | $(BUILDDIR) deps
|
||||
$(RUSTC) $(RUSTCBINFLAGS) $(RESERVED_EXTERNS) -o $$@ $$<
|
||||
$(if $(ENABLE_STRIP),strip $$@,)
|
||||
endef
|
||||
|
||||
# GRRR rust-crypto makes a crate called "crypto".
|
||||
# This should NOT be allowed by crates.io. GRRRR.
|
||||
define DEP_BUILD
|
||||
DEP_$(1):
|
||||
ifeq ($(1),crypto)
|
||||
cd $(BASEDIR)/deps && $(CARGO) build --package rust-crypto --release
|
||||
else ifeq ($(1),kernel32)
|
||||
cd $(BASEDIR)/deps && $(CARGO) build --package kernel32-sys --release
|
||||
else ifeq ($(1),advapi32)
|
||||
cd $(BASEDIR)/deps && $(CARGO) build --package advapi32-sys --release
|
||||
else
|
||||
cd $(BASEDIR)/deps && $(CARGO) build --package $(1) --release
|
||||
endif
|
||||
endef
|
||||
|
||||
define CRATE_BUILD
|
||||
-include $(BUILDDIR)/$(1).d
|
||||
|
||||
$(BUILDDIR)/$($(1)_RLIB): $(SRCDIR)/$(1)/$(1).rs | $(BUILDDIR) deps
|
||||
$(RUSTC) $(RUSTCLIBFLAGS) $(DEP_EXTERN) --crate-type rlib --emit link,dep-info $$< --out-dir $(BUILDDIR)
|
||||
endef
|
||||
|
||||
# Aliases build rule
|
||||
ALIAS_SOURCE = $(firstword $(subst :, ,$(1)))
|
||||
ALIAS_TARGET = $(word 2,$(subst :, ,$(1)))
|
||||
define MAKE_ALIAS
|
||||
|
||||
ifneq ($(ALIAS_TARGET,$(1)),)
|
||||
all: $(BUILDDIR)/$(call ALIAS_TARGET,$(1))
|
||||
$(BUILDDIR)/$(call ALIAS_TARGET,$(1)): $(BUILDDIR)/$(call ALIAS_SOURCE,$(1))
|
||||
$(call command,install $$@ $$<)
|
||||
endif
|
||||
|
||||
endef
|
||||
|
||||
# Test exe built rules
|
||||
define TEST_BUILD
|
||||
test_$(1): $(BUILDDIR)/$(1) $(TEMPDIR)/$(1)/$(1)_test
|
||||
$(call command,cp $(BUILDDIR)/$(1) $(TEMPDIR)/$(1) && cd $(TEMPDIR)/$(1) && $(TEMPDIR)/$(1)/$(1)_test)
|
||||
|
||||
$(TEMPDIR)/$(1)/$(1)_test: $(TESTDIR)/$(1).rs | $(TEMPDIR)/$(1)
|
||||
$(call command,$(RUSTC) $(RUSTCTESTFLAGS) $(DEP_EXTERN) --test -o $$@ $$<)
|
||||
|
||||
$(TEMPDIR)/$(1): | $(TEMPDIR)
|
||||
$(call command,cp -r $(TESTDIR)/fixtures/$(1) $$@ || mkdir $$@)
|
||||
endef
|
||||
|
||||
# Main rules
|
||||
all: $(EXES_PATHS) $(BUILDDIR)/uutils
|
||||
|
||||
# Creating necessary rules for each targets
|
||||
$(foreach crate,$(EXES),$(eval $(call CRATE_BUILD,$(crate))))
|
||||
$(foreach exe,$(EXES),$(eval $(call EXE_BUILD,$(exe))))
|
||||
$(foreach alias,$(ALIASES),$(eval $(call MAKE_ALIAS,$(alias))))
|
||||
$(foreach test,$(TESTS),$(eval $(call TEST_BUILD,$(test))))
|
||||
$(foreach dep,$(sort $(DEPLIBS) $(DEPPLUGS)),$(eval $(call DEP_BUILD,$(dep))))
|
||||
|
||||
-include $(BUILDDIR)/uutils.d
|
||||
$(BUILDDIR)/uutils: $(SRCDIR)/uutils/uutils.rs $(BUILDDIR)/mkuutils $(RLIB_PATHS)
|
||||
$(BUILDDIR)/mkuutils $(BUILDDIR)/gen/uutils.rs $(EXES)
|
||||
$(RUSTC) $(RUSTCBINFLAGS) $(RESERVED_EXTERNS) --emit link,dep-info $(BUILDDIR)/gen/uutils.rs --out-dir $(BUILDDIR)
|
||||
$(if $(ENABLE_STRIP),strip $@)
|
||||
|
||||
# Library for stdbuf
|
||||
$(BUILDDIR)/libstdbuf.$(DYLIB_EXT): $(SRCDIR)/stdbuf/libstdbuf.rs $(SRCDIR)/stdbuf/libstdbuf.c $(SRCDIR)/stdbuf/libstdbuf.h | $(BUILDDIR)
|
||||
cd $(SRCDIR)/stdbuf && \
|
||||
$(RUSTC) libstdbuf.rs --extern libc=$(BUILDDIR)/liblibc.rlib && \
|
||||
$(CC) -c -Wall -Werror -fPIC libstdbuf.c && \
|
||||
$(CC) $(DYLIB_FLAGS) -o libstdbuf.$(DYLIB_EXT) liblibstdbuf.a libstdbuf.o && \
|
||||
mv *.$(DYLIB_EXT) $(BUILDDIR) && $(RM) *.o && $(RM) *.a
|
||||
|
||||
$(BUILDDIR)/stdbuf: $(BUILDDIR)/libstdbuf.$(DYLIB_EXT)
|
||||
|
||||
deps: $(BUILDDIR) $(SRCDIR)/cksum/crc_table.rs $(addprefix DEP_,$(DEPLIBS) $(DEPPLUGS))
|
||||
$(foreach lib,$(subst -,_,$(DEPLIBS)),$(shell cp $(BASEDIR)/deps/target/release/deps/lib$(lib)-*.rlib $(BUILDDIR)/lib$(lib).rlib))
|
||||
$(foreach plug,$(subst -,_,$(DEPPLUGS)),$(shell cp $(BASEDIR)/deps/target/release/deps/lib$(plug)-*.$(DYLIB_EXT) $(BUILDDIR)/lib$(plug).$(DYLIB_EXT)))
|
||||
|
||||
$(BUILDDIR)/mkmain: mkmain.rs | $(BUILDDIR)
|
||||
$(RUSTC) $(RUSTCFLAGS) $< -o $@
|
||||
|
||||
$(BUILDDIR)/mkuutils: mkuutils.rs | $(BUILDDIR)
|
||||
$(RUSTC) $(RUSTCFLAGS) $< -o $@
|
||||
|
||||
$(SRCDIR)/cksum/crc_table.rs: $(SRCDIR)/cksum/gen_table.rs
|
||||
cd $(SRCDIR)/cksum && $(RUSTC) $(RUSTCBINFLAGS) gen_table.rs && ./gen_table && $(RM) gen_table
|
||||
|
||||
$(SRCDIR)/factor/prime_table.rs: $(SRCDIR)/factor/gen_table.rs
|
||||
cd $(SRCDIR)/factor && $(RUSTC) $(RUSTCBINFLAGS) gen_table.rs && ./gen_table > $@ && $(RM) gen_table
|
||||
all: build
|
||||
|
||||
crates:
|
||||
echo $(EXES)
|
||||
echo "okay" $(EXES)
|
||||
|
||||
test: $(TEMPDIR) $(addprefix test_,$(TESTS))
|
||||
$(RM) -rf $(TEMPDIR)
|
||||
build_uutils = ${CARGO} build --features "${1}" ${PROFILE_CMD} --no-default-features
|
||||
build_pkg = ${CARGO} build ${PROFILE_CMD} -p "${1}"
|
||||
run_integration_tests = ${CARGO} test --test "${1}"
|
||||
run_unit_tests = ${CARGO} test -p "${l}"
|
||||
do_install = install ${1}
|
||||
use_default := 1
|
||||
|
||||
test:
|
||||
$(call build_uutils, ${TESTS})
|
||||
$(foreach util, ${TESTS}, $(call run_integration_tests, ${util});)
|
||||
$(foreach util, ${TESTS}, $(call run_unit_tests, ${util});)
|
||||
|
||||
build:
|
||||
$(call build_uutils,${EXES})
|
||||
$(foreach util, ${EXES}, $(call build_pkg,${util});)
|
||||
|
||||
clean:
|
||||
$(RM) -rf $(BUILDDIR) $(TEMPDIR)
|
||||
$(RM) -rf $(BUILDDIR)
|
||||
|
||||
distclean: clean
|
||||
cd $(BASEDIR)/deps && $(CARGO) clean && $(CARGO) update
|
||||
$(CARGO) clean && $(CARGO) update
|
||||
|
||||
$(BUILDDIR):
|
||||
mkdir -p $(BUILDDIR)/gen
|
||||
|
||||
$(TEMPDIR):
|
||||
$(RM) -rf $(TEMPDIR)
|
||||
mkdir $(TEMPDIR)
|
||||
|
||||
install: $(addprefix $(BUILDDIR)/,$(INSTALLEES))
|
||||
mkdir -p $(DESTDIR)$(PREFIX)$(BINDIR)
|
||||
for prog in $(INSTALLEES); do \
|
||||
install $(BUILDDIR)/$$prog $(DESTDIR)$(PREFIX)$(BINDIR)/$(PROG_PREFIX)$$prog; \
|
||||
done
|
||||
mkdir -p $(DESTDIR)$(PREFIX)$(LIBDIR)
|
||||
for lib in $(LIBS); do \
|
||||
install $(BUILDDIR)/$$lib $(DESTDIR)$(PREFIX)$(LIBDIR)/$$lib; \
|
||||
done
|
||||
build-check: build clean
|
||||
test-check: test clean
|
||||
|
||||
# TODO: figure out if there is way for prefixes to work with the symlinks
|
||||
install-multicall: $(BUILDDIR)/uutils
|
||||
mkdir -p $(DESTDIR)$(PREFIX)$(BINDIR)
|
||||
install $(BUILDDIR)/uutils $(DESTDIR)$(PREFIX)$(BINDIR)/$(PROG_PREFIX)uutils
|
||||
cd $(DESTDIR)$(PREFIX)$(BINDIR)
|
||||
for prog in $(INSTALLEES); do \
|
||||
ln -s $(PROG_PREFIX)uutils $$prog; \
|
||||
done
|
||||
mkdir -p $(DESTDIR)$(PREFIX)$(LIBDIR)
|
||||
for lib in $(LIBS); do \
|
||||
install $(BUILDDIR)/$$lib $(DESTDIR)$(PREFIX)$(LIBDIR)/$$lib; \
|
||||
done
|
||||
install: build
|
||||
PROFILE_CMD=--release
|
||||
mkdir -p $(INSTALLDIR)$(BINDIR)
|
||||
ifeq (${MULTICALL}, y)
|
||||
install $(BUILDDIR)/uutils $(INSTALLDIR)$(BINDIR)/$(PROG_PREFIX)uutils
|
||||
cd $(INSTALLDIR)$(BINDIR)
|
||||
$(foreach prog, $(INSTALLEES), ln -s $(PROG_PREFIX)uutils $$prog;)
|
||||
else
|
||||
$(foreach prog, $(INSTALLEES); \
|
||||
install $(PKG_BUILDDIR)/$$prog $(INSTALLDIR)$(BINDIR)/$(PROG_PREFIX)$$prog;)
|
||||
endif
|
||||
mkdir -p $(INSTALLDIR)$(LIBDIR)
|
||||
$(foreach lib, $(LIBS), install $(BUILDDIR)/$$lib $(INSTALLDIR)$(LIBDIR)/$$lib;)
|
||||
|
||||
uninstall:
|
||||
rm -f $(addprefix $(DESTDIR)$(PREFIX)$(BINDIR)/$(PROG_PREFIX),$(PROGS))
|
||||
rm -f $(addprefix $(DESTDIR)$(PREFIX)$(LIBDIR)/,$(LIBS))
|
||||
rm -f $(addprefix $(INSTALLDIR)$(BINDIR)/$(PROG_PREFIX),$(PROGS))
|
||||
rm -f $(addprefix $(INSTALLDIR)$(LIBDIR)/,$(LIBS))
|
||||
|
||||
uninstall-multicall:
|
||||
rm -f $(addprefix $(DESTDIR)$(PREFIX)$(BINDIR)/,$(PROGS) $(PROG_PREFIX)uutils)
|
||||
rm -f $(addprefix $(DESTDIR)$(PREFIX)$(LIBDIR)/,$(LIBS))
|
||||
rm -f $(addprefix $(INSTALLDIR)$(BINDIR)/,$(PROGS) $(PROG_PREFIX)uutils)
|
||||
rm -f $(addprefix $(INSTALLDIR)$(LIBDIR)/,$(LIBS))
|
||||
|
||||
# Test under the busybox testsuite
|
||||
$(BUILDDIR)/busybox: $(BUILDDIR)/uutils
|
||||
rm -f $(BUILDDIR)/busybox
|
||||
ln -s $(BUILDDIR)/uutils $(BUILDDIR)/busybox
|
||||
|
||||
# This is a busybox-specific config file their test suite wants to parse.
|
||||
$(BUILDDIR)/.config: $(BASEDIR)/.busybox-config $(BUILDDIR)/uutils
|
||||
cp $< $@
|
||||
|
||||
ifeq ($(BUSYBOX_SRC),)
|
||||
busytest:
|
||||
@echo
|
||||
@echo "To run \`busytest\` set BUSYBOX_SRC to the directory of the compiled busybox source code."
|
||||
@echo "Optionally set RUNTEST_ARGS to arguments to pass to the busybox \`runtest\` program."
|
||||
@echo
|
||||
@false
|
||||
else
|
||||
busytest: $(BUILDDIR)/busybox $(BUILDDIR)/.config
|
||||
(cd $(BUSYBOX_SRC)/testsuite && bindir=$(BUILDDIR) ./runtest $(RUNTEST_ARGS))
|
||||
endif
|
||||
|
||||
# This rule will build each program, ignore all output, and return pass
|
||||
# or fail depending on whether the build has errors.
|
||||
build-check:
|
||||
@for prog in $(sort $(PROGS)); do \
|
||||
make BUILD="$$prog" >/dev/null 2>&1; status=$$?; \
|
||||
if [ $$status -eq 0 ]; \
|
||||
then printf "%-10s\t\033[1;32mpass\033[00;m\n" $$prog; \
|
||||
else printf "%-10s\t\033[1;31mfail\033[00;m\n" $$prog; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
# This rule will test each program, ignore all output, and return pass
|
||||
# or fail depending on whether the test has errors.
|
||||
test-check:
|
||||
@for prog in $(sort $(TEST_PROGS)); do \
|
||||
make TEST="$$prog" test >/dev/null 2>&1; status=$$?; \
|
||||
if [ $$status -eq 0 ]; \
|
||||
then printf "%-10s\t\033[1;32mpass\033[00;m\n" $$prog; \
|
||||
else printf "%-10s\t\033[1;31mfail\033[00;m\n" $$prog; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
.PHONY: $(TEMPDIR) all deps test distclean clean busytest install uninstall
|
||||
.PHONY: $(TEMPDIR) all build test distclean clean busytest install uninstall
|
||||
|
|
33
appveyor.yml
33
appveyor.yml
|
@ -1,33 +0,0 @@
|
|||
platform:
|
||||
- x64
|
||||
|
||||
environment:
|
||||
global:
|
||||
MSYS2_BASEVER: 20150512
|
||||
MSYS2_ARCH: x86_64
|
||||
MBASH: msys64\usr\bin\sh --login -c
|
||||
|
||||
matrix:
|
||||
- TARGET: i686-pc-windows-gnu
|
||||
|
||||
install:
|
||||
- appveyor DownloadFile "http://kent.dl.sourceforge.net/project/msys2/Base/%MSYS2_ARCH%/msys2-base-%MSYS2_ARCH%-%MSYS2_BASEVER%.tar.xz" -FileName "msys2.tar.xz"
|
||||
- 7z x msys2.tar.xz
|
||||
- 7z x msys2.tar > NUL
|
||||
- call %MBASH% ""
|
||||
- call %MBASH% "for i in {1..3}; do pacman --noconfirm -Suy mingw-w64-%MSYS2_ARCH%-{ragel,freetype,icu,gettext} libtool pkg-config gcc make autoconf automake perl && break || sleep 15; done"
|
||||
- ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe"
|
||||
- rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust"
|
||||
- call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64
|
||||
- SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin
|
||||
- SET PATH=%PATH%;C:\MinGW\bin
|
||||
- rustc -V
|
||||
- cargo -V
|
||||
|
||||
build_script:
|
||||
- call %MBASH% "cd $APPVEYOR_BUILD_FOLDER; PATH=$PATH:/mingw64/bin:/mingw32/bin; exec 0</dev/null; make"
|
||||
- call %MBASH% "cd $APPVEYOR_BUILD_FOLDER; PATH=$PATH:/mingw64/bin:/mingw32/bin; exec 0</dev/null; make build-check"
|
||||
|
||||
test_script:
|
||||
- call %MBASH% "cd $APPVEYOR_BUILD_FOLDER; PATH=$PATH:/mingw64/bin:/mingw32/bin; exec 0</dev/null; make test"
|
||||
- call %MBASH% "cd $APPVEYOR_BUILD_FOLDER; PATH=$PATH:/mingw64/bin:/mingw32/bin; exec 0</dev/null; make test-check"
|
25
deps/Cargo.toml
vendored
25
deps/Cargo.toml
vendored
|
@ -1,25 +0,0 @@
|
|||
[project]
|
||||
name = "deps"
|
||||
version = "0.0.0"
|
||||
|
||||
[lib]
|
||||
name = "null"
|
||||
|
||||
[dependencies]
|
||||
libc = "0.1"
|
||||
getopts = "0.2"
|
||||
bit-vec = "0.4"
|
||||
bit-set = "0.2"
|
||||
vec_map = "0.3"
|
||||
num_cpus = "0.2"
|
||||
rand = "0.3"
|
||||
regex = "0.1"
|
||||
rust-crypto = "0.2"
|
||||
rustc-serialize = "0.3"
|
||||
time = "0.1"
|
||||
unicode-width = "0.1"
|
||||
winapi = "0.2"
|
||||
advapi32-sys = "0.1"
|
||||
kernel32-sys = "0.1"
|
||||
walker = "^1.0"
|
||||
filetime = "0.1"
|
49
mkmain.rs
49
mkmain.rs
|
@ -1,49 +0,0 @@
|
|||
use std::env;
|
||||
use std::io::Write;
|
||||
use std::fs::File;
|
||||
|
||||
static TEMPLATE: &'static str = "\
|
||||
extern crate @UTIL_CRATE@ as uu@UTIL_CRATE@;
|
||||
|
||||
use std::io::Write;
|
||||
use uu@UTIL_CRATE@::uumain;
|
||||
|
||||
fn main() {
|
||||
let code = uumain(std::env::args().collect());
|
||||
|
||||
// Since stdout is line-buffered by default, we need to ensure any pending
|
||||
// writes are flushed before exiting. Ideally, this should be enforced by
|
||||
// each utility.
|
||||
//
|
||||
// See: https://github.com/rust-lang/rust/issues/23818
|
||||
//
|
||||
std::io::stdout().flush().unwrap();
|
||||
|
||||
std::process::exit(code);
|
||||
}
|
||||
";
|
||||
|
||||
fn main() {
|
||||
let args : Vec<String> = env::args().collect();
|
||||
if args.len() != 3 {
|
||||
println!("usage: mkbuild <crate> <outfile>");
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
let crat = match &args[1][..] {
|
||||
"false" => "uufalse",
|
||||
"test" => "uutest",
|
||||
"true" => "uutrue",
|
||||
_ => &args[1][..],
|
||||
};
|
||||
let outfile = &args[2][..];
|
||||
|
||||
let main = TEMPLATE.replace("@UTIL_CRATE@", crat);
|
||||
match File::create(outfile) {
|
||||
Ok(mut out) => match out.write_all(main.as_bytes()) {
|
||||
Err(e) => panic!("{}", e),
|
||||
_ => (),
|
||||
},
|
||||
Err(e) => panic!("{}", e),
|
||||
}
|
||||
}
|
63
mkuutils.rs
63
mkuutils.rs
|
@ -1,63 +0,0 @@
|
|||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
|
||||
fn main() {
|
||||
let args : Vec<String> = env::args().collect();
|
||||
if args.len() < 3 {
|
||||
println!("usage: mkuutils <outfile> <crates>");
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
let mut crates = String::new();
|
||||
let mut util_map = String::new();
|
||||
let mut hashsum = false;
|
||||
for prog in args[2..].iter() {
|
||||
match &prog[..] {
|
||||
"hashsum" | "md5sum" | "sha1sum" | "sha224sum" | "sha256sum" | "sha384sum" | "sha512sum" => {
|
||||
if !hashsum {
|
||||
crates.push_str("extern crate hashsum;\n");
|
||||
util_map.push_str("map.insert(\"hashsum\", hashsum::uumain);\n");
|
||||
util_map.push_str("map.insert(\"md5sum\", hashsum::uumain);\n");
|
||||
util_map.push_str("map.insert(\"sha1sum\", hashsum::uumain);\n");
|
||||
util_map.push_str("map.insert(\"sha224sum\", hashsum::uumain);\n");
|
||||
util_map.push_str("map.insert(\"sha256sum\", hashsum::uumain);\n");
|
||||
util_map.push_str("map.insert(\"sha384sum\", hashsum::uumain);\n");
|
||||
util_map.push_str("map.insert(\"sha512sum\", hashsum::uumain);\n");
|
||||
hashsum = true;
|
||||
}
|
||||
},
|
||||
"true" => {
|
||||
util_map.push_str("fn uutrue(_: Vec<String>) -> i32 { 0 }\n");
|
||||
util_map.push_str("map.insert(\"true\", uutrue as fn(Vec<String>) -> i32);\n");
|
||||
},
|
||||
"false" => {
|
||||
util_map.push_str("fn uufalse(_: Vec<String>) -> i32 { 1 }\n");
|
||||
util_map.push_str("map.insert(\"false\", uufalse as fn(Vec<String>) -> i32);\n");
|
||||
},
|
||||
_ => {
|
||||
if prog == "test" {
|
||||
crates.push_str(&(format!("extern crate uu{0} as uu{0};\n", prog))[..]);
|
||||
} else {
|
||||
crates.push_str(&(format!("extern crate {0} as uu{0};\n", prog))[..]);
|
||||
}
|
||||
util_map.push_str(&(format!("map.insert(\"{prog}\", uu{prog}::uumain as fn(Vec<String>) -> i32);\n", prog = prog))[..]);
|
||||
}
|
||||
}
|
||||
}
|
||||
let outfile = &(args[1])[..];
|
||||
|
||||
// XXX: this all just assumes that the IO works correctly
|
||||
let mut out = File::create(outfile).unwrap();
|
||||
let mut input = File::open("src/uutils/uutils.rs").unwrap();
|
||||
|
||||
let mut template = String::new();
|
||||
input.read_to_string(&mut template).unwrap();
|
||||
let template = template;
|
||||
|
||||
let main = template.replace("@CRATES@", &crates[..]).replace("@UTIL_MAP@", &util_map[..]);
|
||||
match out.write_all(main.as_bytes()) {
|
||||
Err(e) => panic!("{}", e),
|
||||
_ => (),
|
||||
}
|
||||
}
|
|
@ -11,3 +11,7 @@ path = "base64.rs"
|
|||
getopts = "*"
|
||||
libc = "*"
|
||||
rustc-serialize = "*"
|
||||
|
||||
[[bin]]
|
||||
name="base64"
|
||||
path="base64.rs"
|
||||
|
|
|
@ -160,3 +160,8 @@ fn help(opts: Options) {
|
|||
fn version() {
|
||||
println!("{} {}", NAME, VERSION);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
DEPLIBS += rustc-serialize
|
|
@ -10,3 +10,7 @@ path = "basename.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="basename"
|
||||
path="basename.rs"
|
||||
|
|
|
@ -106,3 +106,8 @@ fn strip_suffix(name: &str, suffix: &str) -> String {
|
|||
|
||||
name.to_string()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "cat.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="cat"
|
||||
path="cat.rs"
|
||||
|
|
|
@ -18,9 +18,8 @@ use getopts::Options;
|
|||
use std::fs::File;
|
||||
use std::intrinsics::{copy_nonoverlapping};
|
||||
use std::io::{stdout, stdin, stderr, Write, Read, Result};
|
||||
use libc::consts::os::posix88::STDIN_FILENO;
|
||||
use libc::funcs::posix88::unistd::isatty;
|
||||
use libc::types::os::arch::c95::c_int;
|
||||
use libc::STDIN_FILENO;
|
||||
use libc::{c_int, isatty};
|
||||
|
||||
#[path = "../common/util.rs"]
|
||||
#[macro_use]
|
||||
|
@ -345,3 +344,8 @@ impl<'a, W: Write> Drop for UnsafeWriter<'a, W> {
|
|||
}
|
||||
|
||||
/* vim: set ai ts=4 sw=4 sts=4 et : */
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -15,3 +15,7 @@ memchr = "*"
|
|||
regex = "*"
|
||||
regex-syntax = "*"
|
||||
walker = "*"
|
||||
|
||||
[[bin]]
|
||||
name="chmod"
|
||||
path="chmod.rs"
|
||||
|
|
|
@ -324,3 +324,8 @@ fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
DEPLIBS += aho-corasick memchr regex regex-syntax walker
|
|
@ -10,3 +10,7 @@ path = "chroot.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="chroot"
|
||||
path="chroot.rs"
|
||||
|
|
|
@ -14,7 +14,7 @@ extern crate libc;
|
|||
|
||||
use c_types::{get_pw_from_args, get_group};
|
||||
use getopts::Options;
|
||||
use libc::funcs::posix88::unistd::{setgid, setuid};
|
||||
use libc::{setgid, setuid};
|
||||
use std::ffi::CString;
|
||||
use std::io::{Error, Write};
|
||||
use std::iter::FromIterator;
|
||||
|
@ -218,3 +218,8 @@ If $(SHELL) is not set, /bin/sh is used.", NAME, VERSION);
|
|||
|
||||
print!("{}", options.usage(&msg));
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "cksum.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="cksum"
|
||||
path="cksum.rs"
|
||||
|
|
|
@ -129,3 +129,8 @@ Print CRC and size for each file.", NAME, VERSION);
|
|||
|
||||
exit_code
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "comm.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="comm"
|
||||
path="comm.rs"
|
||||
|
|
|
@ -158,3 +158,8 @@ Compare sorted files line by line.", NAME, VERSION);
|
|||
|
||||
0
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ use self::libc::time_t;
|
|||
#[cfg(target_os = "macos")]
|
||||
use self::libc::int32_t;
|
||||
|
||||
use self::libc::funcs::posix88::unistd::getgroups;
|
||||
use self::libc::getgroups;
|
||||
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::io::{Error, Write};
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
*/
|
||||
|
||||
extern crate libc;
|
||||
extern crate time;
|
||||
|
||||
use libc::{c_int, pid_t};
|
||||
use std::fmt;
|
||||
|
@ -17,6 +16,7 @@ use std::process::Child;
|
|||
use std::sync::{Arc, Condvar, Mutex};
|
||||
use std::thread;
|
||||
use time::{Duration, get_time};
|
||||
use std::time::Duration as StdDuration;
|
||||
|
||||
// This is basically sys::unix::process::ExitStatus
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
||||
|
@ -76,7 +76,7 @@ pub trait ChildExt {
|
|||
|
||||
impl ChildExt for Child {
|
||||
fn send_signal(&mut self, signal: usize) -> io::Result<()> {
|
||||
if unsafe { libc::funcs::posix88::signal::kill(self.id() as pid_t,
|
||||
if unsafe { libc::kill(self.id() as pid_t,
|
||||
signal as i32) } != 0 {
|
||||
Err(io::Error::last_os_error())
|
||||
} else {
|
||||
|
@ -125,7 +125,7 @@ impl ChildExt for Child {
|
|||
return Ok(None)
|
||||
}
|
||||
let ms = (target - get_time()).num_milliseconds() as u32;
|
||||
exitstatus = cvar.wait_timeout_ms(exitstatus, ms).unwrap().0;
|
||||
exitstatus = cvar.wait_timeout(exitstatus, StdDuration::new(0, ms*1000)).unwrap().0;
|
||||
}
|
||||
|
||||
// Turn Option<Result<ExitStatus>> into Result<Option<ExitStatus>>
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "cp.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="cp"
|
||||
path="cp.rs"
|
||||
|
|
|
@ -159,3 +159,8 @@ pub fn paths_refer_to_same_file(p1: &Path, p2: &Path) -> Result<bool> {
|
|||
|
||||
Ok(pathbuf1 == pathbuf2)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
1
src/cut/.gitignore
vendored
Normal file
1
src/cut/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
target
|
|
@ -10,3 +10,7 @@ path = "cut.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="cut"
|
||||
path="cut.rs"
|
||||
|
|
|
@ -544,3 +544,8 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "dirname.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="dirname"
|
||||
path="dirname.rs"
|
||||
|
|
|
@ -68,3 +68,8 @@ directory).", NAME, VERSION);
|
|||
|
||||
0
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -11,3 +11,7 @@ path = "du.rs"
|
|||
getopts = "*"
|
||||
libc = "*"
|
||||
time = "*"
|
||||
|
||||
[[bin]]
|
||||
name="du"
|
||||
path="du.rs"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
DEPLIBS += time kernel32 winapi
|
|
@ -396,3 +396,8 @@ Try '{} --help' for more information.", s, NAME);
|
|||
|
||||
0
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "echo.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="echo"
|
||||
path="echo.rs"
|
||||
|
|
|
@ -252,3 +252,8 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
|
||||
0
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
4
src/env/Cargo.toml
vendored
4
src/env/Cargo.toml
vendored
|
@ -10,3 +10,7 @@ path = "env.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="env"
|
||||
path="env.rs"
|
||||
|
|
5
src/env/env.rs
vendored
5
src/env/env.rs
vendored
|
@ -205,3 +205,8 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
|
||||
0
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -11,3 +11,7 @@ path = "expand.rs"
|
|||
getopts = "*"
|
||||
libc = "*"
|
||||
unicode-width = "*"
|
||||
|
||||
[[bin]]
|
||||
name="expand"
|
||||
path="expand.rs"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
DEPLIBS += unicode-width
|
|
@ -242,3 +242,8 @@ fn expand(options: Options) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -11,3 +11,7 @@ path = "expr.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="expr"
|
||||
path="expr.rs"
|
||||
|
|
|
@ -133,3 +133,8 @@ Environment variables:
|
|||
fn print_version() {
|
||||
println!("{} {}", NAME, VERSION);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -11,3 +11,7 @@ path = "factor.rs"
|
|||
getopts = "*"
|
||||
libc = "*"
|
||||
rand = "*"
|
||||
|
||||
[[bin]]
|
||||
name="factor"
|
||||
path="factor.rs"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
DEPLIBS += rand
|
|
@ -200,3 +200,8 @@ read from standard input.", NAME, VERSION);
|
|||
}
|
||||
0
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "false.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="false"
|
||||
path="false.rs"
|
||||
|
|
|
@ -12,3 +12,8 @@
|
|||
pub fn uumain(_: Vec<String>) -> i32 {
|
||||
1
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -11,3 +11,7 @@ path = "fmt.rs"
|
|||
getopts = "*"
|
||||
libc = "*"
|
||||
unicode-width = "*"
|
||||
|
||||
[[bin]]
|
||||
name="fmt"
|
||||
path="fmt.rs"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
DEPLIBS += unicode-width
|
|
@ -219,3 +219,8 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
|
||||
0
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "fold.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="fold"
|
||||
path="fold.rs"
|
||||
|
|
|
@ -220,3 +220,8 @@ fn rfind_whitespace(slice: &str) -> Option<usize> {
|
|||
}
|
||||
None
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "groups.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="groups"
|
||||
path="groups.rs"
|
||||
|
|
|
@ -50,3 +50,8 @@ Prints the groups a user is in to standard output.", NAME, VERSION);
|
|||
|
||||
0
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -13,3 +13,7 @@ libc = "*"
|
|||
regex = "*"
|
||||
regex-syntax = "*"
|
||||
rust-crypto = "*"
|
||||
|
||||
[[bin]]
|
||||
name="hashsum"
|
||||
path="hashsum.rs"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
DEPLIBS += regex regex-syntax crypto rand rustc-serialize time winapi kernel32
|
|
@ -307,3 +307,8 @@ fn digest_reader<'a, T: Read>(digest: &mut Box<Digest+'a>, reader: &mut BufReade
|
|||
|
||||
Ok(digest.result_str())
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "head.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="head"
|
||||
path="head.rs"
|
||||
|
|
|
@ -208,3 +208,8 @@ fn head<T: Read>(reader: &mut BufReader<T>, settings: &Settings) -> bool {
|
|||
fn version() {
|
||||
println!("{} {}", NAME, VERSION);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "hostid.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="hostid"
|
||||
path="hostid.rs"
|
||||
|
|
|
@ -88,3 +88,8 @@ fn hostid() {
|
|||
result &= 0xffffffff;
|
||||
println!("{:0>8x}", result);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "hostname.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="hostname"
|
||||
path="hostname.rs"
|
||||
|
|
|
@ -174,3 +174,8 @@ fn xsethostname(name: &str) {
|
|||
println!("Cannot set hostname to {}", name);
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "id.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="id"
|
||||
path="id.rs"
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
extern crate getopts;
|
||||
extern crate libc;
|
||||
|
||||
use libc::{getgid, getuid, uid_t};
|
||||
use libc::funcs::posix88::unistd::{getegid, geteuid, getlogin};
|
||||
use libc::{getgid, getuid, uid_t, getegid, geteuid, getlogin};
|
||||
use std::ffi::CStr;
|
||||
use std::io::Write;
|
||||
use std::ptr::read;
|
||||
|
@ -395,3 +394,8 @@ fn id_print(possible_pw: Option<c_passwd>, p_euid: bool, p_egid: bool) {
|
|||
|
||||
println!("");
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "kill.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="kill"
|
||||
path="kill.rs"
|
||||
|
|
|
@ -182,7 +182,7 @@ fn kill(signalname: &str, pids: std::vec::Vec<String>) -> i32 {
|
|||
for pid in pids.iter() {
|
||||
match pid.parse::<usize>() {
|
||||
Ok(x) => {
|
||||
if unsafe { libc::funcs::posix88::signal::kill(x as pid_t, signal_value as c_int) } != 0 {
|
||||
if unsafe { libc::kill(x as pid_t, signal_value as c_int) } != 0 {
|
||||
show_error!("{}", Error::last_os_error());
|
||||
status = 1;
|
||||
}
|
||||
|
@ -192,3 +192,8 @@ fn kill(signalname: &str, pids: std::vec::Vec<String>) -> i32 {
|
|||
}
|
||||
status
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "link.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="link"
|
||||
path="link.rs"
|
||||
|
|
|
@ -64,3 +64,8 @@ Create a link named FILE2 to FILE1.", NAME, VERSION);
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "ln.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="ln"
|
||||
path="ln.rs"
|
||||
|
|
|
@ -331,3 +331,8 @@ pub fn is_symlink<P: AsRef<Path>>(path: P) -> bool {
|
|||
Err(_) => false
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "logname.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="logname"
|
||||
path="logname.rs"
|
||||
|
|
|
@ -79,3 +79,8 @@ fn exec() {
|
|||
None => println!("{}: no login name", NAME)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "mkdir.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="mkdir"
|
||||
path="mkdir.rs"
|
||||
|
|
|
@ -158,3 +158,8 @@ fn mkdir(path: &Path, mode: u16, verbose: bool) -> i32 {
|
|||
}
|
||||
chmod(path, mode)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "mkfifo.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="mkfifo"
|
||||
path="mkfifo.rs"
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
extern crate getopts;
|
||||
extern crate libc;
|
||||
|
||||
use libc::funcs::posix88::stat_::mkfifo;
|
||||
use libc::mkfifo;
|
||||
use std::ffi::CString;
|
||||
use std::io::{Error, Write};
|
||||
|
||||
|
@ -77,3 +77,8 @@ Create a FIFO with the given name.", NAME, VERSION);
|
|||
|
||||
exit_status
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,9 @@ path = "mv.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[dev-dependencies]
|
||||
time = "*"
|
||||
[[bin]]
|
||||
name="mv"
|
||||
path="mv.rs"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
DEPLIBS += kernel32 winapi filetime time
|
|
@ -356,3 +356,8 @@ fn existing_backup_path(path: &PathBuf, suffix: &String) -> PathBuf {
|
|||
}
|
||||
simple_backup_path(path, suffix)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "nice.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="nice"
|
||||
path="nice.rs"
|
||||
|
|
|
@ -110,3 +110,8 @@ process).", NAME, VERSION);
|
|||
show_error!("{}", Error::last_os_error());
|
||||
if Error::last_os_error().raw_os_error().unwrap() as c_int == libc::ENOENT { 127 } else { 126 }
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -14,3 +14,7 @@ aho-corasick = "*"
|
|||
memchr = "*"
|
||||
regex = "*"
|
||||
regex-syntax = "*"
|
||||
|
||||
[[bin]]
|
||||
name="nl"
|
||||
path="nl.rs"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
DEPLIBS += aho-corasick memchr regex regex-syntax
|
|
@ -328,3 +328,8 @@ fn print_usage(opts: &getopts::Options) {
|
|||
fn version() {
|
||||
println!("{} {}", NAME, VERSION);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "nohup.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="nohup"
|
||||
path="nohup.rs"
|
||||
|
|
|
@ -12,17 +12,14 @@
|
|||
extern crate getopts;
|
||||
extern crate libc;
|
||||
|
||||
use libc::c_char;
|
||||
use libc::funcs::posix01::signal::signal;
|
||||
use libc::funcs::posix88::unistd::{dup2, execvp, isatty};
|
||||
use libc::consts::os::posix01::SIG_IGN;
|
||||
use libc::consts::os::posix88::SIGHUP;
|
||||
use std::env;
|
||||
use libc::{c_char, signal, dup2, execvp, isatty};
|
||||
use libc::{SIG_IGN, SIGHUP};
|
||||
use std::ffi::CString;
|
||||
use std::fs::{File, OpenOptions};
|
||||
use std::io::{Error, Write};
|
||||
use std::os::unix::prelude::*;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::env;
|
||||
|
||||
#[path = "../common/util.rs"] #[macro_use] mod util;
|
||||
#[path = "../common/c_types.rs"] mod c_types;
|
||||
|
@ -147,3 +144,8 @@ If standard error is terminal, it'll be redirected to stdout.", NAME, VERSION);
|
|||
|
||||
print!("{}", opts.usage(&msg));
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -11,3 +11,7 @@ path = "nproc.rs"
|
|||
getopts = "*"
|
||||
libc = "*"
|
||||
num_cpus = "*"
|
||||
|
||||
[[bin]]
|
||||
name="nproc"
|
||||
path="nproc.rs"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
DEPLIBS += num_cpus
|
|
@ -12,8 +12,8 @@
|
|||
extern crate getopts;
|
||||
extern crate num_cpus;
|
||||
|
||||
use std::env;
|
||||
use std::io::Write;
|
||||
use std::env;
|
||||
|
||||
static NAME : &'static str = "nproc";
|
||||
static VERSION : &'static str = "0.0.0";
|
||||
|
@ -85,3 +85,8 @@ Print the number of cores available to the current process.", NAME, VERSION);
|
|||
println!("{}", cores);
|
||||
0
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "od.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="od"
|
||||
path="od.rs"
|
||||
|
|
|
@ -56,12 +56,12 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
None => { panic!("Need fname for now") ; }
|
||||
};
|
||||
|
||||
main(&input_offset_base, &fname);
|
||||
odfunc(&input_offset_base, &fname);
|
||||
|
||||
0
|
||||
}
|
||||
|
||||
fn main(input_offset_base: &Radix, fname: &str) {
|
||||
fn odfunc(input_offset_base: &Radix, fname: &str) {
|
||||
let mut f = match File::open(Path::new(fname)) {
|
||||
Ok(f) => f,
|
||||
Err(e) => panic!("file error: {}", e)
|
||||
|
@ -124,3 +124,8 @@ fn print_with_radix(r: &Radix, x: usize) {
|
|||
Radix::Binary => print!("{:07b}", x)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "paste.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="paste"
|
||||
path="paste.rs"
|
||||
|
|
|
@ -128,3 +128,8 @@ fn unescape(s: String) -> String {
|
|||
.replace("\\\\", "\\")
|
||||
.replace("\\", "")
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -10,3 +10,7 @@ path = "printenv.rs"
|
|||
[dependencies]
|
||||
getopts = "*"
|
||||
libc = "*"
|
||||
|
||||
[[bin]]
|
||||
name="printenv"
|
||||
path="printenv.rs"
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
extern crate getopts;
|
||||
extern crate libc;
|
||||
|
||||
use std::env;
|
||||
use std::io::Write;
|
||||
use std::env;
|
||||
|
||||
#[path = "../common/util.rs"]
|
||||
#[macro_use]
|
||||
|
@ -76,3 +76,8 @@ pub fn exec(args: Vec<String>, separator: &str) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn main() {
|
||||
std::process::exit(uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
|
@ -14,3 +14,7 @@ aho-corasick = "*"
|
|||
memchr = "*"
|
||||
regex-syntax = "*"
|
||||
regex = "*"
|
||||
|
||||
[[bin]]
|
||||
name="ptx"
|
||||
path="ptx.rs"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
DEPLIBS += aho-corasick memchr regex regex-syntax
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue