lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [1/5] git commit: refs/heads/master - Move obj_ext to chaz_CC
Date Sat, 04 May 2013 22:01:43 GMT
Updated Branches:
  refs/heads/master 271bd85dd -> 75626953e


Move obj_ext to chaz_CC

It depends on the compiler not the OS.


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

Branch: refs/heads/master
Commit: 598a5ce501a35c0b3f0ccaf49e36e8e6d914593b
Parents: 271bd85
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sat May 4 21:39:19 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sat May 4 22:47:25 2013 +0200

----------------------------------------------------------------------
 charmonizer/src/Charmonizer/Core/Compiler.c        |   27 +++++++++-----
 charmonizer/src/Charmonizer/Core/Compiler.h        |    5 +++
 charmonizer/src/Charmonizer/Core/OperatingSystem.c |   10 +-----
 charmonizer/src/Charmonizer/Core/OperatingSystem.h |    5 ---
 clownfish/compiler/common/charmonizer.main         |    2 +-
 common/charmonizer.main                            |    2 +-
 6 files changed, 25 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/598a5ce5/charmonizer/src/Charmonizer/Core/Compiler.c
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Core/Compiler.c b/charmonizer/src/Charmonizer/Core/Compiler.c
index 22390b4..f2683b5 100644
--- a/charmonizer/src/Charmonizer/Core/Compiler.c
+++ b/charmonizer/src/Charmonizer/Core/Compiler.c
@@ -36,7 +36,7 @@ static struct {
     char     *cc_command;
     char     *cflags;
     char     *try_exe_name;
-    char     *try_obj_name;
+    char      obj_ext[10];
     char      gcc_version_str[30];
     int       cflags_style;
     int       intval___GNUC__;
@@ -47,8 +47,8 @@ static struct {
     chaz_CFlags *extra_cflags;
     chaz_CFlags *temp_cflags;
 } chaz_CC = {
-    NULL, NULL, NULL, NULL,
-    "",
+    NULL, NULL, NULL,
+    "", "",
     0, 0, 0, 0, 0, 0,
     NULL, NULL
 };
@@ -69,18 +69,18 @@ chaz_CC_init(const char *compiler_command, const char *compiler_flags)
{
     /* Set names for the targets which we "try" to compile. */
     chaz_CC.try_exe_name
         = chaz_Util_join("", CHAZ_CC_TRY_BASENAME, chaz_OS_exe_ext(), NULL);
-    chaz_CC.try_obj_name
-        = chaz_Util_join("", CHAZ_CC_TRY_BASENAME, chaz_OS_obj_ext(), NULL);
 
     /* If we can't compile anything, game over. */
     if (chaz_Util_verbosity) {
         printf("Trying to compile a small test file...\n");
     }
     /* Try MSVC argument style. */
+    strcpy(chaz_CC.obj_ext, ".obj");
     chaz_CC.cflags_style = CHAZ_CFLAGS_STYLE_MSVC;
     compile_succeeded = chaz_CC_test_compile(code);
     if (!compile_succeeded) {
         /* Try POSIX argument style. */
+        strcpy(chaz_CC.obj_ext, ".o");
         chaz_CC.cflags_style = CHAZ_CFLAGS_STYLE_POSIX;
         compile_succeeded = chaz_CC_test_compile(code);
     }
@@ -152,7 +152,6 @@ void
 chaz_CC_clean_up(void) {
     free(chaz_CC.cc_command);
     free(chaz_CC.cflags);
-    free(chaz_CC.try_obj_name);
     free(chaz_CC.try_exe_name);
     chaz_CFlags_destroy(chaz_CC.extra_cflags);
     chaz_CFlags_destroy(chaz_CC.temp_cflags);
@@ -223,7 +222,7 @@ chaz_CC_compile_obj(const char *source_path, const char *obj_name,
     const char *extra_cflags_string = "";
     const char *temp_cflags_string  = "";
     const char *local_cflags_string;
-    char *obj_file = chaz_Util_join("", obj_name, chaz_OS_obj_ext(), NULL);
+    char *obj_file = chaz_Util_join("", obj_name, chaz_CC.obj_ext, NULL);
     char *command;
     int result;
 
@@ -264,12 +263,15 @@ chaz_CC_compile_obj(const char *source_path, const char *obj_name,
 int
 chaz_CC_test_compile(const char *source) {
     int compile_succeeded;
-    if (!chaz_Util_remove_and_verify(chaz_CC.try_obj_name)) {
-        chaz_Util_die("Failed to delete file '%s'", chaz_CC.try_obj_name);
+    char *try_obj_name
+        = chaz_Util_join("", CHAZ_CC_TRY_BASENAME, chaz_CC.obj_ext, NULL);
+    if (!chaz_Util_remove_and_verify(try_obj_name)) {
+        chaz_Util_die("Failed to delete file '%s'", try_obj_name);
     }
     compile_succeeded = chaz_CC_compile_obj(CHAZ_CC_TRY_SOURCE_PATH,
                                             CHAZ_CC_TRY_BASENAME, source);
-    chaz_Util_remove_and_verify(chaz_CC.try_obj_name);
+    chaz_Util_remove_and_verify(try_obj_name);
+    free(try_obj_name);
     return compile_succeeded;
 }
 
@@ -332,6 +334,11 @@ chaz_CC_get_temp_cflags(void) {
     return chaz_CC.temp_cflags;
 }
 
+const char*
+chaz_CC_obj_ext(void) {
+    return chaz_CC.obj_ext;
+}
+
 int
 chaz_CC_gcc_version_num(void) {
     return 10000 * chaz_CC.intval___GNUC__

http://git-wip-us.apache.org/repos/asf/lucy/blob/598a5ce5/charmonizer/src/Charmonizer/Core/Compiler.h
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Core/Compiler.h b/charmonizer/src/Charmonizer/Core/Compiler.h
index 0ec499d..1e7803f 100644
--- a/charmonizer/src/Charmonizer/Core/Compiler.h
+++ b/charmonizer/src/Charmonizer/Core/Compiler.h
@@ -91,6 +91,11 @@ chaz_CC_get_extra_cflags(void);
 chaz_CFlags*
 chaz_CC_get_temp_cflags(void);
 
+/* Return the extension for a compiled object.
+ */
+const char*
+chaz_CC_obj_ext(void);
+
 int
 chaz_CC_gcc_version_num(void);
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/598a5ce5/charmonizer/src/Charmonizer/Core/OperatingSystem.c
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Core/OperatingSystem.c b/charmonizer/src/Charmonizer/Core/OperatingSystem.c
index 4a23958..a8f933b 100644
--- a/charmonizer/src/Charmonizer/Core/OperatingSystem.c
+++ b/charmonizer/src/Charmonizer/Core/OperatingSystem.c
@@ -31,11 +31,10 @@ static struct {
     char name[CHAZ_OS_NAME_MAX+1];
     char dev_null[20];
     char exe_ext[5];
-    char obj_ext[5];
     char shared_lib_ext[7];
     char local_command_start[3];
     int  shell_type;
-} chaz_OS = { "", "", "", "", "", "", 0 };
+} chaz_OS = { "", "", "", "", "", 0 };
 
 void
 chaz_OS_init(void) {
@@ -68,7 +67,6 @@ chaz_OS_init(void) {
 
         strcpy(chaz_OS.dev_null, "/dev/null");
         strcpy(chaz_OS.exe_ext, "");
-        strcpy(chaz_OS.obj_ext, ".o");
         if (memcmp(chaz_OS.name, "darwin", 6) == 0) {
             strcpy(chaz_OS.shared_lib_ext, ".dylib");
         }
@@ -84,7 +82,6 @@ chaz_OS_init(void) {
         strcpy(chaz_OS.name, "windows");
         strcpy(chaz_OS.dev_null, "nul");
         strcpy(chaz_OS.exe_ext, ".exe");
-        strcpy(chaz_OS.obj_ext, ".obj");
         strcpy(chaz_OS.shared_lib_ext, ".dll");
         strcpy(chaz_OS.local_command_start, ".\\");
         chaz_OS.shell_type = CHAZ_OS_CMD_EXE;
@@ -116,11 +113,6 @@ chaz_OS_exe_ext(void) {
 }
 
 const char*
-chaz_OS_obj_ext(void) {
-    return chaz_OS.obj_ext;
-}
-
-const char*
 chaz_OS_shared_lib_ext(void) {
     return chaz_OS.shared_lib_ext;
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/598a5ce5/charmonizer/src/Charmonizer/Core/OperatingSystem.h
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Core/OperatingSystem.h b/charmonizer/src/Charmonizer/Core/OperatingSystem.h
index d28b78b..c335cf3 100644
--- a/charmonizer/src/Charmonizer/Core/OperatingSystem.h
+++ b/charmonizer/src/Charmonizer/Core/OperatingSystem.h
@@ -84,11 +84,6 @@ chaz_OS_is_cygwin(void);
 const char*
 chaz_OS_exe_ext(void);
 
-/* Return the extension for a compiled object on this system.
- */
-const char*
-chaz_OS_obj_ext(void);
-
 /* Return the extension for a shared object on this system.
  */
 const char*

http://git-wip-us.apache.org/repos/asf/lucy/blob/598a5ce5/clownfish/compiler/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/clownfish/compiler/common/charmonizer.main b/clownfish/compiler/common/charmonizer.main
index 3b896ba..55f9139 100644
--- a/clownfish/compiler/common/charmonizer.main
+++ b/clownfish/compiler/common/charmonizer.main
@@ -115,7 +115,7 @@ S_write_makefile(struct chaz_CLIArgs *args) {
 
     const char *base_dir = "..";
     const char *exe_ext  = chaz_OS_exe_ext();
-    const char *obj_ext  = chaz_OS_obj_ext();
+    const char *obj_ext  = chaz_CC_obj_ext();
 
     const char *parse_header_y = "$(SRC_DIR)" DIR_SEP "CFCParseHeader.y";
     const char *parse_header_h = "$(SRC_DIR)" DIR_SEP "CFCParseHeader.h";

http://git-wip-us.apache.org/repos/asf/lucy/blob/598a5ce5/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/common/charmonizer.main b/common/charmonizer.main
index 4ebae65..6ce26e3 100644
--- a/common/charmonizer.main
+++ b/common/charmonizer.main
@@ -138,7 +138,7 @@ S_write_makefile(struct chaz_CLIArgs *args) {
 
     const char *base_dir = "..";
     const char *exe_ext  = chaz_OS_exe_ext();
-    const char *obj_ext  = chaz_OS_obj_ext();
+    const char *obj_ext  = chaz_CC_obj_ext();
 
     const char *json_parser_y = "$(CORE_DIR)" DIR_SEP "Lucy" DIR_SEP "Util"
                                 DIR_SEP "Json" DIR_SEP "JsonParser.y";


Mime
View raw message