C ++ 소스 코드의 수정 및 생성을위한 완전히 오픈 소스, 강력한 솔루션. C ++ 프로젝트에서 보일러 플레이트 코드의 양을 줄입니다.
메인 프로젝트 페이지 : https://blockspacer.github.io/flex_docs/
Ubuntu 20.04.2 LTS에서 테스트.
약간의 수정으로 다른 플랫폼에서 작동 할 수 있습니다.
종속성 리모컨 목록을 추가하려면 다음 명령을 입력하십시오.
cmake -E time conan config install conan/remotes/
# OR:
# cmake -E time conan config install conan/remotes_disabled_ssl/ 설치 안내서
코난 패키지
참고 : LLVM 빌드에 집착하는 데 몇 시간이 걸릴 수 있습니다.
아래 명령은 --profile clang12_compiler12_compiler 사용합니다.
코난 프로파일 예제 ~/.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=10
compiler.libcxx=libstdc++11
[ env ]
CC=/usr/bin/clang-10
CXX=/usr/bin/clang++-10
[ build_requires ]
cmake_installer/3.15.5@conan/stableclang12_compiler 프로파일 생성 :
[settings]
# We are building in Ubuntu Linux
os_build=Linux
os=Linux
arch_build=x86_64
arch=x86_64
compiler=clang
compiler.version=12
compiler.libcxx=libstdc++11
compiler.cppstd=17
llvm_9:build_type=Release
[env]
CC=/usr/bin/clang-12
CXX=/usr/bin/clang++-12
[build_requires]
cmake_installer/3.15.5@conan/stableConan 프로필 파일을 생성하기 전에 https://docs.conan.io/en/latest/using_packages/using_profiles.html을 참조하십시오.
.cmake 스크립트를 사용하여 Conan 패키지를 다운로드하여 설치합니다.
git clone https://github.com/blockspacer/conan_github_downloader.git ~ /conan_github_downloader
cmake
-DSCRIPT_PATH= " $PWD /get_conan_dependencies.cmake "
-DENABLE_CLING=TRUE
-DENABLE_LLVM=TRUE
-DENABLE_LLVM_INSTALLER=FALSE
-DEXTRA_CONAN_OPTS= " --profile;clang12_compiler
;-s;build_type=Debug
;-s;cling_conan:build_type=Release
;-s;llvm_12:build_type=Release
;--build;missing "
-P ~ /conan_github_downloader/conan_github_downloader.cmake
# clean build cache
conan remove " * " --build --force FlexTool 및 해당 플러그인을 단일 명령에 설치하려면 tools/buildConanThirdparty.cmake 에 제공된 옵션을 변경하십시오.
참고 : tools/buildConanThirdparty.cmake 전체 재건을 수행합니다. 몇 시간이 걸릴 수 있습니다.
아래 명령은 --profile clang12_compiler12_compiler 사용합니다. Conan 프로필 파일을 생성하기 전에 https://docs.conan.io/en/latest/using_packages/using_profiles.html을 참조하십시오.
Conan 패키지를 다운로드하여 설치하기 위해 buildConanThirdparty.cmake 스크립트를 사용합니다.
참고 : SET -DENABLE_CLING=FALSE 위의 tools/buildConanThirdparty.cmake 사용하여 이미 설치 한 경우.
git clone https://github.com/blockspacer/conan_github_downloader.git ~ /conan_github_downloader
cmake
-DSCRIPT_PATH= " $PWD /get_conan_dependencies.cmake "
-DENABLE_CLING=TRUE
-DENABLE_LLVM=TRUE
-DENABLE_LLVM_INSTALLER=FALSE
-DENABLE_FLEXTOOL=TRUE
-DENABLE_BASIS_PLUGIN_HELPER=TRUE
-DENABLE_FLEX_REFLECT_PLUGIN=TRUE
-DENABLE_SQUARETS=TRUE
-DENABLE_FLEX_SQUARETS_PLUGIN=TRUE
-DENABLE_FLEX_PIMPL_PLUGIN=TRUE
-DENABLE_FLEX_TYPECLASS_PLUGIN=TRUE
-DENABLE_FLEX_META_PLUGIN=TRUE
-DENABLE_FLEX_META_DEMO=TRUE
-DEXTRA_CONAN_OPTS= " --profile;clang12_compiler
;-s;build_type=Debug
;-s;cling_conan:build_type=Release
;-s;llvm_12:build_type=Release
;--build;missing "
-P ~ /conan_github_downloader/conan_github_downloader.cmake
# clean build cache
conan remove " * " --build --force아래 명령을 사용하여 FlexTool을 다시 작성하십시오 (플러그인을 별도로 설치해야 함).
아래 명령은 --profile clang12_compiler12_compiler 사용합니다. Conan 프로필 파일을 생성하기 전에 https://docs.conan.io/en/latest/using_packages/using_profiles.html을 참조하십시오
export VERBOSE=1
export CONAN_REVISIONS_ENABLED=1
export CONAN_VERBOSE_TRACEBACK=1
export CONAN_PRINT_RUN_COMMANDS=1
export CONAN_LOGGING_LEVEL=10
# NOTE: change `build_type=Debug` to `build_type=Release` in production
# NOTE: use --build=missing if you got error `ERROR: Missing prebuilt package`
cmake -E time
conan create . conan/stable
-s build_type=Debug
-s cling_conan:build_type=Release
-s llvm_tools:build_type=Release
--profile clang12_compiler
-e flextool:enable_tests=True
-e flextool:enable_llvm_tools=True
# clean build cache
conan remove " * " --build --forcecompile_commands.json 과 호환되지 않습니다FlexTool을 사용할 때 컴파일 데이터베이스 생성 비활성화.
cmake를 사용하는 경우 CMAKE_EXPORT_COMPILE_COMMANDS FALSE 로 설정하십시오.
compile_commands.json 이 빌드 폴더 (또는 상위 폴더)에 존재하는 경우 flxtool이 실패 할 수 있습니다.
이 프로젝트는 Flexferrum의 autoprogrammer 로 인해 가능합니다.
미디어에서 Flexferrum의 autoprogrammer 관한 기사 :
find . -type f -name " *_buildflags.h " -exec rm {} ;
find . -type f -name " *_buildflags.tmp " -exec rm {} ;
(rm -rf local_build || true)
export CONAN_REVISIONS_ENABLED=1
export CONAN_VERBOSE_TRACEBACK=1
export CONAN_PRINT_RUN_COMMANDS=1
export CONAN_LOGGING_LEVEL=10
export PKG_NAME=flextool/master@conan/stable
(CONAN_REVISIONS_ENABLED=1
conan remove --force $PKG_NAME || true)
# NOTE: use --build=missing if you got error `ERROR: Missing prebuilt package`
cmake -E time
conan install .
--install-folder local_build
-s build_type=Debug
-s cling_conan:build_type=Release
-s llvm_12:build_type=Release
-o openssl:shared=True
-e basis:enable_tests=True
-o chromium_base:shared=True
-e chromium_base:enable_tests=True
-o perfetto:is_hermetic_clang=False
--profile clang12_compiler
-e flexlib:enable_tests=True
-o flexlib:shared=False
-o perfetto:is_hermetic_clang=False
-o flexlib:enable_cling=True
-e flextool:enable_tests=True
-o flextool:enable_cling=True
(rm local_build/CMakeCache.txt || true)
cmake -E time
conan source .
--source-folder .
--install-folder local_build
# You can use `cmake --build . -- -j14` on second run.
cmake -E time
conan build .
--build-folder local_build
--source-folder .
--install-folder local_build
conan package .
--build-folder local_build
--package-folder local_build/package_dir
--source-folder .
--install-folder local_build
cmake -E time
conan export-pkg . conan/stable
--package-folder local_build/package_dir
-s build_type=Debug
--force
-s cling_conan:build_type=Release
-s llvm_12:build_type=Release
-o openssl:shared=True
-e basis:enable_tests=True
-o chromium_base:shared=True
-e chromium_base:enable_tests=True
-o perfetto:is_hermetic_clang=False
--profile clang12_compiler
-e flexlib:enable_tests=True
-o flexlib:shared=False
-o perfetto:is_hermetic_clang=False
-o flexlib:enable_cling=True
-e flextool:enable_tests=True
-o flextool:enable_cling=True
cmake -E time
conan test test_package
flextool/master@conan/stable
-s build_type=Debug
-s cling_conan:build_type=Release
-s llvm_12:build_type=Release
-o openssl:shared=True
-e basis:enable_tests=True
-o chromium_base:shared=True
-e chromium_base:enable_tests=True
-o perfetto:is_hermetic_clang=False
--profile clang12_compiler
-e flexlib:enable_tests=True
-o flexlib:shared=False
-o perfetto:is_hermetic_clang=False
-o flexlib:enable_cling=True
-e flextool:enable_tests=True
-o flextool:enable_cling=True 편집 가능한 패키지를 사용하면 Conan에게 지역 작업 디렉토리에서 소비 할 준비가 된 헤더 및 아티팩트를 찾을 수있는 위치를 알 수 있습니다. conan create 또는 conan export-pkg 실행할 필요가 없습니다.
자세한 내용은 https://docs.conan.io/en/latest/developing_packages/editable_packages.html을 참조하십시오
로컬 빌드 :
export VERBOSE=1
export CONAN_REVISIONS_ENABLED=1
export CONAN_VERBOSE_TRACEBACK=1
export CONAN_PRINT_RUN_COMMANDS=1
export CONAN_LOGGING_LEVEL=10
cmake -E time
conan install .
--install-folder local_build
-s build_type=Debug
-s cling_conan:build_type=Release
-s llvm_tools:build_type=Release
--profile clang12_compiler
-e flextool:enable_tests=True
-e flextool:enable_llvm_tools=True
cmake -E time
conan source .
--source-folder local_build
--install-folder local_build
conan build .
--build-folder local_build
--source-folder local_build
--install-folder local_build
conan package .
--build-folder local_build
--package-folder local_build/package_dir
--source-folder local_build
--install-folder local_build패키지 설정 편집 가능한 모드로 설정 :
conan editable add local_build/package_dir
flextool/master@conan/stable conanfile.py 는 self.in_local_cache 를 통해 로컬 빌드를 감지하도록 수정되었습니다.
폴더에서 소스를 변경 한 후 Local_Build (소스 패키지 폴더에서 실행 명령) :
conan build .
--build-folder local_build
--source-folder local_build
--install-folder local_build
conan package .
--build-folder local_build
--package-folder local_build/package_dir
--source-folder local_build
--install-folder local_build
테스트 프로젝트를 구축하십시오.
편집 가능한 모드를 되돌리려면 다음을 사용하여 링크를 제거하십시오.
conan editable remove
flextool/master@conan/stable 한 번에 여러 프로젝트를 구축 할 수 있습니다. add_subdirectory 가 각 패키지 폴더를 가리키는 CMakeLists.txt 만 생성합니다.
참고 : 일반적인 CMAKE 기반 프로젝트 (Build Directory를 WorkSpaceProject Path로 변경)대로 IDE에서 작업 공간을 열 수 있습니다!
자세한 내용은 https://docs.conan.io/en/latest/developing_packages/workspaces.html을 참조하십시오
예를 들어, FlexTool과 FlexLib를 동시에 구축하려고합니다 (FlexTool은 FlexLib가 필요합니다).
# change ~ to desired build folder
cd ~
# Replace paths to yours!
# Make sure each project in NOT in editable mode!
cat << EOF > ~/conanws.yml
editables:
flexlib/master@conan/stable:
path: /......../flexlib
flextool/master@conan/stable:
path: /......../flextool
layout: layout_flex
workspace_generator: cmake
root:
- flextool/master@conan/stable
EOF
cat << EOF > ~/layout_flex
# This helps to define the location of CMakeLists.txt within package
[source_folder]
.
# This defines where the conanbuildinfo.cmake will be written to
[build_folder]
build/{{settings.build_type}}
EOF mkdir build_flex
cd build_flex
cat << EOF > CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(WorkspaceProject)
include( $ {CMAKE_BINARY_DIR}/conanworkspace.cmake)
list(PREPEND CMAKE_MODULE_PATH " $ {PACKAGE_flexlib_SRC}/cmake")
list(PREPEND CMAKE_MODULE_PATH " $ {PACKAGE_flextool_SRC}/cmake")
conan_workspace_subdirectories()
add_dependencies(flextool flexlib)
EOF
# must contain `include(${CMAKE_BINARY_DIR}/conanworkspace.cmake)` without slash `` (slash added for bash cat command)
cat CMakeLists.txt
# combines options from all projects
conan workspace install
../conanws.yml
--profile=clang
-s build_type=Debug
-s cling_conan:build_type=Release
-s llvm_tools:build_type=Release
-o openssl:shared=True
-o chromium_base:shared=True
-e basis:enable_tests=True
-e abseil:enable_llvm_tools=True
-o chromium_base:use_alloc_shim=True
-o chromium_tcmalloc:use_alloc_shim=True
-o perfetto:is_hermetic_clang=False
-e flextool:enable_tests=True
-e flextool:enable_llvm_tools=True
-o flexlib:shared=False
-o flexlib:enable_clang_from_conan=False
-e flexlib:enable_tests=True conan workspace install :
# NOTE: change `build_type=Debug` to `build_type=Release` in production
export build_type=Debug
# optional
# remove old CMakeCache
(rm CMakeCache.txt || true)
# configure via cmake
cmake -E time cmake .
-DCMAKE_VERBOSE_MAKEFILE=TRUE
-DENABLE_TESTS=TRUE
-DBASE_NEED_GEN_BUILD_DATE=FALSE
-DENABLE_DOCTEST=ON
-DBUILD_SHARED_LIBS=FALSE
-DCONAN_AUTO_INSTALL=OFF
-DCMAKE_BUILD_TYPE= ${build_type}
# remove generated files
# change paths to yours
# rm ~/flex_typeclass_plugin/build/Debug/*generated*
# build code
cmake -E time cmake --build .
--config ${build_type}
-- -j8
# run unit tests for flexlib
cmake -E time cmake --build .
--config ${build_type}
--target flexlib_run_all_tests
# run unit tests for flextool
cmake -E time cmake --build .
--config ${build_type}
--target flextool_run_all_testsWorkspace를 사용하면 기존 소스 파일을 빠르게 변경할 수 있습니다.
우리는 self.in_local_cache 사용하여 코난 편집 모드를 감지합니다.
# Local build
# see https://docs.conan.io/en/latest/developing_packages/editable_packages.html
if not self . in_local_cache :
self . copy ( "conanfile.py" , dst = "." , keep_path = False )모든 대상이 전 세계적으로 고유 한 이름을 가지고 있는지 확인하십시오.
예를 들어 : "테스트"와 같은 이름의 각 프로젝트에서 대상을 가질 수 없습니다. "$ {root_project_name} -test_main_gtest"와 같은 각 대상의 이름에 프로젝트 별 접두사를 추가하여 해당 문제를 해결할 수 있습니다.
CMAKE_BINARY_DIR conan workspace install 로 생성 된 폴더를 가리키기 때문에 CMAKE_CURRENT_BINARY_DIR to CMAKE_BINARY_DIR 등을 선호하는지 확인하십시오.
설치하기 전에 : 플러그인에는 사전 제작 된 flextool (동일한 작업 공간)이 필요합니다. 플러그인없이 작업 공간을 작성해야합니다. 그래야만 플러그인으로 다시 건설 할 수 있습니다.
YML 파일에 플러그인 추가 :
editables :
chromium_base/master@conan/stable :
path : /........./chromium_base
basis/master@conan/stable :
path : /........./basis
flex_support_headers/master@conan/stable :
path : /........./flex_support_headers
flexlib/master@conan/stable :
path : /........./flexlib
flextool/master@conan/stable :
path : /........./flextool
flex_reflect_plugin/master@conan/stable :
path : /........./flex_reflect_plugin
squarets/master@conan/stable :
path : /........./squarets
flex_squarets_plugin/master@conan/stable :
path : /........./flex_squarets_plugin
flex_typeclass_plugin/master@conan/stable :
path : /........./flex_typeclass_plugin
flex_pimpl_plugin/master@conan/stable :
path : /........./flex_pimpl_plugin
flex_meta_plugin/master@conan/stable :
path : /........./flex_meta_plugin
flex_meta_demo/master@conan/stable :
path : /........./flex_meta_demo
layout : layout_flex
workspace_generator : cmake
root :
- flex_reflect_plugin/master@conan/stable
- squarets/master@conan/stable
- flex_squarets_plugin/master@conan/stable
- flex_typeclass_plugin/master@conan/stable
- flex_pimpl_plugin/master@conan/stable
- flex_meta_plugin/master@conan/stable
- flex_meta_demo/master@conan/stable CMakeLists.txt 에서 add_dependencies 사용하십시오.
mkdir build_flex
cd build_flex
cat << EOF > CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(WorkspaceProject)
include( $ {CMAKE_BINARY_DIR}/conanworkspace.cmake)
list(PREPEND CMAKE_MODULE_PATH " $ {PACKAGE_chromium_base_SRC}/cmake")
list(PREPEND CMAKE_MODULE_PATH " $ {PACKAGE_basis_SRC}/cmake")
list(PREPEND CMAKE_MODULE_PATH " $ {PACKAGE_flex_support_headers_SRC}/cmake")
list(PREPEND CMAKE_MODULE_PATH " $ {PACKAGE_flexlib_SRC}/cmake")
list(PREPEND CMAKE_MODULE_PATH " $ {PACKAGE_flex_reflect_plugin_SRC}/cmake")
list(PREPEND CMAKE_MODULE_PATH " $ {PACKAGE_squarets_SRC}/cmake")
list(PREPEND CMAKE_MODULE_PATH " $ {PACKAGE_flex_squarets_plugin_SRC}/cmake")
list(PREPEND CMAKE_MODULE_PATH " $ {PACKAGE_flex_typeclass_plugin_SRC}/cmake")
list(PREPEND CMAKE_MODULE_PATH " $ {PACKAGE_flex_meta_plugin_SRC}/cmake")
list(PREPEND CMAKE_MODULE_PATH " $ {PACKAGE_flex_meta_demo_SRC}/cmake")
list(PREPEND CMAKE_MODULE_PATH " $ {PACKAGE_flex_pimpl_plugin_SRC}/cmake")
list(PREPEND CMAKE_MODULE_PATH " $ {PACKAGE_flextool_SRC}/cmake")
conan_workspace_subdirectories()
add_dependencies(basis chromium_base-static)
add_dependencies(flexlib basis)
add_dependencies(flextool flexlib basis flex_support_headers)
add_dependencies(flex_reflect_plugin flextool)
add_dependencies(flex_squarets_plugin squarets)
add_dependencies(flex_squarets_plugin flextool)
add_dependencies(flex_pimpl_plugin flextool)
add_dependencies(flex_pimpl_plugin flex_reflect_plugin)
add_dependencies(flex_pimpl_plugin flex_squarets_plugin)
add_dependencies(flex_typeclass_plugin flextool)
add_dependencies(flex_typeclass_plugin flex_squarets_plugin)
add_dependencies(flex_meta_demo flex_meta_plugin)
add_dependencies(flex_meta_demo flex_typeclass_plugin)
add_dependencies(flex_meta_demo flex_pimpl_plugin)
add_dependencies(flex_meta_demo flex_squarets_plugin)
EOF conan workspace install 에 플러그인 옵션 추가 :
# combines options from all projects
conan workspace install
../conanws.yml
--profile=clang
-s build_type=Debug
-s cling_conan:build_type=Release
-s llvm_tools:build_type=Release
-e basis:enable_tests=True
-o openssl:shared=True
-o chromium_base:shared=True
-o chromium_base:use_alloc_shim=True
-o perfetto:is_hermetic_clang=False
-o chromium_tcmalloc:use_alloc_shim=True
-e flextool:enable_tests=True
-e flextool:enable_llvm_tools=True
-o flexlib:shared=False
-o flexlib:enable_clang_from_conan=False
-e flexlib:enable_tests=True
-o flex_reflect_plugin:shared=True
-o flex_reflect_plugin:enable_clang_from_conan=False
-e flex_reflect_plugin:enable_tests=True
-o squarets:shared=False
-o squarets:enable_clang_from_conan=False
-e squarets:enable_tests=True
-o flex_squarets_plugin:shared=False
-o flex_squarets_plugin:enable_clang_from_conan=False
-e flex_squarets_plugin:enable_tests=True
-o flex_meta_plugin:shared=False
-o flex_meta_plugin:enable_clang_from_conan=False
-e flex_meta_plugin:enable_tests=True
-o flex_typeclass_plugin:shared=False
-o flex_typeclass_plugin:enable_clang_from_conan=False
-e flex_typeclass_plugin:enable_tests=True
-o flex_pimpl_plugin:shared=False
-o flex_pimpl_plugin:enable_clang_from_conan=False
-e flex_pimpl_plugin:enable_tests=True
-o flex_meta_demo:enable_clang_from_conan=False
-e flex_meta_demo:enable_tests=True작업 공간 빌드 및 테스트 :
# NOTE: change `build_type=Debug` to `build_type=Release` in production
export build_type=Debug
# optional
# remove old CMakeCache
(rm CMakeCache.txt || true)
# configure via cmake
cmake -E time cmake .
-DCMAKE_VERBOSE_MAKEFILE=TRUE
-DENABLE_TESTS=TRUE
-DBASE_NEED_GEN_BUILD_DATE=FALSE
-DENABLE_DOCTEST=ON
-DBUILD_SHARED_LIBS=FALSE
-DCONAN_AUTO_INSTALL=OFF
-DCMAKE_BUILD_TYPE= ${build_type}
# remove generated files
# change paths to yours
# rm ~/flex_typeclass_plugin/build/Debug/*generated*
# build code
cmake -E time cmake --build .
--config ${build_type}
-- -j8
# run unit tests for flexlib
cmake -E time cmake --build .
--config ${build_type}
--target flexlib_run_all_tests
# run unit tests for flextool
cmake -E time cmake --build .
--config ${build_type}
--target flextool_run_all_tests
# run unit tests for flex_reflect_plugin
cmake -E time cmake --build .
--config ${build_type}
--target flex_reflect_plugin_run_all_tests
# run unit tests for squarets
cmake -E time cmake --build .
--config ${build_type}
--target squarets_run_all_tests
# run unit tests for flex_squarets_plugin
cmake -E time cmake --build .
--config ${build_type}
--target flex_squarets_plugin_run_all_tests
# run unit tests for flex_squarets_plugin
cmake -E time cmake --build .
--config ${build_type}
--target flex_meta_plugin_run_all_tests
# run unit tests for flex_squarets_plugin
cmake -E time cmake --build .
--config ${build_type}
--target flex_typeclass_plugin_run_all_tests
# run unit tests for flex_squarets_plugin
cmake -E time cmake --build .
--config ${build_type}
--target flex_pimpl_plugin_run_all_tests
# run unit tests for flex_squarets_plugin
cmake -E time cmake --build .
--config ${build_type}
--target flex_meta_demo_run_all_tests -e flextool:enable_llvm_tools=True 와 함께 Debug 빌드를 사용해야합니다.
Conan을 통해 CPPCHECK 설치 :
cd /tmp
git clone -b testing/1.90 https://github.com/bincrafters/conan-cppcheck_installer.git
cd conan-cppcheck_installer
export VERBOSE=1
export CONAN_REVISIONS_ENABLED=1
export CONAN_VERBOSE_TRACEBACK=1
export CONAN_PRINT_RUN_COMMANDS=1
export CONAN_LOGGING_LEVEL=10
# NOTE: change `build_type=Debug` to `build_type=Release` in production
# NOTE: use --build=missing if you got error `ERROR: Missing prebuilt package`
cmake -E time
conan create . conan/stable
-s build_type=Release
# clean build cache
conan remove " * " --build --force 사용법 ( -DENABLE_CPPCHECK=ON 으로 cmake 실행) :
# creates local build in separate folder and runs cmake targets
# NOTE: -DCLEAN_OLD="OFF" to keep generated html report
cmake -DCPPCHECK= " ON " -DCLEAN_OLD= " OFF " -P tools/run_tool.cmake # `index.html` must exist
# find $PWD -name index.html결과를 확인하려면 'index.html'을 엽니 다.
여러 스크립트를 관리하고 실행하기위한 단일 컨텍스트를 제공하는 데스크탑 응용 프로그램.
로컬 개발 환경 설정을 단순화합니다. 이것은 많은 쉘 터미널을 열지 않습니다.
package.json 또는 plugin/vue-cli-plugin/ui.js 에서 사용자 정의 명령을 추가 할 수 있습니다.
# Before: Install Latest Node.js and NPM
# see https://tecadmin.net/install-latest-nodejs-npm-on-ubuntu/
node --version
npm --versionNPM을 통해 프로젝트 구축 :
npm installsudo npm install -g @vue/cli
sudo vue ui --dev --port 8061 http://localhost:8061/ 열십시오.
프로젝트 디렉토리 가져 오기.
빌드/테스트와 같은 Tasks 선택하십시오 ...
package.json 에서 작업이 변경 될 수 있습니다.
참고 : package.json 만 작업에만 사용합니다. Conan은 Conanfile.txt라는 파일로 제어됩니다.
유용한 링크 :
우리는 .gdbinit add 'add-auto-load-safe-path'를 사용합니다.
.gdbinit 에 대한 자세한 내용은 https://metricpanda.com/tips-for-productive-debugging-with-gdb를 읽으십시오
gdb 에 대한 자세한 내용은 http://www.yolinux.com/tutorials/gdb-commands.html을 참조하십시오
GDB 디버깅 세션은 다음과 같이 자동화 할 수 있습니다.
# see https://gist.github.com/williballenthin/8bd6e29ad8504b9cb308039f675ee889
gdb
-ex " run "
-ex " set pagination off "
-ex " bt "
-ex " set confirm off "
-ex " quit "
--args
${APP_EXE}
${APP_CMD_ARGS} -e flextool:enable_llvm_tools=True 와 함께 Debug 빌드를 사용해야합니다.
자세한 내용은 다음을 참조하십시오.
Valgrind 설치 :
sudo apt install valgrind # Ubuntu, Debian, etc.
# OR
sudo yum install valgrind # RHEL, CentOS, Fedora, etc. 참고 : use_alloc_shim=False 및 enable_valgrind=True 설정하십시오 (아래 참조).
cmake를 통해 Valgrind 실행 :
export VERBOSE=1
export CONAN_REVISIONS_ENABLED=1
export CONAN_VERBOSE_TRACEBACK=1
export CONAN_PRINT_RUN_COMMANDS=1
export CONAN_LOGGING_LEVEL=10
# NOTE: set `use_alloc_shim=False` and `enable_valgrind=True` for valgrind support
cmake -E time
conan install .
--install-folder local_build_valgrind
-s build_type=Debug
-s cling_conan:build_type=Release
-s llvm_tools:build_type=Release
--profile clang12_compiler
-o flextool:enable_valgrind=True
-e flextool:enable_tests=True
-e flextool:enable_llvm_tools=True
-e abseil:enable_llvm_tools=True
-o chromium_base:enable_valgrind=True
-e chromium_base:enable_llvm_tools=True
-o chromium_base:use_alloc_shim=False
-o perfetto:is_hermetic_clang=False
-o basis:enable_valgrind=True
-e basis:enable_llvm_tools=True
-o flexlib:enable_valgrind=True
-e flexlib:enable_llvm_tools=True
-o flexlib:enable_clang_from_conan=False
-o chromium_tcmalloc:use_alloc_shim=False
--build chromium_base
--build chromium_tcmalloc
--build basis
--build flexlib
cd ~ /flextool
# see section about `conan editable mode`
cd local_build_valgrind
# optional
# remove old CMakeCache
(rm CMakeCache.txt || true)
# remove old build artifacts
rm -rf flextool
rm -rf bin
find . -iname ' *.o ' -exec rm {} ;
find . -iname ' *.a ' -exec rm {} ;
find . -iname ' *.dll ' -exec rm {} ;
find . -iname ' *.lib ' -exec rm {} ;
# NOTE: -DENABLE_VALGRIND=ON
cmake ..
-DCMAKE_VERBOSE_MAKEFILE=TRUE
-DENABLE_VALGRIND=ON
-DENABLE_TESTS=TRUE
-DBASE_NEED_GEN_BUILD_DATE=FALSE
-DENABLE_DOCTEST=ON
-DENABLE_VALGRIND_TESTS=TRUE
-DBUILD_SHARED_LIBS=FALSE
-DCONAN_AUTO_INSTALL=OFF
-DCMAKE_BUILD_TYPE=Debug
# NOTE: to run some tests under valgrind
# use `-DENABLE_VALGRIND_TESTS=TRUE`
cmake -E time cmake --build .
--target flextool-gmock_run_valgrind
# Cmake will print valgrind command that was executed.
# You can copy executed command and add custom command-line arguments:
# --gtest_filter=ToolsSanityTest.DISABLED_ValgrindTest
# --gtest_also_run_disabled_tests
# search for valgrind log file
find $PWD -name * valgrind * .log 누출을 찾으려면 로그 파일에서 definitely lost 될 수 있습니다.
참고 : cmake/valgrind.cfg 에 Valgrind 억제를 추가 할 수 있습니다.
참고 : Valgrind에서 실행할 디버그 플래그가있는 프로그램을 컴파일하십시오.
참고 : valgrind --tool=helgrind 사용하여 잠재적 교착 상태와 데이터 경주를 감지하십시오.
참고 : valgrind --tool=massif --massif-out-file=massif_file --stacks=true 힙의 크기를 측정 할 때. https://kde.org/applications/development/org.kde.massif-visualizer도 참조하십시오
자세한 내용은 https://stackoverflow.com/a/44989219를 참조하십시오
TODO : Valgrind 및 Clang 10 https://stackoverflow.com/questions/40509986/valgrind-reporting-mismatched-free-delete-delete와 함께 구축하십시오.
TODO : Valgrind는 Chromium Base, Fixme을 지원하지 않을 수 있습니다. GTEST_NO_SUITE를 제거하십시오
-e flextool:enable_llvm_tools=True 와 함께 Debug 빌드를 사용해야합니다
Clang-Tidy 설치 :
sudo apt-get install clang-tidy # Ubuntu, Debian, etc.
# OR
sudo yum install clang-tidy # RHEL, CentOS, Fedora, etc. 사용법 ( -DENABLE_CLANG_TIDY=ON 으로 cmake 실행) :
# creates local build in separate folder and runs cmake targets
cmake -DCLANG_TIDY= " ON " -DCLEAN_OLD= " ON " -P tools/run_tool.cmake -e flextool:enable_llvm_tools=True 와 함께 Debug 빌드를 사용해야합니다
자세한 내용은 https://chromium.googlesource.com/chromium/src.git/+/mas
이 프로그램 CCC-Analyzer는 가짜 컴파일러처럼 작용하여 명령 줄 인수를 컴파일러로 전달하여 정기적 인 컴파일을 수행하고 Clang을 정적 분석을 수행합니다.
실행 구성은 일반적으로 컴파일러에 대한 하드 유용 경로가있는 makefiles를 생성하며, 스캔 빌드를 통해 구성을 실행함으로써 경로가 CCC-Analyzer로 설정된 경로를 실행함으로써.
# must exist
ccc-analyzer -v
# must exist
c++-analyzer -v
# must exist
scan-build -v
export VERBOSE=1
export CONAN_REVISIONS_ENABLED=1
export CONAN_VERBOSE_TRACEBACK=1
export CONAN_PRINT_RUN_COMMANDS=1
export CONAN_LOGGING_LEVEL=10
cmake -E time
conan install .
--install-folder local_build_scan_build
-s build_type=Debug
-s cling_conan:build_type=Release
-s llvm_tools:build_type=Release
--profile clang12_compiler
-e flextool:enable_tests=True
-e flextool:enable_llvm_tools=True
cmake -E time
conan source .
--source-folder local_build_scan_build
--install-folder local_build_scan_build
# see section about `conan editable mode`
cd local_build_scan_build
# NOTE: change `build_type=Debug` to `build_type=Release` in production
export build_type=Debug
# optional
# remove old CMakeCache
(rm CMakeCache.txt || true)
# NOTE: changed CMAKE_C_COMPILER to ccc-analyzer (!!!)
# configure via cmake
scan-build
--use-cc=clang-10
--use-c++=clang++-10
-o ./scanbuildout/
cmake ..
-DCMAKE_VERBOSE_MAKEFILE=TRUE
-DCMAKE_C_COMPILER=ccc-analyzer
-DCMAKE_CXX_COMPILER=c++-analyzer
-DENABLE_TESTS=FALSE
-DBASE_NEED_GEN_BUILD_DATE=FALSE
-DENABLE_DOCTEST=OFF
-DBUILD_SHARED_LIBS=FALSE
-DCONAN_AUTO_INSTALL=OFF
-DCMAKE_BUILD_TYPE= ${build_type}
# remove old build artifacts
(make clean || true)
rm -rf bin
# NOTE: requires project configured in debug build
# disable other static analyzers
# run from build directory
scan-build
-maxloop 8
-enable-checker alpha.security.taint.TaintPropagation
-enable-checker alpha.core.BoolAssignment
-enable-checker alpha.core.CastSize
-enable-checker alpha.core.DynamicTypeChecker
-enable-checker alpha.core.FixedAddr
-enable-checker alpha.core.IdenticalExpr
-enable-checker alpha.core.PointerArithm
-enable-checker alpha.core.PointerSub
-enable-checker alpha.core.SizeofPtr
-enable-checker alpha.core.TestAfterDivZero
-enable-checker alpha.deadcode.UnreachableCode
-enable-checker alpha.security.ArrayBoundV2
-enable-checker alpha.security.MallocOverflow
-enable-checker alpha.security.ReturnPtrRange
-enable-checker alpha.unix.PthreadLock
-enable-checker alpha.unix.Stream
-enable-checker alpha.unix.cstring.BufferOverlap
-enable-checker alpha.unix.cstring.NotNullTerminated
-enable-checker alpha.unix.cstring.OutOfBounds
-enable-checker nullability.NullableDereferenced
-enable-checker optin.performance.Padding
-enable-checker security.insecureAPI.rand
-enable-checker security.insecureAPI.strcpy
--use-cc=clang-10
--use-c++=clang++-10
-o ./scanbuildout/
make
-j8 결과 scanbuildout/...../index.html 파일을 열십시오
-e flextool:enable_llvm_tools=True 와 함께 Debug 빌드를 사용해야합니다
자세한 내용은 https://github.com/myint/cppclean을 참조하십시오
설치:
pip install --index-url=https://pypi.python.org/simple/ --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --upgrade cppclean 사용법 ( -DENABLE_CPPCLEAN=ON 으로 cmake 실행) :
# creates local build in separate folder and runs cmake targets
cmake -DCPPCLEAN= " ON " -DCLEAN_OLD= " ON " -P tools/run_tool.cmake 참고 : CPPCLEAN은 파일 인코딩이 필요합니다 : UTF-8 without BOM (ASCII)
-e flextool:enable_llvm_tools=True 와 함께 Debug 빌드를 사용해야합니다
포함 내용 (IWYU)은 포함을 최적화하기위한 프로젝트입니다.
필요한 헤더를 계산하고 추가 / 제거 내용이 적절하게 포함됩니다.
자세한 내용은 다음을 참조하십시오. https://include-what-you-use.org/
사용법 ( -DENABLE_IWYU=ON 으로 cmake 실행) :
# creates local build in separate folder and runs cmake targets
cmake -DIWYU= " ON " -DCLEAN_OLD= " ON " -P tools/run_tool.cmake Codestyle : 사용 // IWYU pragma: associated .
참고 : iwyu pragmas : https://github.com/include-what-you-use/include-what-you-us/blob/master/docs/iwyupragmas.md에 대해 읽으십시오
참고 : "비트/"또는 "/세부 사항/*"포함하지 말고 매핑 파일에 추가하십시오 (.imp)
자세한 내용은 다음을 참조하십시오.
-DUSE_CCACHE=ON 사용하십시오
gcc -v
export CC=gcc
export CXX=g++
# NOTE: -DUSE_CCACHE=ON
cmake ..
-DCMAKE_VERBOSE_MAKEFILE=TRUE
-DUSE_CCACHE=ON
-DENABLE_TESTS=FALSE
-DBASE_NEED_GEN_BUILD_DATE=FALSE
-DENABLE_DOCTEST=OFF
-DBUILD_SHARED_LIBS=FALSE
-DCONAN_AUTO_INSTALL=OFF
-DCMAKE_BUILD_TYPE=Debug자세한 내용은 https://www.virag.si/2015/07/use-ccache-with-cmake-for-faster-compilation/을 참조하십시오.
ccache를 최대한 활용하려면 다음과 같은 것을 넣으십시오. ~/.ccache/ccache.conf :
max_size = 50.0G # or whatever cache size you prefer; default is 5G; 0 means unlimited
base_dir = /home/yourname # or wherever you keep your source files 참고 : CCACHE가 다른 리포지토리 / 경로에서 동일한 파일의 캐시 된 컴파일을 공유하려면 base_dir 필요합니다. base_dir 의 경로에 대해서만이 작업을 수행합니다. 따라서이 옵션은 GIT 작업 트리와 함께 CCACHE를 효과적으로 사용하기 위해 필요합니다 (아래 설명).
base_dir "/"또는 시스템 헤더가 포함 된 모든 곳 (CCACHE 문서에 따라)으로 설정해서는 안됩니다.
설치:
sudo apt-get install ccache
# On OS X use homebrew:
# brew install ccache
ccache --version -DUSE_LD_GOLD=ON 사용하십시오
gcc -v
export CC=gcc
export CXX=g++
# NOTE: -DUSE_LD_GOLD=ON
cmake ..
-DCMAKE_VERBOSE_MAKEFILE=TRUE
-DUSE_LD_GOLD=ON
-DENABLE_TESTS=FALSE
-DBASE_NEED_GEN_BUILD_DATE=FALSE
-DENABLE_DOCTEST=OFF
-DBUILD_SHARED_LIBS=FALSE
-DCONAN_AUTO_INSTALL=OFF
-DCMAKE_BUILD_TYPE=Debug자세한 내용은 https://cristianadam.eu/20170709/speeding-up-cmake/를 참조하십시오.
참고 : 기본적으로 골드가 표시되지 않으며 "-enable-shreads"로 구성됩니다.
참고 : LLD는 기본적으로 스레드를 냈으며 금보다 빠를 수 있습니다.
-e flextool:enable_llvm_tools=True 와 함께 Debug 빌드를 사용해야합니다
자세한 내용은 https://oclint-docs.readthedocs.io/en/stable/devel/codingstandards.html을 참조하십시오
설치:
cd ~
wget --no-check-certificate https://github.com/oclint/oclint/releases/download/v0.13.1/oclint-0.13.1-x86_64-linux-4.4.0-112-generic.tar.gz
# mirror 1: http://github.strcpy.cn/oclint/oclint/releases/download/v0.13.1/oclint-0.13.1-x86_64-linux-4.4.0-112-generic.tar.gz
# mirror 2: http://archives.oclint.org/releases/0.8/oclint-0.8.1-x86_64-linux-3.13.0-35-generic.tar.gz
tar -xzvf oclint-0.13.1-x86_64-linux-4.4.0-112-generic.tar.gz
rm -rf oclint-0.13.1-x86_64-linux-4.4.0-112-generic.tar.gz
export OCLINT_HOME= ~ /oclint-0.13.1
export PATH= $OCLINT_HOME /bin: $PATH
oclint -version 사용법 ( -DENABLE_OCLINT=ON 으로 cmake 실행) :
# NOTE: -DCLEAN_OLD="OFF" to keep generated html report
# creates local build in separate folder and runs cmake targets
cmake -DOCLINT= " ON " -DCLEAN_OLD= " OFF " -P tools/run_tool.cmake # `report.html` must exist
# find $PWD -name report.htmlOpen Report.html
Oclint Tutorial : http://docs.oclint.org/en/stable/intro/tutorial.html을 참조하십시오
https://oclint-docs.readthedocs.io/en/stable/rules/에서 oclint 규칙 목록을 참조하십시오.
참고 : Oclint 경고 http://docs.oclint.org/en/stable/howto/suppress.html#oclint-comment를 억제 할 수 있습니다
자세한 내용은 https://clang.llvm.org/docs/clangformat.html을 참조하십시오
사용법 ( -DENABLE_CLANG_FORMAT=ON 으로 cmake 실행) :
# creates local build in separate folder and runs cmake targets
cmake -DCLANG_FORMAT= " ON " -DCLEAN_OLD= " ON " -P tools/run_tool.cmake .clang-format 파일을 사용합니다. 자세한 내용은 https://clang.llvm.org/docs/clangformatstyleoptions.html을 참조하십시오
참고 : DisableFormat 사용하므로 Clang-Format은 SortIncludes 기준으로 순서 만 포함됩니다.
불행히도 clang-format 충분히 구성 할 수 없으므로 포함하는 데만 사용될 수 있습니다. https://stackoverflow.com/a/32191189를 참조하십시오
우리는 Crustify Bacause Clang-format를 사용하고 Astyle은 많은 옵션을 지원하지 않습니다.
자세한 내용은 https://patrickhenson.com/2018/06/07/uncrustify-configuration.html을 참조하십시오
설치:
cd ~
git clone https://github.com/uncrustify/uncrustify.git
cd uncrustify
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .
export UNCRUSTIFY_HOME= ~ /uncrustify/build
export PATH= $UNCRUSTIFY_HOME : $PATH
# OR sudo make install
uncrustify --version 사용법 ( -DENABLE_UNCRUSTIFY=ON 으로 cmake 실행) :
# creates local build in separate folder and runs cmake targets
cmake -DUNCRUSTIFY= " ON " -DCLEAN_OLD= " ON " -P tools/run_tool.cmake 우리는 uncrustify.cfg 파일을 사용합니다. 자세한 내용은 https://patrickhenson.com/2018/06/07/uncrustify-configuration.html을 참조하십시오
사용 가능한 모든 옵션 목록을 얻으려면 사용하십시오.
uncrustify --show-configUncrustify에는 많은 구성 가능한 옵션이 있습니다. http://universalindent.sourceforge.net/
소스 파일의 일부의 처리를 비활성화하려면 /* *INDENT-OFF* */ /* *INDENT-ON* */ 포함하는 주석을 사용하십시오.
uncrustify.cfg 에서 disable_processing_cmt 참조하십시오 :
# Specify the marker used in comments to disable processing of part of the
# file.
# The comment should be used alone in one line.
#
# Default: *INDENT-OFF*
disable_processing_cmt = " *INDENT-OFF* " # string
# Specify the marker used in comments to (re)enable processing in a file.
# The comment should be used alone in one line.
#
# Default: *INDENT-ON*
enable_processing_cmt = " *INDENT-ON* " # string uncrustify IDE와 통합 할 수 있습니다.
https://github.com/blockspacer/llvm_9_installer#how-to-us-with-sanitizers를 참조하십시오
enable_llvm_tools=True , compile_with_llvm_tools=True 및 llvm_tools:build_type=Release :
-s llvm_tools:build_type=Release
-e flextool:enable_llvm_tools=True
-e flextool:compile_with_llvm_tools=True
-o llvm_tools:include_what_you_use=True
...enable_llvm_tools CONAN에서 Clang 10을 설치합니다compile_with_llvm_tools 세트 cmake 변수를 Conan의 Clang 10을 사용하는 데 필요한 변수 conan install 또는 conan create 실행하십시오.
# OR create conan profile https://docs.conan.io/en/latest/reference/profiles.html
-s compiler=clang
-s compiler.version=10
-s compiler.libcxx=libc++ 참고 : 컴파일러 변경에는 모든 DEP ( --build=missing )의 재 구축이 필요할 수 있습니다.
로컬 빌드의 경우 예 :
export CC= $( find ~ /.conan/data/llvm_tools/master/conan/stable/package/ -path " *bin/clang " | head -n 1 )
export CXX= $( find ~ /.conan/data/llvm_tools/master/conan/stable/package/ -path " *bin/clang++ " | head -n 1 )
export VERBOSE=1
export CONAN_REVISIONS_ENABLED=1
export CONAN_VERBOSE_TRACEBACK=1
export CONAN_PRINT_RUN_COMMANDS=1
export CONAN_LOGGING_LEVEL=10
# NOTE: NO `--profile` argument cause we use `CXX` env. var
# NOTE: you may want to re-build `cling_conan` with clang 10
cmake -E time
conan install .
--install-folder local_build_clang_10
-s build_type=Debug
-s cling_conan:build_type=Release
-s llvm_tools:build_type=Release
--build missing
--build cascade
-s cling_conan:compiler=clang
-s cling_conan:compiler.version=10
-s cling_conan:compiler.libcxx=libstdc++11
-o llvm_tools:include_what_you_use=True
-s llvm_tools:compiler=clang
-s llvm_tools:compiler.version=10
-s llvm_tools:compiler.libcxx=libstdc++11
-e flextool:enable_tests=True
-e flextool:enable_llvm_tools=True
-e flextool:compile_with_llvm_tools=True
-e boost:enable_llvm_tools=True
-e boost:compile_with_llvm_tools=True
-s compiler=clang
-s compiler.version=10
-s compiler.libcxx=libc++
cmake -E time
conan source .
--source-folder local_build_clang_10
--install-folder local_build_clang_10
# remove old CMakeCache
(rm local_build_clang_10/CMakeCache.txt || true)
# see section about `conan editable mode`
conan build .
--build-folder local_build_clang_10
--source-folder local_build_clang_10
--install-folder local_build_clang_10수표 수행 :
# check that `libcpp` symbol exists
nm -an EXECUTABLE_PATH | grep libcpp
# list linked dynamic libs
ldd EXECUTABLE_PATH MCSS_ROOT_DIR_FOR_DOCS 다음과 같은 m.css 소스를 가리켜 야합니다.
cd ~
git clone https://github.com/mosra/m.css.git
pip3 install jinja2 Pygments
sudo apt install
texlive-base
texlive-latex-extra
texlive-fonts-extra
texlive-fonts-recommended
sudo apt-get install doxygen
sudo apt install python3-pip
# /usr/bin/python must point to python3
/usr/bin/python --version
# NOTE: switch to python3 for doxygen or use -DPYTHON_EXECUTABLE=/usr/bin/python3
alias python= ' /usr/bin/python3 '
# You may need sudo here
pip3 install jinja2 Pygments
sudo apt install
texlive-base
texlive-latex-extra
texlive-fonts-extra
texlive-fonts-recommended '-target doxydoc'및 -DBUILD_DOXY_DOC=ON 으로 cmake 빌드를 사용하십시오
cd ~ /flextool
# see section about `conan editable mode`
cd local_build_clang_10
# optional
# remove old CMakeCache
(rm CMakeCache.txt || true)
# remove old build artifacts
rm -rf flextool
rm -rf bin
find . -iname ' *.o ' -exec rm {} ;
find . -iname ' *.a ' -exec rm {} ;
find . -iname ' *.dll ' -exec rm {} ;
find . -iname ' *.lib ' -exec rm {} ;
# remove old build docs
rm -rf doc-mcss
rm -rf docs
cmake -E make_directory " doc-mcss "
# NOTE: you can change python version like so: -DPYTHON_EXECUTABLE=/usr/bin/python3
cmake ..
-DCMAKE_VERBOSE_MAKEFILE=TRUE
-DMCSS_ROOT_DIR_FOR_DOCS= $HOME /m.css
-DPYTHON_EXECUTABLE=/usr/bin/python3
-DENABLE_TESTS=TRUE
-DBASE_NEED_GEN_BUILD_DATE=FALSE
-DENABLE_DOCTEST=ON
-DBUILD_DOXY_DOC=ON
-DBUILD_SHARED_LIBS=FALSE
-DCONAN_AUTO_INSTALL=OFF
-DCMAKE_BUILD_TYPE=Debug
-DDOXY_ROOT_DIR= $PWD /doc-mcss
-DDOXY_DOC_COMMON_IMG_PATH= $PWD /..
-DPROJECT_SOURCES_DIR_FOR_DOCS= $PWD /../src
cmake -E time cmake --build .
--target doxyDoc_notheme
cmake -E time cmake --build .
--target doxyDoc
# Use to find index.html
find $PWD -name * .htmldoxydoc/html/index.html을 엽니 다
참고 : 문서/네임 스페이스의 문서 네임 스페이스
참고 : 문서가없는 파일, 디렉토리 및 기호는 전혀 출력에 없습니다.
중고 댓글 스타일 :
/ **
* @brief Path utils
*
* Example usage:
*
* @code{.cpp}
* const ::fs::path workdir = storage::getThisBinaryDirectoryPath ();
* @endcode
** /보다:
자세한 내용은 https://afl-1.readthedocs.io/en/latest/index.html을 참조하십시오
참고 : lcamtuf.coredump.cx/afl 에서 AFL을 업데이트하지 않도록 github.com/google/afl 또는 aflplus.plus를 선호하십시오.
퍼징은 블랙 박스 소프트웨어 테스트 기술입니다.
퍼징은 자동화 된 방식으로 오르 포맷/반응성 데이터 주입을 사용하여 구현 버그를 찾는 것으로 구성됩니다.
Fuzzer는 가능한 한 많은 프로그램 코드 라인에 도달 할 수 있도록 입력을 수정하려고합니다.
따라서 퍼징은 정상적인 사용으로 도달하기 어려운 코드 경로에있는 취약점을 발견 할 수 있습니다.
다음 명령을 사용하여 소스 코드를 설치 + 컴파일하십시오.
# optional
# sudo apt-get update
# optional
# sudo apt-get -y install autoconf automake bison build-essential
ca-certificates llvm-dev libtool libtool-bin
libglib2.0-dev make nasm wget
# Tested with clang 10 and gcc 7
sudo apt-get -y install clang-10 g++-7 gcc-7
export CXX=g++-7
export CC=gcc-7
export PATH=/usr/bin/: $PATH
$CC -v
# llvm-config binary that coresponds to the same clang you are using to compile
export LLVM_CONFIG=/usr/bin/llvm-config-10
$LLVM_CONFIG --cxxflags
cd ~
git clone -b v2.56b https://github.com/google/AFL.git --recursive
# NOTE: original AFL not updated since November 2017,
# so prefer `google/AFL.git` to `lcamtuf.coredump.cx/afl`
# wget http://lcamtuf.coredump.cx/afl/releases/afl-latest.tgz
# tar -xf afl-latest.tgz
# rm afl-latest.tgz
# cd afl*
cd AFL
make
# build llvm using the sample compiler as afl code uses
# see https://groups.google.com/forum/#!topic/afl-users/1WqZpGXvYY0
make
-C llvm_mode
LLVM_CONFIG= $LLVM_CONFIG
CC=clang-10
CXX=clang++-10
#
# optional
# cd qemu_mode
# ./build_qemu_support.sh
# cd ..
#
make
-C libdislocator
make
-C libtokencap
sudo make install
# OR add to PATH via export PATH=$PATH:...
# do not forget to reset CC and LLVM_CONFIG
unset CXX
unset CC
unset LLVM_CONFIG 우리는 AFL 컴파일러를 사용하여 코드를 컴파일합니다 : -DCMAKE_C_COMPILER=afl-clang-fast , -DCMAKE_CXX_COMPILER=afl-clang-fast++ 및 -DCMAKE_LINKER=afl-clang-fast .
이진이 AFL 컴파일러를 사용하는지 확인하려면 : nm BINARY_PATH | grep afl
일부 소독제 및 디버그 정보를 사용하여 응용 프로그램을 구축하려면 : ( -DENABLE_ASAN=ON 등) :
참고 : 주소 소독제를 사용할 때 고려해야 할 사항이 있습니다. ASAN이 메모리 액세스 위반을 발견하더라도 자동으로 응용 프로그램이 충돌하지 않습니다. 자동화 된 퍼징 도구를 사용할 때는 일반적으로 반환 코드를 확인하여 SEGFAULTS를 감지하려고 할 때 문제가됩니다. 그러나 퍼지하기 전에 환경 변수 ASAN_OPTIONS에 오류가 발생하면 ASAN이 소프트웨어를 충돌시킬 수 있습니다. export ASAN_OPTIONS='abort_on_error=1'
참고 : 사용자 정의 메모리 할당 함수를 비활성화합니다. 이렇게하면 메모리 액세스 버그를 숨기고 메모리 액세스 오류 감지를 방지 할 수 있습니다.
# see https://afl-1.readthedocs.io/en/latest/instrumenting.html
# Setting AFL_HARDEN automatically adds code hardening options
# when invoking the downstream compiler.
# This includes -D_FORTIFY_SOURCE=2 and -fstack-protector-all.
# NOTE: _FORTIFY_SOURCE not compatible with ASAN
# export AFL_HARDEN=1
# see https://aflplus.plus/docs/env_variables/
export AFL_EXIT_WHEN_DONE=1
# By default, the wrapper appends -O3 to optimize builds.
export AFL_DONT_OPTIMIZE=1
# or AFL_USE_MSAN, etc.
# READ https://aflplus.plus/docs/notes_for_asan/
NOTE: if you run several slaves only one should run the
# target compiled with ASAN (and UBSAN, CFISAN),
# the others should run the target with no sanitizers compiled in.
export AFL_USE_UBSAN=1
export AFL_USE_ASAN=1
# AFL_PRELOAD causes AFL to set LD_PRELOAD for the target binary
# without disrupting the afl-fuzz process itself.
# This is useful, among other things, for bootstrapping libdislocator.so.
# see __AFL_LOOP
# export AFL_PERSISTENT=1
# make sure you compile app with `-fsanitize=address` or `-fsanitize=memory` etc. 참고 : AFL_DONT_OPTIMIZE=1 ; 읽기 : http://moyix.blogspot.com/2016/07/fuzzing-with-afl-is-an-art.html
자세한 내용은 AFL과 함께 ASAN 사용을 참조하십시오
프로그램을 퍼징하기 전에 Core_pattern을 정리하기 위해 루트 사용자로 전환해야 할 수도 있습니다. 루트로 로그인하고 다음 명령을 입력하십시오.
# see https://afl-1.readthedocs.io/en/latest/tips.html#check-os-configuration
sudo su
# disable core dumps and CPU frequency scaling on your system (AFL will warn you if you should do this)
echo core > /proc/sys/kernel/core_pattern
# afl-fuzz will usually complain that you should change your `CPUFREQ` settings to performance because the automatic frequency scaling by the Linux kernel doesn't work well with afl.
echo performance | tee /sys/devices/system/cpu/cpu * /cpufreq/scaling_governor
exit참고 : 루트 액세스로 퍼저를 실행하지 마십시오
참고 : 퍼저를위한 견고한 환경을 얻으십시오. 낮은 구성 하이퍼 바이저에서 퍼지를 실행하지 마십시오.
afl-fuzz AFL을 실행하는 데 사용됩니다. 실제 구문은 다음과 같습니다.
# see https://afl-1.readthedocs.io/en/latest/fuzzing.html#fuzzing-binaries
# -i is a directory of files to use as fuzz input "seeds"
# -o is a directory to write the results (including inputs that provoke crashes or hangs)
# -m is the memory allowed to use. Example: -m500
# You can use -m none to disable memory limit
# -t is the maximum time that a run is allowed to take before being declared a "hang"
# Timeout of 10 seconds: -t 10000
# @@ is fuzzer input file name
# if you skip @@ it will pass the fuzzed file on the standard input
AFL_PERSISTENT=1 afl-fuzz -i [TESTCASE DIR] -o [RESULT_DIR] [TARGET_BINARY] [BINARY_PARAMS] @@
# Example 1: runs `tar` with arguments `xfJ @@ -C fuzz-garbage/ --force-local`
# where @@ is fuzzer input file name
./afl-1.56b/afl-fuzz -i fuzz-input/ -o fuzz-state/ -t 10000 ~ /tar-1.28/src/tar xfJ @@ -C fuzz-garbage/ --force-local
# Example 2: server is dual core, so we can run one AFL instance per core
AFL_PERSISTENT=1 afl-fuzz -i inputs -o multi_sync -M master ./fuzz_capstone
# In another terminal
AFL_PERSISTENT=1 afl-fuzz -i inputs -o multi_sync -S slave1 ./fuzz_capstoneAFL 상태 화면을 이해하려면 https://afl-1.readthedocs.io/en/latest/user_guide.html#status-screen을 읽으십시오
참고 : total paths 1에 머무르면 아마도 뭔가 잘못된 것을 설정했을 것입니다.
참고 : 선호 -m none . 우리는 주소 사료를 사용합니다. 이것은 그림자 메모리에 대한 많은 페이지를 매핑하므로 메모리 제한을 제거하여 실행되도록 메모리 제한을 제거해야합니다.
참고 : -m none 사용하면 퍼지 소프트웨어가 실제로 퍼지 샘플로 인해 실제로 많은 메모리를 할당하고 사용하려고 시도 할 수 있습니다. 이것은 시스템에서 임의의 충돌로 이어질 수 있습니다. 그렇게하는 동안 중요한 일을해서는 안됩니다.
참고 : ASAN_OPTIONS=hard_rss_limit_mb=2000 시도하여 -m none 피할 수 있습니다. 참조 : https://countuponsecurity.com/category/fuzzing/
afl-fuzz 사용하여 실행될 맞춤형 바이너리를 작성할 수 있습니다. 그렇게 테스트하려는 기능을 래핑 할 수 있습니다.
// harness is simply a C program that makes use of certain methods from
// a library, allowing you to indirectly fuzz it
# include < cstdio >
# include < cstdlib >
# include < string >
# include < iostream >
# include < ifstream >
int main ( int argc, char *argv[]) {
{
// init resources here
if (argc > 1 ) {
std::ifstream fin;
fin. open (argv[ 1 ]);
parse (fin); // custom logic
} else {
// / note requires AFL_PERSISTENT=1
// __AFL_LOOP is the way that we have to tell AFL
// that we want persistent mode.
// Each fuzzing iteration,
// instead of to fork and re-execute the target with a different input,
// is just an execution of this loop.
// Force AFL to run 1000 times,
// with 1000 different inputs fed to the library.
// After that, the process is restarted by AFL.
// This ensures we regularly replace the process to avoid memory leaks.
// see https://toastedcornflakes.github.io/articles/fuzzing_capstone_with_afl.html
while ( __AFL_LOOP ( 1000 )) {
parse (std::cin); // custom logic
}
}
// free resources here
return 0 ;
} 참고 : __AFL_LOOP ()는 AFL을 통해 테스트하려는 모든 새로운 테스트 케이스에 대한 새로운 프로세스를 시작하는 것과는 달리 일부 메모리 마법사를 통해 프로세스에서 이진의 퍼지를 수행 할 수 있습니다. AFL_PERSISTENT=1 필요합니다.
기본적으로 AFL은 다른 입력을 테스트 할 때마다 프로세스를 포크합니다. 우리는 모든 테스트 샘플에 대해 프로그램 상태를 되 돌리지 않고 프로그램의 단일 인스턴스에서 여러 퍼즈 케이스를 실행하도록 AFL을 제어 할 수 있습니다. 이렇게하면 커널 공간에서 소요되는 시간이 줄어들고 퍼징 속도가 향상됩니다. 이를 AFL_Persistent 모드라고합니다. 우리는 테스트 하네스에 __afl_loop (1000) 매크로를 포함시켜 그렇게 할 수 있습니다.
참고 : __AFL_INIT에 관심이있을 수 있습니다. 자세한 내용은 https://robertheaton.com/2019/07/08/how-to-write-an-afl-wrapper-for-any-anguage/를 참조하십시오.
제공된 테스트 케이스에 따라 최대 코드 실행 경로를 생성하므로 퍼저를 몇 시간 또는 며칠 동안 실행하도록하십시오.
AFL 통계 화면의 전체 결과 in the section 총 경로 and UNIQ 충돌 ctrl+c' observing 퍼지 발행 중지.
프로그램 바이너리에있는 모든 상수와 문자열을 가져와 사전에 추가하는 사전을 만듭니다. 스크립트 코드를 참조하십시오 : http : //moyix.blogspot.com/2016/07/fuzzing-with-afl-is-an-art.html을 참조하십시오
#! /bin/bash
# see http://moyix.blogspot.com/2016/07/fuzzing-with-afl-is-an-art.html
objdump -d " ${1} " | grep -Eo ' $0x[0-9a-f]+ ' | cut -c 2- | sort -u | while read const ; do echo $const | python -c ' import sys, struct; sys.stdout.write("".join(struct.pack("<I" if len(l) <= 11 else "<Q", int(l,0)) for l in sys.stdin.readlines())) ' > testcases/ $const ; done
i=0 ; strings " ${1} " | while read line ; do echo -n " $line " > testcases/string_ ${i} ; i=$[ $i + 1 ] ; done사전/readme.dictionaries에서 논의 된 두 형식 중 하나에서 사전을 생성 한 다음 명령 줄의 -x 옵션을 통해 퍼저를 가리 킵니다. 읽기 : https://afl-1.readthedocs.io/en/latest/fuzzing.html#fuzzing-binaries 및 https://github.com/mirrorer/afl/blob/master/dictionaries/readme.dictionaries
libtokencap 사용하여 사전을 만들 수도 있습니다. https://github.com/mirrorer/afl/blob/master/libtokencap/readme.tokencap을 참조하십시오
우리는 생성 한 results 폴더에서 충돌을 일으키는 테스트 케이스를 찾을 수 있습니다. 폴더 results 를 탐색 할 때 폴더가 거의 생성되는 것을 관찰합니다.
참고 : 입력 데이터 파일을 작게 유지하십시오. 1 KB 미만이 이상적입니다.
afl-cmin 사용하여 입력 데이터 파일 수를 최소화하십시오.
afl-tmin 사용하여 각 입력 데이터 파일을 최소화하십시오 (취한 코드 경로에 영향을 미치지 않는 바이트를 제거).
afl-ptmin 사용하여 afl-tmin 병렬로 실행하십시오. 자세한 내용은 다음을 참조하십시오.
Found Crash를 재현하려면 crashwalk (GDB 플러그인)를 사용할 수 있습니다.
apt-get install gdb golang
mkdir src
cd src
git clone https://github.com/jfoote/exploitable.git
cd && mkdir go
export GOPATH= ~ /go
# crashwalk installed in $GOPATH/bin/
go get -u github.com/bnagy/crashwalk/cmd/...
# USAGE
~ /go/bin/cwtriage -root syncdir/fuzzer1/crashes/ -match id -- ~ /parse @@AFL-Fuzz에서 찾은 충돌을 재현 할 수없는 경우, 가장 큰 원인은 도구에서 사용하는 것과 동일한 메모리 제한을 설정하지 않기 때문입니다. 읽기 : https://afl-1.readthedocs.io/en/latest/fuzzing.html#fuzzing-binaries
참고 : afl-cov 사용하여 이진에서 사용 가능한 코드 경로를 얼마나 잘 운동하는지 정량화 할 수 있습니다. 자세한 내용은 다음을 참조하십시오.
참고 : AFL 작업 디렉토리를 RAM 디스크에 넣으면 잠재적으로 약간의 속도를 얻고 동시에 디스크를 착용하지 않을 수 있습니다. 자세한 내용은 https://banananamafia.dev/post/gb-fuzz/를 참조하십시오.
# Fuzzing involves billions of reads and writes to the filesystem (!!!)
# Use RAMdisks for input since, we don't want to destroy harddrives
# Make a 1GB ramdisk file from which AFL can read input
sudo mkdir -p /mnt/inputfiles
sudo chown -R $USER : $( id -gn $USER ) /mnt/inputfiles
sudo mount -t tmpfs -o size=1024M tmpfs /mnt/inputfiles/ 참고 : -fvisibility-inlines-hidden 플래그는 AFL 계측을 깨뜨릴 수 있습니다
AFL은 experimental/crash_triage/triage_crashes.sh 에서 충돌 탐색 스크립트를 제공합니다
실행되면 심사 스크립트는 /out/crashes 디렉토리의 각 충돌 파일을 순환하고 결과 충돌 데이터를 화면에 인쇄합니다.
triage_crashes 사용법 : ./triage_crashes.sh ~/targets/out/ ~/targets/target-app/target-app_binary 자세한 내용은 https://research.aurainfosec.io/hunting-for-bugs-101/
참고 : AFL이있는 악기는 실제로 한 번에 하나씩 스트레스 테스트를 원하는 라이브러리 만 있습니다. 이 프로그램이 실제로 퍼지하고 싶지 않은 기능에 대해 시스템 전체의 비 계측 라이브러리를 사용하도록하십시오.
참고 : -C 통해 crash exploration mode 활성화 할 수 있습니다. https://lcamtuf.blogspot.com/2014/11/afl-fuzz-crash-exploration-mode.html을 참조하십시오
참고 : AFL은 신호 (SIGSEGV, SIGABRT 등)로 인해 첫 번째 생성 된 프로세스 사망을 점검하여 결함을 감지합니다. 이러한 신호에 맞춤 핸들러를 설치하는 프로그램은 관련 코드를 댓글을 달아야 할 수도 있습니다.
자세한 내용은 다음을 참조하십시오.
Libfuzzer는 LLVM 컴파일러 인프라 프로젝트의 일부이며 Clang Compiler와 함께 제공됩니다.
그런 다음 Libfuzzer는 연결 단계에서 -fsanitize=fuzzer 통과시켜 원하는 드라이버에 연결할 수 있습니다.
참고 : -fsanitize=fuzzer 링크.
참고 : 대부분의 경우 Libfuzzer와 ASAN (AddressSanitizer), UBSAN (UndefinedBehaviorsanitizer) 또는 둘 다를 결합 할 수 있습니다. MemorySanitizer (MSAN)로 빌드 할 수도 있지만 지원은 실험적입니다. -fsanitize=undefined,address,fuzzer .
실행 파일은 반복적으로 다음 기능을 호출합니다.
extern " C " int LLVMFuzzerTestOneInput ( const uint8_t *Data, size_t Size ) {
// DoStuffWithYourAPI(Data, Size);
return 0 ;
} -fsanitize=address,fuzzer 사용하십시오. 소독제 (주소, 메모리, 스레드 등)를 변경할 수 있습니다.
참고 : 대상의 메모리 누출이 의심되는 경우 -runs=N 또는 -max_total_time=N 으로 libfuzzer를 실행해야합니다. 대상에 막대한 누출이 있으면 결국 RAM이 떨어질 것입니다. OOM 사망으로부터 기계를 보호하려면 ASAN_OPTIONS=hard_rss_limit_mb=2000 (주소 소지자 포함)을 사용할 수 있습니다.
Libfuzzer는 종자 코퍼스가 필요합니다. 자세한 내용은 https://github.com/google/fuzzing/blob/master/tutorial/libfuzzertutorial.md를 참조하십시오
자세한 내용은 다음을 참조하십시오.
Clang은 스레드 안전 주석 (Guarded_by)을 지원합니다.
-Wthread-safety-analysis 활성화합니다base/thread_annotations.h https://github.com/chromium/chromium/blob/master/base/thread_annotations.h를 사용하십시오. 자세한 내용은 참조하십시오.소독제에 대한 Clang FAS 일류 지원. 문서에서 MSAN, ASAN, TSAN 등에 대한 자세한 내용을 참조하십시오.
Clang은 평생 프로파일로 빌드 할 수 있습니다.
-Wlifetime 활성화를 참조하십시오.모든 오픈 소스 구성 요소는 관련 오픈 소스 라이센스에 따라 사용됩니다.
사용 된 오픈 소스 구성 요소 :
라이센스 파일을 참조하십시오
MIT 라이센스
라이센스의 전체 컨텐츠는 라이센스를 참조하십시오.
Google Chromium 프로젝트를 기반으로 한 오픈 소스 프로젝트.
이것은 공식적인 Google 제품이 아닙니다.
부분 저작권 (c) Google Inc.
라이센스 파일을 참조하십시오.