diff --git a/.gitignore b/.gitignore index a8388bc..1e84dfd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -Testbed/.vs -Testbed/x64 -Testbed/Debug -Testbed/AS_DEBUG +conan*.txt +!conanfile.txt +conan.lock +graph_info.json +Find*.cmake diff --git a/README.md b/README.md index 91844f4..fe8d5f9 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ To install, just copy the 'RefCountingObject\*' files to your project. Define your C++ classes by implementing `RefCountingObject` and calling `RegisterRefCountingObject()` for each type. -``` +```cpp class Foo: RefCountingObject{} Foo::RegisterRefCountingObject("Foo", engine); ``` @@ -39,7 +39,7 @@ Define your C++ smart pointers by qualifying `RefCountingObjectPtr<>` and use them in your interfaces. These will become usable interchangeably from both C++ and script. -``` +```cpp typedef RefCountingObjectPtr FooPtr; // demo API: static FooPtr gf; @@ -59,7 +59,7 @@ engine->RegisterGlobalFunction("FooPtr@ GetFoo()", asFUNCTION(GetFoo), asCALL_CD In C++, use just the smart pointers and you'll be safe. -``` +```cpp FooPtr f1 = new Foo(); // refcount 1 SetFoo(f1); // refcount 2 FooPtr f2 = GetFoo(); // refcount 3 diff --git a/Testbed/CMakeLists.txt b/Testbed/CMakeLists.txt new file mode 100644 index 0000000..b0c5e8d --- /dev/null +++ b/Testbed/CMakeLists.txt @@ -0,0 +1,49 @@ +#------------------------------------------------------- +# Testbed Main Build Script +#------------------------------------------------------- +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_BINARY_DIR}) +cmake_minimum_required(VERSION 3.0) + +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + + +project(Testbed) + +option(USE_CONAN "Use conan for installing deps" ON) + +if (USE_CONAN) + if (NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake") + message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan") + file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/0.18.1/conan.cmake" "${CMAKE_BINARY_DIR}/conan.cmake") + endif () + + include(${CMAKE_BINARY_DIR}/conan.cmake) + conan_cmake_configure(REQUIRES angelscript/2.35.1 GENERATORS cmake_find_package) + conan_cmake_autodetect(settings) + conan_cmake_install(PATH_OR_REFERENCE . BUILD missing SETTINGS ${settings}) +endif () + +find_package(Angelscript REQUIRED) + +set(CMAKE_CXX_STANDARD 11) + +file(COPY "${CMAKE_SOURCE_DIR}/../Example.as" DESTINATION "${CMAKE_BINARY_DIR}") + +set(SRC + ../RefCountingObject.h + ../RefCountingObjectPtr.h + debug_log.h + scriptstdstring.h + + ../Example.cpp + main.cpp + scriptstdstring.cpp +) + +add_executable(${PROJECT_NAME} ${SRC}) +target_compile_definitions(${PROJECT_NAME} PRIVATE RCO_ENABLE_DEBUGTRACE) +target_link_libraries(${PROJECT_NAME} PRIVATE Angelscript::angelscript) + +if (WIN32) + target_link_libraries(${PROJECT_NAME} PRIVATE Winmm) +endif() \ No newline at end of file diff --git a/Testbed/Testbed.sln b/Testbed/Testbed.sln deleted file mode 100644 index ebbe000..0000000 --- a/Testbed/Testbed.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31624.102 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Testbed", "Testbed.vcxproj", "{47D20151-9B88-40C3-ACA2-3621F591D71E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {47D20151-9B88-40C3-ACA2-3621F591D71E}.Debug|x64.ActiveCfg = Debug|x64 - {47D20151-9B88-40C3-ACA2-3621F591D71E}.Debug|x64.Build.0 = Debug|x64 - {47D20151-9B88-40C3-ACA2-3621F591D71E}.Debug|x86.ActiveCfg = Debug|Win32 - {47D20151-9B88-40C3-ACA2-3621F591D71E}.Debug|x86.Build.0 = Debug|Win32 - {47D20151-9B88-40C3-ACA2-3621F591D71E}.Release|x64.ActiveCfg = Release|x64 - {47D20151-9B88-40C3-ACA2-3621F591D71E}.Release|x64.Build.0 = Release|x64 - {47D20151-9B88-40C3-ACA2-3621F591D71E}.Release|x86.ActiveCfg = Release|Win32 - {47D20151-9B88-40C3-ACA2-3621F591D71E}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {B3B30A21-25F8-4DD2-96D6-F7FF05089BCF} - EndGlobalSection -EndGlobal diff --git a/Testbed/Testbed.vcxproj b/Testbed/Testbed.vcxproj deleted file mode 100644 index f358def..0000000 --- a/Testbed/Testbed.vcxproj +++ /dev/null @@ -1,169 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {47d20151-9b88-40c3-aca2-3621f591d71e} - Testbed - 10.0 - - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - C:\Temp\angelscript\include;%(AdditionalIncludeDirectories) - stdcpp17 - MultiThreadedDebug - $(ProjectDir)/debug_log.h - - - Console - true - C:\Temp\angelscript\lib;%(AdditionalLibraryDirectories) - angelscriptd.lib;winmm.lib;%(AdditionalDependencies) - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - C:\Temp\angelscript\include;%(AdditionalIncludeDirectories) - $(ProjectDir)/debug_log.h - - - Console - true - true - true - C:\Temp\angelscript\lib;%(AdditionalLibraryDirectories) - angelscriptd.lib;winmm.lib;%(AdditionalDependencies) - - - - - Level3 - true - _DEBUG;_CONSOLE;RCO_ENABLE_DEBUGTRACE;%(PreprocessorDefinitions) - true - C:\Temp\angelscript\include;%(AdditionalIncludeDirectories) - - - Console - true - C:\Temp\angelscript\lib;%(AdditionalLibraryDirectories) - angelscriptd.lib;%(AdditionalDependencies) - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Testbed/Testbed.vcxproj.filters b/Testbed/Testbed.vcxproj.filters deleted file mode 100644 index a980d1d..0000000 --- a/Testbed/Testbed.vcxproj.filters +++ /dev/null @@ -1,38 +0,0 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {e15a7a2d-69e6-4368-abb9-fbd4f75dadae} - - - - - testbed - - - testbed - - - testbed - - - RefCountingObject - - - RefCountingObject - - - - - testbed - - - testbed - - - - \ No newline at end of file diff --git a/Testbed/Testbed.vcxproj.user b/Testbed/Testbed.vcxproj.user deleted file mode 100644 index 0f14913..0000000 --- a/Testbed/Testbed.vcxproj.user +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Testbed/conanfile.txt b/Testbed/conanfile.txt new file mode 100644 index 0000000..519a842 --- /dev/null +++ b/Testbed/conanfile.txt @@ -0,0 +1,5 @@ +[requires] +angelscript/2.35.1 + +[generators] +cmake_find_package \ No newline at end of file diff --git a/Testbed/main.cpp b/Testbed/main.cpp index 5eb559f..50fa2f3 100644 --- a/Testbed/main.cpp +++ b/Testbed/main.cpp @@ -244,7 +244,7 @@ int CompileScript(asIScriptEngine *engine) // We will load the script from a file on the disk. FILE *f = nullptr; - fopen_s(&f, "../Example.as", "rb"); + fopen_s(&f, "Example.as", "rb"); if( f == 0 ) { std::cout << "Failed to open the script file." << std::endl;