Move library crates under 'lib/'.
Give these crates each a more standard directory layout with sources in a 'src' sub-sirectory and Cargo.toml in the top lib/foo directory. Add license and description fields to each. The build script for the cretonne crate now lives in 'lib/cretonne/build.rs' separating it from the normal library sources under 'lib/cretonne/src'.
This commit is contained in:
@@ -3,6 +3,7 @@ authors = ["The Cretonne Project Developers"]
|
||||
name = "cretonne"
|
||||
version = "0.0.0"
|
||||
description = "Low-level code generator library"
|
||||
license = "Apache-2.0"
|
||||
documentation = "https://cretonne.readthedocs.io/"
|
||||
repository = "https://github.com/stoklund/cretonne"
|
||||
publish = false
|
||||
@@ -10,10 +11,9 @@ build = "build.rs"
|
||||
|
||||
[lib]
|
||||
name = "cretonne"
|
||||
path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
# It is a goal of the cretonne crate to have minimal external dependencies.
|
||||
# Please don't add any unless they are essential to the task of creating binary
|
||||
# machine code. Integration tests that need external dependencies can be
|
||||
# accomodated in src/tools/tests.
|
||||
# accomodated in `tests`.
|
||||
41
lib/cretonne/build.rs
Normal file
41
lib/cretonne/build.rs
Normal file
@@ -0,0 +1,41 @@
|
||||
// Build script.
|
||||
//
|
||||
// This program is run by Cargo when building lib/cretonne. It is used to generate Rust code from
|
||||
// the language definitions in the lib/cretonne/meta directory.
|
||||
//
|
||||
// Environment:
|
||||
//
|
||||
// OUT_DIR
|
||||
// Directory where generated files should be placed.
|
||||
//
|
||||
// The build script expects to be run from the directory where this build.rs file lives. The
|
||||
// current directory is used to find the sources.
|
||||
|
||||
|
||||
use std::env;
|
||||
use std::process;
|
||||
|
||||
fn main() {
|
||||
let out_dir = env::var("OUT_DIR").expect("The OUT_DIR environment variable must be set");
|
||||
|
||||
println!("Build script generating files in {}", out_dir);
|
||||
|
||||
let cur_dir = env::current_dir().expect("Can't access current working directory");
|
||||
let crate_dir = cur_dir.as_path();
|
||||
|
||||
// Scripts are in `$crate_dir/meta`.
|
||||
let meta_dir = crate_dir.join("meta");
|
||||
let build_script = meta_dir.join("build.py");
|
||||
|
||||
// Launch build script with Python. We'll just find python in the path.
|
||||
let status = process::Command::new("python")
|
||||
.current_dir(crate_dir)
|
||||
.arg(build_script)
|
||||
.arg("--out-dir")
|
||||
.arg(out_dir)
|
||||
.status()
|
||||
.expect("Failed to launch second-level build script");
|
||||
if !status.success() {
|
||||
process::exit(status.code().unwrap());
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,13 @@
|
||||
authors = ["The Cretonne Project Developers"]
|
||||
name = "filecheck"
|
||||
version = "0.0.0"
|
||||
description = "Library for matching test outputs against filecheck directives"
|
||||
license = "Apache-2.0"
|
||||
repository = "https://github.com/stoklund/cretonne"
|
||||
publish = false
|
||||
|
||||
[lib]
|
||||
name = "filecheck"
|
||||
path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
regex = "0.1.71"
|
||||
15
lib/reader/Cargo.toml
Normal file
15
lib/reader/Cargo.toml
Normal file
@@ -0,0 +1,15 @@
|
||||
[package]
|
||||
authors = ["The Cretonne Project Developers"]
|
||||
name = "cretonne-reader"
|
||||
version = "0.0.0"
|
||||
description = "Cretonne textual IL reader"
|
||||
license = "Apache-2.0"
|
||||
documentation = "https://cretonne.readthedocs.io/"
|
||||
repository = "https://github.com/stoklund/cretonne"
|
||||
publish = false
|
||||
|
||||
[lib]
|
||||
name = "cton_reader"
|
||||
|
||||
[dependencies]
|
||||
cretonne = { path = "../cretonne" }
|
||||
@@ -1,46 +0,0 @@
|
||||
|
||||
// Build script.
|
||||
//
|
||||
// This program is run by Cargo when building libcretonne. It is used to generate Rust code from
|
||||
// the language definitions in the meta directory.
|
||||
//
|
||||
// Environment:
|
||||
//
|
||||
// OUT_DIR
|
||||
// Directory where generated files should be placed.
|
||||
//
|
||||
// The build script expects to be run from the directory where this build.rs file lives. The
|
||||
// current directory is used to find the sources.
|
||||
|
||||
|
||||
use std::env;
|
||||
use std::process;
|
||||
|
||||
fn main() {
|
||||
let out_dir = env::var("OUT_DIR").expect("The OUT_DIR environment variable must be set");
|
||||
|
||||
println!("Build script generating files in {}", out_dir);
|
||||
|
||||
let mut cur_dir = env::current_dir().expect("Can't access current working directory");
|
||||
|
||||
// We're in src/libcretonne. Find the top-level directory.
|
||||
assert!(cur_dir.pop(), "No parent 'src' directory");
|
||||
assert!(cur_dir.pop(), "No top-level directory");
|
||||
let top_dir = cur_dir.as_path();
|
||||
|
||||
// Scripts are in $top_dir/meta.
|
||||
let meta_dir = top_dir.join("lib/cretonne/meta");
|
||||
let build_script = meta_dir.join("build.py");
|
||||
|
||||
// Launch build script with Python. We'll just find python in the path.
|
||||
let status = process::Command::new("python")
|
||||
.current_dir(top_dir)
|
||||
.arg(build_script)
|
||||
.arg("--out-dir")
|
||||
.arg(out_dir)
|
||||
.status()
|
||||
.expect("Failed to launch second-level build script");
|
||||
if !status.success() {
|
||||
process::exit(status.code().unwrap());
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
[package]
|
||||
authors = ["The Cretonne Project Developers"]
|
||||
name = "cretonne-reader"
|
||||
version = "0.0.0"
|
||||
publish = false
|
||||
|
||||
[lib]
|
||||
name = "cton_reader"
|
||||
path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
cretonne = { path = "../libcretonne" }
|
||||
@@ -10,9 +10,9 @@ name = "cton-util"
|
||||
path = "main.rs"
|
||||
|
||||
[dependencies]
|
||||
cretonne = { path = "../libcretonne" }
|
||||
cretonne-reader = { path = "../libreader" }
|
||||
filecheck = { path = "../libfilecheck" }
|
||||
cretonne = { path = "../../lib/cretonne" }
|
||||
cretonne-reader = { path = "../../lib/reader" }
|
||||
filecheck = { path = "../../lib/filecheck" }
|
||||
docopt = "0.6.80"
|
||||
rustc-serialize = "0.3.19"
|
||||
num_cpus = "1.1.0"
|
||||
|
||||
Reference in New Issue
Block a user