Fix build with --clownfish-prefix on Windows

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

Branch: refs/heads/0.4
Commit: e43b48311f187ea832a3c4dc6df5f11cc02128dc
Parents: 8572510
Author: Nick Wellnhofer <wellnho...@aevum.de>
Authored: Sat Jul 25 15:30:43 2015 +0200
Committer: Nick Wellnhofer <wellnho...@aevum.de>
Committed: Sat Jul 25 15:30:43 2015 +0200

----------------------------------------------------------------------
 common/charmonizer.c    | 44 ++++++++++++++++++++++----------------------
 common/charmonizer.main | 38 ++++++++++++++++++--------------------
 2 files changed, 40 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/e43b4831/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/common/charmonizer.c b/common/charmonizer.c
index 516a04f..75490ac 100644
--- a/common/charmonizer.c
+++ b/common/charmonizer.c
@@ -784,7 +784,7 @@ chaz_MakeFile_add_lemon_grammar(chaz_MakeFile *makefile,
  * @param obj The object file.
  * @param cflags Compiler flags.
  */
-void
+chaz_MakeRule*
 chaz_MakeFile_override_cflags(chaz_MakeFile *makefile, const char *obj,
                               chaz_CFlags *cflags);
 
@@ -4881,7 +4881,7 @@ chaz_MakeFile_add_lemon_grammar(chaz_MakeFile *makefile,
     return rule;
 }
 
-void
+chaz_MakeRule*
 chaz_MakeFile_override_cflags(chaz_MakeFile *makefile, const char *obj,
                               chaz_CFlags *cflags) {
     const char *obj_ext       = chaz_CC_obj_ext();
@@ -4920,6 +4920,8 @@ chaz_MakeFile_override_cflags(chaz_MakeFile *makefile, 
const char *obj,
 
     free(command);
     free(src);
+
+    return rule;
 }
 
 void
@@ -8046,6 +8048,8 @@ S_write_makefile(struct chaz_CLI *cli) {
                                          "Json", "JsonParser", NULL);
     char *test_lucy_exe = chaz_Util_join("", "t", dir_sep, "test_lucy",
                                          exe_ext, NULL);
+    char *test_lucy_obj = chaz_Util_join("", "t", dir_sep, "test_lucy",
+                                         obj_ext, NULL);
 
     char *autogen_inc_dir
         = chaz_Util_join(dir_sep, "autogen", "include", NULL);
@@ -8217,35 +8221,29 @@ S_write_makefile(struct chaz_CLI *cli) {
     test_cflags = chaz_CC_new_cflags();
     chaz_CFlags_enable_optimization(test_cflags);
     chaz_CFlags_add_include_dir(test_cflags, autogen_inc_dir);
-    chaz_CFlags_add_library(test_cflags, lib);
+    rule = chaz_MakeFile_override_cflags(makefile, test_lucy_obj, test_cflags);
+    chaz_MakeRule_add_prereq(rule, autogen_target);
+    chaz_CFlags_destroy(test_cflags);
+
+    link_flags = chaz_CC_new_cflags();
+    chaz_CFlags_add_library(link_flags, lib);
     if (cfish_lib_dir) {
         chaz_CFlags_add_library_path(link_flags, cfish_lib_dir);
     }
-    chaz_CFlags_add_external_library(test_cflags, cfish_lib_name);
-    scratch = chaz_Util_join(dir_sep, "t", "test_lucy.c", NULL);
-    rule = chaz_MakeFile_add_compiled_exe(makefile, test_lucy_exe, scratch,
-                                          test_cflags);
-    free(scratch);
+    chaz_CFlags_add_external_library(link_flags, cfish_lib_name);
+    rule = chaz_MakeFile_add_exe(makefile, test_lucy_exe, test_lucy_obj,
+                                 link_flags);
     chaz_MakeRule_add_prereq(rule, lib_filename);
-    chaz_CFlags_destroy(test_cflags);
+    chaz_CFlags_destroy(link_flags);
 
     rule = chaz_MakeFile_add_rule(makefile, "test", test_lucy_exe);
-    if (strcmp(chaz_OS_shared_lib_ext(), ".so") == 0) {
-        if (cfish_lib_dir) {
-            test_command
-                = chaz_Util_join("", "LD_LIBRARY_PATH=.:", cfish_lib_dir,
-                                 ":$$LD_LIBRARY_PATH ", test_lucy_exe, NULL);
-        }
-        else {
-            test_command
-                = chaz_Util_join(" ", "LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH",
-                                 test_lucy_exe, NULL);
-        }
+    if (cfish_lib_dir) {
+        chaz_MakeRule_add_command_with_libpath(rule, test_lucy_exe, ".",
+                                              cfish_lib_dir, NULL);
     }
     else {
-        test_command = chaz_Util_strdup(test_lucy_exe);
+        chaz_MakeRule_add_command_with_libpath(rule, test_lucy_exe, ".", NULL);
     }
-    chaz_MakeRule_add_command(rule, test_command);
 
     if (chaz_CLI_defined(cli, "enable-coverage")) {
         rule = chaz_MakeFile_add_rule(makefile, "coverage", test_lucy_exe);
@@ -8285,6 +8283,7 @@ S_write_makefile(struct chaz_CLI *cli) {
         chaz_MakeRule_add_rm_command(clean_rule, "$(LUCY_OBJS)");
     }
 
+    chaz_MakeRule_add_rm_command(clean_rule, test_lucy_obj);
     chaz_MakeRule_add_recursive_rm_command(clean_rule, "autogen");
 
     if (chaz_CLI_defined(cli, "enable-coverage")) {
@@ -8307,6 +8306,7 @@ S_write_makefile(struct chaz_CLI *cli) {
     free(utf8proc_dir);
     free(json_parser);
     free(test_lucy_exe);
+    free(test_lucy_obj);
     free(autogen_inc_dir);
     free(autogen_target);
     free(snowstem_inc_dir);

http://git-wip-us.apache.org/repos/asf/lucy/blob/e43b4831/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/common/charmonizer.main b/common/charmonizer.main
index 66644d9..0ed7bc4 100644
--- a/common/charmonizer.main
+++ b/common/charmonizer.main
@@ -161,6 +161,8 @@ S_write_makefile(struct chaz_CLI *cli) {
                                          "Json", "JsonParser", NULL);
     char *test_lucy_exe = chaz_Util_join("", "t", dir_sep, "test_lucy",
                                          exe_ext, NULL);
+    char *test_lucy_obj = chaz_Util_join("", "t", dir_sep, "test_lucy",
+                                         obj_ext, NULL);
 
     char *autogen_inc_dir
         = chaz_Util_join(dir_sep, "autogen", "include", NULL);
@@ -332,35 +334,29 @@ S_write_makefile(struct chaz_CLI *cli) {
     test_cflags = chaz_CC_new_cflags();
     chaz_CFlags_enable_optimization(test_cflags);
     chaz_CFlags_add_include_dir(test_cflags, autogen_inc_dir);
-    chaz_CFlags_add_library(test_cflags, lib);
+    rule = chaz_MakeFile_override_cflags(makefile, test_lucy_obj, test_cflags);
+    chaz_MakeRule_add_prereq(rule, autogen_target);
+    chaz_CFlags_destroy(test_cflags);
+
+    link_flags = chaz_CC_new_cflags();
+    chaz_CFlags_add_library(link_flags, lib);
     if (cfish_lib_dir) {
         chaz_CFlags_add_library_path(link_flags, cfish_lib_dir);
     }
-    chaz_CFlags_add_external_library(test_cflags, cfish_lib_name);
-    scratch = chaz_Util_join(dir_sep, "t", "test_lucy.c", NULL);
-    rule = chaz_MakeFile_add_compiled_exe(makefile, test_lucy_exe, scratch,
-                                          test_cflags);
-    free(scratch);
+    chaz_CFlags_add_external_library(link_flags, cfish_lib_name);
+    rule = chaz_MakeFile_add_exe(makefile, test_lucy_exe, test_lucy_obj,
+                                 link_flags);
     chaz_MakeRule_add_prereq(rule, lib_filename);
-    chaz_CFlags_destroy(test_cflags);
+    chaz_CFlags_destroy(link_flags);
 
     rule = chaz_MakeFile_add_rule(makefile, "test", test_lucy_exe);
-    if (strcmp(chaz_OS_shared_lib_ext(), ".so") == 0) {
-        if (cfish_lib_dir) {
-            test_command
-                = chaz_Util_join("", "LD_LIBRARY_PATH=.:", cfish_lib_dir,
-                                 ":$$LD_LIBRARY_PATH ", test_lucy_exe, NULL);
-        }
-        else {
-            test_command
-                = chaz_Util_join(" ", "LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH",
-                                 test_lucy_exe, NULL);
-        }
+    if (cfish_lib_dir) {
+        chaz_MakeRule_add_command_with_libpath(rule, test_lucy_exe, ".",
+                                              cfish_lib_dir, NULL);
     }
     else {
-        test_command = chaz_Util_strdup(test_lucy_exe);
+        chaz_MakeRule_add_command_with_libpath(rule, test_lucy_exe, ".", NULL);
     }
-    chaz_MakeRule_add_command(rule, test_command);
 
     if (chaz_CLI_defined(cli, "enable-coverage")) {
         rule = chaz_MakeFile_add_rule(makefile, "coverage", test_lucy_exe);
@@ -400,6 +396,7 @@ S_write_makefile(struct chaz_CLI *cli) {
         chaz_MakeRule_add_rm_command(clean_rule, "$(LUCY_OBJS)");
     }
 
+    chaz_MakeRule_add_rm_command(clean_rule, test_lucy_obj);
     chaz_MakeRule_add_recursive_rm_command(clean_rule, "autogen");
 
     if (chaz_CLI_defined(cli, "enable-coverage")) {
@@ -422,6 +419,7 @@ S_write_makefile(struct chaz_CLI *cli) {
     free(utf8proc_dir);
     free(json_parser);
     free(test_lucy_exe);
+    free(test_lucy_obj);
     free(autogen_inc_dir);
     free(autogen_target);
     free(snowstem_inc_dir);

Reply via email to