diff --git a/Cargo.lock b/Cargo.lock index aee8a9f..0fbc52e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,9 +20,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "0.7.20" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" dependencies = [ "memchr", ] @@ -38,9 +38,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.69" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" [[package]] name = "atty" @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "crankstart-cli" -version = "0.2.5" +version = "0.2.9" dependencies = [ "Inflector", "anyhow", @@ -195,9 +195,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", "miniz_oxide", @@ -205,9 +205,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if 1.0.0", "libc", @@ -243,9 +243,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "lazy_static" @@ -255,18 +255,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "log" -version = "0.4.17" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if 1.0.0", -] +checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "memchr" @@ -276,18 +273,18 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "miniz_oxide" -version = "0.6.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ "adler", ] [[package]] name = "pkg-config" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "pretty_env_logger" @@ -308,7 +305,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -325,9 +322,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.51" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" dependencies = [ "unicode-ident", ] @@ -340,9 +337,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.23" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" dependencies = [ "proc-macro2", ] @@ -369,9 +366,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.1" +version = "1.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" dependencies = [ "aho-corasick", "memchr", @@ -380,15 +377,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" [[package]] name = "ryu" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "same-file" @@ -417,26 +414,26 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.152" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" [[package]] name = "serde_derive" -version = "1.0.152" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.22", ] [[package]] name = "serde_json" -version = "1.0.93" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" +checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3" dependencies = [ "itoa", "ryu", @@ -470,14 +467,25 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] name = "syn" -version = "1.0.107" +version = "2.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "2efbeae7acf4eabd6bcdcbd11c92f45231ddda7539edc7806bd1a04a03b24616" dependencies = [ "proc-macro2", "quote", @@ -504,22 +512,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.22", ] [[package]] @@ -544,9 +552,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" [[package]] name = "unicode-segmentation" @@ -574,12 +582,11 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "walkdir" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" dependencies = [ "same-file", - "winapi", "winapi-util", ] diff --git a/Cargo.toml b/Cargo.toml index 4ed753e..1804b81 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "crankstart-cli" -version = "0.2.8" +version = "0.2.9" authors = ["Rob Tsuk "] edition = "2018" description = "A command line tool for use with [Crankstart](https://github.com/pd-rs/crankstart)." diff --git a/src/main.rs b/src/main.rs index aac57ae..f491598 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,11 +3,12 @@ use inflector::cases::titlecase::to_title_case; use log::{debug, info}; use serde_derive::Deserialize; use std::{ + collections::HashMap, env, fs::{self}, io::Write, path::{Path, PathBuf}, - process::Command, + process::{Command, Stdio}, thread, time, }; use structopt::StructOpt; @@ -30,14 +31,6 @@ const GCC_PATH_STR: &'static str = "arm-none-eabi-gcc"; const GCC_PATH_STR: &'static str = r"C:\Program Files (x86)\GNU Tools Arm Embedded\9 2019-q4-major\bin\arm-none-eabi-gcc.exe"; -#[cfg(target_os = "macos")] -const OBJCOPY_PATH_STR: &'static str = "/usr/local/bin/arm-none-eabi-objcopy"; -#[cfg(all(unix, not(target_os = "macos")))] -const OBJCOPY_PATH_STR: &'static str = "arm-none-eabi-objcopy"; -#[cfg(windows)] -const OBJCOPY_PATH_STR: &'static str = - r"C:\Program Files (x86)\GNU Tools Arm Embedded\9 2019-q4-major\bin\arm-none-eabi-objcopy.exe"; - #[cfg(unix)] #[allow(unused)] const PDUTIL_NAME: &'static str = "pdutil"; @@ -203,15 +196,18 @@ impl Build { } fn compile_setup(&self, target_dir: &PathBuf) -> Result<(), Error> { - let gcc_compile_static_args = "-g -c -mthumb -mcpu=cortex-m7 -mfloat-abi=hard \ - -mfpu=fpv4-sp-d16 -D__FPU_USED=1 -O2 -falign-functions=16 -fomit-frame-pointer \ + let gcc_compile_static_args = "-g3 -c -mthumb -mcpu=cortex-m7 -mfloat-abi=hard \ + -mfpu=fpv5-sp-d16 -D__FPU_USED=1 -O2 -falign-functions=16 -fomit-frame-pointer \ -gdwarf-2 -Wall -Wno-unused -Wstrict-prototypes -Wno-unknown-pragmas -fverbose-asm \ - -ffunction-sections -fdata-sections -DTARGET_PLAYDATE=1 -DTARGET_EXTENSION=1"; + -Wdouble-promotion -mword-relocations -fno-common \ + -ffunction-sections -fdata-sections -DTARGET_PLAYDATE=1 -DTARGET_EXTENSION=1 -fno-exceptions"; let args_iter = gcc_compile_static_args.split(" "); let playdate_c_api_path = playdate_c_api_path()?; let setup_path = Self::setup_path()?; let mut command = Command::new(GCC_PATH_STR); command + .stdout(Stdio::null()) + .stderr(Stdio::inherit()) .args(args_iter) .arg(setup_path) .arg("-I") @@ -232,10 +228,11 @@ impl Build { example_name: &str, lib_path: &PathBuf, ) -> Result<(), Error> { - let gcc_link_static_args = "-mthumb -mcpu=cortex-m7 -mfloat-abi=hard \ - -mfpu=fpv4-sp-d16 -D__FPU_USED=1 -Wl,--gc-sections,--no-warn-mismatch"; + let gcc_link_static_args = "-nostartfiles -mthumb -mcpu=cortex-m7 -mfloat-abi=hard \ + -mfpu=fpv5-sp-d16 -D__FPU_USED=1 -Wl,--cref,--gc-sections,--no-warn-mismatch,--emit-relocs -fno-exceptions"; let mut cmd = Command::new(GCC_PATH_STR); + cmd.stdout(Stdio::null()).stderr(Stdio::inherit()); let setup_obj_path = target_dir.join("setup.o"); cmd.arg(setup_obj_path); cmd.arg(lib_path); @@ -253,6 +250,9 @@ impl Build { cmd.arg("-o"); cmd.arg(target_path); + cmd.arg("--entry"); + cmd.arg("eventHandlerShim"); // declared in setup.c + info!("link_binary: {:?}", cmd); let status = cmd.status()?; @@ -269,26 +269,11 @@ impl Build { example_name: &str, source_dir: &PathBuf, ) -> Result<(), Error> { - let mut cmd = Command::new(OBJCOPY_PATH_STR); - let source_path = target_dir.join(format!("{}.elf", example_name)); - let dest_path = target_dir.join(format!("{}.bin", example_name)); + let source_dir_path = source_dir.join("pdex.elf"); - cmd.arg("-O"); - cmd.arg("binary"); - cmd.arg(&source_path); - cmd.arg(&dest_path); - - info!("make_binary: {:?}", cmd); - - let status = cmd.status()?; - if !status.success() { - bail!("objcopy failed with error {:?}", status); - } - - let source_dir_path = source_dir.join("pdex.bin"); - - fs::copy(&dest_path, &source_dir_path)?; + // just copy/rename, from v2.0 pdex.bin producing by pdc by pdex.elf + fs::copy(&source_path, &source_dir_path)?; Ok(()) } @@ -380,15 +365,21 @@ impl Build { info!("run_pdc"); let pdc_path = playdate_sdk_path()?.join("bin").join(PDC_NAME); let mut cmd = Command::new(pdc_path); + cmd.arg("--strip"); + // cmd.arg("--verbose"); cmd.arg(source_dir); cmd.arg(dest_dir); debug!("{:?}", cmd); - let status = cmd.status()?; + let status = cmd + .stdout(std::process::Stdio::piped()) + .stderr(std::process::Stdio::piped()) + .status()?; if !status.success() { bail!("pdc failed with error {:?}", status); } + Ok(()) } @@ -644,10 +635,29 @@ impl Build { if self.device { args.push("--target"); args.push("thumbv7em-none-eabihf"); + + args.push("-Zbuild-std=core,alloc"); } + let envs = if self.device { + let mut map = HashMap::new(); + map.insert( + "RUSTFLAGS", + [ + "-Ctarget-cpu=cortex-m7", + "-Clink-args=--emit-relocs", + "-Crelocation-model=pic", + ] + .join(" "), + ); + map + } else { + Default::default() + }; + let mut command = Command::new("cargo"); command.args(args); + command.envs(envs); info!("build command: {:?}", command); let status = command.status()?;