From 30bba07f9cf96ff597b419604fafaefdbdc330ce Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Wed, 25 Jun 2014 18:47:34 +0200 Subject: [PATCH] always build multicall binary squashed: a2c6b27 - build: automatically generate main() files c942f0f - remove MULTICALL=1 build from travis cb7b35b - make: remove unnecessary shell command 69bbb31 - update README 03a3168 - all: move main() into separate file that links against util crate 8276384 - make: always build multicall binary aa4edeb - make: avoid 'rustc --crate-file-name' --- .travis.yml | 1 - Makefile | 50 +++++++++++++++++--------------------------- README.md | 19 ++--------------- base64/base64.rs | 4 ---- basename/basename.rs | 4 ---- cat/cat.rs | 4 ---- chroot/chroot.rs | 3 --- cksum/cksum.rs | 4 ---- comm/comm.rs | 4 ---- cp/cp.rs | 3 --- dirname/dirname.rs | 4 ---- du/du.rs | 4 ---- echo/echo.rs | 4 ---- env/env.rs | 5 ----- factor/factor.rs | 4 ---- false/false.rs | 6 +++--- fmt/fmt.rs | 4 ---- fold/fold.rs | 4 ---- groups/groups.rs | 4 ---- hashsum/hashsum.rs | 4 ---- head/head.rs | 4 ---- hostid/hostid.rs | 5 ----- hostname/hostname.rs | 5 +---- id/id.rs | 4 ---- kill/kill.rs | 4 ---- link/link.rs | 4 ---- logname/logname.rs | 4 ---- mkdir/mkdir.rs | 4 ---- mkfifo/mkfifo.rs | 3 --- mkmain.rs | 40 +++++++++++++++++++++++++++++++++++ nl/nl.rs | 6 ------ paste/paste.rs | 4 ---- printenv/printenv.rs | 3 --- pwd/pwd.rs | 4 ---- rm/rm.rs | 4 ---- rmdir/rmdir.rs | 4 ---- seq/seq.rs | 4 ---- sleep/sleep.rs | 4 ---- sum/sum.rs | 4 ---- sync/sync.rs | 6 ------ tac/tac.rs | 4 ---- tail/tail.rs | 4 ---- tee/tee.rs | 3 --- touch/touch.rs | 4 ---- tr/tr.rs | 4 ---- true/true.rs | 5 +++-- truncate/truncate.rs | 4 ---- tty/tty.rs | 5 +---- uname/uname.rs | 4 ---- unlink/unlink.rs | 4 ---- uptime/uptime.rs | 4 ---- users/users.rs | 4 ---- wc/wc.rs | 4 ---- whoami/whoami.rs | 4 ---- yes/yes.rs | 4 ---- 55 files changed, 69 insertions(+), 251 deletions(-) create mode 100644 mkmain.rs diff --git a/.travis.yml b/.travis.yml index 8ccb026aa..df04b20f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,4 +5,3 @@ install: script: - make - make test - - make MULTICALL=1 diff --git a/Makefile b/Makefile index c2c4a8b1d..898251825 100644 --- a/Makefile +++ b/Makefile @@ -81,12 +81,12 @@ EXES := \ $(sort $(filter $(BUILD),$(filter-out $(DONT_BUILD),$(PROGS)))) CRATES := \ - $(sort $(filter $(EXES), $(filter-out true false, $(EXES)))) + $(sort $(EXES)) INSTALL ?= $(EXES) INSTALLEES := \ - $(filter $(INSTALL),$(filter-out $(DONT_INSTALL),$(EXES))) + $(filter $(INSTALL),$(filter-out $(DONT_INSTALL),$(EXES) uutils)) # Programs with usable tests TEST_PROGS := \ @@ -109,17 +109,18 @@ command = sh -c '$(1)' # Main exe build rule define EXE_BUILD --include build/$(1).d +build/gen/$(1).rs: build/mkmain + build/mkmain $(1) build/gen/$(1).rs -build/$(1): $(1)/$(1).rs | build deps - $(call command,$(RUSTC) $(RUSTCFLAGS) -L build/ --dep-info build/$(1).d -o build/$(1) $(1)/$(1).rs) +build/$(1): build/gen/$(1).rs build/$(1).timestamp | build deps + $(RUSTC) $(RUSTCFLAGS) -L build/ -o build/$(1) build/gen/$(1).rs endef define CRATE_BUILD -include build/$(1).d - -build/$(2): $(1)/$(1).rs | build deps - $(call command,$(RUSTC) $(RUSTCFLAGS) -L build/ --crate-type rlib --dep-info build/$(1).d $(1)/$(1).rs --out-dir build) +build/$(1).timestamp: $(1)/$(1).rs | build deps + $(RUSTC) $(RUSTCFLAGS) -L build/ --crate-type rlib --dep-info build/$(1).d $(1)/$(1).rs --out-dir build + @touch build/$(1).timestamp endef # Aliases build rule @@ -141,16 +142,11 @@ tmp/$(1)_test: $(1)/test.rs endef # Main rules -ifneq ($(MULTICALL), 1) -all: $(EXES_PATHS) -else -all: build/uutils +all: $(EXES_PATHS) build/uutils -include build/uutils.d - -build/uutils: uutils/uutils.rs $(addprefix build/, $(foreach crate,$(CRATES),$(shell $(RUSTC) --crate-type rlib --crate-file-name $(crate)/$(crate).rs))) +build/uutils: uutils/uutils.rs $(addprefix build/, $(addsuffix .timestamp, $(CRATES))) $(RUSTC) $(RUSTCFLAGS) -L build/ --dep-info $@.d uutils/uutils.rs -o $@ -endif # Dependencies LIBCRYPTO = $(shell $(RUSTC) --crate-file-name --crate-type rlib deps/rust-crypto/src/rust-crypto/lib.rs) @@ -158,8 +154,14 @@ LIBCRYPTO = $(shell $(RUSTC) --crate-file-name --crate-type rlib deps/rust-crypt build/$(LIBCRYPTO): | build $(RUSTC) $(RUSTCFLAGS) --crate-type rlib --dep-info build/rust-crypto.d deps/rust-crypto/src/rust-crypto/lib.rs --out-dir build/ +build/mkmain: mkmain.rs | build + $(RUSTC) $(RUSTCFLAGS) -L build mkmain.rs -o $@ + deps: build/$(LIBCRYPTO) +crates: + echo $(EXES) + test: tmp $(addprefix test_,$(TESTS)) $(RM) -rf tmp @@ -168,28 +170,17 @@ clean: build: git submodule update --init - mkdir build + mkdir -p build/gen tmp: mkdir tmp # Creating necessary rules for each targets -ifeq ($(MULTICALL), 1) -$(foreach crate,$(CRATES),$(eval $(call CRATE_BUILD,$(crate),$(shell $(RUSTC) --crate-type rlib --crate-file-name --out-dir build $(crate)/$(crate).rs)))) -else +$(foreach crate,$(CRATES),$(eval $(call CRATE_BUILD,$(crate)))) $(foreach exe,$(EXES),$(eval $(call EXE_BUILD,$(exe)))) $(foreach alias,$(ALIASES),$(eval $(call MAKE_ALIAS,$(alias)))) -endif $(foreach test,$(TESTS),$(eval $(call TEST_BUILD,$(test)))) -ifeq ($(MULTICALL), 1) -install: build/uutils - mkdir -p $(DESTDIR)$(PREFIX)$(BINDIR) - install build/uutils $(DESTDIR)$(PREFIX)$(BINDIR)/uutils - -uninstall: - rm -f $(DESTDIR)$(PREFIX)$(BINDIR)/uutils -else install: $(addprefix build/,$(INSTALLEES)) mkdir -p $(DESTDIR)$(PREFIX)$(BINDIR) for prog in $(INSTALLEES); do \ @@ -198,10 +189,8 @@ install: $(addprefix build/,$(INSTALLEES)) uninstall: rm -f $(addprefix $(DESTDIR)$(PREFIX)$(BINDIR)/$(PROG_PREFIX),$(PROGS)) -endif # Test under the busybox testsuite -ifeq ($(MULTICALL), 1) build/busybox: build/uutils rm -f build/busybox ln -s $(SRC_DIR)/build/uutils build/busybox @@ -222,6 +211,5 @@ else busytest: build/busybox build/.config (cd $(BUSYBOX_SRC)/testsuite && bindir=$(SRC_DIR)/build ./runtest $(RUNTEST_ARGS)) endif -endif .PHONY: all deps test clean busytest install uninstall diff --git a/README.md b/README.md index ad96e82c6..7bb221e8c 100644 --- a/README.md +++ b/README.md @@ -34,11 +34,6 @@ To build only a few of the available utilities: make BUILD='UTILITY_1 UTILITY_2' ``` -To build the multicall binary (_i.e._ BusyBox-like binary): -``` -make MULTICALL=1 -``` - Installation Instructions ------------------------- @@ -57,12 +52,7 @@ To install only a few of the available utilities: make INSTALL='UTILITY_1 UTILITY_2' install ``` -To install the multicall binary: -``` -make MULTICALL=1 install -``` - -To install every program (other than the multicall binary) with a prefix: +To install every program with a prefix: ``` make PROG_PREFIX=PREFIX_GOES_HERE install ``` @@ -75,12 +65,7 @@ To uninstall all utilities: make uninstall ``` -To uninstall the multicall binary: -``` -make MULTICALL=1 uninstall -``` - -To uninstall every program (other than the multicall binary) with a set prefix: +To uninstall every program with a set prefix: ``` make PROG_PREFIX=PREFIX_GOES_HERE uninstall ``` diff --git a/base64/base64.rs b/base64/base64.rs index e4801dd58..231e2ee42 100644 --- a/base64/base64.rs +++ b/base64/base64.rs @@ -18,7 +18,6 @@ extern crate libc; #[phase(plugin, link)] extern crate log; use std::io::{println, File, stdin, stdout}; -use std::os; use std::str; use getopts::{ @@ -92,9 +91,6 @@ pub fn uumain(args: Vec) -> int { 0 } -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - fn decode(input: &mut Reader, ignore_garbage: bool) { let mut to_decode = match input.read_to_str() { Ok(m) => m, diff --git a/basename/basename.rs b/basename/basename.rs index f46b6cdfe..ef5b38f2d 100644 --- a/basename/basename.rs +++ b/basename/basename.rs @@ -14,7 +14,6 @@ extern crate getopts; extern crate libc; use std::io::{print, println}; -use std::os; use std::str::StrSlice; #[path = "../common/util.rs"] @@ -23,9 +22,6 @@ mod util; static NAME: &'static str = "basename"; static VERSION: &'static str = "1.0.0"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = strip_dir(args.get(0).as_slice()); diff --git a/cat/cat.rs b/cat/cat.rs index 28304f183..4f539d516 100644 --- a/cat/cat.rs +++ b/cat/cat.rs @@ -14,15 +14,11 @@ extern crate getopts; -use std::os; use std::io::{print, File}; use std::io::stdio::{stdout_raw, stdin_raw, stderr}; use std::io::{IoResult}; use std::ptr::{copy_nonoverlapping_memory}; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).as_slice(); let opts = [ diff --git a/chroot/chroot.rs b/chroot/chroot.rs index 414348cc4..5d22cdccb 100644 --- a/chroot/chroot.rs +++ b/chroot/chroot.rs @@ -36,9 +36,6 @@ extern { static NAME: &'static str = "chroot"; static VERSION: &'static str = "1.0.0"; -#[allow(dead_code)] -fn main () { std::os::set_exit_status(uumain(std::os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0); diff --git a/cksum/cksum.rs b/cksum/cksum.rs index 5e25cf4a8..acf341fba 100644 --- a/cksum/cksum.rs +++ b/cksum/cksum.rs @@ -14,7 +14,6 @@ extern crate getopts; use std::io::{BufferedReader, EndOfFile, File, IoError, IoResult, print}; use std::io::stdio::stdin; -use std::os; #[path="../common/util.rs"] mod util; @@ -77,9 +76,6 @@ fn open_file(name: &str) -> IoResult> { } } -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let opts = [ getopts::optflag("h", "help", "display this help and exit"), diff --git a/comm/comm.rs b/comm/comm.rs index 7babb946d..44180428d 100644 --- a/comm/comm.rs +++ b/comm/comm.rs @@ -15,7 +15,6 @@ use std::cmp::Ord; use std::io::{BufferedReader, IoResult, print}; use std::io::fs::File; use std::io::stdio::stdin; -use std::os; use std::path::Path; static NAME : &'static str = "comm"; @@ -94,9 +93,6 @@ fn open_file(name: &str) -> IoResult> { } } -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let opts = [ getopts::optflag("1", "", "suppress column 1 (lines uniq to FILE1)"), diff --git a/cp/cp.rs b/cp/cp.rs index d0c695a92..f059d6772 100644 --- a/cp/cp.rs +++ b/cp/cp.rs @@ -31,9 +31,6 @@ pub enum Mode { Version, } -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let opts = [ optflag("h", "help", "display this help and exit"), diff --git a/dirname/dirname.rs b/dirname/dirname.rs index faa5c74fd..429ebafd8 100644 --- a/dirname/dirname.rs +++ b/dirname/dirname.rs @@ -11,14 +11,10 @@ extern crate getopts; -use std::os; use std::io::print; static VERSION: &'static str = "1.0.0"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).clone(); let opts = [ diff --git a/du/du.rs b/du/du.rs index 60a58c83a..652de8146 100644 --- a/du/du.rs +++ b/du/du.rs @@ -16,7 +16,6 @@ extern crate getopts; extern crate libc; extern crate time; -use std::os; use std::io::{stderr, fs, FileStat, TypeDirectory}; use std::option::Option; use std::path::Path; @@ -89,9 +88,6 @@ fn du(path: &Path, mut my_stat: Stat, stats } -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).as_slice(); let opts = [ diff --git a/echo/echo.rs b/echo/echo.rs index f517b8fc1..ebdfbc470 100644 --- a/echo/echo.rs +++ b/echo/echo.rs @@ -13,7 +13,6 @@ extern crate getopts; extern crate libc; -use std::os; use std::io::{print, println}; use std::uint; @@ -163,9 +162,6 @@ fn print_version() { println!("echo version: {:s}", VERSION); } -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let mut options = EchoOptions { newline: false, diff --git a/env/env.rs b/env/env.rs index 677833fd8..bcc00e781 100644 --- a/env/env.rs +++ b/env/env.rs @@ -13,8 +13,6 @@ #![allow(non_camel_case_types)] -use std::os; - struct options { ignore_env: bool, null: bool, @@ -53,9 +51,6 @@ fn print_env(null: bool) { } } -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let prog = args.get(0).as_slice(); diff --git a/factor/factor.rs b/factor/factor.rs index b4db32292..f1a2468fe 100644 --- a/factor/factor.rs +++ b/factor/factor.rs @@ -14,7 +14,6 @@ extern crate getopts; extern crate libc; use std::u64; -use std::os; use std::vec::{Vec}; use std::io::{stdin}; @@ -64,9 +63,6 @@ fn print_factors_str(num_str: &str) { print_factors(num); } -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).as_slice(); let opts = [ diff --git a/false/false.rs b/false/false.rs index 8d7253899..f6f3dfe92 100644 --- a/false/false.rs +++ b/false/false.rs @@ -1,4 +1,4 @@ -#![crate_id(name="false", vers="1.0.0", author="Seldaek")] +#![crate_id = "uufalse#1.0.0"] /* * This file is part of the uutils coreutils package. @@ -9,6 +9,6 @@ * file that was distributed with this source code. */ -fn main() { - std::os::set_exit_status(1); +pub fn uumain(_: Vec) -> int { + 1 } diff --git a/fmt/fmt.rs b/fmt/fmt.rs index d5bbfcf06..f4e6f64fb 100644 --- a/fmt/fmt.rs +++ b/fmt/fmt.rs @@ -15,7 +15,6 @@ extern crate getopts; use std::io::{BufferedReader, BufferedWriter, File, IoResult}; use std::io::stdio::{stdin_raw, stdout_raw}; -use std::os; use linebreak::break_lines; use parasplit::ParagraphStream; @@ -54,9 +53,6 @@ struct FmtOptions { tabwidth : uint, } -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())) } - pub fn uumain(args: Vec) -> int { let opts = [ diff --git a/fold/fold.rs b/fold/fold.rs index f8e8a0e46..04f99af89 100644 --- a/fold/fold.rs +++ b/fold/fold.rs @@ -17,7 +17,6 @@ extern crate libc; use std::io; use std::io::fs::File; use std::io::BufferedReader; -use std::os; use std::uint; #[path = "../common/util.rs"] @@ -26,9 +25,6 @@ mod util; static NAME: &'static str = "fold"; static VERSION: &'static str = "1.0.0"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let (args, obs_width) = handle_obsolete(args.as_slice()); diff --git a/groups/groups.rs b/groups/groups.rs index bb1231a5b..1a0a3bb53 100644 --- a/groups/groups.rs +++ b/groups/groups.rs @@ -12,7 +12,6 @@ extern crate getopts; -use std::os; use getopts::{ optflag, getopts, @@ -26,9 +25,6 @@ use c_types::{get_pw_from_args, group}; static NAME: &'static str = "groups"; static VERSION: &'static str = "1.0.0"; -#[allow(dead_code)] -fn main () { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).clone(); diff --git a/hashsum/hashsum.rs b/hashsum/hashsum.rs index eeda041f0..03e5eb881 100644 --- a/hashsum/hashsum.rs +++ b/hashsum/hashsum.rs @@ -21,7 +21,6 @@ extern crate getopts; use std::io::fs::File; use std::io::stdio::stdin_raw; use std::io::BufferedReader; -use std::os; use regex::Regex; use crypto::digest::Digest; use crypto::md5::Md5; @@ -88,9 +87,6 @@ fn detect_algo(program: &str, matches: &getopts::Matches) -> (&str, Box) } } -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).clone(); let binary = Path::new(program.as_slice()); diff --git a/head/head.rs b/head/head.rs index 670c988aa..a1c492283 100644 --- a/head/head.rs +++ b/head/head.rs @@ -12,7 +12,6 @@ extern crate getopts; -use std::os; use std::char; use std::io::{stdin}; use std::io::BufferedReader; @@ -22,9 +21,6 @@ use getopts::{optopt, optflag, getopts, usage}; static PROGRAM: &'static str = "head"; -#[allow(dead_code)] -fn main () { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let mut line_count = 10u; diff --git a/hostid/hostid.rs b/hostid/hostid.rs index 0d0d019ea..70d78f316 100644 --- a/hostid/hostid.rs +++ b/hostid/hostid.rs @@ -20,8 +20,6 @@ extern crate libc; #[phase(plugin, link)] extern crate log; -use std::os; - use getopts::{ getopts, optflag, @@ -49,9 +47,6 @@ extern { pub fn gethostid() -> c_long; } -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let opts = [ diff --git a/hostname/hostname.rs b/hostname/hostname.rs index 48426b2e9..9d35c306c 100644 --- a/hostname/hostname.rs +++ b/hostname/hostname.rs @@ -15,7 +15,7 @@ extern crate getopts; extern crate libc; -use std::{os,str}; +use std::str; use getopts::{optflag, getopts, usage}; extern { @@ -32,9 +32,6 @@ extern { fn sethostname(name: *libc::c_char, namelen: libc::size_t) -> libc::c_int; } -#[allow(dead_code)] -fn main () { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0); diff --git a/id/id.rs b/id/id.rs index a3a4c01b9..4ddcde852 100644 --- a/id/id.rs +++ b/id/id.rs @@ -18,7 +18,6 @@ extern crate getopts; extern crate libc; -use std::os; use std::ptr::read; use libc::{ uid_t, @@ -83,9 +82,6 @@ extern { static NAME: &'static str = "id"; -#[allow(dead_code)] -fn main () { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let args_t = args.tail(); diff --git a/kill/kill.rs b/kill/kill.rs index 67efb4e76..40d053335 100644 --- a/kill/kill.rs +++ b/kill/kill.rs @@ -19,7 +19,6 @@ extern crate serialize; #[phase(plugin, link)] extern crate log; -use std::os; use std::from_str::from_str; use std::io::process::Process; @@ -52,9 +51,6 @@ pub enum Mode { Version, } -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let opts = [ diff --git a/link/link.rs b/link/link.rs index 033031635..5f0e8a94f 100644 --- a/link/link.rs +++ b/link/link.rs @@ -13,7 +13,6 @@ extern crate getopts; use std::io::fs::link; -use std::os; use std::path::Path; #[path="../common/util.rs"] @@ -22,9 +21,6 @@ mod util; static NAME : &'static str = "link"; static VERSION : &'static str = "1.0.0"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let opts = [ getopts::optflag("h", "help", "display this help and exit"), diff --git a/logname/logname.rs b/logname/logname.rs index edf11a5d9..eb5e5abc0 100644 --- a/logname/logname.rs +++ b/logname/logname.rs @@ -19,7 +19,6 @@ extern crate getopts; extern crate libc; use std::io::print; -use std::os; use std::str; use libc::c_char; @@ -43,9 +42,6 @@ fn version() { println!("{} {}", NAME, VERSION); } -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).clone(); diff --git a/mkdir/mkdir.rs b/mkdir/mkdir.rs index 7e884f3db..fe90ff26f 100644 --- a/mkdir/mkdir.rs +++ b/mkdir/mkdir.rs @@ -14,7 +14,6 @@ extern crate getopts; extern crate libc; -use std::os; use std::io::fs; use std::io::FilePermission; use std::num::strconv; @@ -28,9 +27,6 @@ static VERSION: &'static str = "1.0.0"; /** * Handles option parsing */ -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let opts = [ diff --git a/mkfifo/mkfifo.rs b/mkfifo/mkfifo.rs index b35d3bd10..b8e0f56f0 100644 --- a/mkfifo/mkfifo.rs +++ b/mkfifo/mkfifo.rs @@ -23,9 +23,6 @@ mod util; static NAME : &'static str = "mkfifo"; static VERSION : &'static str = "1.0.0"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let opts = [ getopts::optopt("m", "mode", "file permissions for the fifo", "(default 0666)"), diff --git a/mkmain.rs b/mkmain.rs new file mode 100644 index 000000000..ad522c116 --- /dev/null +++ b/mkmain.rs @@ -0,0 +1,40 @@ +use std::io::{File, Truncate, ReadWrite}; +use std::os; +use std::path::Path; +use std::str::replace; + +static TEMPLATE : &'static str = r" +extern crate @UTIL_CRATE@; + +use std::os; +use @UTIL_CRATE@::uumain; + +fn main() { + os::set_exit_status(uumain(os::args())); +} +"; + +fn main() { + let args = os::args(); + if args.len() != 3 { + println!("usage: mkbuild "); + os::set_exit_status(1); + return; + } + + let crat = match args.get(1).as_slice() { + "true" => "uutrue", + "false" => "uufalse", + "sync" => "uusync", + s => s.clone(), + }; + let outfile = args.get(2).as_slice(); + + let main = std::str::replace(TEMPLATE, "@UTIL_CRATE@", crat); + let mut out = File::open_mode(&Path::new(outfile), Truncate, ReadWrite); + + match out.write(main.as_bytes()) { + Err(e) => fail!("{}", e), + _ => (), + } +} diff --git a/nl/nl.rs b/nl/nl.rs index 8f8dafccb..7716fe75f 100644 --- a/nl/nl.rs +++ b/nl/nl.rs @@ -16,7 +16,6 @@ extern crate regex_macros; extern crate regex; extern crate getopts; -use std::os; use std::io::{stdin}; use std::io::BufferedReader; use std::io::fs::File; @@ -75,11 +74,6 @@ enum NumberFormat { RightZero, } -#[allow(dead_code)] -fn main () { - os::set_exit_status(uumain(os::args())); -} - pub fn uumain(args: Vec) -> int { let possible_options = [ optopt("b", "body-numbering", "use STYLE for numbering body lines", "STYLE"), diff --git a/paste/paste.rs b/paste/paste.rs index b3241d79a..18e5f8023 100644 --- a/paste/paste.rs +++ b/paste/paste.rs @@ -15,7 +15,6 @@ extern crate getopts; extern crate libc; use std::io; -use std::os; #[path = "../common/util.rs"] mod util; @@ -23,9 +22,6 @@ mod util; static NAME: &'static str = "paste"; static VERSION: &'static str = "1.0.0"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).clone(); diff --git a/printenv/printenv.rs b/printenv/printenv.rs index 31b93f16b..80fe06c22 100644 --- a/printenv/printenv.rs +++ b/printenv/printenv.rs @@ -24,9 +24,6 @@ mod util; static NAME: &'static str = "printenv"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).clone(); let opts = [ diff --git a/pwd/pwd.rs b/pwd/pwd.rs index adc853dd6..b5f7c485e 100644 --- a/pwd/pwd.rs +++ b/pwd/pwd.rs @@ -14,7 +14,6 @@ extern crate getopts; extern crate libc; -use std::os; use std::io::print; #[path = "../common/util.rs"] @@ -23,9 +22,6 @@ mod util; static NAME: &'static str = "pwd"; static VERSION: &'static str = "1.0.0"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).clone(); let opts = [ diff --git a/rm/rm.rs b/rm/rm.rs index 72022b197..04d6461bc 100644 --- a/rm/rm.rs +++ b/rm/rm.rs @@ -14,7 +14,6 @@ extern crate getopts; extern crate libc; -use std::os; use std::io::{print, stdin, stdio, fs, BufferedReader}; #[path = "../common/util.rs"] @@ -29,9 +28,6 @@ enum InteractiveMode { static NAME: &'static str = "rm"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).clone(); diff --git a/rmdir/rmdir.rs b/rmdir/rmdir.rs index 02d1e103c..61cd4d947 100644 --- a/rmdir/rmdir.rs +++ b/rmdir/rmdir.rs @@ -14,7 +14,6 @@ extern crate getopts; extern crate libc; -use std::os; use std::io::{print, fs}; #[path = "../common/util.rs"] @@ -22,9 +21,6 @@ mod util; static NAME: &'static str = "rmdir"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).clone(); diff --git a/seq/seq.rs b/seq/seq.rs index 6c9554918..814a8ff7d 100644 --- a/seq/seq.rs +++ b/seq/seq.rs @@ -10,7 +10,6 @@ extern crate libc; use std::cmp; use std::io; -use std::os; #[path = "../common/util.rs"] mod util; @@ -159,9 +158,6 @@ fn print_version() { println!("seq 1.0.0\n"); } -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).clone(); let mut options = SeqOptions { diff --git a/sleep/sleep.rs b/sleep/sleep.rs index 7268e89f5..9ddfd7b0b 100644 --- a/sleep/sleep.rs +++ b/sleep/sleep.rs @@ -15,7 +15,6 @@ extern crate getopts; extern crate libc; use std::f64; -use std::os; use std::io::{print, timer}; use std::u64; @@ -24,9 +23,6 @@ mod util; static NAME: &'static str = "sleep"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).clone(); diff --git a/sum/sum.rs b/sum/sum.rs index dabf2322e..85beff844 100644 --- a/sum/sum.rs +++ b/sum/sum.rs @@ -13,7 +13,6 @@ extern crate getopts; extern crate libc; -use std::os; use std::io::{File, IoResult, print}; use std::io::stdio::{stdin_raw}; @@ -76,9 +75,6 @@ fn open(name: &str) -> IoResult> { } } -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).as_slice(); let opts = [ diff --git a/sync/sync.rs b/sync/sync.rs index 32f8cad40..7533bebe3 100644 --- a/sync/sync.rs +++ b/sync/sync.rs @@ -15,7 +15,6 @@ extern crate getopts; extern crate libc; -use std::os; use getopts::{optflag, getopts, usage}; #[path = "../common/util.rs"] mod util; @@ -136,11 +135,6 @@ mod platform { } } -static NAME: &'static str = "sync"; - -#[allow(dead_code)] -fn main () { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0); diff --git a/tac/tac.rs b/tac/tac.rs index 9af806327..a0694b5b2 100644 --- a/tac/tac.rs +++ b/tac/tac.rs @@ -15,7 +15,6 @@ extern crate getopts; extern crate libc; use std::io; -use std::os; #[path = "../common/util.rs"] mod util; @@ -23,9 +22,6 @@ mod util; static NAME: &'static str = "tac"; static VERSION: &'static str = "1.0.0"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).clone(); diff --git a/tail/tail.rs b/tail/tail.rs index 61132ed7e..b939a5092 100644 --- a/tail/tail.rs +++ b/tail/tail.rs @@ -11,7 +11,6 @@ extern crate getopts; -use std::os; use std::char; use std::io::{stdin}; use std::io::BufferedReader; @@ -24,9 +23,6 @@ use std::io::timer::sleep; static PROGRAM: &'static str = "tail"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let mut line_count = 10u; let mut sleep_sec = 1000u64; diff --git a/tee/tee.rs b/tee/tee.rs index 503319c77..88746d040 100644 --- a/tee/tee.rs +++ b/tee/tee.rs @@ -24,9 +24,6 @@ use getopts::{getopts, optflag, usage}; static NAME: &'static str = "tee"; static VERSION: &'static str = "1.0.0"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { match options(args.as_slice()).and_then(exec) { Ok(_) => 0, diff --git a/touch/touch.rs b/touch/touch.rs index fe53c5821..cf4f7f8f0 100644 --- a/touch/touch.rs +++ b/touch/touch.rs @@ -14,7 +14,6 @@ extern crate getopts; extern crate time; use std::io::File; -use std::os; #[path = "../common/util.rs"] mod util; @@ -22,9 +21,6 @@ mod util; static NAME: &'static str = "touch"; static VERSION: &'static str = "1.0.0"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let opts = [ getopts::optflag("a", "", "change only the access time"), diff --git a/tr/tr.rs b/tr/tr.rs index eebb89a0a..76ef85906 100644 --- a/tr/tr.rs +++ b/tr/tr.rs @@ -20,7 +20,6 @@ use std::char::from_u32; use std::io::print; use std::io::stdio::{stdin,stdout}; use std::iter::FromIterator; -use std::os; use std::vec::Vec; #[path="../common/util.rs"] @@ -146,9 +145,6 @@ fn usage(opts: &[OptGroup]) { print(getopts::usage("Translate or delete characters.", opts).as_slice()); } -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let opts = [ getopts::optflag("c", "complement", "use the complement of SET1"), diff --git a/true/true.rs b/true/true.rs index 888e9db06..c4bcc4b8e 100644 --- a/true/true.rs +++ b/true/true.rs @@ -1,4 +1,4 @@ -#![crate_id(name="true", vers="1.0.0", author="Seldaek")] +#![crate_id = "uutrue#1.0.0"] /* * This file is part of the uutils coreutils package. @@ -9,5 +9,6 @@ * file that was distributed with this source code. */ -fn main() { +pub fn uumain(_: Vec) -> int { + 0 } diff --git a/truncate/truncate.rs b/truncate/truncate.rs index c4c34de9d..f448ffea5 100644 --- a/truncate/truncate.rs +++ b/truncate/truncate.rs @@ -15,7 +15,6 @@ extern crate getopts; extern crate libc; use std::io::{File, Open, ReadWrite, fs}; -use std::os; use std::u64; #[path = "../common/util.rs"] @@ -34,9 +33,6 @@ enum TruncateMode { static NAME: &'static str = "truncate"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).clone(); diff --git a/tty/tty.rs b/tty/tty.rs index 92efa31f6..a74662913 100644 --- a/tty/tty.rs +++ b/tty/tty.rs @@ -19,7 +19,7 @@ extern crate getopts; extern crate libc; -use std::{str,os}; +use std::str; use std::io::println; use std::io::stdio::stderr; use getopts::{optflag,getopts}; @@ -34,9 +34,6 @@ extern { static NAME: &'static str = "tty"; -#[allow(dead_code)] -fn main () { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let options = [ optflag("s", "silent", "print nothing, only return an exit status") diff --git a/uname/uname.rs b/uname/uname.rs index 38984e6c0..c8f4787e0 100644 --- a/uname/uname.rs +++ b/uname/uname.rs @@ -17,7 +17,6 @@ extern crate getopts; extern crate libc; -use std::os; use std::mem::uninitialized; use std::io::print; use std::str::raw::from_c_str; @@ -51,9 +50,6 @@ unsafe fn getuname() -> utsrust { static NAME: &'static str = "uname"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).as_slice(); let opts = [ diff --git a/unlink/unlink.rs b/unlink/unlink.rs index 2f432baaf..2f3847706 100644 --- a/unlink/unlink.rs +++ b/unlink/unlink.rs @@ -16,7 +16,6 @@ extern crate getopts; extern crate libc; -use std::os; use std::io; use std::io::fs; use std::io::print; @@ -26,9 +25,6 @@ mod util; static NAME: &'static str = "unlink"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).clone(); let opts = [ diff --git a/uptime/uptime.rs b/uptime/uptime.rs index 97e809bac..796eee351 100644 --- a/uptime/uptime.rs +++ b/uptime/uptime.rs @@ -17,7 +17,6 @@ extern crate getopts; extern crate libc; -use std::os; use std::mem::transmute; use std::io::{print, File}; use std::ptr::null; @@ -47,9 +46,6 @@ extern { fn utmpxname(file: *c_char) -> c_int; } -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).clone(); let opts = [ diff --git a/users/users.rs b/users/users.rs index 49becaa9c..e359c3eb3 100644 --- a/users/users.rs +++ b/users/users.rs @@ -21,7 +21,6 @@ extern crate libc; use std::io::print; use std::mem; -use std::os; use std::ptr; use std::str; use utmpx::*; @@ -47,9 +46,6 @@ extern { static NAME: &'static str = "users"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).as_slice(); let opts = [ diff --git a/wc/wc.rs b/wc/wc.rs index 13663144a..b9726cff2 100644 --- a/wc/wc.rs +++ b/wc/wc.rs @@ -14,7 +14,6 @@ extern crate getopts; extern crate libc; -use std::os; use std::str::from_utf8; use std::io::{print, stdin, File, BufferedReader}; use StdResult = std::result::Result; @@ -34,9 +33,6 @@ struct Result { static NAME: &'static str = "wc"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).clone(); let opts = [ diff --git a/whoami/whoami.rs b/whoami/whoami.rs index 4abe953e7..ad3080263 100644 --- a/whoami/whoami.rs +++ b/whoami/whoami.rs @@ -19,7 +19,6 @@ extern crate getopts; extern crate libc; use std::io::print; -use std::os; #[path = "../common/util.rs"] mod util; @@ -67,9 +66,6 @@ mod platform { static NAME: &'static str = "whoami"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).as_slice(); let opts = [ diff --git a/yes/yes.rs b/yes/yes.rs index 2b6fae868..5b827abe7 100644 --- a/yes/yes.rs +++ b/yes/yes.rs @@ -16,7 +16,6 @@ extern crate getopts; extern crate libc; -use std::os; use std::io::{print, println}; #[path = "../common/util.rs"] @@ -24,9 +23,6 @@ mod util; static NAME: &'static str = "yes"; -#[allow(dead_code)] -fn main() { os::set_exit_status(uumain(os::args())); } - pub fn uumain(args: Vec) -> int { let program = args.get(0).clone(); let opts = [