-
-
Notifications
You must be signed in to change notification settings - Fork 15
building
The project uses cmake and can therefore be build with
mkdir build
mkdir install
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install
cmake --build . --config Release
cmake --install . --component <component-name e.g. lib>
After this you can use cpack
to create zip-archives for the different components of that project.
It is also possible to install a component with cmake --install . --component <component-name e.g. lib>
If you are interested in a debug build von inkcpp you can set -DCMAKE_BUILD_TYPE=Debug
instead, and build with cmake --build . --config Debug
which will produce the debug version.
The components are:
-
lib
-
contains the
inkcpp
andinkcpp_compiler
libraries and header files needed to use it in a C++ project this component supports cmakefind_package
command, for a example see this example. -
cl
-
contains
inkcpp_cl
the inkcpp command line client, for example to compile the ink binaries. -
unreal
-
contains folder structure to include inkcpp in a Unreal project.
tree
|- test.ink
|- main.cpp
|- CMakeListst.txt
inklecat -j test.ink
mkdir build; cd build
cmake .. -DCMAKE_PREFIX_PATH=<path-to-install-directory> -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release
cd ..
./build/main
Path for the executable may depends on your build system.
test.ink
EXTERNAL my_ink_function(a,b)
Hello world!
* Hello back!
Nice to hear from you!
* Bye
BTW 3 + 5 = {my_ink_function(3,5)}
-> END
Create test.ink.json
with inkclecat -j test.ink
CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
project(main)
find_package(inkcpp CONFIG REQUIRED)
add_executable(main main.cpp)
set_property(TARGET main PROPERTY CXX_STANDARD 17)
target_link_libraries(main inkcpp inkcpp_compiler)
main.cpp
#include <ink/system.h>
#include <ink/choice.h>
#include <ink/runner.h>
#include <ink/story.h>
#include <ink/compiler.h>
#include <iostream>
using namespace ink::runtime;
int
MyInkFunction( int a, int b )
{
return a + b;
}
int
main()
{
ink::compiler::run("test.ink.json", "test.bin");
// Load ink binary story, generated from the inkCPP compiler
story* myInk = story::from_file( "test.bin" );
// Create a new thread
runner thread = myInk->new_runner();
// Register external functions (glue automatically generated via templates)
thread->bind( "my_ink_function", &MyInkFunction );
// Write to cout
while ( thread->can_continue() )
std::cout << thread->getline();
// Iterate choices
int id = 0;
for ( const choice& c : *thread )
{
std::cout << (id++) << ". " << c.text() << std::endl;
}
std::cin >> id;
thread->choose(id);
// Write to cout
while ( thread->can_continue() )
std::cout << thread->getline();
}