Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
43 changes: 43 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,53 @@ 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)
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)
2 changes: 2 additions & 0 deletions Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@PACKAGE_INIT@
include ( "${CMAKE_CURRENT_LIST_DIR}/inkcppTargets.cmake" )
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Release|Debug>` 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/]
Expand All @@ -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 <lib/cl/unreal>`.
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
Expand All @@ -106,6 +108,7 @@ Instructions:
#include <ink/runner.h>
#include <ink/choice.h>
```
6. if you use cmake checkout the (wiki)[https://github.com/brwarner/inkcpp/wiki/building#cmake-example] for including the library via cmake


### Troubleshooting
Expand Down
19 changes: 9 additions & 10 deletions inkcpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,19 @@ list(APPEND SOURCES
)
source_group(Collections REGULAR_EXPRESSION collections/.*)
add_library(inkcpp ${SOURCES})
target_include_directories(inkcpp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
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)
8 changes: 8 additions & 0 deletions inkcpp/functional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ namespace ink::runtime::internal
return val.get<value_type::int32>();
}

template<>
const char* function_base::pop<const char*>(basic_eval_stack* stack)
{
value val = stack->pop();
inkAssert(val.type() == value_type::string, "Type missmatch!");
return val.get<value_type::string>().str;
}

template<>
void function_base::push<int32_t>(basic_eval_stack* stack, const int32_t& v)
{
Expand Down
4 changes: 2 additions & 2 deletions inkcpp_cl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
23 changes: 11 additions & 12 deletions inkcpp_compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
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)
2 changes: 1 addition & 1 deletion inkcpp_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 12 additions & 4 deletions shared/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/public>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/private>
$<INSTALL_INTERFACE:inkcpp>
)
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)
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)
2 changes: 1 addition & 1 deletion unreal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Copy files into destination directory
install(DIRECTORY "inkcpp/" DESTINATION "inkcpp" COMPONENT unreal)
install(DIRECTORY "inkcpp/" DESTINATION "inkcpp" COMPONENT unreal EXCLUDE_FROM_ALL)