ããã«ã¡ã¯ã ä»æ¥ã¯ãC / C ++ã®ææ°ã®äŸåé¢ä¿ãããŒãžã£ãŒã§ããConanã«ã€ããŠèª¬æããŸãã ããªããæ¢ã«åœŒãšç©æ¥µçã«ä»äºãããŠãããªããããªãã¯ããªãèªèº«ã®ããã«äœãæ°ãããã®ãèŠã€ããå¯èœæ§ã¯äœãã§ãããã ããã§ãªããã°-ç«ã®äžã§ãé¡ãããŸãã
äŸåé¢ä¿ãããŒãžã£ãŒãå¿ èŠãªçç±
LinuxããŒã¹ã®ãã£ã¹ããªãã¥ãŒã·ã§ã³ãŸãã¯macOSã®ãŠãŒã¶ãŒã§ããã°ãå¿ èŠãªäŸåé¢ä¿ã匷åããããšã¯ããããåé¡ã§ã¯ãããŸããããã£ã¹ããªãã¥ãŒã·ã§ã³ã«ã¯ãå¿ èŠãª<library_name> -devããã±ãŒãžãå«ãŸããŠããå¯èœæ§ããããŸãã ããããããªããWindowsãŠãŒã¶ãŒã§ããå Žåãç§ã¯ãã°ãã°åé¡ã«ééãããšæããŸããã©ã®ããã«ããŠäžæ¯ããããžã§ã¯ãã«è¿œå ã§ããŸããã ãµãŒãããŒãã£ã©ã€ãã©ãªãããããŒã®ã¿ã®å ŽåãããããŒãã¡ã€ã«ãé©åãªãã®ã«ã³ããŒããŠäœ¿çšãéå§ããã ãã§ãã ãã ããéåžžã¯ã©ã€ãã©ãªãã¢ã»ã³ãã«ããå¿ èŠãããïŒC ++ã«ã¯åç©åããããããããã¯ããã»ã©åçŽã§ã¯ãªãããšãå€ãïŒãã³ã³ãã€ã«ããã©ã€ãã©ãªãå¿ èŠãªå Žæã«é 眮ããŸãã ãããŠããã®åŸã®ã¿äœ¿çšã§ããŸãã
ããã«ãã§ããã°1ã€ã®ã³ã³ãã€ã©ã§ã©ã€ãã©ãªãã³ã³ãã€ã«ããããšãABIã®äºææ§ãªã©ãå¿ããªãããšãå¿ããªãã§ãã ããã ã¯ããã³ã³ãã€ã«èªäœã«éåžžã«é·ãæéãããããŸãïŒHi BoostïŒã æ®éã®äººéã«ãšã£ãŠã¯å€ãããŸããã äžæ¹ãäžéšã®äººã ã¯pip ã npm ã cargo ã mavenãªã©ã䜿çšããã ãã§ãã ããããã®ç¥çµãç¯çŽããŠãã ããã
以åã®è©Šã¿
npmã®é¡äŒŒç©ã欲ããã®ã§ãããC ++çšã§ãã æåéã1ã€ã®ããŒã ã§ãããžã§ã¯ãã«å¿ èŠãªäŸåé¢ä¿ãåŒãäžããé çã®çš®ãç¥ããŸããã
C ++çšã®ãã®ãããªããŒã«ãäœæããè©Šã¿ã¯ãã§ã«è¡ãããŠããŸãã ãã¶ãããªãã®äœäººãã¯biicodeã®ãããªãã®ãèŠããŠããŸãã æ®å¿µãªããã圌ã¯é·åœãåœããŸããã ããã§ã¯ãæ£è ã®æ»å ãèŠã€ããããšãã§ããŸãã èå³æ·±ãäºå®ïŒConanãšbiicodeã®äœæè ã¯ã»ãŒåã人ãã¡ã§ãã åççãªçåãçããŸããã³ãã³ã¯biicodeã®éåœãç¹°ãè¿ããŸããïŒ
ã³ãã³ã«ä»£ããçŸä»£çãªéžæè¢ããããŸãã æãæåãªã®ã¯vcpkg ã hunter ã buckarooã§ãã
ã€ã³ã¹ããŒã«æ¹æ³
ãŸããConanèªäœãã€ã³ã¹ããŒã«ããå¿ èŠããããŸãã ãããè¡ãã«ã¯å€ãã®æ¹æ³ããããŸãïŒãæ°ã«å ¥ãã®ããã±ãŒãžãããŒãžã£ãŒãpipãbrewã Ubuntu / Debianããã³Windowsçšã®ãã€ããªãã«ãããããŸãã èè èªèº«ããpipãä»ããã€ã³ã¹ããŒã«ã®äœ¿çšãæšå¥šããŠããŸãã ãããã®ã¡ãœãããæ°ã«å ¥ããªãå Žåã¯ã ãœãŒã¹ã³ãŒããããã€ã§ãã³ã³ãã€ã«ã§ããŸã ã
ç¹åŸŽ
Conanã¯ãã³ã³ãã€ã©ãã³ã³ãã€ã©ããŒãžã§ã³ããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ãOSã®ããã深床ãã¢ã»ã³ããªã®ã¿ã€ãïŒãªãªãŒã¹/ãããã°ïŒãæšæºã©ã€ãã©ãªã®ããŒãžã§ã³ãªã©ã远跡ããŸãã ãããã®ãã©ã¡ãŒã¿ãŒã䜿çšããŠãConanã¯æ§æçšã«ã¢ã»ã³ãã«ãããããŒãžã§ã³ãèŠã€ããããšããŸãã éããããã°ããªããžããªã«ã¯ãã§ã«ã¢ã»ã³ãã«ãããããŒãžã§ã³ããããäœãã³ã³ãã€ã«ããå¿ èŠã¯ãããŸããã
OS /ã³ã³ãã€ã©/ãªã©ã®çµã¿åããã§ãäžéãªãã ããã±ãŒãžãèŠã€ãããªãã£ãå ŽåãConanã¯å¿ èŠãªã©ã€ãã©ãªã®ãœãŒã¹ã³ãŒããèªåçã«ããŠã³ããŒãããäœæ¥äžã®ãã·ã³ã§ã³ã³ãã€ã«ããŸãã ãã®åŸããããã誰ãã«ãã£ãŠæ¢ã«ã¢ã»ã³ãã«ãããŠãããã®ããã«ãã©ã€ãã©ãªãå®å šã«äœ¿çšã§ããŸãã
䜿ãæ¹
ãã®ãããªtimer.cppããããã³ã³ãã€ã«ãšåäœã匷å¶ããå¿ èŠããããŸãã
#include "Poco/Timer.h" #include "Poco/Thread.h" #include "Poco/Stopwatch.h" #include <iostream> using Poco::Timer; using Poco::TimerCallback; using Poco::Thread; using Poco::Stopwatch; class TimerExample{ public: TimerExample(){ _sw.start();} void onTimer(Timer& timer){ std::cout << "Callback called after " << _sw.elapsed()/1000 << " milliseconds." << std::endl; } private: Stopwatch _sw; }; int main(int argc, char** argv){ TimerExample example; Timer timer(250, 500); timer.start(TimerCallback<TimerExample>(example, &TimerExample::onTimer)); Thread::sleep(5000); timer.stop(); return 0; }
ããã¥ã¡ã³ãã®æšæºçãªäŸãèããŠã¿ãŸãããã ãããžã§ã¯ãã«POCOã©ã€ãã©ãªãå«ããŸãïŒ CMakeã䜿çšãããšããŸãïŒã ãããè¡ãã«ã¯ããããžã§ã¯ããã©ã«ããŒã§ã次ã®ããã¹ããå«ããã¡ã€ã«conanfile.txtãäœæããŸãã
[requires]
Poco/1.8.0.1@pocoproject/stable
[generators]
cmake
ãã®ãã¡ã€ã«ã®å 容ãèŠãŠã¿ãŸãããã Requiresã»ã¯ã·ã§ã³ã§ã¯ãå¿ èŠãªäŸåé¢ä¿ãNameLibraries / VersionLibraries @ MaintainerName / Package Stabilityã®åœ¢åŒã§èª¬æããŸãã ã¡ã³ãããŒã®ååã¯ãããã±ãŒãžããµããŒãããå人ãŸãã¯çµç¹ã§ãã å®å®æ§ã¯ãåã«ããã±ãŒãžã®å®å®æ§ã瀺ãææšã§ãã éåžžãå®å®ãããã¹ãã䜿çšããŸãã å®å®ããããã±ãŒãžã®ã¿ã䜿çšããããšããå§ãããŸãã
ãžã§ãã¬ãŒã¿ã»ã¯ã·ã§ã³ã§ã¯ãçµ±åãããã®ã瀺ããŸãã ãã®å ŽåãCMakeãšã®çµ±åã瀺ããŸãã CMakeãšçµ±åããããã®Conanã¯ãconanbuildinfo.cmakeãã¡ã€ã«ãèªåçã«äœæããŸãããã®ãã¡ã€ã«ã«ã¯ãCMakeLists.txtã§äœ¿çšããããããŒãã¡ã€ã«ãšæ¢ã«ã³ã³ãã€ã«ãããã©ã€ãã©ãªãžã®ãã¹ãæã€å€æ°ãå®çŸ©ãããŸãã
project(FoundationTimer) cmake_minimum_required(VERSION 2.8.12) add_definitions("-std=c++11") include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() add_executable(timer timer.cpp) target_link_libraries(timer ${CONAN_LIBS})
5-6è¡ç®ã«æ³šæããŠãã ããã 5è¡ç®ã§ã¯ã以åã«çæãããconanbuildinfo.cmakeãæ¥ç¶ãã6è¡ç®ã§ã¯ãåã«Conanãéæ³ã®ããã«åäœããããã¯ããå®çŸ©ããŸã:-)
ããã§çµã¿ç«ãŠã®æºåãæŽããŸããã ãŸããCMakeã®æšæºçãªèµ·åã®åã«ãConanã«äŸåé¢ä¿ã®ã€ã³ã¹ããŒã«ãäŸé Œããå¿ èŠããããŸãã ããã¯ã次ã®ã³ãã³ãã§å®è¡ãããŸãã
conan install /path/to/conanfile.txt
éåžžãããŒã ã¯æ¬¡ã®ããã«ãªããŸã
conan install ..
ã³ãã³ãäžæ¯ãåŒãèµ·ããæ¹æ³-ããã«æ¥œããéšåããããŸã
äŸåé¢ä¿ã®æ€çŽ¢é åºïŒ
- ããŒã«ã«ãã£ãã·ã¥ã確èªããŸãã
- æ¥ç¶ããããªããžããªã§å¿ èŠãªã¬ã·ããæ¢ããŠããŸãã ãªããžããªãæ¥ç¶ãããŠããé åºã§å³å¯ã«æ€çŽ¢ãå®è¡ãããããšã«æ³šæããŠãã ããã ããã±ãŒãžã2ã€ã®ãªããžããªã«ããå Žåãæåã®ãªããžããªãèŠã€ãããŸãã
- ã¬ã·ããèŠã€ãããæ§æçšã«æ§ç¯ãããã©ã€ãã©ãªãæ¢ã«ååšããå Žåã¯ããªããžããªããããã±ãŒãžãããŠã³ããŒãããŠãããŒã«ã«ãã£ãã·ã¥ã«ä¿åããã ãã§ãã ããã±ãŒãžã¯ãäŸåé¢ä¿ããã¹ãŠèªåçã«ãã³ãã¢ãŠããããããšã«æ³šæããŠãã ããã
- æ§æã«ã¢ã»ã³ãã«ãããã©ã€ãã©ãªããªãå ŽåïŒãŸãã¯æ§æã®äŸåã©ã€ãã©ãªãåéãããŠããªãå ŽåïŒãã³ãã³ã¯ãããéç¥ãããã·ã³äžã§ããã±ãŒãžã®ãã«ããéå§ããããã«--build missingãã©ã°ãä»ããŠå床å®è¡ããããã«èŠæ±ããŸãã
誰ããã¢ã»ã³ãã«ããã©ã€ãã©ãªã䜿çšããããªããä»ã®äººã®ã¢ã»ã³ããªãä¿¡é Œããªãå Žåãã©ã€ãã©ãªãšãã®ãã¹ãŠã®äŸåé¢ä¿ããã·ã³äžã§åŒ·å¶çã«åæ§ç¯ãããããã«ãåžžã«--buildãã©ã°ãæå®ã§ããŸãã
ããã§ãšãããã¹ãŠã®äŸåé¢ä¿ãConanã§ãã«ã¢ãããããŠããŸãïŒéããããã°ïŒïŒ
ã³ãã³ãšãã«ãã·ã¹ãã ãšã®çµ±å
ç®çã®ããŒãžã§ã³ã®ã©ã€ãã©ãªãããŠã³ããŒãããã ãã§ãªãããããžã§ã¯ãã«æ£ããæ¥ç¶ããããšãéèŠã§ãã ãããŠãããã¯éçºè ã«ãšã£ãŠã§ããã ãç°¡åã«è¡ãããããšãæãŸããã ãããã£ãŠãConanã¯CMakeãVisual StudioãXcodeãªã©ãšçµ±åã§ããŸãã ããªãã¯ãã€ã§ãããã§å®å šãªãªã¹ããèŠã€ããããšãã§ããŸã ã
ç¬èªã®äŸåé¢ä¿ã管çããæ¹æ³ãšããŠã®ã³ãã³
Conanã¯ã誰ããæ¢ã«äœæãããªããžããªããäŸåé¢ä¿ãã€ã³ã¹ããŒã«ããããã®ã¯ã©ã€ã¢ã³ãã ãã§ã¯ãããŸããã ãŸãããã®äŸåé¢ä¿ãããŒãžã£ãŒã®äœæè ã¯ã conan-serverããã°ã©ã ã芪åã«æäŸããŠãããŸãããããã«ãããããã€ãã®ã¢ã¯ã·ã§ã³ã§æ¢è£œã®ã©ã€ãã©ãªãŒã䜿çšããŠæåéãç¬èªã®ãµãŒããŒãäœæã§ããŸãã ç¬èªã®äŸåé¢ä¿ç®¡çã€ã³ãã©ã¹ãã©ã¯ãã£ãæ§ç¯ãããäŒæ¥ã«ãšã£ãŠéåžžã«äŸ¿å©ã§ãã
æ¢åã®åé¡
ããã±ãŒãžãããŒãžã£ãŒã®äŸ¡å€ã¯ã䜿ãããããšããã±ãŒãžã®æ°ã«ãã£ãŠæ±ºãŸããŸãã æåã®ãã®ã«ç¹å¥ãªåé¡ããªãå ŽåïŒã³ãã³ã®äœ¿çšã¯éåžžã«äŸ¿å©ã§ãïŒãããã±ãŒãžã®æ°ã«ç¹å®ã®åé¡ããããŸãã ã¡ã€ã³ã®ãªããžããªãèŠããšããããã®2ã€ãèŠãããŸãïŒ conan-centerãšconan-transitã§ãã åæãããããã¯èª€è§£ãæã-ã©ã®1ã€ã䜿çšããã®ãïŒ ããã§ãå°ã話ãããå¿ èŠããããŸãã
æåã¯ãConanã«ã¯1ã€ã®ãªããžããªããããããã«ä»»æã®ãŠãŒã¶ãŒãããã±ãŒãžãããŒãããæš©å©ããããŸããã ãã®ãããConanãªããžããªã¯ããã«1ã€ã®å€§ããªãŽããã³ãã«å€ãããŸããã èè ã¯ãããã¯ç¶ç¶ã§ããªããšå€æããããã±ãŒãžã培åºçã«ãã§ãã¯ããåŸã«ã®ã¿ååŸããããªããžããªãäœæããããšã決å®ããŸããã ã³ãã³ã»ã³ã¿ãŒããããŸããã ãããŠãå€ããžã£ã³ã¯ãªããžããªãåé€ãããåã«èªã¿åãå°çšã¢ãŒãã«ããŠãconan-transitãšããååã«å€æŽããããšã«ããŸããã
ãªãŒãã³ãœãŒã¹ã©ã€ãã©ãªã®ããã±ãŒãžã¯ã©ãã«ä¿åãããŠããŸããïŒ
ãã¹ãŠã®ããã±ãŒãžã¯JFrog Bintrayã«ãã£ãŠä¿åãããŸãã å°ãåãŸã§ãã³ãã³ã¯Bintrayã€ã³ãã©ã¹ãã©ã¯ãã£ã«ç§»åããããã CDNã ãã§ãªãããã容éã®å€§ããããã±ãŒãžãªããžããªã«ãã¢ã¯ã»ã¹ã§ããããã«ãªããŸããã 移è¡åŸã®æãèå³æ·±ãé©æ°ã®1ã€ã¯ã OSSããã±ãŒãžçšã«å®å šã«ç¡æã®ç¬èªã®ãªããžããªãäœæã§ããããšã§ãã ãã©ã€ãã·ãŒãå¿ èŠãªå Žåã¯ã30æ¥éè©Šçšçã䜿çšã§ããŸãããã®åŸãæéãæ¯æãå¿ èŠããããŸãã
Bincrafters
ããããã®ã©ã€ãã©ãªãããã誰ã§ã䜿ããæ¢è£œã®ããã±ãŒãžã欲ããã§ãã ConanããŒã ã¯çŸåšéåžžã«å°ãããäž»ã«ããã±ãŒãžãããŒãžã£ãŒèªäœã®éçºã«åŸäºããŠããããããã¹ãŠãé£ç¶ããŠããã±ãŒãžåããæéã¯ãããŸããïŒãã ããããã±ãŒãžã³ã°ãå«ãéçºè ãåžžã«æ¢ããŠããŸãïŒã ãã ããã©ã€ãã©ãªãããã±ãŒãžåããå¿ èŠããããŸããããããªããšãConanã«æå³ããããŸããã ããã§ãBincraftersããŒã ãç»å ŽããŸãããããã¯ããªãŒãã³ãœãŒã¹ã©ã€ãã©ãªãç©æ¥µçã«ããã¯ããããã¢ã®ããŒã ã§ãã 圌ãã¯çŸåšãè¿œå ã®CIèœåã®ã¬ã³ã¿ã«ã®ããã®è³éã調éããããã®ããã°ã©ã ãPatreonã«éèšããŸããã ããŒã ã«åå ãããå Žå-ã©ãããããŸããŠã
Xã©ã€ãã©ãªãConanã«ãªãå Žåã¯ã©ããªããŸããïŒ
éçºã®ãã®æ®µéã§ã¯ãããã¯éåžžã«é »ç¹ã«èµ·ãããŸãã ããã«ããã±ãŒãžãäœæãããªã¯ãšã¹ãããã€ã§ãæ®ãããšãã§ããŸã ïŒãã®åã«ã誰ãããªãã«å°ããŠããªãããšã確èªããŠãã ããïŒã ã¢ããªã±ãŒã·ã§ã³ãæ¢ã«ååšããå Žåã¯ããã®ã©ã€ãã©ãªãå¿ èŠãªãã®ã§ãããšããã³ã¡ã³ããåã«æžããŠãã ããã ãããŠããã¡ãããããªãèªèº«ãã©ã€ãã©ãªãããã±ãŒãžåããããšãã§ããŸãã誰ããæè¬ãèšãã ãã§ãã
æã䟿å©ãªã³ãã³ãïŒç§ã®æèŠã§ã¯ïŒ
-
conan search <library_name_pattern>
-conan search <library_name_pattern>
ããããã³ãã¬ãŒãã«ãã£ãŠãªããžããªå ã®ããã±ãŒãžãæ€çŽ¢ããŸã -
conan info
ããã±ãŒãžæ å ±ã®è¡šç€ºïŒã©ã€ã»ã³ã¹ãäœææ¥ãããã±ãŒãžãœãŒã¹ã³ãŒãã®ã¢ãã¬ã¹ãªã©ïŒ -
conan remote
-ConanãªããžããªãŒã®ç®¡çïŒè¿œå ãåé€ãªã©ïŒ
ãã³ã
- å®å®ããããã±ãŒãžã®ã¿ã䜿çšããŠãã ããã ãã¹ãããã³ciããã±ãŒãžã¯å®æçã«ç Žæããå¯èœæ§ãããããã䜿çšããªãããšããå§ãããŸãã
- ç¬èªã®ã¬ã·ããäœæããå Žåã¯ã ããã§åªããã¬ã·ãã®äŸãèŠã€ããããšãã§ããŸã ã
- ããã±ãŒãžãäœæãããšãã¯ããã¹ãŠã®ã¿ãŒã²ãããã©ãããã©ãŒã çšã«æ§ææžã¿ã®CIãçšæããŠããããšã匷ããå§ãããŸãã ããªãã¯ããããæåŸ ããªãå Žæã«åžžã«åé¡ããããã¢ããããŸã:-)
- ã³ãã³ãæŽæ°ããããšãå¿ããªãã§ãã ããã ã³ãã³ã¯åã«åŸæ¹äºææ§ãç Žããæ°ããã³ãã³ã§æ©èœããã¬ã·ãã¯å€ããã®ã§ã¯æ©èœããªãããšããããŸãã
- æšå¥šããã±ãŒãžæ€çŽ¢é åºïŒçŸæç¹ïŒïŒconan -center ã public- conanïŒBincraftersããŒã ãªããžããªïŒãconan -transit ããã®ä»ã®ãªããžããªã
䟿å©ãªãªã³ã¯ïŒ
- ã³ãã³ã®ãŠã§ããµã€ã
- Bincrafters
- Youtubeã®è³æïŒ one ã two ããŠã§ãããŒïŒ 1ã2ã3 ïŒã 3