buildinfo is now quoted from the build systems, avoids stripping quotes on startup.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 22 Aug 2011 12:24:14 +0000 (12:24 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 22 Aug 2011 12:24:14 +0000 (12:24 +0000)
tested with linux/cmake linux/scons windows/cmake/mingw windows/cmake/msvc

CMakeLists.txt
build_files/cmake/buildinfo.cmake
build_files/cmake/macros.cmake
build_files/scons/tools/Blender.py
source/creator/CMakeLists.txt
source/creator/buildinfo.c
source/creator/creator.c

index 0cdf1fb..ccd101d 100644 (file)
@@ -62,6 +62,22 @@ set(CMAKE_BUILD_TYPE_INIT "Release")
 # quiet output for Makefiles, 'make -s' helps too
 # set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
 
+#-----------------------------------------------------------------------------
+# Set policy
+
+# see "cmake --help-policy CMP0003"
+# So library linking is more sane
+cmake_policy(SET CMP0003 NEW)
+
+# So BUILDINFO and BLENDERPATH strings are automatically quoted
+cmake_policy(SET CMP0005 NEW)
+
+# So syntax problems are errors
+cmake_policy(SET CMP0010 NEW)
+
+# Input directories must have CMakeLists.txt
+cmake_policy(SET CMP0014 NEW)
+
 #-----------------------------------------------------------------------------
 # Load some macros.
 include(build_files/cmake/macros.cmake)
index bfc17ae..e68015e 100644 (file)
@@ -27,9 +27,9 @@ endif()
 
 # Write a file with the SVNVERSION define
 file(WRITE buildinfo.h.txt
-       "#define BUILD_REV ${MY_WC_REVISION}\n"
-       "#define BUILD_DATE ${BUILD_DATE}\n"
-       "#define BUILD_TIME ${BUILD_TIME}\n"
+       "#define BUILD_REV \"${MY_WC_REVISION}\"\n"
+       "#define BUILD_DATE \"${BUILD_DATE}\"\n"
+       "#define BUILD_TIME \"${BUILD_TIME}\"\n"
 )
 
 # Copy the file to the final header only if the version changes
index 27694bc..58938c8 100644 (file)
@@ -145,11 +145,6 @@ endmacro()
 
 
 macro(SETUP_LIBDIRS)
-       # see "cmake --help-policy CMP0003"
-       if(COMMAND cmake_policy)
-               cmake_policy(SET CMP0003 NEW)
-       endif()
-
        link_directories(${JPEG_LIBPATH} ${PNG_LIBPATH} ${ZLIB_LIBPATH} ${FREETYPE_LIBPATH})
 
        if(WITH_PYTHON)  #  AND NOT WITH_PYTHON_MODULE  # WIN32 needs
index 0b1f3fc..271f555 100644 (file)
@@ -364,16 +364,16 @@ def buildinfo(lenv, build_type):
 
     obj = []
     if lenv['BF_BUILDINFO']:
-        lenv.Append (CPPDEFINES = ['BUILD_TIME="%s"'%(build_time),
-                                    'BUILD_DATE="%s"'%(build_date),
-                                    'BUILD_TYPE="%s"'%(build_type),
-                                    'BUILD_REV="%s"'%(build_rev),
+        lenv.Append (CPPDEFINES = ['BUILD_TIME=\\"%s\\"'%(build_time),
+                                    'BUILD_DATE=\\"%s\\"'%(build_date),
+                                    'BUILD_TYPE=\\"%s\\"'%(build_type),
+                                    'BUILD_REV=\\"%s\\"'%(build_rev),
                                     'NAN_BUILDINFO',
-                                    'BUILD_PLATFORM="%s:%s"'%(platform.system(), platform.architecture()[0]),
+                                    'BUILD_PLATFORM=\\"%s:%s\\"'%(platform.system(), platform.architecture()[0]),
                                     'BUILD_CFLAGS=\\"%s\\"'%(build_cflags),
                                     'BUILD_CXXFLAGS=\\"%s\\"'%(build_cxxflags),
                                     'BUILD_LINKFLAGS=\\"%s\\"'%(build_linkflags),
-                                    'BUILD_SYSTEM="SCons"'
+                                    'BUILD_SYSTEM=\\"SCons\\"'
                     ])
 
         lenv.Append (CPPPATH = [root_build_dir+'source/blender/blenkernel'])
index 43fec85..129ddca 100644 (file)
@@ -25,9 +25,6 @@
 #
 # ***** END GPL LICENSE BLOCK *****
 
-# So BUILDINFO and BLENDERPATH strings are automatically quoted
-cmake_policy(SET CMP0005 NEW)
-
 setup_libdirs()
 
 blender_include_dirs(
index 48a4352..3853d6c 100644 (file)
 
 
 #ifdef WITH_BUILDINFO_HEADER
-#include "buildinfo.h"
+#  include "buildinfo.h"
 #endif
 
 #ifdef BUILD_DATE
 
-/* copied from BLI_utildefines.h */
-#define STRINGIFY_ARG(x) #x
-#define STRINGIFY(x) STRINGIFY_ARG(x)
-
 /* currently only these are defined in the header */
-char build_date[]= STRINGIFY(BUILD_DATE);
-char build_time[]= STRINGIFY(BUILD_TIME);
-char build_rev[]= STRINGIFY(BUILD_REV);
+char build_date[]= BUILD_DATE;
+char build_time[]= BUILD_TIME;
+char build_rev[]= BUILD_REV;
 
-char build_platform[]= STRINGIFY(BUILD_PLATFORM);
-char build_type[]= STRINGIFY(BUILD_TYPE);
+char build_platform[]= BUILD_PLATFORM;
+char build_type[]= BUILD_TYPE;
 
 #ifdef BUILD_CFLAGS
-char build_cflags[]= STRINGIFY(BUILD_CFLAGS);
-char build_cxxflags[]= STRINGIFY(BUILD_CXXFLAGS);
-char build_linkflags[]= STRINGIFY(BUILD_LINKFLAGS);
-char build_system[]= STRINGIFY(BUILD_SYSTEM);
+char build_cflags[]= BUILD_CFLAGS;
+char build_cxxflags[]= BUILD_CXXFLAGS;
+char build_linkflags[]= BUILD_LINKFLAGS;
+char build_system[]= BUILD_SYSTEM;
 #else
 char build_cflags[]= "unmaintained buildsystem alert!";
 char build_cxxflags[]= "unmaintained buildsystem alert!";
index 36209db..6aa1773 100644 (file)
@@ -182,20 +182,6 @@ static void blender_esc(int sig)
 }
 #endif
 
-/* buildinfo can have quotes */
-#ifdef BUILD_DATE
-static void strip_quotes(char *str)
-{
-       if(str[0] == '"') {
-               int len= strlen(str) - 1;
-               memmove(str, str+1, len);
-               if(str[len-1] == '"') {
-                       str[len-1]= '\0';
-               }
-       }
-}
-#endif
-
 static int print_version(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
 {
        printf (BLEND_VERSION_STRING_FMT);
@@ -1181,18 +1167,6 @@ int main(int argc, const char **argv)
        // need this.
 
        BLI_where_am_i(bprogname, sizeof(bprogname), argv[0]);
-       
-#ifdef BUILD_DATE      
-       strip_quotes(build_date);
-       strip_quotes(build_time);
-       strip_quotes(build_rev);
-       strip_quotes(build_platform);
-       strip_quotes(build_type);
-       strip_quotes(build_cflags);
-       strip_quotes(build_cxxflags);
-       strip_quotes(build_linkflags);
-       strip_quotes(build_system);
-#endif
 
        BLI_threadapi_init();