一個完全開源的,有力的解決方案,用於修改和生成C ++源代碼。減少C ++項目中的樣板代碼量。
此存儲庫將盡快遷移到https://github.com/blockspacer/flextool
CXXCTP將被棄用。喜歡Flextool
CXXCTP是一種跨副本,可擴展C ++以進行新的內省,反射和編譯時間執行。
CXXCTP並非旨在創建預定義的源代碼轉換集。用戶可以共享C ++腳本以進行源代碼轉換。
假設有人在開源社區共享了有用的腳本interface.cxx和enum_to_json.cxx 。您只需將它們放入ctp_scripts文件夾中,就可以在項目中使用它們。
元編程是編寫程序的“藝術”,以將其他程序視為其數據。這意味著程序可以生成,讀取,分析和轉換代碼甚至自身以實現某個解決方案。
注意:該項目是按原樣提供的,無需任何保修(請參閱許可證)。
您為什麼不只是擴展Clang,因為它還提供了一些實驗功能(例如模塊)?
Clang是一個編譯器,而該項目是一個轉板器,它將代碼轉換為標準化的C ++代碼,而無需修改LLVM/組件。
由於該工具的輸出是C ++代碼,因此您可以使用Emscripten編譯轉移代碼,使用靜態代碼分析儀,運行代碼在Cring等。
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 --remote安裝和配置docker:https://medium.com/@saniaky/configure-docker-to-use-a-host-proxy-e88bd988888888c0aa
克隆代碼(如上)和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/latest/reference/config_files/config_files/conan.conf.html#proxies
配置Conan Clang配置文件,然後使用-Profile 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=bincrafters如果要設置Corp。卡塞特:
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.sh安裝CXTPL庫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.sh如CXTPL 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或手動手動forly for clang支持(替換folly_use_jemalloc用folly_assume_no_jemalloc)運行bash腳本/install_folly.sh。
在構建和-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 --plugins如果您安裝了cxxctp_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不要忘記設置cring包括-extra-arg=-I$PWD/include和庫路徑,包括-extra-arg=-L$PWD/build和.so/.dll libs by -extra-arg=-lCXXCTP_core :
# 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.cpp使用-extra-arg選項CXXCTP_tool :
-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_script的示例內容:
utils必須在腳本之前加載(相關),因此我們在文件夾名稱之前添加了1_ , 2_ ,...(請參見上文)。
您可以在C ++腳本中使用#include ,使用文件系統,訪問Internet等。
目錄`
安裝-DENABLE_CLING=TRUE -DINSTALL_CLING=TRUE並設置LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/lib/: $LD_LIBRARY_PATH
sudo ldconfig您可以使用C ++註釋來告訴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 (按照您需要的名稱)。
__attribute__ ((annotate( " {gen};{funccall};make_interface;make_removefuncbody " ))) {gen}; - 每個CXXCTP註釋中使用的關鍵字。
{funccall}; - 用於告訴CXXCTP的關鍵字必須用包裹執行C ++腳本。
make_interface;make_removefuncbody兩個腳本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 /等。
在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中(可以在cring / 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和make_removefuncbody兩個函數名稱:
$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模式(例如Cring模式)中,最好使用CXTPL_TOOL https://github.com/blockspacer/cxtpl生成模板文件,您可以將生成規則添加到Codegen_files.cmake中。
注意:不要忘記為.cxtpl和.cxtpl.h文件提供共享代碼規則(添加到版本控制系統)。
.cxtpl您有兩個選擇:
.cxtpl生成文件,然後將其包含在C ++腳本中。類似於編譯時間,但是您可以重新生成或更改文件而無需計劃重新編譯。請注意,可以生成文件並將其包含在腳本中;只需將腳本分為多個倍數。.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 path與cxxctp_tool有關的選項(類型-HELP,不是-HELP):
ctp_scripts_paths通行費將搜索CTP_Scripts子文件夾的路徑列表
注意: ctp_scripts_paths需要-DENABLE_CLING=TRUE
-L .=DBG9是格式中的日誌配置
將記錄配置的示例寫入文件和控制台流的示例:
./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 。
禁用人為投影腳本-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使用CRING在編譯時執行C ++。
您可以將保留用於熱代碼重新加載 / repl / fast C ++原型 /腳本引擎 / jit /等。
有用的鏈接:
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 Files通過樣式檢查,可以通過從存儲庫的根中運行運行cmake-format.py來修復。這需要Python 3和Cmake_format(注意:當前在Windows上不起作用)
使用autoformatter cmake-format.py和run-cmake-format.py
pip3 install cmake_format
python3 run-cmake-format.py在命令行運行中使用特定cmakelists.txt文件上使用cmake-format
python3 -m cmake_format -c cmake-format.py -i CMakeLists.txt有一個官方的Visual Studio擴展名,可以在此處找到其詳細信息。
關注Cmake styleguide https://github.com/ruslo/0
.cxtpl的項目