Skip to content

Commit aec941d

Browse files
committed
build fix; whole api chain works, just need to make it more useful now
1 parent a94e974 commit aec941d

File tree

6 files changed

+33
-5
lines changed

6 files changed

+33
-5
lines changed

crackers/src/synthesis/assignment_model.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ impl<'ctx, T: ModelingContext<'ctx>> AssignmentModel<'ctx, T> {
6363

6464
impl<'ctx, T: ModelingContext<'ctx> + Display> Display for AssignmentModel<'ctx, T> {
6565
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
66-
dbg!("hello");
6766
writeln!(f, "Gadgets:\n")?;
6867
for block in &self.gadgets {
6968
writeln!(f, "{}\n", block)?;

crackers/src/synthesis/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use jingle::modeling::{ModeledBlock, ModeledInstruction, ModelingContext};
1+
use jingle::modeling::{ModeledBlock, ModeledInstruction, ModelingContext, State};
22
use jingle::sleigh::Instruction;
33
use jingle::JingleContext;
44
use std::cmp::Ordering;
@@ -183,7 +183,6 @@ impl<'ctx> AssignmentSynthesis<'ctx> {
183183
"Theory returned SAT for {:?}!",
184184
response.assignment
185185
);
186-
dbg!("Terminating remaining workers");
187186
req_channels.clear();
188187
for x in &kill_senders {
189188
x.send(()).unwrap();
@@ -193,11 +192,11 @@ impl<'ctx> AssignmentSynthesis<'ctx> {
193192
let jingle = JingleContext::new(self.z3, self.library.as_ref());
194193
let a: PcodeAssignment<'ctx> =
195194
t.build_assignment(&jingle, response.assignment)?;
196-
dbg!("Workers Terminated; building and checking model");
195+
event!(Level::DEBUG, "Workers Terminated; building and checking model");
197196
let solver = Solver::new(self.z3);
198197
let jingle = JingleContext::new(self.z3, self.library.as_ref());
199198
let model = a.check(&jingle, &solver)?;
200-
dbg!("Model built");
199+
event!(Level::DEBUG, "Model built");
201200
return Ok(DecisionResult::AssignmentFound(model));
202201
}
203202
Some(c) => {

crackers_python/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ pyo3 = { version = "0.24", features = ["extension-module", "py-clone"] }
1313
crackers = {path = "../crackers", features = ["pyo3"]}
1414
jingle = {git = "https://github.com/toolCHAINZ/jingle.git", branch = "main", features = ["pyo3"]}
1515
toml_edit = "0.22.22"
16+
z3 = { git = "https://github.com/toolCHAINZ/z3.rs.git", branch = "patch-1" }
1617

1718
[dev-dependencies]
1819
pyo3 = { version = "0.24", features = ["extension-module"] }
20+
z3 = { git = "https://github.com/toolCHAINZ/z3.rs.git", branch = "patch-1" }

crackers_python/build.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use std::process::Command;
2+
3+
fn main() {
4+
// Run the Python script to get the venv's lib directory
5+
let output = Command::new("python3")
6+
.arg("find_venv_library_path.py")
7+
.output()
8+
.expect("Failed to execute Python script");
9+
10+
if !output.status.success() {
11+
panic!("cargo:warning=Could not find python's z3, this wheel is unlikely to work.");
12+
} else {
13+
let venv_lib = String::from_utf8_lossy(&output.stdout).trim().to_string();
14+
let z3_python_lib = std::path::Path::new(&venv_lib).join("z3").join("lib");
15+
println!("cargo:rustc-link-search=native={}", z3_python_lib.display());
16+
}
17+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import sys
2+
import os
3+
import sysconfig
4+
5+
# Get the virtual environment's lib directory
6+
venv_lib = sysconfig.get_paths()["purelib"]
7+
8+
# Print the path so that we can capture it in build.rs
9+
print(venv_lib)

crackers_python/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ use ::crackers::config::synthesis::SynthesisConfig;
1414
use ::crackers::gadget::library::builder::GadgetLibraryConfig;
1515
use ::crackers::synthesis::builder::SynthesisSelectionStrategy;
1616
use pyo3::prelude::*;
17+
use std::ffi::CString;
1718

1819
/// A Python module implemented in Rust.
1920
#[pymodule]
2021
fn crackers(m: &Bound<'_, PyModule>) -> PyResult<()> {
22+
m.py().run(&CString::new("import z3")?, None, None)?;
2123
m.add_class::<PythonCrackersConfig>()?;
2224
m.add_class::<MetaConfig>()?;
2325
m.add_class::<SpecificationConfig>()?;

0 commit comments

Comments
 (0)