-
-
Notifications
You must be signed in to change notification settings - Fork 16
building
Julian Benda edited this page Jun 9, 2022
·
6 revisions
The project uses cmake and can therefore be build with
mkdir build
cd build
cmake ..
cmake --build .
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>
The components are:
lib
:
: contains the inkcpp
and inkcpp_compiler
libraries and header files needed to use it in a C++ project
this component supports cmake find_package
command, for a example see #cmake-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
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 <inkcpp/system.h>
#include <inkcpp/choice.h>
#include <inkcpp/runner.h>
#include <inkcpp/story.h>
#include <inkcpp/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();
}