Repository: lucy
Updated Branches:
  refs/heads/master 8576b7418 -> 0959ad9d3


Regenerate charmonizer.c for pattern rules fix

Fixes LUCY-309.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/26d3c773
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/26d3c773
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/26d3c773

Branch: refs/heads/master
Commit: 26d3c773fc2784ef6f45eac622e4d99af63a5476
Parents: 8576b74
Author: Nick Wellnhofer <[email protected]>
Authored: Thu Sep 29 16:29:11 2016 +0200
Committer: Nick Wellnhofer <[email protected]>
Committed: Thu Sep 29 16:29:11 2016 +0200

----------------------------------------------------------------------
 common/charmonizer.c | 39 +++++++++++++++++++++++++++++++--------
 1 file changed, 31 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/26d3c773/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/common/charmonizer.c b/common/charmonizer.c
index 652f3f3..f74a45f 100644
--- a/common/charmonizer.c
+++ b/common/charmonizer.c
@@ -4567,9 +4567,10 @@ typedef struct {
 static struct {
     char *make_command;
     int   shell_type;
+    int   supports_pattern_rules;
 } chaz_Make = {
     NULL,
-    0
+    0, 0
 };
 
 /* Detect make command.
@@ -4695,7 +4696,12 @@ S_chaz_Make_detect(const char *make1, ...) {
     va_list args;
     const char *candidate;
     int found = 0;
-    const char makefile_content[] = "foo:\n\t@echo 643490c943525d19\n";
+    const char makefile_content[] =
+        "foo:\n"
+        "\t@echo 643490c943525d19\n"
+        "\n"
+        "%.ext:\n"
+        "\t@echo 8f4ef20576b070d5\n";
     chaz_Util_write_file("_charm_Makefile", makefile_content);
 
     /* Audition candidates. */
@@ -4727,12 +4733,28 @@ S_chaz_Make_audition(const char *make) {
         free(content);
     }
     chaz_Util_remove_and_verify("_charm_foo");
+    free(command);
 
     if (succeeded) {
         chaz_Make.make_command = chaz_Util_strdup(make);
+
+        command = chaz_Util_join(" ", make, "-f", "_charm_Makefile", "foo.ext",
+                                 NULL);
+        chaz_OS_run_redirected(command, "_charm_foo");
+        if (chaz_Util_can_open_file("_charm_foo")) {
+            size_t len;
+            char *content = chaz_Util_slurp_file("_charm_foo", &len);
+            if (content != NULL
+                && strstr(content, "8f4ef20576b070d5") != NULL
+               ) {
+                chaz_Make.supports_pattern_rules = 1;
+            }
+            free(content);
+        }
+        chaz_Util_remove_and_verify("_charm_foo");
+        free(command);
     }
 
-    free(command);
     return succeeded;
 }
 
@@ -5186,11 +5208,12 @@ S_chaz_MakeFile_write_binary_rules(chaz_MakeFile *self,
 
     /* Write rules to compile with custom flags. */
     if (cflags[0] != '\0') {
-        if (chaz_Make.shell_type == CHAZ_OS_CMD_EXE) {
-            /* Write a rule for each object file. This is needed for nmake
-             * which doesn't support pattern rules but also for mingw32-make
-             * which has problems with pattern rules and backslash directory
-             * separators.
+        if (!chaz_Make.supports_pattern_rules
+            || chaz_Make.shell_type == CHAZ_OS_CMD_EXE) {
+            /* Write a rule for each object file. This is needed for make
+             * utilities that don't support pattern rules but also for
+             * mingw32-make which has problems with pattern rules and
+             * backslash directory separators.
              */
             S_chaz_MakeFile_write_object_rules(binary->sources, cflags, out);
         }

Reply via email to