Skip to content

Commit

Permalink
Try run on apple silicon.
Browse files Browse the repository at this point in the history
  • Loading branch information
sheredom committed Feb 2, 2024
1 parent 06aa578 commit 4bee9aa
Show file tree
Hide file tree
Showing 10 changed files with 931 additions and 323 deletions.
25 changes: 18 additions & 7 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest, windows-latest, macos-11, macos-14]
type: [Debug, RelWithDebInfo, MinSizeRel, Release]
compiler: [default, clang, gcc]
compiler: [default, clang, gcc, tcc]
exclude:
- {os: "macOS-latest", compiler: "clang"}
- {os: "windows-latest", compiler: "gcc"}
- {os: "macOS-latest", compiler: "gcc"}
- {os: "macos-11", compiler: "clang"}
- {os: "macos-11", compiler: "gcc"}
- {os: "macos-11", compiler: "tcc"}
- {os: "macos-14", compiler: "clang"}
- {os: "macos-14", compiler: "gcc"}
- {os: "macos-14", compiler: "tcc"}
- {os: "ubuntu-latest", compiler: "default"}
- {os: "ubuntu-latest", compiler: "default"}
- {os: "windows-latest", compiler: "gcc"}
- {os: "windows-latest", compiler: "tcc"}
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -29,7 +34,7 @@ jobs:

- name: Setup dependencies
if: startsWith(matrix.os, 'ubuntu')
run: sudo apt-get install -y gcc-10 g++-10 clang-10
run: sudo apt-get install -y gcc-10 g++-10 clang tcc

- name: Configure CMake
shell: bash
Expand All @@ -43,11 +48,17 @@ jobs:
working-directory: ${{github.workspace}}/build
run: cmake $GITHUB_WORKSPACE/test -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10

- name: Configure CMake with TCC (Ubuntu)
shell: bash
if: matrix.compiler == 'tcc' && startsWith(matrix.os, 'ubuntu')
working-directory: ${{github.workspace}}/build
run: cmake $GITHUB_WORKSPACE/test -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DCMAKE_C_COMPILER=tcc -DCMAKE_CXX_COMPILER=g++-10

- name: Configure CMake with Clang (Ubuntu)
shell: bash
if: (matrix.compiler == 'clang') && startsWith(matrix.os, 'ubuntu')
working-directory: ${{github.workspace}}/build
run: cmake $GITHUB_WORKSPACE/test -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DCMAKE_C_COMPILER=clang-10 -DCMAKE_CXX_COMPILER=clang++-10
run: cmake $GITHUB_WORKSPACE/test -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++

- name: Configure CMake with Clang (Windows)
shell: bash
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

- name: Setup dependencies
if: startsWith(matrix.os, 'ubuntu')
run: sudo apt-get install -y clang-10
run: sudo apt-get install -y clang

- name: Configure CMake (macOS)
shell: bash
Expand All @@ -37,7 +37,7 @@ jobs:
shell: bash
if: startsWith(matrix.os, 'ubuntu')
working-directory: ${{github.workspace}}/build
run: cmake $GITHUB_WORKSPACE/test -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DCMAKE_C_COMPILER=clang-10 -DCMAKE_CXX_COMPILER=clang++-10 -DJSON_USE_SANITIZER=${{ matrix.sanitizer }}
run: cmake $GITHUB_WORKSPACE/test -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DJSON_USE_SANITIZER=${{ matrix.sanitizer }}

- name: Build
working-directory: ${{github.workspace}}/build
Expand Down
17 changes: 14 additions & 3 deletions json.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,18 @@
#include <stddef.h>
#include <string.h>

#if defined(__TINYC__)
#define JSON_ATTRIBUTE(a) __attribute((a))
#else
#define JSON_ATTRIBUTE(a) __attribute__((a))
#endif

#if defined(_MSC_VER) || defined(__WATCOMC__)
#define json_weak __inline
#elif defined(__clang__) || defined(__GNUC__)
#define json_weak __attribute__((weak))
#elif defined(__clang__) || defined(__GNUC__) || defined(__TINYC__)
#define json_weak JSON_ATTRIBUTE(weak)
#else
#error Non clang, non gcc, non MSVC, non WATCOM compiler found!
#error Non clang, non gcc, non MSVC, non tcc, non WATCOM compiler found!
#endif

#ifdef __cplusplus
Expand Down Expand Up @@ -435,6 +441,11 @@ typedef struct json_parse_result_s {
/* Who cares if nullptr doesn't work with C++98, we don't use it there! */
#pragma clang diagnostic ignored "-Wc++98-compat"
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"

#if __has_warning("-Wunsafe-buffer-usage")
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
#endif

#elif defined(_MSC_VER)
#pragma warning(push)

Expand Down
1 change: 0 additions & 1 deletion test/allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ UTEST(allocator, null) {
struct json_parse_result_s result;
struct json_value_s *value =
json_parse_ex(payload, strlen(payload), 0, &_::alloc, 0, &result);
struct json_object_s *object = 0;

ASSERT_FALSE(value);

Expand Down
2 changes: 0 additions & 2 deletions test/allow_c_style_comments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ UTEST_F_TEARDOWN(allow_c_style_comments) {
struct json_value_s *value = utest_fixture->value;
struct json_object_s *object = 0;
struct json_value_s *value2 = 0;
size_t size = 0;
void *json = 0;

ASSERT_TRUE(value);
ASSERT_TRUE(value->payload);
Expand Down
2 changes: 0 additions & 2 deletions test/allow_equals_in_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,6 @@ UTEST_F_TEARDOWN(allow_equals_in_object) {
struct json_value_s *value = utest_fixture->value;
struct json_object_s *object = 0;
struct json_value_s *value2 = 0;
size_t size = 0;
void *json = 0;

ASSERT_TRUE(value);
ASSERT_TRUE(value->payload);
Expand Down
2 changes: 0 additions & 2 deletions test/allow_global_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,6 @@ UTEST_F_TEARDOWN(allow_global_object) {
struct json_value_s *value = utest_fixture->value;
struct json_object_s *object = 0;
struct json_value_s *value2 = 0;
size_t size = 0;
void *json = 0;

ASSERT_TRUE(value);
ASSERT_TRUE(value->payload);
Expand Down
6 changes: 0 additions & 6 deletions test/allow_json5.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ UTEST(allow_json5, example1) {
"}";
struct json_value_s *value = json_parse_ex(
payload, strlen(payload), json_parse_flags_allow_json5, 0, 0, 0);
struct json_object_s *object = 0;
struct json_value_s *value2 = 0;
struct json_string_s *string = 0;

ASSERT_TRUE(value);

Expand Down Expand Up @@ -111,9 +108,6 @@ UTEST(allow_json5, example2) {
"}\n";
struct json_value_s *value = json_parse_ex(
payload, strlen(payload), json_parse_flags_allow_json5, 0, 0, 0);
struct json_object_s *object = 0;
struct json_value_s *value2 = 0;
struct json_string_s *string = 0;

ASSERT_TRUE(value);

Expand Down
2 changes: 0 additions & 2 deletions test/allow_no_commas.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ UTEST(allow_no_commas, array_one) {
payload, strlen(payload), json_parse_flags_allow_no_commas, 0, 0, 0);
struct json_array_s *array = 0;
struct json_array_element_s *element = 0;
struct json_value_s *value2 = 0;

ASSERT_TRUE(value);
ASSERT_TRUE(value->payload);
Expand Down Expand Up @@ -189,7 +188,6 @@ UTEST_F_TEARDOWN(allow_no_commas) {
struct json_value_s *value = utest_fixture->value;
struct json_array_s *array = 0;
struct json_array_element_s *element = 0;
struct json_value_s *value2 = 0;

ASSERT_TRUE(value);
ASSERT_TRUE(value->payload);
Expand Down
Loading

0 comments on commit 4bee9aa

Please sign in to comment.