Procházet zdrojové kódy

(#35) Pass command line args to second phase of GO_REBUILD_URSELF

rexim před 4 roky
rodič
revize
a1a74d424d
1 změnil soubory, kde provedl 18 přidání a 12 odebrání
  1. 18 12
      nobuild.h

+ 18 - 12
nobuild.h

@@ -210,18 +210,24 @@ void chain_echo(Chain chain);
 #endif
 
 // NOTE: The implementation idea is stolen from https://github.com/zhiayang/nabs
-#define GO_REBUILD_URSELF(argc, argv)                           \
-    do {                                                        \
-        const char *source_path = __FILE__;                     \
-        assert(argc >= 1);                                      \
-        const char *binary_path = argv[0];                      \
-                                                                \
-        if (is_path1_modified_after_path2(source_path, binary_path)) {  \
-            RENAME(binary_path, CONCAT(binary_path, ".old"));   \
-            REBUILD_URSELF(binary_path, source_path);           \
-            CMD(binary_path);                                   \
-            exit(0);                                            \
-        }                                                       \
+#define GO_REBUILD_URSELF(argc, argv)                                  \
+    do {                                                               \
+        const char *source_path = __FILE__;                            \
+        assert(argc >= 1);                                             \
+        const char *binary_path = argv[0];                             \
+                                                                       \
+        if (is_path1_modified_after_path2(source_path, binary_path)) { \
+            RENAME(binary_path, CONCAT(binary_path, ".old"));          \
+            REBUILD_URSELF(binary_path, source_path);                  \
+            Cmd cmd = {                                                \
+                .line = {                                              \
+                    .elems = (Cstr*) argv,                             \
+                    .count = argc,                                     \
+                },                                                     \
+            };                                                         \
+            cmd_run_sync(cmd);                                         \
+            exit(0);                                                   \
+        }                                                              \
     } while(0)
 
 void rebuild_urself(const char *binary_path, const char *source_path);