A backend for the p≡p Engine built on Sequoia.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.0 KiB

use std::env;
use std::fs::File;
use std::io::{Read, Write};
use std::path::PathBuf;
fn main() -> Result<(), std::io::Error> {
// Generate
// ${CARGO_TARGET_DIR}/${PROFILE}/pep_engine_sequoia_backend.pc from
// ${SRC}/pep_engine_sequoia_backend.pc.in.
// Location of pep_engine_sequoia_backend.pc.in.
let src = env::current_dir()?;
let mut pc_in = PathBuf::from(&src);
// Location of the build directory (e.g.,
// `/tmp/pep_engine_sequoia_backend/debug`).
let mut build_dir = PathBuf::from(&src);
if let Some(target_dir) = env::var_os("CARGO_TARGET_DIR") {
// If CARGO_TARGET_DIR is absolute, this will first clear pc.
let profile = env::var_os("PROFILE")
.expect("PROFILE not set");
// Location of pep_engine_sequoia_backend.pc.
let mut pc = build_dir.clone();
// Read the .pc.in file, do the substitutions, and generate the
// .pc file.
let mut pc_in = File::open(pc_in)?;
let mut content = Vec::new();
pc_in.read_to_end(&mut content)?;
// This is set to allow the use of the library from the build
// directory.
let content = String::from_utf8(content).unwrap()
.expect("build directory is not UTF-8 encoded"))
.expect("CARGO_PKG_VERSION not set")
.expect("CARGO_PKG_VERSION is not UTF-8 encoded"));
let mut pc = File::create(&pc).unwrap();
eprintln!("Generated {:?} with:\n{}\nEOF", pc, content);