Start PoC of pas2rust conversion routine
authorunc0rr
Tue, 11 Apr 2023 09:30:56 +0200
changeset 15951 5aed6c0b63e2
parent 15950 77f1973611ec
child 15952 28b692ef6f15
Start PoC of pas2rust conversion routine
tools/rc/convert.sh
tools/rc/to_f64.rs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/rc/convert.sh	Tue Apr 11 09:30:56 2023 +0200
@@ -0,0 +1,20 @@
+#!/usr/bin/env sh
+
+ls ../rc || exit
+
+rm -rdfv build engine
+mkdir -p build engine
+cd build
+cmake -DNOSERVER=on -DBUILD_ENGINE_C=on -DLUA_SYSTEM=on -DNOVIDEOREC=off ../../../
+cmake --build . --target engine_c
+
+# this one you can get from pip: pip install scan-build
+intercept-build cmake --build . --target hwengine
+c2rust transpile --emit-build-files --emit-modules --reduce-type-annotations --binary hwengine compile_commands.json --output-dir=../engine
+
+cd ../engine
+sed -i 's/f128.*//g' Cargo.toml
+sed -i 's/extern crate f128.*//g' lib.rs
+sed -i 's/mod src {/mod src{\npub mod to_f64;/g' lib.rs
+find -type f -name '*.rs' -exec sed -i 's/f128/f64/g' {} \; -exec sed -i 's/f64::f64/f64/g' {} \; -exec sed -i 's/use ::f64;/use crate::src::to_f64::to_f64;/g' {} \; -exec sed -i 's/f64::new/to_f64/g' {} \;
+cp ../to_f64.rs src/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/rc/to_f64.rs	Tue Apr 11 09:30:56 2023 +0200
@@ -0,0 +1,4 @@
+pub fn to_f64<T: Into<f64>>(v: T) -> f64 {
+    v.into()
+}
+