C ++ソースコードの変更と生成のための完全なオープンソース、強力なソリューション。 C ++プロジェクトのボイラープレートコードの量を減らします。
このレポは、できるだけ早くhttps://github.com/blockspacer/flextoolに移行します
CXXCTPは非推奨になります。 flextoolを好む
CXXCTPは、新しい内省、反射、コンパイル時間の実行のためにC ++を拡張するトランスピラーです。
CXXCTPは、定義されたソースコード変換のセットを作成することを目指していません。ユーザーは、ソースコード変換のためにC ++スクリプトを共有できます。
誰かがinterface.cxxやenum_to_json.cxxなどの有用なスクリプトをオープンソースコミュニティに共有したとします。 ctp_scriptsフォルダーに配置するだけで、プロジェクトでそれらを使用できます。
メタプログラムは、他のプログラムをデータとして扱うプログラムを執筆する「芸術」です。これは、プログラムがコードを生成、読み取り、分析、およびそれ自体を変換して、特定のソリューションを実現できることを意味します。
注:このプロジェクトは、保証なしでそのまま提供されます(ライセンスを参照)。
いくつかの実験機能(たとえばモジュール)も提供するので、なぜClangを拡張しないのですか?
Clangはコンパイラですが、このプロジェクトはトランスピラーであり、LLVM/アセンブリを変更することなく標準化されたC ++コードにコードを変換します。
ツールの出力はC ++コードであるため、emscriptenを使用してトランスピールコードをコンパイルし、静的コードアナライザーを使用し、Cling内のコードを実行できます。
CXXCTPを使用すると、スクリプトを作成および共有できます
開発では、例を参照してください。現在、Linuxのみをサポートしています。
Windows/Mac/などの下でLinuxコンテナを実行できることに注意してください。
// usage example from ReflShapeKind.hpp
enum class
$apply(
reflect_enum
)
ReflShapeKind0 : uint32_t {
Box = 3 ,
Sphere = 6 ,
}; // Usage example. NOTE: no inheritance & definition outside lib.
// in lib .h
struct drawable {
virtual void draw ( const char * arg1) const noexcept = 0;
};
struct printable {
virtual void print ( const char * arg1, const char * arg2) const noexcept = 0;
};
struct canvas3D {
std::string name3D;
};
struct canvas4D {
std::string name4D;
};
// in app .cpp
void draw<drawable>( const canvas3D& data, const char * arg1){
std::cout << " drawing to canvas3D name = " << data. name3D << std::endl;
}
void draw<drawable>( const canvas4D& data, const char * arg1){
std::cout << " drawing to canvas4D name = " << data. name4D << std::endl;
}
void print<printable>( const canvas3D& data, const char * arg1, const char * arg2){
std::cout << " printing to canvas3D name = " << data. name3D << std::endl;
}
void print<printable>( const canvas4D& data, const char * arg1, const char * arg2){
std::cout << " printing to canvas4D name = " << data. name4D << std::endl;
}
std::vector< _tc_combined_t <drawable>> vec {
canvas3D{},
canvas4D{},
};
_tc_combined_t <drawable, printable> CVS = canvas4D{};
CVS.draw( " " );
CVS.print( " " , " " );
canvas3D cvs3D;
CVS = std::move(cvs3D);
canvas4D cvs4D;
CVS = cvs4D; // copy
CVS = vec.at( 0 ); // <drawable> to <drawable, printable>$ export (
static int resultSomeInt = 2345 ;
)
$eval( " #include <optional> " )
$exec(
printf ( " execkjljlk n " );
printf ( " execasdasd n " );
)
$set_embed( " set_embed103 " ,
printf ( " set_embed101 n " );
printf ( " set_embed102 n " );
)
$embed(
[&clangMatchResult, &clangRewriter, &clangDecl]() {
printf ( " embed01 n " );
printf ( " embed02 n " );
return new llvm::Optional<std::string>{ " embed03 " };
}();
) class
$apply(make_interface;make_removefuncbody;make_reflect)
SomeInterfaceName {
virtual ~SomeInterfaceName () = 0 ;
/* int f ( ) { // {}
int i = 6;
{
// {
// }
}
return i;
}; */
int foo ();
virtual void foobar ( int & arg1) = 0 ;
virtual inline void zoobar ( int & arg2);
// int m_bar;
// int m_bar2 = 2;
};git submodule sync --recursive
git fetch --recurse-submodules
git submodule update --init --recursive --depth 100 --progress
# or
git submodule update --force --recursive --init --remotedocker:https://medium.com/@saniaky/configure-docker-to-use-a-host-proxy-e88bd988c0aa
クローンコード(上記のように)とcdにクローニングされたdir。
注: --build-arg NO_SSL="False"を使用してDocker画像を作成することもできます。 dockerfileでコメントを読んでください。
# Give docker the rights to access X-server
sudo -E xhost +local:docker
# build Dockerfile
sudo -E docker build --no-cache
--build-arg GIT_WITH_OPENSSL= " "
--build-arg NO_SSL= " False "
-t cpp-docker-cxxctp .
# Now let’s check if our image has been created.
sudo -E docker images
# Run in container without leaving host terminal
sudo -E docker run -v " $PWD " :/home/u/cxxctp -w /home/u/cxxctp cpp-docker-cxxctp CXXCTP_tool -version --version
# Run a terminal in container
sudo -E docker run --rm -v " $PWD " :/home/u/cxxctp -w /home/u/cxxctp -it -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix cpp-docker-cxxctp
# type in container terminal
CXXCTP_tool -version --version # Run a terminal in container
sudo -E docker run --rm -v " $PWD " :/home/u/cxxctp -w /home/u/cxxctp -it -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix cpp-docker-cxxctp
# An example of how to build (with Makefile generated from cmake) inside the container
# Mounts $PWD to /home/u/cxxctp and runs command
mkdir build
sudo -E docker run --rm -v " $PWD " :/home/u/cxxctp -w /home/u/cxxctp/build cpp-docker-cxxctp cmake -DCONAN_AUTO_INSTALL=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE ..
# Run resulting app in host OS:
# ./build/<app> pip install --index-url=https://pypi.python.org/simple/ --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org wheel
&&
pip install --index-url=https://pypi.python.org/simple/ --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org virtualenv
&&
pip install --index-url=https://pypi.python.org/simple/ --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org conan
&&
pip install --index-url=https://pypi.python.org/simple/ --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org conan_package_tools
conan profile new default --detect
# conan profile update settings.compiler.libcxx=libstdc++11 default
conan remote list
conan search * boost * -r all ~/.conan/conan.confでプロキシとcacert_pathを構成します。https://docs.conan.io/en/en/latest/reference/config_files/conan.conf.html#proxiesを参照してください
Conan Clangプロファイルを構成して、プロファイルClangを使用します。
/usr/bin/clang-6.0 -v
/usr/bin/clang++-6.0 -v
nano ~ /.conan/profiles/clang
[settings]
# We are building in Ubuntu Linux
os_build=Linux
os=Linux
arch_build=x86_64
arch=x86_64
compiler=clang
compiler.version=6.0
compiler.libcxx=libstdc++11
[env]
CC=/usr/bin/clang-6.0
CXX=/usr/bin/clang++-6.0そして、 conan install ***** --profile clang
/usr/bin/gcc -v
/usr/bin/g++ -v
nano ~ /.conan/profiles/gcc
[settings]
# We are building in Ubuntu Linux
os_build=Linux
os=Linux
arch_build=x86_64
arch=x86_64
compiler=gcc
compiler.version=7
compiler.libcxx=libstdc++11
[env]
CC=/usr/bin/gcc
CXX=/usr/bin/g++SSLを無効にしたい場合(プロキシなど):
# see https://docs.conan.io/en/latest/reference/commands/misc/remote.html#conan-remote
conan remote update conan-center https://conan.bintray.com False
conan search boost * -r=conan-center
conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan
conan remote update bincrafters https://api.bintray.com/conan/bincrafters/public-conan False
conan search boost * -r=bincraftersCorpを設定したい場合。 CACERT:
CONAN_CACERT_PATH=/path/to/ca-bundle.crt
file $CONAN_CACERT_PATH便利なリンク:
依存関係リモートのリストを追加できるようにするには、次のコマンドを入力してください。
cmake -E time conan config install conan/remotes/
# OR:
# cmake -E time conan config install conan/remotes_disabled_ssl/ # NOTE: don't forget to re-run `conan install` after command below
# NOTE: change `build_type=Debug` to `build_type=Release` in production
cmake -DEXTRA_CONAN_OPTS= " --profile;clang;-s;build_type=Debug;--build;missing " -P tools/buildConanThirdparty.cmakeconan remote add Manu343726 https://api.bintray.com/conan/manu343726/conan-packages False
git clone http://github.com/foonathan/type_safe.git -b v0.2.1
cd type_safe
# NOTE: change `build_type=Debug` to `build_type=Release` in production
CONAN_REVISIONS_ENABLED=1
CONAN_VERBOSE_TRACEBACK=1
CONAN_PRINT_RUN_COMMANDS=1
CONAN_LOGGING_LEVEL=10
GIT_SSL_NO_VERIFY=true
conan create . conan/stable -s build_type=Debug --profile clang --build missing # NOTE: change `build_type=Debug` to `build_type=Release` in production
git clone http://github.com/mosra/corrade.git && cd corrade
CONAN_REVISIONS_ENABLED=1
CONAN_VERBOSE_TRACEBACK=1
CONAN_PRINT_RUN_COMMANDS=1
CONAN_LOGGING_LEVEL=10
GIT_SSL_NO_VERIFY=true
conan create . magnum/stable -s build_type=Debug --profile clang --build missing -tf package/conan/test_packagesudo apt-get install openmpi-bin openmpi-common libopenmpi-devsudo -E apt-get purge -y cmake
bash scripts/install_cmake.shCXTPLライブラリhttps://github.com/blockspacer/cxtplをインストールします
cxtpl_tool https://github.com/blockspacer/cxtpl#how-to-buildをインストールします
BEFORE install_cling.sh:
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install clang-6.0 libstdc++6 libstdc++-6-dev
sudo update-alternatives --config c++
sudo update-alternatives --config cc
sudo ldconfig
export CC=clang-6.0
export CXX=clang++-6.0 # Build Cling into `cling-build` folder
cd scripts
bash install_cling.shcxtpl https://github.com/blockspacer/cxtpl#how-to-buildのようにDEPSをインストールします
export CC=clang-6.0
export CXX=clang++-6.0
cmake -E remove_directory build
cmake -E make_directory build
cmake -E remove_directory resources/cxtpl/generated
cmake -E make_directory resources/cxtpl/generated
# NOTE: change `build_type=Debug` to `build_type=Release` in production
CONAN_REVISIONS_ENABLED=1
CONAN_VERBOSE_TRACEBACK=1
CONAN_PRINT_RUN_COMMANDS=1
CONAN_LOGGING_LEVEL=10
GIT_SSL_NO_VERIFY=true
cmake -E chdir build
cmake -E time
conan install
-s build_type=Debug
--build=missing
--profile clang
-o enable_tests=False
-o openssl:shared=True
..
cmake -E chdir build cmake -E time cmake -DCONAN_AUTO_INSTALL=OFF -DENABLE_CLING=TRUE -DBUILD_SHARED_LIBS=FALSE -DBUILD_EXAMPLES=FALSE -DALLOW_PER_PROJECT_CTP_SCRIPTS=TRUE -DBUNDLE_EXAMPLE_SCRIPTS=FALSE -DCMAKE_BUILD_TYPE=Debug -DENABLE_CXXCTP=TRUE ..
cmake -E chdir build cmake -E time cmake --build . -- -j6
# you can install CXXCTP_tool:
sudo cmake -E chdir build make install
# NOTE: You can also use the “-p” flag with CMAKE_EXPORT_COMPILE_COMMANDS. See https://variousburglarious.com/2018/02/18/include-paths-for-clang-tools/
# cmake -E chdir build ./tool/CXXCTP_tool -p=../example_compile_commands/
# NOTE: runs CXXCTP_tool on multiple files and adds include paths by `-extra-arg=-I`
cmake -E chdir build ./tool/CXXCTP_tool -L .=DBG9 -extra-arg=-I $PWD /include -extra-arg=-I../resources ../examples/built_in/for_codegen/example_make_reflect.cpp
# check generator output
file build/example_make_reflect.cpp.generated.cppまたはGDBの下:
rm -rf * generated * ; clear && clear ; gdb ./CXXCTP -ex " run " -ex " bt " -ex " q " 共有ライブラリとして共有CXXCTP_COREを使用します-DBUILD_SHARED_LIBS=TRUE 。
https://github.com/blockspacer/cxtplからbash scripts/install_folly.shを実行するか、clangサポートのために手動でパッチします(folly_use_jemallocを置き換えます。
buildと-DENABLE_CLING=TRUEの前にclang(gccではありません!)を使用してください:
export CC=clang-6.0
export CXX=clang++-6.0
sudo rm -rf examples/ * /ctp_scripts/ * / * /generated/
cmake -E remove_directory build
cmake -E make_directory build
cmake -E remove_directory resources/cxtpl/generated
cmake -E make_directory resources/cxtpl/generated
# NOTE: clang profile!
# NOTE: change `build_type=Debug` to `build_type=Release` in production
CONAN_REVISIONS_ENABLED=1
CONAN_VERBOSE_TRACEBACK=1
CONAN_PRINT_RUN_COMMANDS=1
CONAN_LOGGING_LEVEL=10
GIT_SSL_NO_VERIFY=true
cmake -E chdir build
cmake -E time
conan install
-s build_type=Debug
--build=missing
--profile clang
-o enable_tests=False
-o openssl:shared=True
..
cmake -E chdir build cmake -E time cmake -DCONAN_AUTO_INSTALL=OFF -DENABLE_CLING=TRUE -DBUILD_SHARED_LIBS=TRUE -DALLOW_PER_PROJECT_CTP_SCRIPTS=TRUE -DBUILD_EXAMPLES=FALSE -DBUNDLE_EXAMPLE_SCRIPTS=FALSE -DCLEAN_CXXCTP_GEN=TRUE -DCMAKE_BUILD_TYPE=Debug -DENABLE_CXXCTP=TRUE ..
# OR cmake -E chdir build cmake -E time cmake -DCONAN_AUTO_INSTALL=OFF -DENABLE_CLING=TRUE -DBUILD_SHARED_LIBS=TRUE -DALLOW_PER_PROJECT_CTP_SCRIPTS=FALSE -DBUILD_EXAMPLES=FALSE -DBUNDLE_EXAMPLE_SCRIPTS=TRUE -DCLEAN_CXXCTP_GEN=TRUE -DCMAKE_BUILD_TYPE=Debug -DENABLE_CXXCTP=TRUE ..
cmake -E chdir build cmake -E time cmake --build . -- -j6
# you can install CXXCTP_tool:
sudo cmake -E chdir build make install
# check supported plugins
/usr/local/bin/CXXCTP_tool --pluginscxxctp_toolをインストールした場合 - 例を実行できます:
# requires CXXCTP_tool
sudo cmake -E chdir build make install
# use -DBUILD_EXAMPLES=TRUE
rm ./build/examples/simple/CXXCTP_tool_for_CXXCTP_example.log
cmake -E chdir build cmake -E time cmake -DCONAN_AUTO_INSTALL=OFF -DENABLE_CLING=TRUE -DBUILD_SHARED_LIBS=TRUE -DBUILD_EXAMPLES=TRUE -DBUNDLE_EXAMPLE_SCRIPTS=FALSE -DALLOW_PER_PROJECT_CTP_SCRIPTS=TRUE -DCMAKE_BUILD_TYPE=Debug -DENABLE_CXXCTP=TRUE ..
cmake -E chdir build cmake -E time cmake --build . -- -j6
cat ./build/examples/simple/CXXCTP_tool_for_CXXCTP_example.log
Check that ` .log ` find doesn ` t contain errors
# run examples
build/bin/CXXCTP_example Clingを設定することを忘れないでください-extra-arg=-I$PWD/include and and and by -extra-arg=-L$PWD/buildおよび.so/.dll libs by -extra-arg=-lCXXCTP_core :so/.dll libsによるライブラリパス:
# NOTE: runs CXXCTP_tool on multiple files and adds include paths by `-extra-arg=-I`
cmake -E chdir build ./tool/CXXCTP_tool --ctp_scripts_paths= $PWD -L .=DBG9 -extra-arg=-I $PWD /include -extra-arg=-L $PWD /build -extra-arg=-lCXXCTP_core -extra-arg=-I../resources ../resources/ReflShapeKind.hpp ../resources/test_typeclass_base1.hpp ../resources/test_typeclass_instance1.hpp ../resources/test.cppCXXCTP_toolの-extra-argオプションを使用してください:
-extra-arg=-I $PWD /include -extra-arg=-I $PWD /include/foo -extra-arg=-DMY_DEFINITION=1 -extra-arg=-DONE_MORE_DEFINITION=1例:
cmake -E chdir build ./tool/CXXCTP_tool --ctp_scripts_paths= $PWD -L .=DBG9 -extra-arg=-I $PWD /include -extra-arg=-I../resources ../resources/ReflShapeKind.hpp ../resources/test_typeclass_base1.hpp ../resources/test_typeclass_instance1.hpp ../resources/test.cpp次のセクションでは、CXXCTPの使用、カスタムルール、デバッグについて説明します。
ソースコード変換のためにカスタムC ++スクリプトを記述するか、既存のコードの変換を使用できます。
CXXCTPは、辞書順にctp_scriptsフォルダーからすべてのC ++スクリプトをロードします。
ctp_scriptsの例の例:
UTILはスクリプトの前にロードする必要があるため(関連する関連)、フォルダー名の前に1_ 、 2_ 、...を追加しました(上記参照)。
#includeを使用したり、ファイルシステムを使用したり、インターネットにアクセスしたり、C ++スクリプトでアクセスできます。
ディレクトリ `
-DENABLE_CLING=TRUE -DINSTALL_CLING=TRUEを添えてインストールし、 LD_LIBRARY_PATHを設定します
export LD_LIBRARY_PATH=/usr/local/lib/: $LD_LIBRARY_PATH
sudo ldconfigC ++アノテーションを使用して、CXXCTPに実行する必要があるアクションを伝えることができます。
クラスをインターフェイスに変換したいとします。
// Source
class SomeInterfaceName {
int foo1 () {
// ...
};
int foo ();
virtual void foobar ( int & arg1) = 0;
virtual void zoobar ( int & arg2);
virtual ~SomeInterfaceName () = 0 ;
};
// <== will be changed into ==>
// Result
class SomeInterfaceName {
virtual int foo1 () = 0;
virtual int foo () = 0;
virtual void foobar ( int & arg1) = 0;
virtual void zoobar ( int & arg2) = 0;
virtual ~SomeInterfaceName () = 0 ;
}; funccallアクションを使用して、ソースコード変換のためにC ++スクリプトを実行できます。スクリプト名がmake_interfaceであり、 make_removefuncbody (name as waks)であるとしましょう。
__attribute__ ((annotate( " {gen};{funccall};make_interface;make_removefuncbody " ))) {gen}; - すべてのCXXCTP注釈で使用されるキーワード。
{funccall}; -CXXCTPに、C ++スクリプトをClingで実行する必要があることを伝えるために使用されるキーワード。
make_interface;make_removefuncbody -2つのスクリプトcxxctpが実行するもの。
スクリプトは、左( make_interface )から右( make_removefuncbody )に実行されます。
通常、長いC ++アノテーションを書く必要はありません。C++ #define使用するだけです(または、共通定義のある組み込みヘッダーを含めます):
# define $apply(...)
__attribute__ ((annotate( " {gen};{funccall}; " #__VA_ARGS__)))
class
$apply(make_interface;
make_removefuncbody)
SomeInterfaceName {
virtual ~SomeInterfaceName () = 0 ;
int foo ();
virtual void foobar ( int & arg1) = 0 ;
virtual void zoobar ( int & arg2);
};同様のアプローチを使用して、複数のソースコード変換ステップを同じclass / struct / etcに適用できます。
ctp_scriptsで関数を使用してファイルを作成します
custom_plugins.cmake.exampleをcustom_plugins.cmakeとしてコピーします
add_ctp_pluginを介して、 custom_plugins.cmakeにスクリプトパスを追加します。
# first arg - typeclass_instance - script function name
# second arg - script source file
# third arg - script header file
# last arg - path to CMakeLists.txt used to generate script-related files
add_ctp_plugin(
" typeclass_instance "
${CMAKE_CURRENT_SOURCE_DIR} /examples/simple/ctp_scripts/2_scripts/typeclass_instance/typeclass_instance.cpp
${CMAKE_CURRENT_SOURCE_DIR} /examples/simple/ctp_scripts/2_scripts/typeclass_instance/typeclass_instance.hpp
${CMAKE_CURRENT_SOURCE_DIR} /examples/simple/ctp_scripts/2_scripts/typeclass_instance
)生成されたファイルctp_registry.cppに関数名が存在することを確認してください(Cling / Dev-Modeでスキップされる場合があります)
コード変換の関数署名は、 cxxctp_callbackと互換性がなければなりません:
typedef std::function< const char *(
const cxxctp::parsed_func& func_with_args,
const clang::ast_matchers::MatchFinder::MatchResult& matchResult,
clang::Rewriter& rewriter,
const clang::Decl* decl,
const std::vector<cxxctp::parsed_func>& all_funcs_with_args)> cxxctp_callback;詳細な関数の署名:
all_funcs_with_argsリストから現在実行されている機能(以下を参照)parsed_func interfaceとfoo_with_argsになります。関数名を__VA_ARGS__から考えてください
# define $apply(...)
__attribute__ ((annotate( " {gen};{funccall}; " #__VA_ARGS__)))例make_interface and make_removefuncbody -2つの関数名:
$apply(make_interface;
make_removefuncbody)コード生成が必要な場合:
.cxtpl )を作成します。 cxtpl_tool https://github.com/blockspacer/cxtplを使用してファイルを構築しますstd::string cxtpl_outputを作成します。.cxtpl )からファイル生成を含めます。 .cxtplとは何ですか.cxtplは、C ++テンプレートエンジンhttps://github.com/blockspacer/cxtplのファイル拡張機能です
.cxtplを追加する方法(cmake) .cxtplファイルをCodegen_files.cmakeに追加します
注:DEVモード(Cling Modeなど)では、CXTPL_TOOL https://github.com/blockspacer/cxtplを使用してテンプレートからファイルを生成することをお勧めします。リリースビルドの後半にCodegen_files.cmakeに生成ルールを追加できます。
注:共有CodeGenルールを使用して.cxtplと.cxtpl.hの両方のファイルを提供することを忘れないでください(バージョン制御システムに追加)。
.cxtpl使用する方法2つのオプションがあります。
.cxtplからファイルを生成し、C ++スクリプトをclingに含めます。コンパイル時間と同様ですが、プログラムの再コンパイルなしでファイルを再生成または変更できます。ファイルを生成し、スクリプトに含めることが可能であることに注意してください。スクリプトを複数に分割するだけです。.cxtplから文字列を生成し、別のしつこい通訳者で実行します。ほとんどの場合、最初のオプションを使用します。 .cxtplの使用方法反射データをテンプレートエンジンに渡します。
cxtpl_tool https://github.com/blockspacer/cxtplを使用してテンプレートからファイルを生成します
cxxctpスクリプト( .cpp ):
// see ReflectAST.cpp
reflection::NamespacesTree m_namespaces;
// `node` from AST parser (libtooling)
reflection::ClassInfoPtr structInfo = reflector.ReflectClass(node, &m_namespaces);
// ...
stuct Arguments {
// any custom arguments here ...
std::string arg1 = " arg1... " ;
std::string arg2 = " arg2... " ;
// reflection data here (ClassInfoPtr) ...
};
// ...
std::map<std::string, std::any> cxtpl_params;
{
cxtpl_params[ " Arguments " ] =
std::make_any<Arguments>(Arguments{});
cxtpl_params[ " generator_path " ] =
std::make_any<std::string>( " enum_gen_hpp.cxtpl " );
cxtpl_params[ " generator_includes " ] =
std::make_any<std::vector<std::string>>(
std::vector<std::string>{});
std::string cxtpl_output;
# include " ../../resources/cxtpl/generated/enum_gen_hpp.cxtpl.cpp "
writeToFile (cxtpl_output, gen_hpp_name);
} .cxtplテンプレート:
const auto arguments = std::any_cast<Arguments>(cxtpl_params.at( " Arguments " ));
std::cout << arguments.arg1;例としてresources/cxtpl/enum_gen_hpp.cxtplを参照してください。
CXXCTP_TOOLラップLibToolingをラップして、カスタムコマンドラインオプションを追加します。
Libtoolingに関連するオプション(タイプ-helpまたは-help):
Generic Options:
-help - Display available options (-help-hidden for more)
-help-list - Display list of available options (-help-list-hidden for more)
-version - Display the version of this program
Use override options:
-extra-arg= < string > - Additional argument to append to the compiler command line
-extra-arg-before= < string > - Additional argument to prepend to the compiler command line
-p= < string > - Build pathcxxctp_toolに関連するオプション(タイプ - ヘルプ、ヘルプではありません):
ctp_scripts_paths通行料がctp_scripts subfolderを検索するパスのリスト
注: ctp_scripts_pathsは-DENABLE_CLING=TRUE必要とします
-L .=DBG9形式のログ構成ですhttps://github.com/facebook/folly/blob/master/folly/logging/docs/config.md
ファイルとコンソールの両方のストリームに書き込むログ構成の例:
./build/bin/CXXCTP_tool -L " .:=INFO:default:console; default=file:path=y.log,async=true,sync_level=DBG9;console=stream:stream=stderr " --srcdir入力ファイルの現在のファイルシステムパスを変更します。
--resdir出力ファイルの現在のファイルシステムパスを変更します。
例(カスタム出力dir):
# Remove old generated files
rm -rf gen
rm -rf build/ * generated *
` --version ` to get tool version
` -version ` to get clang version
# Build files to `gen/out` dir
mkdir -p gen/out
cmake -E chdir gen ../build/bin/CXXCTP_tool --resdir= $PWD /gen/out --ctp_scripts_paths= $PWD -L .=DBG9 -extra-arg=-I $PWD /include -extra-arg=-I../resources ../resources/ReflShapeKind.hpp ../resources/test_typeclass_base1.hpp ../resources/test_typeclass_instance1.hpp ../resources/test.cppctp_scriptsをデバッグする方法古いビルドアーティファクトと生成されたファイルを削除します。
-DBUNDLE_EXAMPLE_SCRIPTS=TRUE経由でCXXCTP_toolでスクリプトをバンドルします。
custom_plugins.cmake.exampleを介してスクリプト(プラグイン)がCXXCTP_toolに追加されていることを確認してください。
PROJECT Scripts -DALLOW_PER_PROJECT_CTP_SCRIPTS=FALSEを無効にします。
スクリプト(プラグイン)がbuild/tool/CXXCTP_tool --pluginsにあることを確認してください
CXXCTP_toolのシステムインストールバージョンがbuild/tool/CXXCTP_toolと同じであることを確認します(日付/ファイルハッシュ)
gdbで手動でCXXCTP_toolを実行します:
gdb -ex " r " -ex " bt " --args build/tool/CXXCTP_tool .........必要なすべてのパスが-extra-arg=にあることを確認します。
DBG9モードでファイルするログを作成し、 .logファイルを確認します。
CXXCTPは、LibToolingを使用してC ++を解析および変更します。
Libtoolingは、Clangに基づいたスタンドアロンツールの作成をサポートするライブラリです。
便利なリンク:
CXXCTPは、コンパイル時にC ++を実行するためにClingを使用します。
ホットコードリロード / REPL / FAST C ++プロトタイピング /スクリプトエンジン / JIT /などにClingを使用できます。
便利なリンク:
sudo apt install clang-format .clang-formatファイルに基づいて実行します。
find . -regex ' .*.(cpp|hpp|cu|c|h) ' -exec clang-format -style=file -i {} ;便利なリンク:
.clang-formatファイルhttps://leimao.github.io/blog/clang-format-quick-tutorial/を作成して使用しますプルリクエストを行う前に、貢献ガイドラインをお読みください。
このプロジェクトは行動規範でリリースされていることに注意してください。このプロジェクトに参加することにより、お客様はその条件を順守することに同意します。
FlexFerrumのautoprogrammerのために可能なプロジェクト。
メディアにおけるFlexFerrumのautoprogrammerに関する記事:
すべてのオープンソースコンポーネントは、関連するオープンソースライセンスの下で使用されます。
使用済みオープンソースコンポーネント:
ライセンスファイルを参照してください
cmakeファイルパススタイルのチェックは、リポジトリのルートからrun-cmake-format.pyを実行することで修正できます。これにはPython 3とcmake_formatが必要です(注:これは現在Windowsで動作しません)
autoformatter cmake-format.pyおよびrun-cmake-format.pyを使用してください
pip3 install cmake_format
python3 run-cmake-format.pyCMAKELISTS.TXTファイルでcmake-formatを使用するには、command line runでファイル
python3 -m cmake_format -c cmake-format.py -i CMakeLists.txt公式のビジュアルスタジオエクステンションがあり、その詳細はここにあります。
cmake styleguide https://github.com/ruslo/0をフォローしてください
.cxtplを使用するプロジェクト