Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
amousset committed Dec 24, 2024
1 parent 389dab4 commit dba9a00
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
25 changes: 19 additions & 6 deletions raugeas_src/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
use std::env;
use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;

/// Information about the locations of files generated by `build()`.
///
/// After the jq sources have been compiled, the fields in this struct
/// represent where the various files ended up, and what sort of build was
/// done (ie, static or dynamic).
pub struct Artifacts {
include_dir: PathBuf,
lib_dir: PathBuf,
Expand All @@ -20,7 +17,10 @@ impl Artifacts {
pub fn print_cargo_metadata(&self) {
println!("cargo:include={}", self.include_dir.display());
println!("cargo:rustc-link-search=native={}", self.lib_dir.display());
println!("cargo:rustc-link-lib=static={}", "augeas");
println!("cargo:rustc-link-lib=static=augeas");
println!("cargo:rustc-link-lib=static=fa");
println!("cargo:rustc-link-lib=static=xml2");
// println!("cargo:rustc-link-lib=static=lfl");
}
pub fn include_dir(&self) -> &Path {
&self.include_dir
Expand All @@ -38,8 +38,21 @@ pub fn build() -> Result<Artifacts, String> {

let augeas_dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("augeas");

// Bootstrap needs to run from the submodule dir as it uses git
// FIXME: autobootstrap does not work
/*let bootstrap_res = Command::new("./bootstrap")
.current_dir(&augeas_dir)
.status()
.expect("failed to execute bootstrap");
if !bootstrap_res.success() {
return Err("Bootstrap failed".to_string());
}*/

// Build in a clean dir
//prepare_sources(&augeas_dir, &build_dir);

autotools::Config::new(&augeas_dir)
.reconf("-iv")
.reconf("-ifv")
.out_dir(&out_dir)
.enable_static()
.disable_shared()
Expand Down
1 change: 1 addition & 0 deletions raugeas_src/testcrate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.1.0"
authors = ["Alexis Mousset <[email protected]>"]
links = "augeas"
build = "build.rs"
edition = "2021"

[build-dependencies]
raugeas_src = { path = ".." }
13 changes: 7 additions & 6 deletions raugeas_sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#[cfg(feature = "bundled")]
extern crate augeas_src;
extern crate bindgen;
#[cfg(feature = "pkg-config")]
extern crate pkg_config;
#[cfg(feature = "bundled")]
extern crate raugeas_src;

use std::env;
use std::path::{PathBuf};
use std::path::PathBuf;

#[cfg(feature = "bundled")]
fn build_bundled() -> Vec<String> {
let artifacts = augeas_src::build().expect("autotools build");
let artifacts = raugeas_src::build().expect("autotools build");
artifacts.print_cargo_metadata();
vec![artifacts.include_dir().to_str().unwrap().to_string()]
}
Expand All @@ -21,10 +21,11 @@ fn build_shared() -> Vec<String> {
.probe("augeas")
.unwrap();

augeas
augeas
.include_paths
.iter()
.map(|path| format!("-I{}", path.display())).collect()
.map(|path| format!("-I{}", path.display()))
.collect()
}

fn main() {
Expand Down

0 comments on commit dba9a00

Please sign in to comment.