Move the 'core_generator' from a build script to an in-repository tool

The core generator will be run manually before release.
This commit is contained in:
Dylan McKay 2021-01-28 04:37:06 +13:00
parent 309426d6a6
commit db36e8b0b7
5 changed files with 45 additions and 11 deletions

View File

@ -1,3 +1,9 @@
[workspace]
members = [
".",
"./core_generator",
]
[package]
name = "ruduino"
version = "0.2.7"
@ -15,8 +21,6 @@ description = """
Reusable components for AVR microcontrollers
"""
build = "core_generator/build.rs"
keywords = ["avr", "arduino", "uno"]
[features]
@ -25,8 +29,3 @@ default = ["avr-std-stub"]
[dependencies]
avr-std-stub = { version = "1.0", optional = true }
target-cpu-macro = "0.1"
[build-dependencies]
avr-mcu = "0.3"
target-cpu-fetch = "0.1"

22
core_generator/Cargo.toml Normal file
View File

@ -0,0 +1,22 @@
[package]
name = "ruduino-core-generator"
version = "0.0.0" # not versioned
publish = false
edition = "2018"
authors = [
"The AVR-Rust Project Developers",
"Jake Goulding <jake.goulding@gmail.com>",
"Dylan McKay <me@dylanmckay.io>",
]
license = "MIT/Apache-2.0"
readme = "README.md"
repository = "https://github.com/avr-rust/ruduino"
[[bin]]
name = "ruduino-core-generator"
path = "src/main.rs"
[dependencies]
avr-mcu = "0.3"
target-cpu-fetch = "0.1"

View File

@ -14,12 +14,15 @@ const DEFAULT_MCU_FOR_NON_AVR_DOCS: &'static str = "atmega328";
const DEFAULT_FREQUENCY_HZ_FOR_NON_AVR_DOCS: u64 = 16_000_000;
fn src_path() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR")).join("src")
fn base_output_path() -> PathBuf {
match std::env::args().skip(1).next() {
Some(path) => Path::new(&path).to_owned(),
None => panic!("please pass a destination path for the generated cores on the command line"),
}
}
fn cores_path() -> PathBuf {
src_path().join("cores")
base_output_path().join("cores")
}
fn core_module_name(mcu: &Mcu) -> String {
@ -57,7 +60,7 @@ fn generate_cores(mcus: &[Mcu]) -> Result<(), io::Error> {
}
fn generate_config_module() -> Result<(), io::Error> {
let path = src_path().join("config.rs");
let path = base_output_path().join("config.rs");
let mut f = File::create(&path)?;
let clock: u64 = if cfg!(arch = "avr") {

10
regenerate-cores.sh Executable file
View File

@ -0,0 +1,10 @@
#! /bin/sh -ea
set -o pipefail
SCRIPT_DIR=$(dirname $0)
cd "${SCRIPT_DIR}/core_generator"
cargo run "../src"