mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-19 06:40:20 +03:00
updated clap
This commit is contained in:
parent
cad6ac7bf9
commit
dc8a6abf22
32
Cargo.lock
generated
32
Cargo.lock
generated
@ -474,17 +474,26 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "3.0.0-beta.5"
|
||||
version = "3.1.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "feff3878564edb93745d58cf63e17b63f24142506e7a20c87a5521ed7bfb1d63"
|
||||
checksum = "85a35a599b11c089a7f49105658d089b8f2cf0882993c17daf6de15285c2c35d"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"bitflags",
|
||||
"clap_lex",
|
||||
"indexmap",
|
||||
"os_str_bytes",
|
||||
"strsim 0.10.0",
|
||||
"termcolor",
|
||||
"textwrap 0.14.2",
|
||||
"textwrap 0.15.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a37c35f1112dad5e6e0b1adaff798507497a18fceeb30cceb3bae7d1427b9213"
|
||||
dependencies = [
|
||||
"os_str_bytes",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2640,12 +2649,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "os_str_bytes"
|
||||
version = "4.2.0"
|
||||
version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "addaa943333a514159c80c97ff4a93306530d965d27e139188283cd13e06a799"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
|
||||
|
||||
[[package]]
|
||||
name = "output_vt100"
|
||||
@ -3497,7 +3503,7 @@ name = "roc_cli"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"clap 3.0.0-beta.5",
|
||||
"clap 3.1.15",
|
||||
"cli_utils",
|
||||
"const_format",
|
||||
"criterion 0.3.5 (git+https://github.com/Anton-4/criterion.rs)",
|
||||
@ -3756,7 +3762,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"bumpalo",
|
||||
"clap 3.0.0-beta.5",
|
||||
"clap 3.1.15",
|
||||
"iced-x86",
|
||||
"memmap2 0.5.3",
|
||||
"object 0.26.2",
|
||||
@ -4728,9 +4734,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.14.2"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
|
||||
checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
clap = "3.0.0-beta.2"
|
||||
clap = "3.1.15"
|
||||
regex = "1.5.4"
|
||||
is_executable = "1.0.1"
|
||||
ring = "0.16.20"
|
||||
|
@ -61,7 +61,7 @@ roc_error_macros = { path = "../error_macros" }
|
||||
roc_editor = { path = "../editor", optional = true }
|
||||
roc_linker = { path = "../linker" }
|
||||
roc_repl_cli = { path = "../repl_cli", optional = true }
|
||||
clap = { version = "3.0.0-beta.5", default-features = false, features = ["std", "color", "suggestions"] }
|
||||
clap = { version = "3.1.15", default-features = false, features = ["std", "color", "suggestions"] }
|
||||
const_format = "0.2.22"
|
||||
bumpalo = { version = "3.8.0", features = ["collections"] }
|
||||
mimalloc = { version = "0.1.26", default-features = false }
|
||||
|
@ -3,7 +3,8 @@ extern crate const_format;
|
||||
|
||||
use build::BuiltFile;
|
||||
use bumpalo::Bump;
|
||||
use clap::{App, AppSettings, Arg, ArgMatches};
|
||||
use clap::Command;
|
||||
use clap::{Arg, ArgMatches};
|
||||
use roc_build::link::LinkType;
|
||||
use roc_error_macros::user_error;
|
||||
use roc_load::LoadingProblem;
|
||||
@ -13,7 +14,6 @@ use std::io;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::process;
|
||||
use std::process::Command;
|
||||
use target_lexicon::BinaryFormat;
|
||||
use target_lexicon::{
|
||||
Architecture, Environment, OperatingSystem, Triple, Vendor, X86_32Architecture,
|
||||
@ -52,39 +52,39 @@ pub const ARGS_FOR_APP: &str = "ARGS_FOR_APP";
|
||||
|
||||
const VERSION: &str = include_str!("../../version.txt");
|
||||
|
||||
pub fn build_app<'a>() -> App<'a> {
|
||||
let app = App::new("roc")
|
||||
pub fn build_app<'a>() -> Command<'a> {
|
||||
let app = Command::new("roc")
|
||||
.version(concatcp!(VERSION, "\n"))
|
||||
.about("Runs the given .roc file, if there are no compilation errors.\nUse one of the SUBCOMMANDS below to do something else!")
|
||||
.subcommand(App::new(CMD_BUILD)
|
||||
.subcommand(Command::new(CMD_BUILD)
|
||||
.about("Build a binary from the given .roc file, but don't run it")
|
||||
.arg(
|
||||
Arg::new(ROC_FILE)
|
||||
.about("The .roc file to build")
|
||||
.help("The .roc file to build")
|
||||
.required(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_OPTIMIZE)
|
||||
.long(FLAG_OPTIMIZE)
|
||||
.about("Optimize your compiled Roc program to run faster. (Optimization takes time to complete.)")
|
||||
.help("Optimize your compiled Roc program to run faster. (Optimization takes time to complete.)")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_OPT_SIZE)
|
||||
.long(FLAG_OPT_SIZE)
|
||||
.about("Optimize your compiled Roc program to have a small binary size. (Optimization takes time to complete.)")
|
||||
.help("Optimize your compiled Roc program to have a small binary size. (Optimization takes time to complete.)")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_DEV)
|
||||
.long(FLAG_DEV)
|
||||
.about("Make compilation as fast as possible. (Runtime performance may suffer)")
|
||||
.help("Make compilation as fast as possible. (Runtime performance may suffer)")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_TARGET)
|
||||
.long(FLAG_TARGET)
|
||||
.about("Choose a different target")
|
||||
.help("Choose a different target")
|
||||
.default_value(Target::default().as_str())
|
||||
.possible_values(Target::OPTIONS)
|
||||
.required(false),
|
||||
@ -92,66 +92,66 @@ pub fn build_app<'a>() -> App<'a> {
|
||||
.arg(
|
||||
Arg::new(FLAG_LIB)
|
||||
.long(FLAG_LIB)
|
||||
.about("Build a C library instead of an executable.")
|
||||
.help("Build a C library instead of an executable.")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_NO_LINK)
|
||||
.long(FLAG_NO_LINK)
|
||||
.about("Does not link. Instead just outputs the `.o` file")
|
||||
.help("Does not link. Instead just outputs the `.o` file")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_DEBUG)
|
||||
.long(FLAG_DEBUG)
|
||||
.about("Store LLVM debug information in the generated program")
|
||||
.help("Store LLVM debug information in the generated program")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_TIME)
|
||||
.long(FLAG_TIME)
|
||||
.about("Prints detailed compilation time information.")
|
||||
.help("Prints detailed compilation time information.")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_LINK)
|
||||
.long(FLAG_LINK)
|
||||
.about("Deprecated in favor of --linker")
|
||||
.help("Deprecated in favor of --linker")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_LINKER)
|
||||
.long(FLAG_LINKER)
|
||||
.about("Sets which linker to use. The surgical linker is enabeld by default only when building for wasm32 or x86_64 Linux, because those are the only targets it currently supports. Otherwise the legacy linker is used by default.")
|
||||
.help("Sets which linker to use. The surgical linker is enabeld by default only when building for wasm32 or x86_64 Linux, because those are the only targets it currently supports. Otherwise the legacy linker is used by default.")
|
||||
.possible_values(["surgical", "legacy"])
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_PRECOMPILED)
|
||||
.long(FLAG_PRECOMPILED)
|
||||
.about("Assumes the host has been precompiled and skips recompiling the host. (Enabled by default when using a --target other than `--target host`)")
|
||||
.help("Assumes the host has been precompiled and skips recompiling the host. (Enabled by default when using a --target other than `--target host`)")
|
||||
.possible_values(["true", "false"])
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_VALGRIND)
|
||||
.long(FLAG_VALGRIND)
|
||||
.about("Some assembly instructions are not supported by valgrind, this flag prevents those from being output when building the host.")
|
||||
.help("Some assembly instructions are not supported by valgrind, this flag prevents those from being output when building the host.")
|
||||
.required(false),
|
||||
)
|
||||
)
|
||||
.subcommand(App::new(CMD_REPL)
|
||||
.subcommand(Command::new(CMD_REPL)
|
||||
.about("Launch the interactive Read Eval Print Loop (REPL)")
|
||||
)
|
||||
.subcommand(App::new(CMD_RUN)
|
||||
.subcommand(Command::new(CMD_RUN)
|
||||
.about("Run a .roc file even if it has build errors")
|
||||
.arg(
|
||||
Arg::new(ROC_FILE)
|
||||
.about("The .roc file of an app to run")
|
||||
.help("The .roc file of an app to run")
|
||||
.required(true),
|
||||
)
|
||||
)
|
||||
.subcommand(App::new(CMD_FORMAT)
|
||||
.subcommand(Command::new(CMD_FORMAT)
|
||||
.about("Format a .roc file using standard Roc formatting")
|
||||
.arg(
|
||||
Arg::new(DIRECTORY_OR_FILES)
|
||||
@ -161,112 +161,112 @@ pub fn build_app<'a>() -> App<'a> {
|
||||
.arg(
|
||||
Arg::new(FLAG_CHECK)
|
||||
.long(FLAG_CHECK)
|
||||
.about("Checks that specified files are formatted. If formatting is needed, it will return a non-zero exit code.")
|
||||
.help("Checks that specified files are formatted. If formatting is needed, it will return a non-zero exit code.")
|
||||
.required(false),
|
||||
)
|
||||
)
|
||||
.subcommand(App::new(CMD_VERSION)
|
||||
.subcommand(Command::new(CMD_VERSION)
|
||||
.about(concatcp!("Print the Roc compiler’s version, which is currently ", VERSION)))
|
||||
.subcommand(App::new(CMD_CHECK)
|
||||
.subcommand(Command::new(CMD_CHECK)
|
||||
.about("Check the code for problems, but doesn’t build or run it")
|
||||
.arg(
|
||||
Arg::new(FLAG_TIME)
|
||||
.long(FLAG_TIME)
|
||||
.about("Prints detailed compilation time information.")
|
||||
.help("Prints detailed compilation time information.")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(ROC_FILE)
|
||||
.about("The .roc file of an app to check")
|
||||
.help("The .roc file of an app to check")
|
||||
.required(true),
|
||||
)
|
||||
)
|
||||
.subcommand(
|
||||
App::new(CMD_DOCS)
|
||||
Command::new(CMD_DOCS)
|
||||
.about("Generate documentation for Roc modules (Work In Progress)")
|
||||
.arg(Arg::new(DIRECTORY_OR_FILES)
|
||||
.index(1)
|
||||
.multiple_values(true)
|
||||
.required(false)
|
||||
.about("The directory or files to build documentation for")
|
||||
.help("The directory or files to build documentation for")
|
||||
|
||||
)
|
||||
)
|
||||
.setting(AppSettings::TrailingVarArg)
|
||||
.trailing_var_arg(true)
|
||||
.arg(
|
||||
Arg::new(FLAG_OPTIMIZE)
|
||||
.long(FLAG_OPTIMIZE)
|
||||
.about("Optimize the compiled program to run faster. (Optimization takes time to complete.)")
|
||||
.help("Optimize the compiled program to run faster. (Optimization takes time to complete.)")
|
||||
.requires(ROC_FILE)
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_OPT_SIZE)
|
||||
.long(FLAG_OPT_SIZE)
|
||||
.about("Optimize the compiled program to have a small binary size. (Optimization takes time to complete.)")
|
||||
.help("Optimize the compiled program to have a small binary size. (Optimization takes time to complete.)")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_DEV)
|
||||
.long(FLAG_DEV)
|
||||
.about("Make compilation finish as soon as possible, at the expense of runtime performance.")
|
||||
.help("Make compilation finish as soon as possible, at the expense of runtime performance.")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_DEBUG)
|
||||
.long(FLAG_DEBUG)
|
||||
.about("Store LLVM debug information in the generated program.")
|
||||
.help("Store LLVM debug information in the generated program.")
|
||||
.requires(ROC_FILE)
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_TIME)
|
||||
.long(FLAG_TIME)
|
||||
.about("Prints detailed compilation time information.")
|
||||
.help("Prints detailed compilation time information.")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_LINK)
|
||||
.long(FLAG_LINK)
|
||||
.about("Deprecated in favor of --linker")
|
||||
.help("Deprecated in favor of --linker")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_LINKER)
|
||||
.long(FLAG_LINKER)
|
||||
.about("Sets which linker to use. The surgical linker is enabeld by default only when building for wasm32 or x86_64 Linux, because those are the only targets it currently supports. Otherwise the legacy linker is used by default.")
|
||||
.help("Sets which linker to use. The surgical linker is enabeld by default only when building for wasm32 or x86_64 Linux, because those are the only targets it currently supports. Otherwise the legacy linker is used by default.")
|
||||
.possible_values(["surgical", "legacy"])
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_PRECOMPILED)
|
||||
.long(FLAG_PRECOMPILED)
|
||||
.about("Assumes the host has been precompiled and skips recompiling the host. (Enabled by default when using `roc build` with a --target other than `--target host`)")
|
||||
.help("Assumes the host has been precompiled and skips recompiling the host. (Enabled by default when using `roc build` with a --target other than `--target host`)")
|
||||
.possible_values(["true", "false"])
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(ROC_FILE)
|
||||
.about("The .roc file of an app to build and run")
|
||||
.help("The .roc file of an app to build and run")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(ARGS_FOR_APP)
|
||||
.about("Arguments to pass into the app being run")
|
||||
.help("Arguments to pass into the app being run")
|
||||
.requires(ROC_FILE)
|
||||
.multiple_values(true),
|
||||
);
|
||||
|
||||
if cfg!(feature = "editor") {
|
||||
app.subcommand(
|
||||
App::new(CMD_EDIT)
|
||||
Command::new(CMD_EDIT)
|
||||
.about("Launch the Roc editor (Work In Progress)")
|
||||
.arg(
|
||||
Arg::new(DIRECTORY_OR_FILES)
|
||||
.index(1)
|
||||
.multiple_values(true)
|
||||
.required(false)
|
||||
.about("(optional) The directory or files to open on launch."),
|
||||
.help("(optional) The directory or files to open on launch."),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
@ -570,7 +570,7 @@ fn roc_run(
|
||||
run_with_wasmer(generated_filename, &args);
|
||||
return Ok(0);
|
||||
}
|
||||
_ => Command::new(&binary_path),
|
||||
_ => std::process::Command::new(&binary_path),
|
||||
};
|
||||
|
||||
if let Architecture::Wasm32 = triple.architecture {
|
||||
|
@ -22,7 +22,7 @@ roc_mono = { path = "../compiler/mono" }
|
||||
roc_build = { path = "../compiler/build" }
|
||||
roc_collections = { path = "../compiler/collections" }
|
||||
bumpalo = { version = "3.8.0", features = ["collections"] }
|
||||
clap = { version = "3.0.0-beta.5", default-features = false, features = ["std", "color", "suggestions"] }
|
||||
clap = { version = "3.1.15", default-features = false, features = ["std", "color", "suggestions"] }
|
||||
iced-x86 = { version = "1.15.0", default-features = false, features = ["std", "decoder", "op_code_info", "instr_info"] }
|
||||
memmap2 = "0.5.3"
|
||||
object = { version = "0.26.2", features = ["read", "write"] }
|
||||
|
@ -1,5 +1,5 @@
|
||||
use bincode::{deserialize_from, serialize_into};
|
||||
use clap::{App, AppSettings, Arg, ArgMatches};
|
||||
use clap::{Arg, ArgMatches, Command};
|
||||
use iced_x86::{Decoder, DecoderOptions, Instruction, OpCodeOperandKind, OpKind};
|
||||
use memmap2::{Mmap, MmapMut};
|
||||
use object::write;
|
||||
@ -21,7 +21,6 @@ use std::io::{BufReader, BufWriter};
|
||||
use std::mem;
|
||||
use std::os::raw::c_char;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use std::time::{Duration, SystemTime};
|
||||
use target_lexicon::Triple;
|
||||
use tempfile::Builder;
|
||||
@ -49,64 +48,65 @@ fn report_timing(label: &str, duration: Duration) {
|
||||
println!("\t{:9.3} ms {}", duration.as_secs_f64() * 1000.0, label,);
|
||||
}
|
||||
|
||||
pub fn build_app<'a>() -> App<'a> {
|
||||
App::new("link")
|
||||
pub fn build_app<'a>() -> Command<'a> {
|
||||
Command::new("link")
|
||||
.about("Preprocesses a platform and surgically links it to an application.")
|
||||
.setting(AppSettings::SubcommandRequiredElseHelp)
|
||||
.subcommand_required(true)
|
||||
.arg_required_else_help(true)
|
||||
.subcommand(
|
||||
App::new(CMD_PREPROCESS)
|
||||
Command::new(CMD_PREPROCESS)
|
||||
.about("Preprocesses a dynamically linked platform to prepare for linking.")
|
||||
.arg(
|
||||
Arg::new(EXEC)
|
||||
.about("The dynamically linked platform executable")
|
||||
.help("The dynamically linked platform executable")
|
||||
.required(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(METADATA)
|
||||
.about("Where to save the metadata from preprocessing")
|
||||
.help("Where to save the metadata from preprocessing")
|
||||
.required(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(OUT)
|
||||
.about("The modified version of the dynamically linked platform executable")
|
||||
.help("The modified version of the dynamically linked platform executable")
|
||||
.required(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(SHARED_LIB)
|
||||
.about("The name of the shared library used in building the platform")
|
||||
.help("The name of the shared library used in building the platform")
|
||||
.default_value("libapp.so"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_VERBOSE)
|
||||
.long(FLAG_VERBOSE)
|
||||
.short('v')
|
||||
.about("Enable verbose printing")
|
||||
.help("Enable verbose printing")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_TIME)
|
||||
.long(FLAG_TIME)
|
||||
.short('t')
|
||||
.about("Print timing information")
|
||||
.help("Print timing information")
|
||||
.required(false),
|
||||
),
|
||||
)
|
||||
.subcommand(
|
||||
App::new(CMD_SURGERY)
|
||||
Command::new(CMD_SURGERY)
|
||||
.about("Links a preprocessed platform with a Roc application.")
|
||||
.arg(
|
||||
Arg::new(APP)
|
||||
.about("The Roc application object file waiting to be linked")
|
||||
.help("The Roc application object file waiting to be linked")
|
||||
.required(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(METADATA)
|
||||
.about("The metadata created by preprocessing the platform")
|
||||
.help("The metadata created by preprocessing the platform")
|
||||
.required(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(OUT)
|
||||
.about(
|
||||
.help(
|
||||
"The modified version of the dynamically linked platform. \
|
||||
It will be consumed to make linking faster.",
|
||||
)
|
||||
@ -116,14 +116,14 @@ pub fn build_app<'a>() -> App<'a> {
|
||||
Arg::new(FLAG_VERBOSE)
|
||||
.long(FLAG_VERBOSE)
|
||||
.short('v')
|
||||
.about("Enable verbose printing")
|
||||
.help("Enable verbose printing")
|
||||
.required(false),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(FLAG_TIME)
|
||||
.long(FLAG_TIME)
|
||||
.short('t')
|
||||
.about("Print timing information")
|
||||
.help("Print timing information")
|
||||
.required(false),
|
||||
),
|
||||
)
|
||||
@ -243,7 +243,7 @@ fn generate_dynamic_lib(
|
||||
)
|
||||
.expect("failed to write object to file");
|
||||
|
||||
let output = Command::new("ld")
|
||||
let output = std::process::Command::new("ld")
|
||||
.args(&[
|
||||
"-shared",
|
||||
"-soname",
|
||||
|
Loading…
Reference in New Issue
Block a user