master
Avril 5 years ago
parent 2df51330d3
commit 89d6dd010f
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -1,7 +1,21 @@
VERSION:= v0.1.0
all: clean generator trust
trust:
if [[ ! -f generator-$(VERSION) ]]; then \
make -B generator || exit 1; \
fi
ln -sf generator-$(VERSION) generator
generator: generator:
cd generator-native && cargo build --release cd generator-native && cargo build --release
ln -sf generator-native/target/release/generator-native generator ln -sf generator-native/target/release/generator-native generator
cp -f `readlink generator` ./generator-$(VERSION)
gpg --sign ./generator-$(VERSION)
clean:
rm -f generator-v*
sfexec-output: sfexec-output:
g++ -Iinclude/ -w --std=c++17 main.cpp sha256_literal/sha256.cpp -o sfexec g++ -Iinclude/ -w --std=c++17 main.cpp sha256_literal/sha256.cpp -o sfexec

@ -1 +1 @@
generator-native/target/release/generator-native generator-v0.1.0

@ -2,6 +2,7 @@
name = "generator-native" name = "generator-native"
version = "0.1.0" version = "0.1.0"
authors = ["Avril <flanchan@cumallover.me>"] authors = ["Avril <flanchan@cumallover.me>"]
license = "GPL 3.0"
edition = "2018" edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

@ -3,6 +3,7 @@ use crate::{
}; };
pub enum OperationMode { pub enum OperationMode {
Version(bool),
Normal(Options, Vec<String>), Normal(Options, Vec<String>),
Help, Help,
} }
@ -22,6 +23,12 @@ pub fn parse() -> Result<OperationMode, &'static str>
"-h" if i == 1 => { "-h" if i == 1 => {
return Ok(OperationMode::Help); return Ok(OperationMode::Help);
}, },
"-v" if i==1 => {
return Ok(OperationMode::Version(false));
},
"-V" if i==1 => {
return Ok(OperationMode::Version(true));
},
"-s" if look => { "-s" if look => {
opt |= Opt::Silent; opt |= Opt::Silent;
}, },

@ -28,13 +28,28 @@ macro_rules! flush {
} }
} }
fn version(verbose: bool)
{
if verbose {
println!("sfexec-generator-native verison: {}", env!("CARGO_PKG_VERSION"));
println!("author: {} (https://flanchan.moe/)", env!("CARGO_PKG_AUTHORS"));
println!("license: GPL 3.0\n");
} else {
print!("{}", env!("CARGO_PKG_VERSION"));
}
}
fn usage() -> ! { fn usage() -> ! {
let prog = &arg::program_name(); let prog = &arg::program_name();
version(true);
println!("Usage: {} [-s] [-e <exec string>] [-o <output file>] [-] <files...>", prog); println!("Usage: {} [-s] [-e <exec string>] [-o <output file>] [-] <files...>", prog);
println!("Usage: {} -h", prog); println!("Usage: {} -h", prog);
println!("Usage: {} -v|-V", prog);
println!(); println!();
println!(" -\t\tStop reading options.");
println!(" -h\t\tPrint this message."); println!(" -h\t\tPrint this message.");
println!(" -v\t\tPrint version.");
println!(" -V\t\tPrint program info.");
println!(" -\t\tStop reading options.");
println!(" -s\t\tSilent mode."); println!(" -s\t\tSilent mode.");
println!(" -e <exec>\tScript to run after extraction."); println!(" -e <exec>\tScript to run after extraction.");
println!(" -o <file>\tOutput filename."); println!(" -o <file>\tOutput filename.");
@ -77,23 +92,8 @@ fn attempt_get_name<'a, P>(path: &'a P) -> Result<&'a str, &'static str>
} }
} }
fn main() -> Result<(), Box<dyn Error>>{ fn main() -> Result<(), Box<dyn Error>>
/*let file = OpenOptions::new()
.read(true)
.open("test.txt")?;
println!("{{");
for buf in file.into_iter(4)
.map(|byte| format!("0x{:02x},", byte))
.group_at(4)
.map(|strs| format!("\t{}", strs.join(" ")))
{ {
println!("{}", buf);
}
println!("}}");*/
match arg::parse()? { match arg::parse()? {
arg::OperationMode::Normal(options, files) => { arg::OperationMode::Normal(options, files) => {
let output = options.find(|opt| match opt { let output = options.find(|opt| match opt {
@ -190,6 +190,9 @@ fn main() -> Result<(), Box<dyn Error>>{
arg::OperationMode::Help => { arg::OperationMode::Help => {
usage(); usage();
}, },
arg::OperationMode::Version(verbose) => {
version(verbose);
},
}; };
Ok(()) Ok(())

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save