diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 20044156..78376445 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,14 +23,12 @@ jobs: - os: windows-latest artifact: win64 name: Windows x64 - inklecate_url: https://github.com/inkle/ink/releases/download/0.9.0/inklecate_windows_and_linux.zip + inklecate_url: https://github.com/inkle/ink/releases/download/v1.0.0/inklecate_windows.zip proof: false - os: "ubuntu-20.04" artifact: linux name: Linux x64 - inklecate_url: https://github.com/inkle/ink/releases/download/0.9.0/inklecate_windows_and_linux.zip - inklecate_pre: "mono " - inklecate_post: ".exe" + inklecate_url: https://github.com/inkle/ink/releases/download/v1.0.0/inklecate_linux.zip proof: true steps: @@ -94,7 +92,7 @@ jobs: - name: Install working-directory: ${{github.workspace}}/build shell: bash - run: cmake --install . --config $BUILD_TYPE --prefix bin + run: cmake --install . --config $BUILD_TYPE --prefix bin --component cl # Upload bin directory as artifact - name: Upload Binary Artifact @@ -113,7 +111,7 @@ jobs: cp ../inkcpp_runtime_driver drivers/ chmod +x drivers/inkcpp_runtime_driver mkdir deps/inkcpp - cp ../../build/bin/bin/* deps/inkcpp/ + cp ../../build/bin/* deps/inkcpp/ chmod +x deps/inkcpp/inkcpp_cl # Run it diff --git a/CMakeLists.txt b/CMakeLists.txt index c820b5e7..59541441 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,8 @@ enable_testing() project(inkcpp VERSION 0.1) SET(CMAKE_CXX_STANDARD 17) SET(CMAKE_CXX_STANDARD_REQUIRED ON) +SET(CMAKE_INSTALL_LIBRARY_DIR lib) +SET(CMAKE_INSTALL_INCLUDE_DIR include) # Add subdirectories add_subdirectory(shared) add_subdirectory(inkcpp) @@ -14,3 +16,44 @@ add_subdirectory(inkcpp_compiler) add_subdirectory(inkcpp_cl) add_subdirectory(inkcpp_test) add_subdirectory(unreal) + + +get_target_property(TEE inkcpp PUBLIC_HEADER) +install(TARGETS inkcpp inkcpp_compiler inkcpp_shared + EXPORT inkcppTarget + ARCHIVE DESTINATION "lib/ink" + COMPONENT lib EXCLUDE_FROM_ALL + PUBLIC_HEADER DESTINATION "include/ink" + COMPONENT lib EXCLUDE_FROM_ALL +) + +install(EXPORT inkcppTarget + FILE inkcppTargets.cmake DESTINATION "lib/cmake/inkcpp" + COMPONENT lib EXCLUDE_FROM_ALL) + +include(CMakePackageConfigHelpers) +configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/inkcppConfig.cmake" + INSTALL_DESTINATION "lib/cmake/inkcpp" + NO_SET_AND_CHECK_MACRO + NO_CHECK_REQUIRED_COMPONENTS_MACRO) +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/inkcppConfigVersion.cmake" + VERSION "${inkcpp_VERSION_MAJOR}.${inkcpp_VERSION_MINOR}" + COMPATIBILITY AnyNewerVersion) +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/inkcppConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/inkcppConfigVersion.cmake + DESTINATION lib/cmake/inkcpp COMPONENT lib EXCLUDE_FROM_ALL) +export(EXPORT inkcppTarget + FILE "${CMAKE_CURRENT_BINARY_DIR}/inkcppTargets.cmake") + +# include(InstallRequiredSystemLibraries) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt") +set(CPACK_PACKAGE_VERSION_MAJOR "${inkcpp_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${inkcpp_VERSION_MINOR}") +set(CPACK_SOURCE_GENERATOR "ZIP") +set(CPACK_GENERATOR "ZIP") +set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) +set(CPACK_COMPONENTS_GROUPING IGNORE) +include(CPack) diff --git a/Config.cmake.in b/Config.cmake.in new file mode 100644 index 00000000..6cb414fc --- /dev/null +++ b/Config.cmake.in @@ -0,0 +1,2 @@ +@PACKAGE_INIT@ +include ( "${CMAKE_CURRENT_LIST_DIR}/inkcppTargets.cmake" ) diff --git a/README.md b/README.md index 3eef40a9..35195eaa 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,8 @@ CMake will then generate the necessary build files for your environment. By defa To build, either run the generated buildfiles OR you can use `cmake --build . --config ` from the build folder to automatically execute the relevant toolchain. +For a more in depth installation description please checkout the (wiki)[https://github.com/brwarner/inkcpp/wiki/building]. + ## Including in C++ Code Required software: (CMake)[https://cmake.org/] @@ -89,15 +91,15 @@ Instructions: 1. Clone the repository 2. Configure and build the project with CMake, as described above -3. From your newly-created `build` directory, run `cmake --install . --prefix Path/To/Desired/Library/Directory`. Note that this will currently fail if the project was built for Debug instead of Release. +3. From your newly-created `build` directory, run `cmake --install . --prefix Path/To/Desired/Library/Directory --component `. 4. Generated in your chosen directory, you will find a collection of folders. The following must be linked into your build solution for your C++ to compile correctly: - - `include/public`: contains important shared headers. - + For a Visual Studio project, link this directory as an Include Directory in VC++ Directories. - - `inkcpp/Source/inkcpp/Public`: contains the primary headers for using InkCPP in your code. + - `include/ink`: contains important shared headers. + For a Visual Studio project, link this directory as an Include Directory in VC++ Directories. - `lib/inkcpp.lib` and `lib/inkcpp_compiler.lib`: contains the library code for the InkCPP runner and compiler, respectively. + For a Visual Studio project, link these files as Additional Dependencies in Linker->Input. + You don't need to link the compiler if you're not using it within your program. + - if you used the `cl` component you will find the `inkcpp_cl` executable in this location + - for `unreal` you will find a `Source` directory containing the Unreal needed libs and headers. **Note:** not working for the current unreal version, we are working to fix this. 5. Reference the headers in your code like so: ```cpp @@ -106,6 +108,7 @@ Instructions: #include #include ``` +6. if you use cmake checkout the (wiki)[https://github.com/brwarner/inkcpp/wiki/building#cmake-example] for including the library via cmake ### Troubleshooting diff --git a/inkcpp/CMakeLists.txt b/inkcpp/CMakeLists.txt index 0e4a426d..876b6b18 100644 --- a/inkcpp/CMakeLists.txt +++ b/inkcpp/CMakeLists.txt @@ -26,20 +26,19 @@ list(APPEND SOURCES ) source_group(Collections REGULAR_EXPRESSION collections/.*) add_library(inkcpp ${SOURCES}) +target_include_directories(inkcpp PUBLIC + $ + $ +) +FILE(GLOB PUBLIC_HEADERS "include/*") +set_target_properties(inkcpp PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}") # Make sure the include directory is included -target_include_directories(inkcpp - PUBLIC include - PUBLIC ../shared/public - PRIVATE ../shared/private - ) - +target_link_libraries(inkcpp PRIVATE inkcpp_shared) # Make sure this project and all dependencies use the C++17 standard target_compile_features(inkcpp PUBLIC cxx_std_17) -# Default installation -install(TARGETS inkcpp DESTINATION lib) # Unreal installation -install(DIRECTORY "include/" DESTINATION "inkcpp/Source/inkcpp/Public/ink/" COMPONENT unreal) -install(FILES ${SOURCES} DESTINATION "inkcpp/Source/inkcpp/Private/ink/" COMPONENT unreal) +install(DIRECTORY "include/" DESTINATION "inkcpp/Source/inkcpp/Public/ink/" COMPONENT unreal EXCLUDE_FROM_ALL) +install(FILES ${SOURCES} DESTINATION "inkcpp/Source/inkcpp/Private/ink/" COMPONENT unreal EXCLUDE_FROM_ALL) diff --git a/inkcpp/functional.cpp b/inkcpp/functional.cpp index 0fe4cc69..9c0cad62 100644 --- a/inkcpp/functional.cpp +++ b/inkcpp/functional.cpp @@ -18,6 +18,14 @@ namespace ink::runtime::internal return val.get(); } + template<> + const char* function_base::pop(basic_eval_stack* stack) + { + value val = stack->pop(); + inkAssert(val.type() == value_type::string, "Type missmatch!"); + return val.get().str; + } + template<> void function_base::push(basic_eval_stack* stack, const int32_t& v) { diff --git a/inkcpp_cl/CMakeLists.txt b/inkcpp_cl/CMakeLists.txt index c9c0e338..5483a05d 100644 --- a/inkcpp_cl/CMakeLists.txt +++ b/inkcpp_cl/CMakeLists.txt @@ -2,7 +2,7 @@ add_executable(inkcpp_cl inkcpp_cl.cpp test.h test.cpp) # Include compiler and runtime libraries -target_link_libraries(inkcpp_cl PUBLIC inkcpp inkcpp_compiler) +target_link_libraries(inkcpp_cl PUBLIC inkcpp inkcpp_compiler inkcpp_shared) # For https://en.cppreference.com/w/cpp/filesystem#Notes if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") @@ -16,4 +16,4 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") endif() # Install -install(TARGETS inkcpp_cl DESTINATION bin) +install(TARGETS inkcpp_cl DESTINATION . COMPONENT cl EXCLUDE_FROM_ALL) diff --git a/inkcpp_compiler/CMakeLists.txt b/inkcpp_compiler/CMakeLists.txt index 8a4c6205..b3da94dc 100644 --- a/inkcpp_compiler/CMakeLists.txt +++ b/inkcpp_compiler/CMakeLists.txt @@ -1,4 +1,4 @@ -list(APPEND SOURCES +list(APPEND SOURCES compiler.cpp binary_stream.h binary_stream.cpp json.hpp json_compiler.h json_compiler.cpp emitter.h emitter.cpp @@ -11,19 +11,18 @@ list(APPEND SOURCES add_definitions(-DINK_COMPILER -DINK_EXPOSE_JSON) add_library(inkcpp_compiler ${SOURCES}) -# Make sure the include directory is included -target_include_directories(inkcpp_compiler - PUBLIC include - PUBLIC ../shared/public - PRIVATE ../shared/private - ) +target_include_directories(inkcpp_compiler PUBLIC + $ + $ +) +FILE(GLOB PUBLIC_HEADERS "include/*") +set_target_properties(inkcpp_compiler PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}") + +target_link_libraries(inkcpp_compiler PRIVATE inkcpp_shared) # Make sure this project and all dependencies use the C++17 standard target_compile_features(inkcpp_compiler PUBLIC cxx_std_17) -# Default installation -install(TARGETS inkcpp_compiler DESTINATION lib) - # Unreal installation -install(DIRECTORY "include/" DESTINATION "inkcpp/Source/inkcpp_editor/Private/ink/" COMPONENT unreal) -install(FILES ${SOURCES} DESTINATION "inkcpp/Source/inkcpp_editor/Private/ink/" COMPONENT unreal) +install(DIRECTORY "include/" DESTINATION "inkcpp/Source/inkcpp_editor/Private/ink/" COMPONENT unreal EXCLUDE_FROM_ALL) +install(FILES ${SOURCES} DESTINATION "inkcpp/Source/inkcpp_editor/Private/ink/" COMPONENT unreal EXCLUDE_FROM_ALL) diff --git a/inkcpp_test/CMakeLists.txt b/inkcpp_test/CMakeLists.txt index 92e0c6ed..4ee6fbb6 100644 --- a/inkcpp_test/CMakeLists.txt +++ b/inkcpp_test/CMakeLists.txt @@ -11,7 +11,7 @@ add_executable(inkcpp_test catch.hpp Main.cpp NewLines.cpp ) -target_link_libraries(inkcpp_test PUBLIC inkcpp inkcpp_compiler) +target_link_libraries(inkcpp_test PUBLIC inkcpp inkcpp_compiler inkcpp_shared) target_include_directories(inkcpp_test PRIVATE ../shared/private/) # For https://en.cppreference.com/w/cpp/filesystem#Notes diff --git a/shared/CMakeLists.txt b/shared/CMakeLists.txt index 616f643f..e01c32c0 100644 --- a/shared/CMakeLists.txt +++ b/shared/CMakeLists.txt @@ -1,6 +1,14 @@ -# Install public files into the include directory -install(DIRECTORY public DESTINATION include) +add_library(inkcpp_shared INTERFACE) + +target_include_directories(inkcpp_shared + INTERFACE + $ + $ + $ +) +FILE(GLOB PUBLIC_HEADERS "public/*") +set_target_properties(inkcpp_shared PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}") # Unreal installation -install(DIRECTORY "public/" DESTINATION "inkcpp/Source/shared/Public/" COMPONENT unreal) -install(DIRECTORY "private/" DESTINATION "inkcpp/Source/shared/Private/" COMPONENT unreal) \ No newline at end of file +install(DIRECTORY "public/" DESTINATION "inkcpp/Source/shared/Public/" COMPONENT unreal EXCLUDE_FROM_ALL) +install(DIRECTORY "private/" DESTINATION "inkcpp/Source/shared/Private/" COMPONENT unreal EXCLUDE_FROM_ALL) diff --git a/unreal/CMakeLists.txt b/unreal/CMakeLists.txt index cdebc57c..91909cea 100644 --- a/unreal/CMakeLists.txt +++ b/unreal/CMakeLists.txt @@ -1,2 +1,2 @@ # Copy files into destination directory -install(DIRECTORY "inkcpp/" DESTINATION "inkcpp" COMPONENT unreal) \ No newline at end of file +install(DIRECTORY "inkcpp/" DESTINATION "inkcpp" COMPONENT unreal EXCLUDE_FROM_ALL)