diff options
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | 2010-11-05 10:33:57 +0100 |
---|---|---|
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | 2010-11-05 10:33:57 +0100 |
commit | a7ab7633a603c6c3e31bb54a45da2afbb54a98c9 (patch) | |
tree | bc44aced8dbe2559ecc8683254c10c52eceecf14 | |
parent | 85d7bb555c260c24c404c7a65b6331379a12433c (diff) | |
parent | fa8d253822661f7c5ba3bd72a4a4f8fbf2d9bb26 (diff) | |
download | yajl-a7ab7633a603c6c3e31bb54a45da2afbb54a98c9.tar.gz |
Merge remote branch 'lloyd/parsetree' into parsetree
-rw-r--r-- | BUILDING.win32 | 23 | ||||
-rw-r--r-- | CMakeLists.txt | 13 | ||||
-rw-r--r-- | src/CMakeLists.txt | 10 | ||||
-rw-r--r-- | src/api/yajl_common.h | 6 | ||||
-rw-r--r-- | src/yajl_gen.c | 2 | ||||
-rwxr-xr-x | test/run_tests.sh | 55 |
6 files changed, 73 insertions, 36 deletions
diff --git a/BUILDING.win32 b/BUILDING.win32 index 3668541..6b35aa4 100644 --- a/BUILDING.win32 +++ b/BUILDING.win32 @@ -1,5 +1,7 @@ -YAJL has been successfully built using Visual Studio 8. CMake is used to -build the software and by specifying a generator explicitly at cmake: +YAJL has been successfully built using Visual Studio 8. CMake, a +build file generator, is used to build the software. CMake supports +several different build environments, so you may either build YAJL +using the IDE via the following steps: 1. acquire cmake (http://www.cmake.org) 2. mkdir build @@ -8,5 +10,18 @@ build the software and by specifying a generator explicitly at cmake: 5. devenv YetAnotherJSONParser.sln /project ALL_BUILD /build Release 6. build output is left in build/yajl-X.Y.Z -Earlier versions of visual studio have not been tested, but should -work without any major issues. +Or you can build from the command line using nmake: + +1. Click Start > Programs > Microsoft Visual Studio > Visual Studio +Tools > Visual Studio Command Prompt -- for your version of Visual +Studio, which will open a command prompt. You may verify that the +compiler is in your path by typing "cl /?" at the prompt. +2. cd C:\path\to\yajl\source\ +3. mkdir build +4. cd build +5. cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release .. +6. nmake +7. nmake install + +Earlier versions of visual studio and other build generators haven't +been thoroughly tested, but should work without any major issues. diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fa3ec4..727a488 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,10 +38,6 @@ SET (YAJL_MICRO 11) SET (YAJL_DIST_NAME "yajl-${YAJL_MAJOR}.${YAJL_MINOR}.${YAJL_MICRO}") -# RPATH handling -- given we statically link, we'll turn off -# unnec. rpath embedding -SET(CMAKE_SKIP_RPATH TRUE) - IF (NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE "Release") ENDIF (NOT CMAKE_BUILD_TYPE) @@ -66,8 +62,15 @@ IF (WIN32) SET(CMAKE_C_FLAGS_DEBUG "/D DEBUG /Od /Z7") SET(CMAKE_C_FLAGS_RELEASE "/D NDEBUG /O2") ELSE (WIN32) + IF(CMAKE_COMPILER_IS_GNUCC) + INCLUDE(CheckCCompilerFlag) + CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_GCC_VISIBILITY) + IF(HAVE_GCC_VISIBILITY) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") + ENDIF(HAVE_GCC_VISIBILITY) + ENDIF(CMAKE_COMPILER_IS_GNUCC) SET(CMAKE_C_FLAGS - "${CMAKE_C_FLAGS} -fPIC -std=c99 -pedantic -Wpointer-arith -Wno-format-y2k -Wstrict-prototypes -Wmissing-declarations -Wnested-externs -Wextra -Wundef -Wwrite-strings -Wold-style-definition -Wredundant-decls -Wno-unused-parameter -Wno-sign-compare -Wmissing-prototypes") + "${CMAKE_C_FLAGS} -std=c99 -pedantic -Wpointer-arith -Wno-format-y2k -Wstrict-prototypes -Wmissing-declarations -Wnested-externs -Wextra -Wundef -Wwrite-strings -Wold-style-definition -Wredundant-decls -Wno-unused-parameter -Wno-sign-compare -Wmissing-prototypes") SET(CMAKE_C_FLAGS_DEBUG "-DDEBUG -g") SET(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2 -Wuninitialized") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index da63915..3ca0dc5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -60,6 +60,13 @@ SET_TARGET_PROPERTIES(yajl PROPERTIES SOVERSION ${YAJL_MAJOR} VERSION ${YAJL_MAJOR}.${YAJL_MINOR}.${YAJL_MICRO}) +#### ensure a .dylib has correct absolute installation paths upon installation +IF(APPLE) + MESSAGE("INSTALL_NAME_DIR: ${CMAKE_INSTALL_PREFIX}/lib") + SET_TARGET_PROPERTIES(yajl PROPERTIES + INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") +ENDIF(APPLE) + #### build up an sdk as a post build step # create some directories @@ -86,5 +93,6 @@ IF(NOT WIN32) # 64-bit systems which use 'lib64' INSTALL(TARGETS yajl LIBRARY DESTINATION lib${LIB_SUFFIX}) INSTALL(TARGETS yajl_s ARCHIVE DESTINATION lib${LIB_SUFFIX}) - INSTALL(DIRECTORY api/ DESTINATION include/yajl) + INSTALL(FILES ${PUB_HDRS} DESTINATION include/yajl) + INSTALL(FILES ${incDir}/yajl_version.h DESTINATION include/yajl) ENDIF() diff --git a/src/api/yajl_common.h b/src/api/yajl_common.h index a227deb..0e75db1 100644 --- a/src/api/yajl_common.h +++ b/src/api/yajl_common.h @@ -49,7 +49,11 @@ extern "C" { # define YAJL_API __declspec(dllimport) # endif #else -# define YAJL_API +# if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 +# define YAJL_API __attribute__ ((visibility("default"))) +# else +# define YAJL_API +# endif #endif /** pointer to a malloc function, supporting client overriding memory diff --git a/src/yajl_gen.c b/src/yajl_gen.c index 6ad9c0b..548d948 100644 --- a/src/yajl_gen.c +++ b/src/yajl_gen.c @@ -202,7 +202,7 @@ yajl_gen_double(yajl_gen g, double number) ENSURE_VALID_STATE; ENSURE_NOT_KEY; if (isnan(number) || isinf(number)) return yajl_gen_invalid_number; INSERT_SEP; INSERT_WHITESPACE; - sprintf(i, "%g", number); + sprintf(i, "%.20g", number); g->print(g->ctx, i, strlen(i)); APPENDED_ATOM; FINAL_NEWLINE; diff --git a/test/run_tests.sh b/test/run_tests.sh index f5063ed..d596daf 100755 --- a/test/run_tests.sh +++ b/test/run_tests.sh @@ -1,9 +1,13 @@ -#!/usr/bin/env bash +#!/bin/sh + +ECHO=`which echo` DIFF_FLAGS="-u" -if [[ `uname` == *W32* ]] ; then - DIFF_FLAGS="-wu" -fi +case "$(uname)" in + *W32*) + DIFF_FLAGS="-wu" + ;; +esac if [ -z "$testBin" ]; then testBin="$1" @@ -13,52 +17,55 @@ fi # particular test binary (useful for non-cmake build systems). if [ -z "$testBin" ]; then testBin="../build/test/Debug/yajl_test.exe" - if [[ ! -x $testBin ]] ; then + if [ ! -x $testBin ] ; then testBin="../build/test/yajl_test" - if [[ ! -x $testBin ]] ; then - echo "cannot execute test binary: '$testBin'" + if [ ! -x $testBin ] ; then + ${ECHO} "cannot execute test binary: '$testBin'" exit 1; fi fi fi -echo "using test binary: $testBin" +${ECHO} "using test binary: $testBin" -let testsSucceeded=0 -let testsTotal=0 +testsSucceeded=0 +testsTotal=0 for file in cases/*.json ; do allowComments="-c" # if the filename starts with dc_, we disallow comments for this test - if [[ $(basename $file) == dc_* ]] ; then - allowComments="" - fi - echo -n " test case: '$file': " - let iter=1 + case $(basename $file) in + dc_*) + allowComments="" + ;; + esac + ${ECHO} -n " test case: '$file': " + iter=1 success="success" + ${ECHO} "$testBin $allowComments -b $iter < $file > ${file}.test " # parse with a read buffer size ranging from 1-31 to stress stream parsing - while (( $iter < 32 )) && [ $success == "success" ] ; do + while [ $iter -lt 32 ] && [ $success = "success" ] ; do $testBin $allowComments -b $iter < $file > ${file}.test 2>&1 diff ${DIFF_FLAGS} ${file}.gold ${file}.test - if [[ $? == 0 ]] ; then - if (( $iter == 31 )) ; then let testsSucceeded+=1 ; fi + if [ $? -eq 0 ] ; then + if [ $iter -eq 31 ] ; then : $(( testsSucceeded += 1)) ; fi else success="FAILURE" - let iter=32 + iter=32 fi - let iter+=1 + : $(( iter += 1 )) rm ${file}.test done - echo $success - let testsTotal+=1 + ${ECHO} $success + : $(( testsTotal += 1 )) done -echo $testsSucceeded/$testsTotal tests successful +${ECHO} $testsSucceeded/$testsTotal tests successful -if [[ $testsSucceeded != $testsTotal ]] ; then +if [ $testsSucceeded != $testsTotal ] ; then exit 1 fi |