Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gpr and its dependencies to 24.0 #8

Merged
merged 3 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gpr"
version = "0.1.2"
version = "0.1.3"
edition = "2021"
authors = ["Johannes Kliemann <jk@jkliemann.de"]
description = "Libgpr binding for Rust. Provides an easy way to build Ada projects with cargo."
Expand All @@ -19,7 +19,7 @@ thiserror = "1.0"
lazy_static = "1.4.0"

[dev-dependencies]
libloading = "0.5"
libloading = "0.8"

[build-dependencies]
git2 = "0.14"
git2 = "0.18"
5 changes: 4 additions & 1 deletion alire.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ authors = ["Johannes Kliemann"]
maintainers = ["Johannes Kliemann <jk@jkliemann.de>"]
maintainers-logins = ["jklmnn"]
[[depends-on]]
libgpr2 = "^23.0.0"
gnatcoll = "^24.0.0"
gnatcoll_gmp = "^24.0.0"
gnatcoll_iconv = "^24.0.0"
xmlada = "^24.0.0"
53 changes: 37 additions & 16 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ use git2::{ErrorCode, Repository, ResetType};
use std::{collections::HashMap, env, ffi::OsStr, path::Path, process::Command};

const GPR2_GIT: &str = "https://github.com/AdaCore/gpr.git";
const GPR2_REV: &str = "814f4654598dbc98db16dc47fb0e9f5cdeea4182";
const GPR2_REV: &str = "965de290e8caebb47d18b00e2c4638b4e36884ed";
const LANGKIT_GIT: &str = "https://github.com/AdaCore/langkit.git";
const LANGKIT_REV: &str = "a638facb03edb4baefdf8f1819db4ca56f191a5b";
const LANGKIT_REV: &str = "694c2b902d233139f8188df17b59fcca02a06887";
const GPRCONFIG_KB_GIT: &str = "https://github.com/AdaCore/gprconfig_kb.git";
const GPRCONFIG_KB_REV: &str = "923c46ba4f0831d21dee4cd3d1179055e121de6c";
const GPRCONFIG_KB_REV: &str = "b732437d7828ae83fbdc549bd5e145703e8282cd";
const ADASAT_GIT: &str = "https://github.com/AdaCore/AdaSAT.git";
const ADASAT_REV: &str = "f948e2271aec51f9313fa41ff3c00230a483f9e8";

fn checkout(url: &str, rev: &str, path: &Path) {
let path = path.to_str().unwrap();
Expand Down Expand Up @@ -53,15 +55,14 @@ where
output.current_dir(d.to_str().unwrap());
}
let output = output.args(args).output().unwrap();
let stdout = String::from_utf8(output.stdout).unwrap();
let stderr = String::from_utf8(output.stderr).unwrap();
println!("{}", &stdout);
println!("{}", &stderr);
if !output.status.success() && panic_on_fail {
println!("{}", String::from_utf8(output.stdout).unwrap());
panic!(
"failed to run command: {} {}",
cmd,
String::from_utf8(output.stderr).unwrap()
);
panic!("failed to run command: {} {}", cmd, &stderr,);
}
String::from_utf8(output.stdout).unwrap()
stdout
}

fn main() {
Expand All @@ -76,6 +77,7 @@ fn main() {
);
let langkit_path = contrib.join("langkit");
let gprconfig_kb_path = contrib.join("gprconfig_kb");
let adasat_path = langkit_path.join("langkit").join("adasat");
let venv_path = contrib.join("venv");
checkout(GPR2_GIT, GPR2_REV, gpr_path.as_path());
checkout(LANGKIT_GIT, LANGKIT_REV, langkit_path.as_path());
Expand All @@ -84,9 +86,11 @@ fn main() {
GPRCONFIG_KB_REV,
gprconfig_kb_path.as_path(),
);
checkout(ADASAT_GIT, ADASAT_REV, adasat_path.as_path());
let mut envs: HashMap<String, String> = env::vars()
.filter(|e| !e.0.ends_with("ALIRE_PREFIX"))
.collect();
let _ = call("alr", &envs, None, ["index", "--update-all"], true);
let alire_path = out_dir.join("gpr_rust_alire");
if !alire_path.join("alire.toml").exists() {
let _ = call(
Expand All @@ -101,14 +105,26 @@ fn main() {
"alr",
&envs,
Some(&alire_path),
["--no-tty", "-n", "with", "libgpr2"],
[
"--no-tty",
"-n",
"with",
"gnatcoll=24.0.0",
"gnatcoll_iconv=24.0.0",
"gnatcoll_gmp=24.0.0",
"xmlada=24.0.0",
],
false,
);
//FIXME: This should be alr update however alire 2.0
// does not run post_fetch on alr update which breaks
// xmlada.
// alire-project/alire#1235
let _ = call(
"alr",
&envs,
Some(&alire_path),
["--no-tty", "-n", "update"],
["--no-tty", "-n", "build", "--", "-cargs", "-fPIC"],
true,
);
let env_output = call(
Expand Down Expand Up @@ -166,14 +182,17 @@ fn main() {
let mut gprconfig_db_path = String::from("GPR2KBDIR=");
gprconfig_db_path.push_str(gprconfig_kb_path.join("db").as_path().to_str().unwrap());
let mut gpr_project_path = langkit_path.join("support").to_str().unwrap().to_owned();
gpr_project_path.push(':');
if let Ok(gpp) = env::var("GPR_PROJECT_PATH") {
gpr_project_path.push(':');
gpr_project_path.push_str(gpp.as_str());
envs.get_mut("GPR_PROJECT_PATH").unwrap().push(':');
envs.get_mut("GPR_PROJECT_PATH")
.unwrap()
.push_str(&gpr_project_path);
}
gpr_project_path.push(':');
gpr_project_path.push_str(gpr_path.to_str().unwrap());
envs.get_mut("GPR_PROJECT_PATH").unwrap().push(':');
envs.get_mut("GPR_PROJECT_PATH")
.unwrap()
.push_str(&gpr_project_path);
let _ = call(
"make",
&envs,
Expand Down Expand Up @@ -210,6 +229,8 @@ fn main() {
.to_str()
.unwrap(),
"-XGPR2_BUILD=release",
"-cargs",
"-fPIC",
],
true,
);
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,13 @@ mod tests {
.unwrap()
.wait()
.unwrap();
let test2 = lib::Library::new(format!(
"{}/lib{}.so",
prj.library_dir().unwrap().to_str().unwrap(),
prj.library_name().unwrap()
))
.unwrap();
unsafe {
let test2 = lib::Library::new(format!(
"{}/lib{}.so",
prj.library_dir().unwrap().to_str().unwrap(),
prj.library_name().unwrap()
))
.unwrap();
let test2init: lib::Symbol<unsafe extern "C" fn()> = test2.get(b"test2init").unwrap();
let test2final: lib::Symbol<unsafe extern "C" fn()> = test2.get(b"test2final").unwrap();
let test2_add: lib::Symbol<unsafe extern "C" fn(c_int, c_int) -> c_int> =
Expand Down
Loading