Compile and link test executable with custom flags

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

Branch: refs/heads/chaz-cflags
Commit: ed2c05608f50edc99c8d7ecaaf52a978149b5492
Parents: 89b7b93
Author: Nick Wellnhofer <[email protected]>
Authored: Wed Apr 3 22:36:50 2013 +0200
Committer: Nick Wellnhofer <[email protected]>
Committed: Wed Apr 3 22:36:50 2013 +0200

----------------------------------------------------------------------
 charmonizer/src/Charmonizer/Core/Make.c |   28 +++++++++++-----------
 charmonizer/src/Charmonizer/Core/Make.h |   12 +++++-----
 common/charmonizer.main                 |   31 +++++++++++--------------
 3 files changed, 34 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/ed2c0560/charmonizer/src/Charmonizer/Core/Make.c
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Core/Make.c 
b/charmonizer/src/Charmonizer/Core/Make.c
index 82fc379..c5baee9 100644
--- a/charmonizer/src/Charmonizer/Core/Make.c
+++ b/charmonizer/src/Charmonizer/Core/Make.c
@@ -241,24 +241,24 @@ chaz_MakeFile_add_dir_to_cleanup(chaz_MakeFile *makefile, 
const char *dir) {
 
 chaz_MakeRule*
 chaz_MakeFile_add_exe(chaz_MakeFile *makefile, const char *exe,
-                      const char *objects, chaz_CFlags *library_flags) {
+                      const char *sources, chaz_CFlags *link_flags) {
     int            cflags_style = chaz_CC_get_cflags_style();
     chaz_CFlags   *local_flags  = chaz_CFlags_new(cflags_style);
     const char    *link         = chaz_CC_link_command();
-    const char    *library_flags_string = "";
+    const char    *link_flags_string = "";
     const char    *local_flags_string;
     chaz_MakeRule *rule;
     char          *command;
 
-    rule = chaz_MakeFile_add_rule(makefile, exe, objects);
+    rule = chaz_MakeFile_add_rule(makefile, exe, sources);
 
-    if (library_flags) {
-        library_flags_string = chaz_CFlags_get_string(library_flags);
+    if (link_flags) {
+        link_flags_string = chaz_CFlags_get_string(link_flags);
     }
     chaz_CFlags_set_link_output(local_flags, exe);
     local_flags_string = chaz_CFlags_get_string(local_flags);
-    command = chaz_Util_join(" ", link, local_flags_string, objects,
-                             library_flags_string, NULL);
+    command = chaz_Util_join(" ", link, sources, link_flags_string,
+                             local_flags_string, NULL);
     chaz_MakeRule_add_command(rule, command);
 
     chaz_MakeFile_add_to_cleanup(makefile, exe);
@@ -270,25 +270,25 @@ chaz_MakeFile_add_exe(chaz_MakeFile *makefile, const char 
*exe,
 
 chaz_MakeRule*
 chaz_MakeFile_add_shared_lib(chaz_MakeFile *makefile, const char *shared_lib,
-                             const char *objects, chaz_CFlags *library_flags) {
+                             const char *sources, chaz_CFlags *link_flags) {
     int            cflags_style = chaz_CC_get_cflags_style();
     chaz_CFlags   *local_flags  = chaz_CFlags_new(cflags_style);
     const char    *link         = chaz_CC_link_command();
-    const char    *library_flags_string = "";
+    const char    *link_flags_string = "";
     const char    *local_flags_string;
     chaz_MakeRule *rule;
     char          *command;
 
-    rule = chaz_MakeFile_add_rule(makefile, shared_lib, objects);
+    rule = chaz_MakeFile_add_rule(makefile, shared_lib, sources);
 
-    if (library_flags) {
-        library_flags_string = chaz_CFlags_get_string(library_flags);
+    if (link_flags) {
+        link_flags_string = chaz_CFlags_get_string(link_flags);
     }
     chaz_CFlags_link_shared_library(local_flags);
     chaz_CFlags_set_link_output(local_flags, shared_lib);
     local_flags_string = chaz_CFlags_get_string(local_flags);
-    command = chaz_Util_join(" ", link, local_flags_string, objects,
-                             library_flags_string, NULL);
+    command = chaz_Util_join(" ", link, sources, link_flags_string,
+                             local_flags_string, NULL);
     chaz_MakeRule_add_command(rule, command);
 
     chaz_MakeFile_add_to_cleanup(makefile, shared_lib);

http://git-wip-us.apache.org/repos/asf/lucy/blob/ed2c0560/charmonizer/src/Charmonizer/Core/Make.h
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Core/Make.h 
b/charmonizer/src/Charmonizer/Core/Make.h
index 103133d..4307fd1 100644
--- a/charmonizer/src/Charmonizer/Core/Make.h
+++ b/charmonizer/src/Charmonizer/Core/Make.h
@@ -110,24 +110,24 @@ chaz_MakeFile_add_dir_to_cleanup(chaz_MakeFile *makefile, 
const char *dir);
  *
  * @param makefile The makefile.
  * @param exe The name of the executable.
- * @param objects The list of object files.
- * @param library_flags Additional link flags for libraries.
+ * @param sources The list of source files.
+ * @param link_flags Additional link flags.
  */
 chaz_MakeRule*
 chaz_MakeFile_add_exe(chaz_MakeFile *makefile, const char *exe,
-                      const char *objects, chaz_CFlags *library_flags);
+                      const char *sources, chaz_CFlags *link_flags);
 
 /** Add a rule to link a shared library. The shared library will also be added
  * to the list of files to clean.
  *
  * @param makefile The makefile.
  * @param shared_lib The name of the shared library.
- * @param objects The list of object files.
- * @param library_flags Additional link flags for libraries.
+ * @param sources The list of source files.
+ * @param link_flags Additional link flags.
  */
 chaz_MakeRule*
 chaz_MakeFile_add_shared_lib(chaz_MakeFile *makefile, const char *shared_lib,
-                             const char *objects, chaz_CFlags *library_flags);
+                             const char *sources, chaz_CFlags *link_flags);
 
 /** Write the makefile to a file named 'Makefile' in the current directory.
  *

http://git-wip-us.apache.org/repos/asf/lucy/blob/ed2c0560/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/common/charmonizer.main b/common/charmonizer.main
index c007856..c3274b9 100644
--- a/common/charmonizer.main
+++ b/common/charmonizer.main
@@ -141,7 +141,7 @@ S_write_makefile() {
 
     int          cflags_style = chaz_CC_get_cflags_style();
     chaz_CFlags *extra_cflags = chaz_CC_get_extra_cflags();
-    chaz_CFlags *library_cflags;
+    chaz_CFlags *link_flags;
     const char  *math_library;
 
     printf("Creating Makefile...\n");
@@ -253,9 +253,6 @@ S_write_makefile() {
     chaz_MakeVar_append(var, "$(AUTOGEN_DIR)" DIR_SEP "source" DIR_SEP
                         "parcel$(OBJ_EXT)");
 
-    chaz_MakeFile_add_var(makefile, "TEST_LUCY_OBJS",
-                          "t" DIR_SEP "test_lucy$(OBJ_EXT)");
-
     /* Executables */
 
     chaz_MakeFile_add_var(makefile, "LEMON_EXE",
@@ -298,26 +295,27 @@ S_write_makefile() {
     chaz_MakeRule_add_prereq(rule, json_parser_c);
     chaz_MakeRule_add_prereq(rule, "$(AUTOGEN_DIR)");
 
-    library_cflags = chaz_CFlags_new(cflags_style);
+    link_flags = chaz_CFlags_new(cflags_style);
     if (math_library) {
-        chaz_CFlags_add_library(library_cflags, math_library);
+        chaz_CFlags_add_library(link_flags, math_library);
     }
     if (chaz_HeadCheck_check_header("pcre.h")) {
-        chaz_CFlags_add_library(library_cflags, "pcre");
+        chaz_CFlags_add_library(link_flags, "pcre");
     }
     chaz_MakeFile_add_shared_lib(makefile, "$(LUCY_SHLIB)", "$(LUCY_OBJS)",
-                                 library_cflags);
-    chaz_CFlags_destroy(library_cflags);
-
-    chaz_MakeFile_add_rule(makefile, "$(TEST_LUCY_OBJS)", "$(AUTOGEN_DIR)");
+                                 link_flags);
+    chaz_CFlags_destroy(link_flags);
 
-    library_cflags = chaz_CFlags_new(cflags_style);
-    chaz_CFlags_add_library_path(library_cflags, ".");
-    chaz_CFlags_add_library(library_cflags, "lucy");
+    link_flags = chaz_CFlags_new(cflags_style);
+    chaz_CFlags_add_include_dir(link_flags, ".");
+    chaz_CFlags_add_include_dir(link_flags,
+                                "$(AUTOGEN_DIR)" DIR_SEP "include");
+    chaz_CFlags_add_library_path(link_flags, ".");
+    chaz_CFlags_add_library(link_flags, "lucy");
     rule = chaz_MakeFile_add_exe(makefile, "$(TEST_LUCY_EXE)",
-                                 "$(TEST_LUCY_OBJS)", library_cflags);
+                                 "t" DIR_SEP "test_lucy.c", link_flags);
     chaz_MakeRule_add_prereq(rule, "$(LUCY_SHLIB)");
-    chaz_CFlags_destroy(library_cflags);
+    chaz_CFlags_destroy(link_flags);
 
     rule = chaz_MakeFile_add_rule(makefile, "test", "$(TEST_LUCY_EXE)");
     const char *test_command = "$(TEST_LUCY_EXE)";
@@ -326,7 +324,6 @@ S_write_makefile() {
     }
     chaz_MakeRule_add_command(rule, test_command);
 
-    chaz_MakeFile_add_to_cleanup(makefile, "$(TEST_LUCY_OBJS)");
     chaz_MakeFile_add_to_cleanup(makefile, "$(LUCY_OBJS)");
     chaz_MakeFile_add_to_cleanup(makefile, json_parser_h);
     chaz_MakeFile_add_to_cleanup(makefile, json_parser_c);

Reply via email to