From 8584e7e95d7f4e7042a42c01cd791e46380752ae Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@factorcode.org>
Date: Sat, 3 Nov 2007 15:42:30 -0400
Subject: [PATCH] Deploy tool can now strip out libc debugging

---
 extra/tools/deploy/deploy.factor            |  4 ++--
 extra/tools/deploy/shaker/shaker.factor     | 15 +++++++++++++--
 extra/tools/deploy/shaker/strip-libc.factor |  8 ++++++++
 3 files changed, 23 insertions(+), 4 deletions(-)
 create mode 100644 extra/tools/deploy/shaker/strip-libc.factor

diff --git a/extra/tools/deploy/deploy.factor b/extra/tools/deploy/deploy.factor
index 2832551a34..c11b41e09c 100644
--- a/extra/tools/deploy/deploy.factor
+++ b/extra/tools/deploy/deploy.factor
@@ -37,8 +37,8 @@ IN: tools.deploy
         ""
         deploy-math? get " math" ?append
         deploy-compiler? get " compiler" ?append
-        native-io? " io" ?append
         deploy-ui? get " ui" ?append
+        native-io? " io" ?append
     ] bind ;
 
 : deploy-command-line ( vm image vocab config -- vm flags )
@@ -49,7 +49,7 @@ IN: tools.deploy
 
         "\"-output-image=" swap "\"" 3append ,
 
-        "-no-stack-traces" ,
+        ! "-no-stack-traces" ,
         
         "-no-user-init" ,
     ] { } make ;
diff --git a/extra/tools/deploy/shaker/shaker.factor b/extra/tools/deploy/shaker/shaker.factor
index 4531a88011..4b20c3f0ee 100644
--- a/extra/tools/deploy/shaker/shaker.factor
+++ b/extra/tools/deploy/shaker/shaker.factor
@@ -5,7 +5,7 @@ assocs kernel vocabs words sequences memory io system arrays
 continuations math definitions mirrors splitting parser classes
 inspector layouts vocabs.loader prettyprint.config prettyprint
 debugger io.streams.c io.streams.duplex io.files io.backend
-quotations words.private tools.deploy.config ;
+quotations words.private tools.deploy.config compiler ;
 IN: tools.deploy.shaker
 
 : show ( msg -- )
@@ -23,6 +23,15 @@ IN: tools.deploy.shaker
         "Stripping debugger" show
         "resource:extra/tools/deploy/shaker/strip-debugger.factor"
         run-file
+        recompile
+    ] when ;
+
+: strip-libc ( -- )
+    "libc" vocab [
+        "Stripping manual memory management debug code" show
+        "resource:extra/tools/deploy/shaker/strip-libc.factor"
+        run-file
+        recompile
     ] when ;
 
 : strip-cocoa ( -- )
@@ -30,6 +39,7 @@ IN: tools.deploy.shaker
         "Stripping unused Cocoa methods" show
         "resource:extra/tools/deploy/shaker/strip-cocoa.factor"
         run-file
+        recompile
     ] when ;
 
 : strip-assoc ( retained-keys assoc -- newassoc )
@@ -126,7 +136,7 @@ SYMBOL: deploy-vocab
             } %
         ] unless
 
-        deploy-c-types? get deploy-ui? get or [
+        deploy-c-types? get [
             "c-types" "alien.c-types" lookup ,
         ] when
 
@@ -141,6 +151,7 @@ SYMBOL: deploy-vocab
     ] { } make dup . ;
 
 : strip ( -- )
+    strip-libc
     strip-cocoa
     strip-debugger
     strip-init-hooks
diff --git a/extra/tools/deploy/shaker/strip-libc.factor b/extra/tools/deploy/shaker/strip-libc.factor
new file mode 100644
index 0000000000..f62b4b5935
--- /dev/null
+++ b/extra/tools/deploy/shaker/strip-libc.factor
@@ -0,0 +1,8 @@
+USING: libc.private ;
+IN: libc
+
+: malloc (malloc) ;
+
+: free (free) ;
+
+: realloc (realloc) ;