Skip to content

Commit

Permalink
Rename build target name to format-json
Browse files Browse the repository at this point in the history
  • Loading branch information
karekoho committed Jun 5, 2021
1 parent 03bd0f5 commit 83ad8f7
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 18 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.0.2)
project(json)
project(format-json)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCES
Expand All @@ -24,8 +24,8 @@ set(SOURCES
src/json/json_leaf.h
src/json/json_exception.h)

add_library(json SHARED ${SOURCES})
install(TARGETS json DESTINATION lib)
add_library(format-json SHARED ${SOURCES})
install(TARGETS format-json DESTINATION lib)
install(DIRECTORY src/json/ DESTINATION include/format FILES_MATCHING PATTERN "*.h")

# If “make install” is invoked or INSTALL is built, this directory is prepended onto all install directories.
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ In the _root of the repository_ run the following commands:
cmake .
make & make install
```
A shared library called `libjson` will be created in `/usr/local/lib`. The development headers will be found in `/usr/local/include/format`.
A shared library called `libformat-json` will be created in `/usr/local/lib`. The development headers will be found in `/usr/local/include/format`.
#### Include
```c++
<format/json.h>
Expand Down Expand Up @@ -79,7 +79,7 @@ const json::value & val = j[L"Image"];

{
// Get the primitive value of an object
bool value = animated.get ();
bool value = animated.value ();

std::cout << value << ',' <<
// This get the same value
Expand All @@ -89,7 +89,7 @@ const json::value & val = j[L"Image"];
}

// Object and array values are represented as a string
std::wcout << ids.get() << std::endl;
std::wcout << ids.value () << std::endl;
// output: [116,943,234,38793,{}]

// Array and object types are iterable.
Expand Down Expand Up @@ -127,14 +127,14 @@ const json::json j ( new json::object {
{ L"Height", new json::number (600.0) },
{ L"Title", new json::string (L"View from 15th Floor") },
{ L"Thumbnail", new json::object { { L"Url", new json::string (L"http://www.example.com/image/481989943") },
{ L"Height", new json::number (static_cast<long long>(125) ) },
{ L"Width", new json::number (static_cast<long long> (100)) } }
{ L"Height", new json::number (125) },
{ L"Width", new json::number (100) } }
},
{ L"Animated", new json::boolean (false) },
{ L"IDs", new json::array { new json::number (static_cast<long long> (116)),
new json::number (static_cast<long long> (943)),
new json::number (static_cast<long long> (234)),
new json::number (static_cast<long long> (38793)) }
{ L"IDs", new json::array { new json::number (116),
new json::number (943),
new json::number (234),
new json::number (38793) }
}
}
}
Expand All @@ -147,11 +147,11 @@ const json::array & ids = static_cast<const json::array &> (j[L"Image"][L"IDs"])
json::array *copy_ids = new json::array (ids);

// Modify existing value
(*copy_ids)[1] = static_cast<long long> (100);
(*copy_ids)[1] = 100;

// Add a new value. If index is greater than array.size - 1,
// new value goes at the end, i.e. array[array.size]
(*copy_ids)[4] = static_cast<long long> (101);
(*copy_ids)[4] = 101;

// Remove value by assigning undefined to it
(*copy_ids)[3] = json::undefined ();
Expand Down
35 changes: 35 additions & 0 deletions build/linux/json/debug/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.0.2)
project(format-json)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(PATH "../../../../src/json/")
set(SOURCES
${PATH}json_value.cpp
${PATH}json_undefined.cpp
${PATH}json_string.cpp
${PATH}json_object.cpp
${PATH}json_number.cpp
${PATH}json_json.cpp
${PATH}json_array.cpp
${PATH}json_exception.cpp
# headers
${PATH}json_value.h
${PATH}json_undefined.h
${PATH}json_string.h
${PATH}json_object.h
${PATH}json_number.h
${PATH}json_null.h
${PATH}json_json.h
${PATH}json_boolean.h
${PATH}json_array.h
${PATH}json_leaf.h
${PATH}json_exception.h)

add_library(format-json SHARED ${SOURCES})
install(TARGETS format-json DESTINATION lib)
install(DIRECTORY ${PATH} DESTINATION include/format FILES_MATCHING PATTERN "*.h")

# If “make install” is invoked or INSTALL is built, this directory is prepended onto all install directories.
# This variable defaults to /usr/local on UNIX and c:/Program Files on Windows
# cmake .. -DCMAKE_INSTALL_PREFIX=../_install

4 changes: 1 addition & 3 deletions build/linux/test/debug/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
cmake_minimum_required(VERSION 3.0.2)
project(test_debug)
#set(CMAKE_BUILD_TYPE Release)
#project(tests_debug)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(PATH "../../../../src/test/")
Expand All @@ -28,7 +26,7 @@ set(SOURCES
${PATH}test_selector_test.h)

find_library (CPPUNIT_LIB cppunit)
find_library (JSON_LIB json)
find_library (JSON_LIB format-json)

message(${CPPUNIT_LIB})
message(${JSON_LIB})
Expand Down
36 changes: 36 additions & 0 deletions build/macos/test/release/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
cmake_minimum_required(VERSION 3.0.2)
project(test_release)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(PATH "../../../../src/test/")
set(SOURCES
${PATH}main.cpp
${PATH}json_array_iterator_test.h
${PATH}json_exception_test.h
${PATH}json_mock_value.h
${PATH}json_object_iterator_test.h
${PATH}json_test.h
${PATH}json_value_test_interface.h
${PATH}unit_test.h
${PATH}json_array_test.h
${PATH}json_leaf_iterator_test.h
${PATH}json_null_test.h
${PATH}json_object_test.h
${PATH}json_undefined_test.h
${PATH}test_selector.h
${PATH}json_boolean_test.h
${PATH}json_leaf_test.h
${PATH}json_number_test.h
${PATH}json_string_test.h
${PATH}json_value_test.h
${PATH}test_selector_test.h)

find_library (CPPUNIT_LIB cppunit)
find_library (JSON_LIB format-json)

message(${CPPUNIT_LIB})
message(${JSON_LIB})

add_executable (test_release ${SOURCES})
target_include_directories (test_release PUBLIC "/usr/local/include")
target_link_libraries (test_release ${CPPUNIT_LIB} ${JSON_LIB})
15 changes: 15 additions & 0 deletions doc/debugging-in-container.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Start container:
cd to repository root
run: docker run -tiv $PWD:/valgrind karek/valgrind:latest

Build libjson:
cd to build/linux/json/debug
run: cmake .
run: make && sudo make install

Build tests:
cd to to build/linux/test/debug
run: cmake .
run: make && sudo make install

run: valgrind ./test_debug
6 changes: 5 additions & 1 deletion src/test/json_test.pro
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,14 @@ SUBDIRS += \
../json/json.pro

DISTFILES += \
../../CMakeLists.txt \
../../README.md \
../../build/linux/json/debug/CMakeLists.txt \
../../build/linux/test/debug/CMakeLists.txt \
../../build/macos/test/release/CMakeLists.txt \
../../build/tests/CMakeLists.txt
../../build/tests/CMakeLists.txt \
../../doc/debugging-in-container.txt \
../../doc/roadmap.txt



0 comments on commit 83ad8f7

Please sign in to comment.