From 817273931a42f807809a9d0f000564e2bd38dfb8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Aug 2011 12:24:14 +0000 Subject: buildinfo is now quoted from the build systems, avoids stripping quotes on startup. tested with linux/cmake linux/scons windows/cmake/mingw windows/cmake/msvc --- CMakeLists.txt | 16 ++++++++++++++++ build_files/cmake/buildinfo.cmake | 6 +++--- build_files/cmake/macros.cmake | 5 ----- build_files/scons/tools/Blender.py | 12 ++++++------ source/creator/CMakeLists.txt | 3 --- source/creator/buildinfo.c | 24 ++++++++++-------------- source/creator/creator.c | 26 -------------------------- 7 files changed, 35 insertions(+), 57 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cdf1fb9da9..ccd101dd46d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/build_files/cmake/buildinfo.cmake b/build_files/cmake/buildinfo.cmake index bfc17ae2cfe..e68015e36d3 100644 --- a/build_files/cmake/buildinfo.cmake +++ b/build_files/cmake/buildinfo.cmake @@ -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 diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 27694bcb875..58938c8b0b0 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -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 diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 0b1f3fcd8a8..271f555522c 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -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']) diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 43fec85b5bf..129ddca8c38 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -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( diff --git a/source/creator/buildinfo.c b/source/creator/buildinfo.c index 48a4352b11b..3853d6ca693 100644 --- a/source/creator/buildinfo.c +++ b/source/creator/buildinfo.c @@ -33,28 +33,24 @@ #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!"; diff --git a/source/creator/creator.c b/source/creator/creator.c index 36209dbda78..6aa1773be5a 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -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(); -- cgit v1.2.3