diff --git a/.travis.yml b/.travis.yml index be9750fb49..d02fccb131 100644 --- a/.travis.yml +++ b/.travis.yml @@ -67,8 +67,9 @@ install: fi - pip install --upgrade pygooglechart - pip install --upgrade graphviz - - (pip install --upgrade FoBiS.py && FoBiS.py --version) - - (pip install --upgrade ford && ford --version) + - (pip install --upgrade FoBiS.py==2.2.8 && FoBiS.py --version) + - (pip install --upgrade ford==5.0.6 && ford --version) + - (pip install --upgrade markdown==2.6.9) - (pip install --upgrade git+https://github.com/dmeranda/demjson.git && jsonlint --version) before_script: diff --git a/CMakeLists.txt b/CMakeLists.txt index d6007eef91..0288499eca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -301,9 +301,9 @@ if ( ENABLE_TESTS ) endif() endforeach ( UNIT_TEST ) - set_property ( TEST jf_test_3 + set_property ( TEST jf_test_03 APPEND - PROPERTY DEPENDS jf_test_2 ) + PROPERTY DEPENDS jf_test_02 ) # Validate output if ( JSONLINT ) @@ -423,4 +423,4 @@ install(FILES if(MSVC_IDE) INCLUDE_DIRECTORIES("src") SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fpp") -endif() \ No newline at end of file +endif() diff --git a/README.md b/README.md index 9bcea0c732..e39fcb801e 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,22 @@ script) with the [NAG Fortran compiler 6.0](http://www.nag.com/nagware/NP/NP_des Currently, several ways are provided to build the JSON-fortran library (libjsonfortran). -* A build script, `build.sh` is provided in the project root directory. This script uses [FoBiS](https://github.com/szaghi/FoBiS) to build the JSON-Fortran library and the unit tests. Edit the script to use either the [Intel Fortran Compiler](https://software.intel.com/en-us/fortran-compilers) or [Gfortran](https://gcc.gnu.org/wiki/GFortran). Note that version 1.2.5 of FoBiS (or later) is required. +* A build script, `build.sh` is provided in the project root directory. This script uses [FoBiS](https://github.com/szaghi/FoBiS) to build the JSON-Fortran library and the unit tests on Unix-like systems. Edit the script to use either the [Intel Fortran Compiler](https://software.intel.com/en-us/fortran-compilers) or [Gfortran](https://gcc.gnu.org/wiki/GFortran). Note that version 1.2.5 of FoBiS (or later) is required. + +* A [FoBiS](https://github.com/szaghi/FoBiS) configuration file (`json-fortran.fobis`) is also provided that can also build the library and examples. Use the `mode` flag to indicate what to build. For example: + + * To build all the examples using gfortran: `FoBiS.py build -f json-fortran.fobis -mode tests-gnu` + * To build all the examples using ifort: `FoBiS.py build -f json-fortran.fobis -mode tests-intel` + * To build a static library using gfortran: `FoBiS.py build -f json-fortran.fobis -mode static-gnu` + * To build a static library using ifort: `FoBiS.py build -f json-fortran.fobis -mode static-intel` + + The full set of modes are: `static-gnu`, `static-gnu-debug`, `static-intel`, `static-intel-debug`, `shared-gnu`, `shared-gnu-debug`, `shared-intel`, `shared-intel-debug`, `tests-gnu`, `tests-gnu-debug`, `tests-intel`, `tests-intel-debug` + + To generate the documentation using [ford](https://github.com/cmacmackin/ford), run: + +``` + FoBis.py rule --execute makedoc -f json-fortran.fobis +``` * A [Visual Studio](https://www.visualstudio.com) project is included for building the library (and unit tests) on Windows with the Intel Fortran Compiler. The project has been tested with Visual Studio 2010 and 2013. @@ -116,7 +131,7 @@ project ( jf_test NONE ) find_package ( jsonfortran-${CMAKE_Fortran_COMPILER_ID} 6.2.0 REQUIRED ) include_directories ( "${jsonfortran_INCLUDE_DIRS}" ) -file ( GLOB JF_TEST_SRCS "src/tests/jf_test_*.f90" ) +file ( GLOB JF_TEST_SRCS "src/tests/jf_test_*.F90" ) foreach ( UNIT_TEST ${JF_TEST_SRCS} ) get_filename_component ( TEST ${UNIT_TEST} NAME_WE ) add_executable ( ${TEST} ${UNIT_TEST} ) diff --git a/deploy.sh b/deploy.sh index bb17d4fedf..27016ab766 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Script to deploy documentation after successfull build of master branch or tag +# Script to deploy documentation after successful build of master branch or tag # If running under travis-ci this will automatically deploy updates to the master branch's # documentation on build events for the master branch, and will add/update documentation for # any new/updated tags that are pushed. @@ -20,7 +20,7 @@ if [ "$TRAVIS" ]; then #running under travis git commit -m "Development documentation updated by travis job $TRAVIS_JOB_NUMBER for commits $TRAVIS_COMMIT_RANGE" || true git push -fq origin gh-pages > /dev/null 2>&1 || true fi - # If publishing a new/updated tag, deploy it's documentation + # If publishing a new/updated tag, deploy its documentation if [ "$TRAVIS_TAG" ] && [ "$(ls -A "$TRAVIS_BUILD_DIR/doc")" ] ; then #not empty cd "$TRAVIS_BUILD_DIR" || exit 1 git clone -q --branch=gh-pages "https://${GH_TOKEN}@github.com/$TRAVIS_REPO_SLUG" gh-pages >/dev/null 2>&1 diff --git a/json-fortran.fobis b/json-fortran.fobis new file mode 100644 index 0000000000..a95d918da2 --- /dev/null +++ b/json-fortran.fobis @@ -0,0 +1,144 @@ +[modes] +modes = static-gnu static-gnu-debug + static-intel static-intel-debug + shared-gnu shared-gnu-debug + shared-intel shared-intel-debug + tests-gnu tests-gnu-debug + tests-intel tests-intel-debug + +[common-variables] +$MOD_FILE = json_module.F90 +$FORD_FILE = json-fortran.md +$STATIC_LIB = libjsonfortran.a +$SHARED_LIB = libjsonfortran.so +$OPTIMIZE = -O2 +$CSTATIC_GNU = -c -fbacktrace -Wall -Wextra -Wno-maybe-uninitialized -Wno-unused-function -pedantic -std=f2008ts +$DEBUG_GNU = -O0 -g3 -Warray-bounds -Wcharacter-truncation -Wline-truncation -Wimplicit-interface -Wimplicit-procedure -Wunderflow -fcheck=all -fmodule-private -ffree-line-length-132 -fimplicit-none -fbacktrace -fdump-core -finit-real=nan -std=f2008ts -fall-intrinsics +$CSTATIC_INT = -c -std15 +$DEBUG_INT = -O0 -debug all -check all -warn all -extend-source 132 -traceback -gen-interfaces -fpe-all=0 -fp-stack-check -fstack-protector-all -ftrapuv -no-ftz -std15 +$EXCLUDE_DIRS = ./src/tests/introspection + ./visual_studio/jsonfortrantest + +# modes templates +[template-static] +cflags_heritage = True +build_dir = ./lib/ +mod_dir = ./mod/ +obj_dir = ./obj/ +src = ./src/ +colors = True +quiet = False +log = False +jobs = 2 +mklib = static +target = $MOD_FILE +output = $STATIC_LIB +exclude_dirs = $EXCLUDE_DIRS + +[template-shared] +cflags_heritage = True +build_dir = ./lib/ +mod_dir = ./mod/ +obj_dir = ./obj/ +src = ./src/ +colors = True +quiet = False +log = False +jobs = 2 +mklib = shared +target = $MOD_FILE +output = $SHARED_LIB +exclude_dirs = $EXCLUDE_DIRS + +[template-tests] +cflags_heritage = True +build_dir = ./bin/ +mod_dir = ./mod/ +obj_dir = ./obj/ +src = ./src/ +colors = True +quiet = False +log = False +jobs = 2 +exclude_dirs = $EXCLUDE_DIRS + +# main modes + +# library +[static-gnu] +description = Build library with GNU gfortran by optimized-static flags +compiler = gnu +cflags = $CSTATIC_GNU $OPTIMIZE +template = template-static + +[static-gnu-debug] +description = Build library with GNU gfortran by debug-static flags +compiler = gnu +cflags = $CSTATIC_GNU $DEBUG_GNU +template = template-static + +[static-intel] +description = Build library with Intel Fortran by optimized-static flags +compiler = intel +cflags = $CSTATIC_INT $OPTIMIZE +template = template-static + +[static-intel-debug] +description = Build library with Intel Fortran by debug-static flags +compiler = intel +cflags = $CSTATIC_INT $DEBUG_INT +template = template-static + +[shared-gnu] +description = Build library with GNU gfortran by optimized-shared flags +compiler = gnu +cflags = $CSTATIC_GNU $OPTIMIZE +template = template-shared + +[shared-gnu-debug] +description = Build library with GNU gfortran by debug-shared flags +compiler = gnu +cflags = $CSTATIC_GNU $DEBUG_GNU +template = template-shared + +[shared-intel] +description = Build library with Intel Fortran by optimized-shared flags +compiler = intel +cflags = $CSTATIC_INT $OPTIMIZE +template = template-shared + +[shared-intel-debug] +description = Build library with Intel Fortran by debug-shared flags +compiler = intel +cflags = $CSTATIC_INT $DEBUG_INT +template = template-shared + +# test programs +[tests-gnu] +description = Build all tests with GNU gfortran by optimized-static flags +compiler = gnu +cflags = $CSTATIC_GNU $OPTIMIZE +template = template-tests + +[tests-gnu-debug] +description = Build all tests with GNU gfortran by debug-static flags +compiler = gnu +cflags = $CSTATIC_GNU $DEBUG_GNU +template = template-tests + +[tests-intel] +description = Build all tests with Intel Fortran by optimized-static flags +compiler = intel +cflags = $CSTATIC_INT $OPTIMIZE +template = template-tests + +[tests-intel-debug] +description = Build all tests with Intel Fortran by debug-static flags +compiler = intel +cflags = $CSTATIC_INT $DEBUG_INT +template = template-tests + +# auxiliary rules +[rule-makedoc] +help = Rule for building documentation from source files +rule_1 = ford $FORD_FILE diff --git a/src/json_string_utilities.F90 b/src/json_string_utilities.F90 index e4db447d55..7348beab54 100644 --- a/src/json_string_utilities.F90 +++ b/src/json_string_utilities.F90 @@ -369,6 +369,9 @@ subroutine escape_string(str_in, str_out, escape_solidus) if (escape_solidus) then str_out(ipos:ipos+1) = backslash//c ipos = ipos + 2 + else + str_out(ipos:ipos) = c + ipos = ipos + 1 end if case(bspace) str_out(ipos:ipos+1) = '\b' diff --git a/src/tests/jf_test_1.F90 b/src/tests/jf_test_01.F90 similarity index 100% rename from src/tests/jf_test_1.F90 rename to src/tests/jf_test_01.F90 diff --git a/src/tests/jf_test_2.F90 b/src/tests/jf_test_02.F90 similarity index 100% rename from src/tests/jf_test_2.F90 rename to src/tests/jf_test_02.F90 diff --git a/src/tests/jf_test_3.F90 b/src/tests/jf_test_03.F90 similarity index 100% rename from src/tests/jf_test_3.F90 rename to src/tests/jf_test_03.F90 diff --git a/src/tests/jf_test_4.F90 b/src/tests/jf_test_04.F90 similarity index 100% rename from src/tests/jf_test_4.F90 rename to src/tests/jf_test_04.F90 diff --git a/src/tests/jf_test_5.F90 b/src/tests/jf_test_05.F90 similarity index 100% rename from src/tests/jf_test_5.F90 rename to src/tests/jf_test_05.F90 diff --git a/src/tests/jf_test_6.F90 b/src/tests/jf_test_06.F90 similarity index 100% rename from src/tests/jf_test_6.F90 rename to src/tests/jf_test_06.F90 diff --git a/src/tests/jf_test_7.F90 b/src/tests/jf_test_07.F90 similarity index 100% rename from src/tests/jf_test_7.F90 rename to src/tests/jf_test_07.F90 diff --git a/src/tests/jf_test_8.F90 b/src/tests/jf_test_08.F90 similarity index 100% rename from src/tests/jf_test_8.F90 rename to src/tests/jf_test_08.F90 diff --git a/src/tests/jf_test_9.F90 b/src/tests/jf_test_09.F90 similarity index 100% rename from src/tests/jf_test_9.F90 rename to src/tests/jf_test_09.F90 diff --git a/src/tests/jf_test_30.F90 b/src/tests/jf_test_30.F90 index f58c36ec7a..9a7035eb05 100644 --- a/src/tests/jf_test_30.F90 +++ b/src/tests/jf_test_30.F90 @@ -22,7 +22,7 @@ subroutine test_30(error_cnt) type(json_core) :: json_c integer :: i - character(kind=CK,len=*),parameter :: str = CK_'{"vars":{"a/first":1,"a\/second":2}}' + character(kind=CK,len=*),parameter :: str = CK_'{"vars":{"a/first":1,"a\/second":2,"a\\b\\c\/third/blah/blah":3}}' character(len=*),dimension(2),parameter :: tf = ['True ','False'] error_cnt = 0 diff --git a/visual_studio/jsonfortranlib/jsonfortranlib.vfproj b/visual_studio/jsonfortranlib/jsonfortranlib.vfproj index 36d4ea4458..97d56c021d 100644 --- a/visual_studio/jsonfortranlib/jsonfortranlib.vfproj +++ b/visual_studio/jsonfortranlib/jsonfortranlib.vfproj @@ -42,7 +42,8 @@ - + + diff --git a/visual_studio/jsonfortrantest/jsonfortrantest.vfproj b/visual_studio/jsonfortrantest/jsonfortrantest.vfproj index ad96bfe25d..9a6a38c524 100644 --- a/visual_studio/jsonfortrantest/jsonfortrantest.vfproj +++ b/visual_studio/jsonfortrantest/jsonfortrantest.vfproj @@ -46,7 +46,15 @@ - + + + + + + + + + @@ -57,7 +65,6 @@ - @@ -67,13 +74,6 @@ - - - - - - -