GithubHelp home page GithubHelp logo

cling-cmake's People

Contributors

derofim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cling-cmake's Issues

use -DLLVM_BUILD_TOOLS=Off

# NOTE: use -DLLVM_BUILD_TOOLS=Off, see https://github.com/root-project/cling/issues/297
cmake -DCMAKE_CXX_STANDARD=17 -DLLVM_BUILD_TOOLS=Off -DCMAKE_INSTALL_PREFIX=../release -DCMAKE_BUILD_TYPE=Release ../src

practical examples of integration. Any tutorials or samples you could share?

Any tutorials or samples you could share?


Best example is official demo: https://github.com/root-project/cling/blob/ee374738072fab73d2b9896c968a000cf0a1bfb4/tools/demo/cling-demo.cpp

Note that in cling-demo.cpp we can use global data and functions freely, as usual (see int aGlobal).

I use install_cling.sh from https://github.com/blockspacer/CXXCTP#how-to-build

Just copy install_cling.sh and FindCling.cmake into your project and link with cling::Interpreter library. CXXCTP is MIT licensed.

Than you can create cling::Interpreter

interpreter_ = std::make_uniquecling::Interpreter( interp_args.size(), &(interp_args[0]), LLVMDIR/, {}, false/);

See https://github.com/blockspacer/CXXCTP/blob/master/src/ClingInterpreterModule.cpp#L165

Than you can run any C++ code:

metaProcessor_->process(".L " + CPP_FILENAME_OR_ANY_CODE_HERE, compilationResult, nullptr, true);

If you want to pass not global data into script - wrap data into struct and convert pointer to that struct into hex string. See std::hex << std::showbase from https://github.com/blockspacer/CXXCTP/blob/master/src/clangPipeline.cpp#L220

Now you can get result of running code in Cling via cling::Value result;

I prefer to pass arbitrary data into cling::Value as void*, like so https://github.com/blockspacer/CXXCTP/blob/master/src/clangPipeline.cpp#L438

A lot of useful links can be found at README.md from https://github.com/derofim/cling-cmake

https://github.com/root-project/cling/tree/master/www/docs/talks https://github.com/caiorss/C-Cpp-Notes/blob/master/Root-cern-repl.org

pass C++ variables into Cling

If you want to use cling, maybe following will be useful:
https://github.com/blockspacer/CXXCTP/blob/master/src/template_engine/engine_main.cpp#L20

Note argRefToCling function, it allows to pass C++ variables into Cling (or maybe it is possible to do it easier).

// Or use macro / codegen
#define ARG_REF_TO_CLING(varType, varName) argRefToCling(varType, #varName, (varName))

Also note that usage example is reflection/codegen engine ( https://github.com/blockspacer/CXXCTP ), may be useful for game engine/level editor/e.t.c.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.