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)
|
project(cjson)
|
||||||
|
|
||||||
|
set(CMAKE_C_STANDARD 11)
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/include)
|
include_directories(${CMAKE_CURRENT_LIST_DIR}/include)
|
||||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/../pocketpy/include)
|
include_directories(${CMAKE_CURRENT_LIST_DIR}/../pocketpy/include)
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS_RELEASE "-O2")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
add_library(
|
add_library(
|
||||||
cjson
|
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
|
#pragma GCC visibility pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "cjson.hpp"
|
#include "cJSON.h"
|
||||||
|
|
||||||
/* define our own boolean type */
|
/* define our own boolean type */
|
||||||
#ifdef true
|
#ifdef true
|
||||||
@ -1,6 +1,4 @@
|
|||||||
#include "cjson/cJSON.h"
|
#include "cJSONw.hpp"
|
||||||
#include "pocketpy/pocketpy.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace pkpy{
|
namespace pkpy{
|
||||||
|
|
||||||
@ -90,7 +88,7 @@ static Dict convert_cjson_to_dict(const cJSON * const item, VM* vm)
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void add_module_cjson(VM* vm){
|
void add_module_cjson(VM* vm){
|
||||||
PyObject* mod = vm->new_module("cjson");
|
PyObject* mod = vm->new_module("cjson");
|
||||||
vm->bind_func<1>(mod, "loads", [](VM* vm, ArgsView args) {
|
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)
|
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src POCKETPY_SRC)
|
||||||
|
|
||||||
option(PK_USE_BOX2D "Use Box2D" OFF)
|
option(PK_USE_BOX2D "Use Box2D" OFF)
|
||||||
|
option(PK_USE_CJSON "Use cJSON" ON)
|
||||||
option(PK_USE_DYLIB "Use dylib" OFF)
|
option(PK_USE_DYLIB "Use dylib" OFF)
|
||||||
|
|
||||||
if(PK_USE_BOX2D)
|
if(PK_USE_BOX2D)
|
||||||
@ -49,8 +50,11 @@ if(PK_USE_BOX2D)
|
|||||||
add_definitions(-DPK_USE_BOX2D)
|
add_definitions(-DPK_USE_BOX2D)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(PK_USE_CJSON)
|
||||||
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/3rd/cjson)
|
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/3rd/cjson)
|
||||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/3rd/cjson/include)
|
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
|
# 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).
|
# or if it is added as a dependency (through add_subdirectory for example).
|
||||||
|
|||||||
@ -4,11 +4,14 @@
|
|||||||
#include "box2dw.hpp"
|
#include "box2dw.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PK_USE_CJSON
|
||||||
|
#include "cJSONw.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined (_WIN32) && PK_SUPPORT_DYLIB == 1
|
#if defined (_WIN32) && PK_SUPPORT_DYLIB == 1
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
#include "cjson.hpp"
|
|
||||||
|
|
||||||
namespace pkpy{
|
namespace pkpy{
|
||||||
|
|
||||||
@ -1713,7 +1716,6 @@ void VM::post_init(){
|
|||||||
add_module_traceback(this);
|
add_module_traceback(this);
|
||||||
add_module_time(this);
|
add_module_time(this);
|
||||||
add_module_json(this);
|
add_module_json(this);
|
||||||
add_module_cjson(this);
|
|
||||||
add_module_math(this);
|
add_module_math(this);
|
||||||
add_module_re(this);
|
add_module_re(this);
|
||||||
add_module_dis(this);
|
add_module_dis(this);
|
||||||
@ -1750,6 +1752,10 @@ void VM::post_init(){
|
|||||||
#ifdef PK_USE_BOX2D
|
#ifdef PK_USE_BOX2D
|
||||||
add_module_box2d(this);
|
add_module_box2d(this);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef PK_USE_CJSON
|
||||||
|
add_module_cjson(this);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user