You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2016/09/30 15:39:55 UTC

lucy-charmonizer git commit: Add feature test for Makefile pattern rules

Repository: lucy-charmonizer
Updated Branches:
  refs/heads/master 26c6577ea -> 508ca633e


Add feature test for Makefile pattern rules


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

Branch: refs/heads/master
Commit: 508ca633e8f2b173be1b1e138440859362518c7a
Parents: 26c6577
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Sep 30 17:36:49 2016 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Fri Sep 30 17:36:49 2016 +0200

----------------------------------------------------------------------
 src/Charmonizer/Core/Make.c | 39 +++++++++++++++++++++++++++++++--------
 1 file changed, 31 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/508ca633/src/Charmonizer/Core/Make.c
----------------------------------------------------------------------
diff --git a/src/Charmonizer/Core/Make.c b/src/Charmonizer/Core/Make.c
index 3240ff5..9c4722b 100644
--- a/src/Charmonizer/Core/Make.c
+++ b/src/Charmonizer/Core/Make.c
@@ -79,9 +79,10 @@ typedef struct {
 static struct {
     char *make_command;
     int   shell_type;
+    int   supports_pattern_rules;
 } chaz_Make = {
     NULL,
-    0
+    0, 0
 };
 
 /* Detect make command.
@@ -207,7 +208,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. */
@@ -239,12 +245,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;
 }
 
@@ -698,11 +720,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);
         }