Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
BasedOnStyle: Google
---
Language: Cpp

BreakBeforeBraces: Attach
PointerAlignment: Right
IndentWidth: 2
Standard: Cpp11
TabWidth: 2
UseTab: ForIndentation

AccessModifierOffset: 0
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: DontAlign
AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: BeforeColon
BreakStringLiterals: true
ColumnLimit: 160
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: true
DerivePointerAlignment: false
FixNamespaceComments: true
IndentCaseLabels: true
IndentWrappedFunctionNames: true
KeepEmptyLinesAtTheStartOfBlocks: false
NamespaceIndentation: None
ReflowComments: false
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false

74 changes: 74 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: ci
on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash

jobs:
build:
name: ${{ matrix.platform.name }}-${{ matrix.config.name }}-${{ matrix.type.name }}
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- { name: Windows VS2019 x86, os: windows-2019, flags: -GNinja }
- { name: Windows VS2019 x64, os: windows-2019, flags: -GNinja }
- { name: Windows VS2022 x86, os: windows-2022, flags: -GNinja }
- { name: Windows VS2022 x64, os: windows-2022, flags: -GNinja }
- { name: Windows LLVM/Clang, os: windows-2022, flags: -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -GNinja }
- { name: Windows MinGW, os: windows-2022, flags: -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc -GNinja }
- { name: Linux GCC, os: ubuntu-22.04, flags: -GNinja }
- { name: Linux Clang, os: ubuntu-22.04, flags: -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -GNinja }
config:
- { name: Shared, flags: -DBUILD_SHARED_LIBS=TRUE }
- { name: Static, flags: -DBUILD_SHARED_LIBS=FALSE }
type:
- { name: Release }
- { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug }

include:
- platform: { name: Android, os: ubuntu-22.04 }
config: { name: x86 (API 33), flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=33 -DCMAKE_ANDROID_NDK=$ANDROID_SDK_ROOT/ndk/26.1.10909125 -DBUILD_SHARED_LIBS=TRUE -DCMAKE_ANDROID_STL_TYPE=c++_shared, arch: x86, api: 33 }
type: { name: Release }
- platform: { name: Android, os: ubuntu-22.04 }
config: { name: x86_64 (API 33), flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=x86_64 -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=33 -DCMAKE_ANDROID_NDK=$ANDROID_SDK_ROOT/ndk/26.1.10909125 -DBUILD_SHARED_LIBS=TRUE -DCMAKE_ANDROID_STL_TYPE=c++_shared, arch: x86_64, api: 33 }
type: { name: Release }
- platform: { name: Android, os: ubuntu-22.04 }
config: { name: armeabi-v7a (API 33), flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=33 -DCMAKE_ANDROID_NDK=$ANDROID_SDK_ROOT/ndk/26.1.10909125 -DBUILD_SHARED_LIBS=TRUE -DCMAKE_ANDROID_STL_TYPE=c++_shared, arch: armeabi-v7a, api: 33 }
type: { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug }
- platform: { name: Android, os: ubuntu-22.04 }
config: { name: arm64-v8a (API 33), flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=33 -DCMAKE_ANDROID_NDK=$ANDROID_SDK_ROOT/ndk/26.1.10909125 -DBUILD_SHARED_LIBS=TRUE -DCMAKE_ANDROID_STL_TYPE=c++_shared, arch: arm64-v8a, api: 33 }
type: { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug }

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set VS Arch
if: contains(matrix.platform.name, 'Windows VS') && !contains(matrix.platform.name, 'MSBuild')
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ contains(matrix.platform.name, 'x86') && 'x86' || 'x64' }}

- name: Get CMake and Ninja
uses: lukka/get-cmake@latest
with:
cmakeVersion: ${{ runner.os == 'Windows' && '3.27' || '3.27' }}
ninjaVersion: latest

- name: Install Android Components
if: matrix.platform.name == 'Android'
run: |
echo "y" | ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "build-tools;33.0.2"
echo "y" | ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "ndk;26.1.10909125"

- name: build
run: |
mkdir build && cd build
cmake ${{ matrix.config.flags }} ${{ matrix.platform.flags }} ..
cmake --build . --config ${{ matrix.type.name }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ meta/documentation/generated/
*.xcworkspace/
xcuserdata/

build
build*

*.pbxuser
*.perspective
Expand Down
11 changes: 5 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.7.2...3.14)
cmake_minimum_required(VERSION 3.7.2...3.17)

project(JsonBox)

Expand Down Expand Up @@ -35,17 +35,16 @@ set(JSONBOX_HEADERS

# set options for android
if(CMAKE_SYSTEM_NAME MATCHES "Android")
message("-- Compiling for Android")
set(BUILD_SHARED_LIBS TRUE)
message("-- Compiling for Android")
if (CMAKE_ANDROID_API LESS 14)
message(FATAL_ERROR "Android API level (${CMAKE_ANDROID_API}) must be equal or greater than 14.")
endif()
if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")
message(WARNING "CMake might not properly support setting the STL. Make sure to adjust all generated library projects!")
endif()
set(ANDROID_NDK "$ENV{ANDROID_NDK}")
set(CMAKE_INSTALL_PREFIX ${CMAKE_ANDROID_NDK}/sources/third_party/jsonbox)
set(DEFAULT_INSTALL_MISC_DIR ${CMAKE_ANDROID_NDK}/sources/third_party/jsonbox)
set(ANDROID_NDK "$ENV{ANDROID_NDK}")
set(CMAKE_INSTALL_PREFIX ${CMAKE_ANDROID_NDK}/sources/third_party/JsonBox)
set(DEFAULT_INSTALL_MISC_DIR ${CMAKE_ANDROID_NDK}/sources/third_party/JsonBox)
set(LIB_SUFFIX "/${CMAKE_ANDROID_ARCH_ABI}")
if(CMAKE_ANDROID_STL_TYPE MATCHES "_shared")
add_definitions("-DSTL_LIBRARY=${CMAKE_ANDROID_STL_TYPE}")
Expand Down
47 changes: 0 additions & 47 deletions cmake/Modules/FindJSONBOX.cmake

This file was deleted.

66 changes: 66 additions & 0 deletions cmake/Modules/FindJsonBox.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#
# Try to find JsonBox library and include path.
# Once done this will define
#
# JsonBox_FOUND
# JsonBox_INCLUDE_DIR
# JsonBox_LIBRARIES
# JsonBox_LIBRARY
# JsonBox_ROOT
#

set(FIND_JsonBox_PATHS
${JsonBox_ROOT}
$ENV{JsonBox_ROOT}
/usr/local
/usr/local/include
/usr
/sw
/opt/local
/opt/csw
/opt)

if(JsonBox_ROOT)
SET(LIB_SUFFIX "/")
if(CMAKE_SYSTEM_NAME MATCHES "Android")
SET(LIB_SUFFIX "/${CMAKE_ANDROID_ARCH_ABI}")
endif(CMAKE_SYSTEM_NAME MATCHES "Android")
SET(JsonBox_INCLUDE_DIR "${JsonBox_ROOT}/include")
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
if(CMAKE_BUILD_TYPE MATCHES "Debug")
SET(JsonBox_LIBRARY "${JsonBox_ROOT}/lib${LIB_SUFFIX}/JsonBox_d.lib")
else()
SET(JsonBox_LIBRARY "${JsonBox_ROOT}/lib${LIB_SUFFIX}/JsonBox.lib")
endif()
else()
if(CMAKE_BUILD_TYPE MATCHES "Debug")
SET(JsonBox_LIBRARY "${JsonBox_ROOT}/lib${LIB_SUFFIX}/libJsonBox_d.a")
else()
SET(JsonBox_LIBRARY "${JsonBox_ROOT}/lib${LIB_SUFFIX}/libJsonBox.a")
endif()
endif()
SET(JsonBox_LIBRARIES ${JsonBox_LIBRARY})
SET(JsonBox_FOUND 1)
endif(JsonBox_ROOT)

find_path(JsonBox_INCLUDE_DIR include/JsonBox.h
PATH_SUFFIXES include
PATHS ${FIND_JsonBox_PATHS})

find_library(JsonBox_LIBRARY
NAMES JsonBox
PATH_SUFFIXES lib
PATHS ${FIND_JsonBox_PATHS})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(JsonBox DEFAULT_MSG JsonBox_LIBRARY JsonBox_INCLUDE_DIR)

set(JsonBox_INCLUDE_DIR "${JsonBox_INCLUDE_DIR}")
set(JsonBox_LIBRARIES "${JsonBox_LIBRARY}")

if(NOT JsonBox_FOUND)
set(FIND_JsonBox_ERROR "Could NOT find JsonBox")
if(JsonBox_FIND_REQUIRED)
message(FATAL_ERROR ${FIND_JsonBox_ERROR})
endif()
endif()
7 changes: 5 additions & 2 deletions readme.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<!-- -*- markdown -*- -->
# Json Box

[![ci](https://github.com/cristianglezm/JsonBox/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/cristianglezm/JsonBox/actions/workflows/ci.yml)

[JSON](http://json.org/) (JavaScript Object Notation) is a lightweight data-interchange format.

Json Box is a C++ library used to read and write JSON with ease and speed.
Expand Down Expand Up @@ -28,10 +30,11 @@ Android
mkdir build
cd build && mkdir armeabi-v7a
cd armeabi-v7a
cmake -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_NDK=<android_ndk> \
export ANDROID_NDK=<android_ndk>
cmake -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_NDK=$ANDROID_NDK \
-DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a -DCMAKE_ANDROID_STL_TYPE=c++_static \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang \
-DCMAKE_INSTALL_PREFIX=<android_ndk>/sources/third_party/JsonBox ../..
-DCMAKE_INSTALL_PREFIX=$ANDROID_NDK/sources/third_party/JsonBox ../..
make install
```

Expand Down
28 changes: 27 additions & 1 deletion src/Android.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := JsonBox_d
LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libJsonBox_d.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include

prebuilt_path := $(call local-prebuilt-path,$(LOCAL_SRC_FILES))
prebuilt := $(strip $(wildcard $(prebuilt_path)))

ifdef prebuilt
include $(PREBUILT_SHARED_LIBRARY)
endif

include $(CLEAR_VARS)
LOCAL_MODULE := JsonBox
LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libJsonBox.so
Expand All @@ -23,4 +36,17 @@ prebuilt := $(strip $(wildcard $(prebuilt_path)))

ifdef prebuilt
include $(PREBUILT_STATIC_LIBRARY)
endif
endif

include $(CLEAR_VARS)

LOCAL_MODULE := JsonBox_d-static
LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libJsonBox_d.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include

prebuilt_path := $(call local-prebuilt-path,$(LOCAL_SRC_FILES))
prebuilt := $(strip $(wildcard $(prebuilt_path)))

ifdef prebuilt
include $(PREBUILT_STATIC_LIBRARY)
endif
Loading