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 2013/02/12 23:21:06 UTC

[lucy-commits] [2/3] git commit: refs/heads/c-bindings-cfc - Fix Windows build

Fix Windows build


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

Branch: refs/heads/c-bindings-cfc
Commit: 074a99761c4abfaa98df9231966cd0fce56a9bac
Parents: 369a995
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Tue Feb 12 22:13:58 2013 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue Feb 12 23:03:17 2013 +0100

----------------------------------------------------------------------
 charmonizer/src/Charmonizer/Core/Make.c    |   30 +++++++++++++++++-----
 clownfish/compiler/common/charmonizer.main |    9 ++++++-
 clownfish/compiler/src/CFCUtil.c           |    6 ----
 3 files changed, 31 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/074a9976/charmonizer/src/Charmonizer/Core/Make.c
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Core/Make.c b/charmonizer/src/Charmonizer/Core/Make.c
index a005d73..3470af1 100644
--- a/charmonizer/src/Charmonizer/Core/Make.c
+++ b/charmonizer/src/Charmonizer/Core/Make.c
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <ctype.h>
 #include <string.h>
 #include "Charmonizer/Core/Make.h"
 #include "Charmonizer/Core/Compiler.h"
@@ -324,7 +325,7 @@ chaz_MakeFile_write(chaz_MakeFile *makefile) {
             fprintf(file, "clean :\n");
             for (i = 0; makefile->cleanups[i]; i++) {
                 const char *cleanup = makefile->cleanups[i];
-                fprintf(file, "\tfor %%i in (%s) do if exist %%i del /f %%i\n",
+                fprintf(file, "\tfor %%i in (%s) do @if exist %%i del /f %%i\n",
                         cleanup);
             }
             fprintf(file, "\n");
@@ -336,17 +337,28 @@ chaz_MakeFile_write(chaz_MakeFile *makefile) {
 
     fprintf(file, "distclean : clean\n");
     if (shell_type == CHAZ_OS_POSIX) {
-        fprintf(file, "\trm -f charmonizer charmony.h Makefile\n\n");
+        fprintf(file, "\trm -f charmonizer$(EXE_EXT) charmony.h Makefile\n\n");
     }
     else if (shell_type == CHAZ_OS_CMD_EXE) {
         fprintf(file,
-            "\tfor %%i in (charmonizer charmony.h Makefile) do"
-            " if exist %%i del /f %%i\n\n");
+            "\tfor %%i in (charmonizer$(EXE_EXT) charmonizer$(OBJ_EXT)"
+            " charmony.h Makefile) do @if exist %%i del /f %%i\n\n");
     }
     else {
         chaz_Util_die("Unsupported shell type: %d", shell_type);
     }
 
+    if (chaz_Make.is_nmake) {
+        /* Inference rule for .c files. */
+        fprintf(file, ".c.obj :\n");
+        if (chaz_CC_msvc_version_num()) {
+            fprintf(file, "\t$(CC) $(CFLAGS) /c $< /Fo$@\n\n");
+        }
+        else {
+            fprintf(file, "\t$(CC) $(CFLAGS) -c $< -o $@\n\n");
+        }
+    }
+
     fclose(file);
 }
 
@@ -520,7 +532,7 @@ chaz_Make_list_files(const char *dir, const char *ext,
          * path of the directory. This is done by using the variable
          * substitution feature of the 'for' command.
          */
-        pattern = "for %%I in (%s) do echo %%~fI";
+        pattern = "for %%I in (%s) do @echo %%~fI";
         command_size = strlen(pattern) + strlen(dir) + 10;
         command = (char*)malloc(command_size);
         sprintf(command, pattern, dir);
@@ -528,7 +540,10 @@ chaz_Make_list_files(const char *dir, const char *ext,
         free(command);
         if (!output) { chaz_Util_die("Failed to find absolute path"); }
 
-        prefix_len = strcspn(output, "\r\n");
+        /* Strip whitespace from end of output. */
+        for (prefix_len = output_len; prefix_len > 0; --prefix_len) {
+            if (!isspace(output[prefix_len-1])) { break; }
+        }
         prefix = (char*)malloc(prefix_len + 2);
         memcpy(prefix, output, prefix_len);
         prefix[prefix_len++] = '\\';
@@ -542,7 +557,8 @@ chaz_Make_list_files(const char *dir, const char *ext,
         if (strlen(file) <= prefix_len
             || memcmp(file, prefix, prefix_len) != 0
            ) {
-            chaz_Util_die("Unexpected file name");
+            chaz_Util_die("Expected prefix '%s' for file name '%s'", prefix,
+                          file);
         }
 
         callback(file + prefix_len, context);

http://git-wip-us.apache.org/repos/asf/lucy/blob/074a9976/clownfish/compiler/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/clownfish/compiler/common/charmonizer.main b/clownfish/compiler/common/charmonizer.main
index 4e9b028..4b45c3a 100644
--- a/clownfish/compiler/common/charmonizer.main
+++ b/clownfish/compiler/common/charmonizer.main
@@ -23,7 +23,11 @@
 #include "Charmonizer/Probe.h"
 #include "Charmonizer/Probe/Integers.h"
 
-#define DIR_SEP "/"
+#if defined(_WIN32) && !defined(__CYGWIN__)
+  #define DIR_SEP "\\"
+#else
+  #define DIR_SEP "/"
+#endif
 
 typedef struct SourceFileContext {
     chaz_MakeVar *common_objs;
@@ -134,6 +138,9 @@ S_write_makefile() {
 
     chaz_MakeFile_add_var(makefile, "CC", chaz_CC_get_cc());
 
+    if (chaz_CC_msvc_version_num()) {
+        chaz_CC_add_extra_cflags("/nologo");
+    }
     chaz_CC_set_optimization_level("2");
     chaz_CC_add_include_dir(".");
     chaz_CC_add_include_dir("$(INCLUDE_DIR)");

http://git-wip-us.apache.org/repos/asf/lucy/blob/074a9976/clownfish/compiler/src/CFCUtil.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCUtil.c b/clownfish/compiler/src/CFCUtil.c
index c373382..7d8f7a5 100644
--- a/clownfish/compiler/src/CFCUtil.c
+++ b/clownfish/compiler/src/CFCUtil.c
@@ -335,12 +335,6 @@ CFCUtil_make_path(const char *path) {
     size_t orig_len = strlen(target);
     size_t len = orig_len;
     for (size_t i = 0; i <= len; i++) {
-#ifndef WIN32
-        if (target[i] == '\\') {
-            i++;
-            continue;
-        }
-#endif
         if (target[i] == CHY_DIR_SEP_CHAR || i == len) {
             target[i] = 0; // NULL-terminate.
             struct stat stat_buf;