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:
Jakob Stoklund Olesen
2016-10-17 14:44:43 -07:00
parent e7f30a40b4
commit 0764df28b5
52 changed files with 64 additions and 64 deletions

View File

@@ -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
View 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());
}
}

View File

@@ -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
View 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" }

View File

@@ -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());
}
}

View File

@@ -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" }

View File

@@ -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"