1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-30 04:27:45 +00:00

Make dependency info usable for test, sync, true, and false

This commit is contained in:
Arcterus 2015-01-10 13:00:15 -08:00
parent 7838e839aa
commit 41cc268df8
7 changed files with 39 additions and 50 deletions

View file

@ -20,14 +20,17 @@ TESTDIR := $(BASEDIR)/test
TEMPDIR := $(BASEDIR)/tmp TEMPDIR := $(BASEDIR)/tmp
# Flags # Flags
RUSTCFLAGS := -O -L $(BUILDDIR)/ RUSTCFLAGS := -O
RMFLAGS := RMFLAGS :=
RUSTCLIBFLAGS := $(RUSTCFLAGS) -L $(BUILDDIR)/
RUSTCTESTFLAGS := $(RUSTCFLAGS)
# Handle config setup # Handle config setup
ifeq ($(ENABLE_LTO),y) ifeq ($(ENABLE_LTO),y)
RUSTCBINFLAGS := $(RUSTCFLAGS) -Z lto RUSTCBINFLAGS := $(RUSTCLIBFLAGS) -Z lto
else else
RUSTCBINFLAGS := $(RUSTCFLAGS) RUSTCBINFLAGS := $(RUSTCLIBFLAGS)
endif endif
ifneq ($(ENABLE_STRIP),y) ifneq ($(ENABLE_STRIP),y)
@ -170,7 +173,7 @@ $(BUILDDIR)/gen/$(1).rs: $(BUILDDIR)/mkmain
$(BUILDDIR)/mkmain $(1) $$@ $(BUILDDIR)/mkmain $(1) $$@
$(BUILDDIR)/$(1): $(BUILDDIR)/gen/$(1).rs $(BUILDDIR)/$($(1)_RLIB) | $(BUILDDIR) deps $(BUILDDIR)/$(1): $(BUILDDIR)/gen/$(1).rs $(BUILDDIR)/$($(1)_RLIB) | $(BUILDDIR) deps
$(RUSTC) $(RUSTCBINFLAGS) -o $$@ $$< $(RUSTC) $(RUSTCBINFLAGS) --extern test=$(BUILDDIR)/libtest.rlib -o $$@ $$<
$(if $(ENABLE_STRIP),strip $$@,) $(if $(ENABLE_STRIP),strip $$@,)
endef endef
@ -178,7 +181,7 @@ define CRATE_BUILD
-include $(BUILDDIR)/$(1).d -include $(BUILDDIR)/$(1).d
$(BUILDDIR)/$($(1)_RLIB): $(SRCDIR)/$(1)/$(1).rs | $(BUILDDIR) deps $(BUILDDIR)/$($(1)_RLIB): $(SRCDIR)/$(1)/$(1).rs | $(BUILDDIR) deps
$(RUSTC) $(RUSTCFLAGS) --extern time=$(BUILDDIR)/libtime.rlib --extern regex=$(BUILDDIR)/libregex.rlib --crate-type rlib --emit link,dep-info $$< --out-dir $(BUILDDIR) $(RUSTC) $(RUSTCLIBFLAGS) --extern time=$(BUILDDIR)/libtime.rlib --extern regex=$(BUILDDIR)/libregex.rlib --crate-type rlib --emit link,dep-info $$< --out-dir $(BUILDDIR)
endef endef
# Aliases build rule # Aliases build rule
@ -200,7 +203,7 @@ test_$(1): $(TEMPDIR)/$(1)/$(1)_test $(BUILDDIR)/$(1)
$(call command,cp $(BUILDDIR)/$(1) $(TEMPDIR)/$(1) && cd $(TEMPDIR)/$(1) && $$<) $(call command,cp $(BUILDDIR)/$(1) $(TEMPDIR)/$(1) && cd $(TEMPDIR)/$(1) && $$<)
$(TEMPDIR)/$(1)/$(1)_test: $(TESTDIR)/$(1).rs | $(TEMPDIR)/$(1) $(TEMPDIR)/$(1)/$(1)_test: $(TESTDIR)/$(1).rs | $(TEMPDIR)/$(1)
$(call command,$(RUSTC) $(RUSTCFLAGS) --extern time=$(BUILDDIR)/libtime.rlib --extern regex=$(BUILDDIR)/libregex.rlib --test -o $$@ $$<) $(call command,$(RUSTC) $(RUSTCTESTFLAGS) --extern time=$(BUILDDIR)/libtime.rlib --extern regex=$(BUILDDIR)/libregex.rlib --test -o $$@ $$<)
$(TEMPDIR)/$(1): | $(TEMPDIR) $(TEMPDIR)/$(1): | $(TEMPDIR)
$(call command,cp -r $(TESTDIR)/fixtures/$(1) $$@ || mkdir $$@) $(call command,cp -r $(TESTDIR)/fixtures/$(1) $$@ || mkdir $$@)
@ -218,7 +221,7 @@ $(foreach test,$(TESTS),$(eval $(call TEST_BUILD,$(test))))
-include $(BUILDDIR)/uutils.d -include $(BUILDDIR)/uutils.d
$(BUILDDIR)/uutils: $(SRCDIR)/uutils/uutils.rs $(BUILDDIR)/mkuutils $(RLIB_PATHS) $(BUILDDIR)/uutils: $(SRCDIR)/uutils/uutils.rs $(BUILDDIR)/mkuutils $(RLIB_PATHS)
$(BUILDDIR)/mkuutils $(BUILDDIR)/gen/uutils.rs $(EXES) $(BUILDDIR)/mkuutils $(BUILDDIR)/gen/uutils.rs $(EXES)
$(RUSTC) $(RUSTCBINFLAGS) --emit link,dep-info $(BUILDDIR)/gen/uutils.rs -o $@ $(RUSTC) $(RUSTCBINFLAGS) --extern test=$(BUILDDIR)/libtest.rlib --emit link,dep-info $(BUILDDIR)/gen/uutils.rs --out-dir $(BUILDDIR)
$(if $(ENABLE_STRIP),strip $@) $(if $(ENABLE_STRIP),strip $@)
# Dependencies # Dependencies
@ -229,12 +232,12 @@ $(BUILDDIR)/.rust-crypto: | $(BUILDDIR)
cp -r $(BASEDIR)/deps/rust-crypto/target/release/libcrypto*.rlib $(BUILDDIR)/libcrypto.rlib cp -r $(BASEDIR)/deps/rust-crypto/target/release/libcrypto*.rlib $(BUILDDIR)/libcrypto.rlib
@touch $@ @touch $@
#$(BUILDDIR)/.rust-time: #$(BUILDDIR)/.rust-time: | $(BUILDDIR)
# cd $(BASEDIR)/deps/time && $(CARGO) build --release # cd $(BASEDIR)/deps/time && $(CARGO) build --release
# cp -r $(BASEDIR)/deps/time/target/release/libtime*.rlib $(BUILDDIR)/libtime.rlib # cp -r $(BASEDIR)/deps/time/target/release/libtime*.rlib $(BUILDDIR)/libtime.rlib
# @touch $@ # @touch $@
$(BUILDDIR)/.rust-regex: $(BUILDDIR)/.rust-regex: | $(BUILDDIR)
cd $(BASEDIR)/deps/regex/regex_macros && $(CARGO) build --release cd $(BASEDIR)/deps/regex/regex_macros && $(CARGO) build --release
cp -r $(BASEDIR)/deps/regex/regex_macros/target/release/libregex_macros* $(BUILDDIR) cp -r $(BASEDIR)/deps/regex/regex_macros/target/release/libregex_macros* $(BUILDDIR)
cp -r $(BASEDIR)/deps/regex/regex_macros/target/release/deps/libregex*.rlib $(BUILDDIR)/libregex.rlib cp -r $(BASEDIR)/deps/regex/regex_macros/target/release/deps/libregex*.rlib $(BUILDDIR)/libregex.rlib
@ -247,7 +250,7 @@ $(BUILDDIR)/mkuutils: mkuutils.rs | $(BUILDDIR)
$(RUSTC) $(RUSTCFLAGS) $< -o $@ $(RUSTC) $(RUSTCFLAGS) $< -o $@
$(SRCDIR)/cksum/crc_table.rs: $(SRCDIR)/cksum/gen_table.rs $(SRCDIR)/cksum/crc_table.rs: $(SRCDIR)/cksum/gen_table.rs
cd $(SRCDIR)/cksum && $(RUSTC) $(RUSTCFLAGS) gen_table.rs && ./gen_table && $(RM) gen_table cd $(SRCDIR)/cksum && $(RUSTC) $(RUSTCBINFLAGS) gen_table.rs && ./gen_table && $(RM) gen_table
deps: $(BUILDDIR)/.rust-crypto $(BUILDDIR)/.rust-regex $(SRCDIR)/cksum/crc_table.rs deps: $(BUILDDIR)/.rust-crypto $(BUILDDIR)/.rust-regex $(SRCDIR)/cksum/crc_table.rs

View file

@ -6,10 +6,10 @@ use std::path::Path;
static TEMPLATE: &'static str = "\ static TEMPLATE: &'static str = "\
#![allow(unstable)] #![allow(unstable)]
extern crate @UTIL_CRATE@; extern crate \"@UTIL_CRATE@\" as uu@UTIL_CRATE@;
use std::os; use std::os;
use @UTIL_CRATE@::uumain; use uu@UTIL_CRATE@::uumain;
fn main() { fn main() {
os::set_exit_status(uumain(os::args())); os::set_exit_status(uumain(os::args()));
@ -24,13 +24,7 @@ fn main() {
return; return;
} }
let crat = match args[1].as_slice() { let crat = args[1].as_slice();
"test" => "uutest",
"true" => "uutrue",
"false" => "uufalse",
"sync" => "uusync",
s => s.clone(),
};
let outfile = args[2].as_slice(); let outfile = args[2].as_slice();
let main = TEMPLATE.replace("@UTIL_CRATE@", crat); let main = TEMPLATE.replace("@UTIL_CRATE@", crat);

View file

@ -30,19 +30,11 @@ fn main() {
hashsum = true; hashsum = true;
} }
} }
"test" => {
crates.push_str("extern crate uutest;\n");
util_map.push_str("map.insert(\"test\", uutest::uumain);\n");
}
"true" => util_map.push_str("fn uutrue(_: Vec<String>) -> isize { 0 }\nmap.insert(\"true\", uutrue);\n"), "true" => util_map.push_str("fn uutrue(_: Vec<String>) -> isize { 0 }\nmap.insert(\"true\", uutrue);\n"),
"false" => util_map.push_str("fn uufalse(_: Vec<String>) -> isize { 1 }\nmap.insert(\"false\", uufalse);\n"), "false" => util_map.push_str("fn uufalse(_: Vec<String>) -> isize { 1 }\nmap.insert(\"false\", uufalse);\n"),
"sync" => {
crates.push_str("extern crate uusync;\n");
util_map.push_str("map.insert(\"sync\", uusync::uumain);\n");
}
_ => { _ => {
crates.push_str(format!("extern crate {};\n", prog).as_slice()); crates.push_str(format!("extern crate \"{0}\" as uu{0};\n", prog).as_slice());
util_map.push_str(format!("map.insert(\"{prog}\", {prog}::uumain as fn(Vec<String>) -> isize);\n", prog = prog).as_slice()); util_map.push_str(format!("map.insert(\"{prog}\", uu{prog}::uumain as fn(Vec<String>) -> isize);\n", prog = prog).as_slice());
} }
} }
} }

View file

@ -1,4 +1,4 @@
#![crate_name = "uufalse"] #![crate_name = "false"]
#![allow(unstable)] #![allow(unstable)]
/* /*

View file

@ -1,4 +1,4 @@
#![crate_name = "uusync"] #![crate_name = "sync"]
#![allow(unstable)] #![allow(unstable)]
/* /*
@ -163,7 +163,7 @@ pub fn uumain(args: Vec<String>) -> isize {
return 0 return 0
} }
uusync(); sync();
0 0
} }
@ -179,7 +179,7 @@ fn help(program: &str, options: &[getopts::OptGroup]) {
print!("{}", usage("Force changed blocks to disk, update the super block.", options)); print!("{}", usage("Force changed blocks to disk, update the super block.", options));
} }
fn uusync() -> isize { fn sync() -> isize {
unsafe { unsafe {
platform::do_sync() platform::do_sync()
} }

View file

@ -1,4 +1,4 @@
#![crate_name = "uutest"] #![crate_name = "test"]
#![allow(unstable)] #![allow(unstable)]
/* /*

View file

@ -1,4 +1,4 @@
#![crate_name= "uutrue"] #![crate_name= "true"]
#![allow(unstable)] #![allow(unstable)]
/* /*