{ "info": { "author": "Max Peng", "author_email": "max.peng1768@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "cmWalk\n======\n\n1. Introduction\n---------------\n\n``cmWalk`` is a python script to walk the directory tree of a C/C++\nproject of embedded system to generate CMakeLists.txt files for building\nthe executable.\n\n2. Usage\n--------\n\nusage: cmwalk.py [-h] input_dir\n\nA python script to generate CMakeLists.txt of a C/C++ project - 0.0.7.\n\npositional arguments: input_dir The base directory of C/C++ project.\n\noptional arguments: -h, \u2013help show this help message and exit\n\n3. Configuration File\n---------------------\n\nYou can create a json file for each directory of project directory tree\nto configure how ``cmwalk`` to generate CMakeLists.txt. The\nconfiguration filename of ``cmwalk`` is ``cmwalk.json``.\n\nIf there is no ``cmwalk.json`` in a directory of project directory tree, then all the files and\nsubdirectories of that directory will be parsed for CMakeLists.txt generation.\n\n3.1 Supported properties of ``cmwalk.json``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n- **cmakeToolchainFile**\n\n Specifying the toolchain file of the used compiler for current\n project. You can also set the used toolchain file by invoking\n ``cmake`` with the command line parameter\n ``-DCMAKE_TOOLCHAIN_FILE=path/to/file``.\n\n Refer cmake documentation\n `cmake-toolchains(7) `__\n for the details.\n\n Example:\n\n .. code:: json\n\n {\n \"cmakeToolchainFile\": \"gcc_arm_none_eabi_toolchain.cmake\"\n }\n\n For above example, ``cmwalk`` will generate following command before ``project`` command to set the used toolchain.\n\n .. code:: cmake\n\n # set the toolchain file.\n # toolchain file should be set before \"project\" command.\n # the toolchain file can also be set via \"cmake -DCMAKE_TOOLCHAIN_FILE=path/to/file\".\n set(CMAKE_TOOLCHAIN_FILE gcc_arm_none_eabi_toolchain.cmake)\n\n An example of toolchain file:\n\n .. code:: cmake\n\n # refer https://cmake.org/Wiki/CMake_Cross_Compiling\n #include(CMakeForceCompiler) # cmake_force_c_compiler and cmake_force_cxx_compiler are deprecated.\n\n set(CMAKE_SYSTEM_NAME Generic)\n set(CMAKE_SYSTEM_VERSION 1)\n set(CMAKE_SYSTEM_PROCESSOR \"armv7-m\")\n\n\n # refer https://cmake.org/pipermail/cmake-developers/2016-February/027871.html\n # about how to solve this problem: \"arm-none-eabi-gcc.exe\" is not able to compile a simple test program.\n set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)\n\n # find the cross compiler and associated tools that we need:\n find_program(ARM_NONE_EABI_GCC arm-none-eabi-gcc)\n find_program(ARM_NONE_EABI_GPP arm-none-eabi-g++)\n find_program(ARM_NONE_EABI_OBJCOPY arm-none-eabi-objcopy)\n\n\n macro(gcc_program_notfound progname)\n message(\"**************************************************************************\\n\")\n message(\" ERROR: the arm gcc program ${progname} could not be found\\n\")\n if(CMAKE_HOST_SYSTEM_NAME STREQUAL \"Windows\" OR CMAKE_HOST_SYSTEM_NAME STREQUAL \"Linux\")\n message(\" you can install the ARM GCC embedded compiler tools from:\")\n message(\" https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads\")\n elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL \"Darwin\")\n message(\" it is included in the arm-none-eabi-gcc package that you can install\")\n message(\" with homebrew:\\n\")\n message(\" brew tap ARMmbed/homebrew-formulae\")\n message(\" brew install arm-none-eabi-gcc\")\n endif()\n message(\"\\n**************************************************************************\")\n message(FATAL_ERROR \"missing program prevents build\")\n return()\n endmacro(gcc_program_notfound)\n\n if(NOT ARM_NONE_EABI_GCC)\n gcc_program_notfound(\"arm-none-eabi-gcc\")\n endif()\n\n if(NOT ARM_NONE_EABI_GPP)\n gcc_program_notfound(\"arm-none-eabi-g++\")\n endif()\n\n if(NOT ARM_NONE_EABI_OBJCOPY)\n gcc_program_notfound(\"arm-none-eabi-objcopy\")\n endif()\n\n\n set(CMAKE_C_COMPILER arm-none-eabi-gcc)\n set(CMAKE_CXX_COMPILER arm-none-eabi-g++)\n\n set(C_FAMILY_FLAGS_INIT \"-ffunction-sections -fdata-sections -g -fno-common -fmessage-length=0 --specs=nosys.specs --specs=nano.specs\")\n set(CMAKE_C_FLAGS_INIT \"${C_FAMILY_FLAGS_INIT} -std=c99\")\n set(CMAKE_CXX_FLAGS_INIT \"${C_FAMILY_FLAGS_INI} -std=c++11\")\n set(CMAKE_ASM_FLAGS_INIT \"-fno-exceptions -fno-unwind-tables -x assembler-with-cpp\")\n set(CMAKE_EXE_LINKER_FLAGS_INIT \"-Wl,-gc-sections,-print-memory-usage\")\n\n- **cmakeCompilerOptionsFile**\n\n Specifying a file that contains the additional compiler settings\n to be included in the top-level CMakeLists.txt file.\n\n Example:\n\n .. code:: json\n\n {\n \"cmakeCompilerOptionsFile\": \"gcc_arm_none_eabi_opts.cmake\"\n }\n\n For above example, ``cmwalk`` will generate following command after ``project`` command to set the compiler options.\n\n .. code:: cmake\n\n # load and run the CMake code from the given file to specify project specific options.\n include(gcc_arm_none_eabi_opts.cmake)\n\n An example of compiler option files for `GNU Arm Embedded\n Toolchain `__:\n\n .. code:: cmake\n\n set(EXTRA_COMMON_FLAGS \"-mcpu=cortex-m4 -mthumb-interwork -mfloat-abi=hard -mfpu=fpv4-sp-d16 -DUSE_HAL_DRIVER -DSTM32F429xx\")\n set(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} ${EXTRA_COMMON_FLAGS}\")\n set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} ${EXTRA_COMMON_FLAGS}\")\n\n set(CMAKE_ASM_FLAGS \"${CMAKE_ASM_FLAGS} -mcpu=cortex-m4 -mthumb-interwork -mfloat-abi=hard -mfpu=fpv4-sp-d16\")\n\n set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/app/STM32F429ZITx_FLASH.ld)\n set(CMAKE_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS} -Wl,-Map=${CMAKE_BINARY_DIR}/${PROJECT_NAME}.map -T${LINKER_SCRIPT}\")\n\n- **addToCompilerIncludeDirectories**\n\n A flag to control if current directory should be added to the include directories of compiler.\n\n The default option is true when ``addToCompilerIncludeDirectories`` does not exist.\n\n An example of not adding current directory to include directories of compiler.\n\n .. code:: json\n\n {\n \"addToCompilerIncludeDirectories\": false\n }\n\n- **sourceDirectories**\n\n A list of source directories.\n\n If ``sourceDirectories`` is specified in ``cmwalk.json``, then only\n the specified directories will be included for parsing, other\n directories will be excluded. If ``sourceDirectories`` does not exist\n but ``ignoredDirectories`` exist, then all the directories except\n those specified by ``ignoredDirectories`` will be excluded.\n\n An example of specifying the source subdirectories for searching the\n source files:\n\n .. code:: json\n\n {\n \"sourceDirectories\": [\"app\", \"libs\"]\n }\n\n- **ignoredDirectories** - A list of ignored directories.\n\n ``sourceDirectories`` property has higher priority than ``ignoredDirectories``\n property. If both of ``sourceDirectories`` and ``ignoredDirectories`` properties\n are specified in ``cmwalk.json``, ``ignoredDirectories`` property has no\n effect.\n\n An example of excluding subdirectories for searching the source\n files:\n\n .. code:: json\n\n {\n \"ignoredDirectories\": [\"docs\"]\n }\n\n- **ignoredFiles** - A list of ignored files.\n\n An example of excluding a file from ``cmake`` build system:\n\n .. code:: json\n\n {\n \"ignoredFiles\": [\"cfg.h.template\"]\n }\n\n\n4. Example of generated CMakeLists.txt\n--------------------------------------\n\nThis is an example of generated top-level ``CMakeLists.txt``:\n\n.. code:: cmake\n\n cmake_minimum_required(VERSION 3.9)\n\n # set the toolchain file.\n # toolchain file should be set before \"project\" command.\n # the toolchain file can also be set via \"cmake -DCMAKE_TOOLCHAIN_FILE=path/to/file\".\n set(CMAKE_TOOLCHAIN_FILE gcc_arm_none_eabi_toolchain.cmake)\n\n project(nucleo_f429zi_freertos_lwip)\n enable_language(C CXX ASM)\n\n # load and run the CMake code from the given file to specify project specific options.\n include(gcc_arm_none_eabi_opts.cmake)\n\n\n # export the executable target through a variable to CMakeLists.txt files in subdirectories.\n # update the dependent sources.\n add_executable(nucleo_f429zi_freertos_lwip.elf\n \"\"\n )\n\n if (${LINK_SCRIPT})\n set_target_properties(nucleo_f429zi_freertos_lwip.elf PROPERTIES LINK_DEPENDS ${LINKER_SCRIPT})\n endif()\n\n\n # export the name of executable target via a variable to CMakeLists.txt files in subdirectories.\n set(CURRENT_EXE_NAME ${PROJECT_NAME}.elf)\n # load and run the CMake code from subdirectories for current target.\n include(app/CMakeLists.txt)\n include(libs/CMakeLists.txt)\n\n # if compiler is GNU gcc/g++, then generate *.bin & *.hex files.\n if (\"${CMAKE_C_COMPILER_ID}\" STREQUAL \"GNU\")\n # generate the hex file from the built target.\n set(HEX_FILE ${PROJECT_NAME}.hex)\n add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD\n COMMAND ${CMAKE_OBJCOPY} -O ihex $ ${HEX_FILE}\n COMMENT \"Building ${HEX_FILE}...\")\n\n # generate the bin file from the built target.\n set(BIN_FILE ${PROJECT_NAME}.bin)\n add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD\n COMMAND ${CMAKE_OBJCOPY} -O binary $ ${BIN_FILE}\n COMMENT \"Building ${BIN_FILE}...\")\n endif()\n\n5. References\n-------------\n\n1. `Enhanced source file handling with target_sources() \u2013\n Crascit `__\n2. `CLion for embedded development \\| CLion\n Blog `__\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/maxpeng/cmWalk", "keywords": "cmake", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "cmwalk", "package_url": "https://pypi.org/project/cmwalk/", "platform": "", "project_url": "https://pypi.org/project/cmwalk/", "project_urls": { "Homepage": "https://github.com/maxpeng/cmWalk" }, "release_url": "https://pypi.org/project/cmwalk/0.1.0/", "requires_dist": [ "jinja2", "walkdir" ], "requires_python": "", "summary": "A python script to walk subdirectories of a C/C++ project of embedded system to generate CMakeLists.txt files for building the executable.", "version": "0.1.0" }, "last_serial": 3520581, "releases": { "0.0.6": [ { "comment_text": "", "digests": { "md5": "20a757b9da6a57978a6857cac4f31346", "sha256": "8de8731e01d73fef1446647de56989ba96b2cd4ec4e2b2735fc80e49258a2299" }, "downloads": -1, "filename": "cmwalk-0.0.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "20a757b9da6a57978a6857cac4f31346", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17618, "upload_time": "2017-12-22T00:51:40", "url": "https://files.pythonhosted.org/packages/8f/5b/ad2d9a0c1888faebc5073ab8f12b8a01d50bfd7178eec004accc24f8aec7/cmwalk-0.0.6-py2.py3-none-any.whl" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "7927fb8e2c4f8957170fedc976229bd0", "sha256": "94293d4c42ecdc22eb4d5fa6281df936e1ac3d1f7d2f95d30fe5bdd27af2e17c" }, "downloads": -1, "filename": "cmwalk-0.0.7-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7927fb8e2c4f8957170fedc976229bd0", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17883, "upload_time": "2017-12-24T06:48:55", "url": "https://files.pythonhosted.org/packages/96/2a/492c9a2f618d5df7d7f5d46b85a3ecbd0d2f4ed14a24a667698b94678c8b/cmwalk-0.0.7-py2.py3-none-any.whl" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "563e160b3ea6f10328cd26399a947865", "sha256": "87698b04a4a30b99dcf0a649d1db784cfa2648d5cd144e5cf9d4511ac5bf0450" }, "downloads": -1, "filename": "cmwalk-0.0.8-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "563e160b3ea6f10328cd26399a947865", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 15570, "upload_time": "2018-01-23T13:00:20", "url": "https://files.pythonhosted.org/packages/6a/d1/85e533bf22c36c33737317ee51802fda5ba4cf43eb993fcd441a5be2960d/cmwalk-0.0.8-py2.py3-none-any.whl" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "c426d176c8b6ecf02ebe055e185909c6", "sha256": "f0cbe303d23eb03d879a44e7eac3f79f43d7afe3213143e58989acf828b62210" }, "downloads": -1, "filename": "cmwalk-0.0.9-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c426d176c8b6ecf02ebe055e185909c6", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 15572, "upload_time": "2018-01-24T00:34:10", "url": "https://files.pythonhosted.org/packages/50/3f/5ed6983a2222e6eca9fe8b2be31221334a2bcad0beafa40cff2530e062f1/cmwalk-0.0.9-py2.py3-none-any.whl" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "d2e81aa7c5c03ccb581234f361ec2c11", "sha256": "bc841f9900f9cb13224602a9b55dc3b4b23835cb9aa959eaf997d41b4559c171" }, "downloads": -1, "filename": "cmwalk-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d2e81aa7c5c03ccb581234f361ec2c11", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 15640, "upload_time": "2018-01-25T13:59:39", "url": "https://files.pythonhosted.org/packages/a6/84/487f07f34277b08595ea359ab7753c5b2733cbda0b549686444733ec1590/cmwalk-0.1.0-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d2e81aa7c5c03ccb581234f361ec2c11", "sha256": "bc841f9900f9cb13224602a9b55dc3b4b23835cb9aa959eaf997d41b4559c171" }, "downloads": -1, "filename": "cmwalk-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d2e81aa7c5c03ccb581234f361ec2c11", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 15640, "upload_time": "2018-01-25T13:59:39", "url": "https://files.pythonhosted.org/packages/a6/84/487f07f34277b08595ea359ab7753c5b2733cbda0b549686444733ec1590/cmwalk-0.1.0-py2.py3-none-any.whl" } ] }