mirror of
https://github.com/pocketpy/pocketpy
synced 2025-11-10 21:50:19 +00:00
necessary changes of project structure
This commit is contained in:
parent
8ebe610e33
commit
4afef54da7
@ -2,14 +2,18 @@ cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
project(cjson)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/../pocketpy/include)
|
||||
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O2")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
add_library(
|
||||
cjson
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/cJSON.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/cJSON.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/cJSONw.cpp
|
||||
)
|
||||
|
||||
8
3rd/cjson/include/cJSONw.hpp
Normal file
8
3rd/cjson/include/cJSONw.hpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "cJSON.h"
|
||||
#include "pocketpy/pocketpy.h"
|
||||
|
||||
namespace pkpy {
|
||||
|
||||
void add_module_cjson(VM* vm);
|
||||
|
||||
} // namespace pkpy
|
||||
@ -56,7 +56,7 @@
|
||||
#pragma GCC visibility pop
|
||||
#endif
|
||||
|
||||
#include "cjson.hpp"
|
||||
#include "cJSON.h"
|
||||
|
||||
/* define our own boolean type */
|
||||
#ifdef true
|
||||
@ -1,6 +1,4 @@
|
||||
#include "cjson/cJSON.h"
|
||||
#include "pocketpy/pocketpy.h"
|
||||
|
||||
#include "cJSONw.hpp"
|
||||
|
||||
namespace pkpy{
|
||||
|
||||
@ -90,7 +88,7 @@ static Dict convert_cjson_to_dict(const cJSON * const item, VM* vm)
|
||||
return output;
|
||||
}
|
||||
|
||||
inline void add_module_cjson(VM* vm){
|
||||
void add_module_cjson(VM* vm){
|
||||
PyObject* mod = vm->new_module("cjson");
|
||||
vm->bind_func<1>(mod, "loads", [](VM* vm, ArgsView args) {
|
||||
|
||||
@ -41,6 +41,7 @@ include_directories(${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src POCKETPY_SRC)
|
||||
|
||||
option(PK_USE_BOX2D "Use Box2D" OFF)
|
||||
option(PK_USE_CJSON "Use cJSON" ON)
|
||||
option(PK_USE_DYLIB "Use dylib" OFF)
|
||||
|
||||
if(PK_USE_BOX2D)
|
||||
@ -49,8 +50,11 @@ if(PK_USE_BOX2D)
|
||||
add_definitions(-DPK_USE_BOX2D)
|
||||
endif()
|
||||
|
||||
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/3rd/cjson)
|
||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/3rd/cjson/include)
|
||||
if(PK_USE_CJSON)
|
||||
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/3rd/cjson)
|
||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/3rd/cjson/include)
|
||||
add_definitions(-DPK_USE_CJSON)
|
||||
endif()
|
||||
|
||||
# PK_IS_MAIN determines whether the project is being used from root
|
||||
# or if it is added as a dependency (through add_subdirectory for example).
|
||||
|
||||
@ -4,11 +4,14 @@
|
||||
#include "box2dw.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef PK_USE_CJSON
|
||||
#include "cJSONw.hpp"
|
||||
#endif
|
||||
|
||||
#if defined (_WIN32) && PK_SUPPORT_DYLIB == 1
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include "cjson.hpp"
|
||||
|
||||
namespace pkpy{
|
||||
|
||||
@ -1713,7 +1716,6 @@ void VM::post_init(){
|
||||
add_module_traceback(this);
|
||||
add_module_time(this);
|
||||
add_module_json(this);
|
||||
add_module_cjson(this);
|
||||
add_module_math(this);
|
||||
add_module_re(this);
|
||||
add_module_dis(this);
|
||||
@ -1750,6 +1752,10 @@ void VM::post_init(){
|
||||
#ifdef PK_USE_BOX2D
|
||||
add_module_box2d(this);
|
||||
#endif
|
||||
#ifdef PK_USE_CJSON
|
||||
add_module_cjson(this);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user