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:
parent
309426d6a6
commit
db36e8b0b7
13
Cargo.toml
13
Cargo.toml
|
@ -1,3 +1,9 @@
|
||||||
|
[workspace]
|
||||||
|
members = [
|
||||||
|
".",
|
||||||
|
"./core_generator",
|
||||||
|
]
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "ruduino"
|
name = "ruduino"
|
||||||
version = "0.2.7"
|
version = "0.2.7"
|
||||||
|
@ -15,8 +21,6 @@ description = """
|
||||||
Reusable components for AVR microcontrollers
|
Reusable components for AVR microcontrollers
|
||||||
"""
|
"""
|
||||||
|
|
||||||
build = "core_generator/build.rs"
|
|
||||||
|
|
||||||
keywords = ["avr", "arduino", "uno"]
|
keywords = ["avr", "arduino", "uno"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -25,8 +29,3 @@ default = ["avr-std-stub"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
avr-std-stub = { version = "1.0", optional = true }
|
avr-std-stub = { version = "1.0", optional = true }
|
||||||
target-cpu-macro = "0.1"
|
target-cpu-macro = "0.1"
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
avr-mcu = "0.3"
|
|
||||||
target-cpu-fetch = "0.1"
|
|
||||||
|
|
||||||
|
|
|
@ -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"
|
|
@ -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;
|
const DEFAULT_FREQUENCY_HZ_FOR_NON_AVR_DOCS: u64 = 16_000_000;
|
||||||
|
|
||||||
fn src_path() -> PathBuf {
|
fn base_output_path() -> PathBuf {
|
||||||
Path::new(env!("CARGO_MANIFEST_DIR")).join("src")
|
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 {
|
fn cores_path() -> PathBuf {
|
||||||
src_path().join("cores")
|
base_output_path().join("cores")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn core_module_name(mcu: &Mcu) -> String {
|
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> {
|
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 mut f = File::create(&path)?;
|
||||||
|
|
||||||
let clock: u64 = if cfg!(arch = "avr") {
|
let clock: u64 = if cfg!(arch = "avr") {
|
|
@ -0,0 +1,10 @@
|
||||||
|
#! /bin/sh -ea
|
||||||
|
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
SCRIPT_DIR=$(dirname $0)
|
||||||
|
|
||||||
|
cd "${SCRIPT_DIR}/core_generator"
|
||||||
|
|
||||||
|
cargo run "../src"
|
||||||
|
|
Loading…
Reference in New Issue