From 6ec1e9107f70d5d863f7e770556404a134b14615 Mon Sep 17 00:00:00 2001 From: Marek Fiala Date: Fri, 13 Sep 2024 10:18:20 +0200 Subject: [PATCH] feat(tools): Move sample_project from examples to tools Extended example readme.md by further development options. --- examples/README.md | 12 +++++ examples/get-started/sample_project/README.md | 44 ------------------- tools/ci/check_build_test_rules.py | 4 +- tools/ci/check_copyright_config.yaml | 1 + tools/ci/check_copyright_ignore.txt | 3 -- tools/ci/exclude_check_tools_files.txt | 3 ++ tools/idf_py_actions/create_ext.py | 3 +- .../templates}/sample_project/CMakeLists.txt | 0 .../sample_project/main/CMakeLists.txt | 0 .../templates}/sample_project/main/main.c | 0 10 files changed, 19 insertions(+), 51 deletions(-) delete mode 100644 examples/get-started/sample_project/README.md rename {examples/get-started => tools/templates}/sample_project/CMakeLists.txt (100%) rename {examples/get-started => tools/templates}/sample_project/main/CMakeLists.txt (100%) rename {examples/get-started => tools/templates}/sample_project/main/main.c (100%) diff --git a/examples/README.md b/examples/README.md index 9d2eccc18a..ce9aac24ba 100644 --- a/examples/README.md +++ b/examples/README.md @@ -96,6 +96,18 @@ The `IDF_PATH` environment variable is the only thing that connects the example If you're looking for a more bare-bones project to start from, try [esp-idf-template](https://github.com/espressif/esp-idf-template). +## Further Development + +For further steps on how to develop a project, see the following: + +- Managing the project: + - [IDF Frontend](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html#start-a-new-project) document + - ESP-IDF Getting Started video ([YouTube](https://youtu.be/J8zc8mMNKtc?t=340), [bilibili](https://www.bilibili.com/video/BV1114y1r7du/?t=336)) + - [Overview](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#example-project) of an example project + - [Build System](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/build-system.html) document +- Writing code: + - Write your own code following the [API references](https://docs.espressif.com/projects/esp-idf/en/stable/api-reference/index.html) + ## Contributing Examples If you have a new example you think we'd like, please consider sending it to us as a Pull Request. diff --git a/examples/get-started/sample_project/README.md b/examples/get-started/sample_project/README.md deleted file mode 100644 index 6b5f943c04..0000000000 --- a/examples/get-started/sample_project/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# _Sample project_ - -(For general overview of examples and their usage, see the `README.md` file in the upper level 'examples' directory.) - -> [!NOTE] -> After you click any link to [ESP-IDF Programming Guide](https://docs.espressif.com/projects/esp-idf/en/latest/index.html), go to the top of the sidebar, then make sure you have the appropriate **Espressif chip** (target) and **ESP-IDF version** selected in the dropdown menus. - -This is the example of a simplest buildable project. It is also used by the command `idf.py create-project` which copies these files to the path specified by the user and sets the project name. - -This sample projects contains: - -```sh -├── CMakeLists.txt # Build configuration declaring entire project -├── main -│   ├── CMakeLists.txt # File that registers the main component -│   └── main.c # Source file for the main component -└── README.md # File you are currently browsing -``` - -If you want to develop a project for the legacy build system based on Make that requires `Makefile` and `component.mk` files, see [esp-idf-template](https://github.com/espressif/esp-idf-template). - - -## Usage - -For brief instructions on how to configure, build, and flash the project, see [Examples README](https://github.com/espressif/esp-idf/blob/master/examples/README.md#using-examples) > Using Examples. - - -## Further Development - -For further steps on how to develop the project, see the following: - -- Managing the project: - - [IDF Frontend](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html#start-a-new-project) document - - ESP-IDF Getting Started video ([YouTube](https://youtu.be/J8zc8mMNKtc?t=340), [bilibili](https://www.bilibili.com/video/BV1114y1r7du/?t=336)) - - [Overview](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#example-project) of an example project - - [Build System](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/build-system.html) document -- Writing code: - - Find appropriate bits of code in [application examples](https://github.com/espressif/esp-idf/tree/master/examples) - - Write your own code following the [API references](https://docs.espressif.com/projects/esp-idf/en/stable/api-reference/index.html) - - -## Documentation - -If you want to contribute this project as an ESP-IDF application example, please write this README based on the [example README template](https://github.com/espressif/esp-idf/blob/master/docs/TEMPLATE_EXAMPLE_README.md). diff --git a/tools/ci/check_build_test_rules.py b/tools/ci/check_build_test_rules.py index 1e2060bdfe..39e55d9359 100755 --- a/tools/ci/check_build_test_rules.py +++ b/tools/ci/check_build_test_rules.py @@ -427,9 +427,9 @@ if __name__ == '__main__': check_dirs = {IDF_PATH} _exclude_dirs = [os.path.join(IDF_PATH, 'tools', 'unit-test-app'), os.path.join(IDF_PATH, 'tools', 'test_build_system', 'build_test_app'), - os.path.join(IDF_PATH, 'examples', 'get-started', 'sample_project')] + os.path.join(IDF_PATH, 'tools', 'templates', 'sample_project')] else: - _exclude_dirs = [os.path.join(IDF_PATH, 'examples', 'get-started', 'sample_project')] + _exclude_dirs = [os.path.join(IDF_PATH, 'tools', 'templates', 'sample_project')] extra_default_build_targets_list: List[str] = [] bypass_check_test_targets_list: List[str] = [] diff --git a/tools/ci/check_copyright_config.yaml b/tools/ci/check_copyright_config.yaml index aadfcc5d55..35e80ecbd3 100644 --- a/tools/ci/check_copyright_config.yaml +++ b/tools/ci/check_copyright_config.yaml @@ -242,3 +242,4 @@ ignore: - components/protocomm/python/ - components/wifi_provisioning/proto-c/ - components/wifi_provisioning/python/ + - tools/templates/ diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index a2537c7741..97f177b8ab 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -995,7 +995,6 @@ examples/ethernet/basic/main/ethernet_example_main.c examples/ethernet/enc28j60/components/eth_enc28j60/enc28j60.h examples/ethernet/enc28j60/main/enc28j60_example_main.c examples/get-started/blink/main/blink_example_main.c -examples/get-started/sample_project/main/main.c examples/mesh/internal_communication/main/include/mesh_light.h examples/mesh/internal_communication/main/mesh_light.c examples/mesh/internal_communication/main/mesh_main.c @@ -1146,8 +1145,6 @@ tools/ble/lib_gatt.py tools/catch/catch.hpp tools/ldgen/samples/template.ld tools/ldgen/test/data/linker_script.ld -tools/templates/sample_component/include/main.h -tools/templates/sample_component/main.c tools/test_apps/build_system/embed_test/main/test_main.c tools/test_apps/build_system/ldgen_test/main/src1.c tools/test_apps/build_system/ldgen_test/main/src2.c diff --git a/tools/ci/exclude_check_tools_files.txt b/tools/ci/exclude_check_tools_files.txt index 614bb15c63..1bc83c8b68 100644 --- a/tools/ci/exclude_check_tools_files.txt +++ b/tools/ci/exclude_check_tools_files.txt @@ -32,6 +32,9 @@ tools/eclipse-code-style.xml tools/format.sh tools/mocks/**/* tools/set-submodules-to-github.sh +tools/templates/sample_project/main/main.c +tools/templates/sample_project/CMakeLists.txt +tools/templates/sample_project/main/CMakeLists.txt tools/templates/sample_component/CMakeLists.txt tools/templates/sample_component/include/main.h tools/templates/sample_component/main.c diff --git a/tools/idf_py_actions/create_ext.py b/tools/idf_py_actions/create_ext.py index cffcefd128..3d97147854 100644 --- a/tools/idf_py_actions/create_ext.py +++ b/tools/idf_py_actions/create_ext.py @@ -40,7 +40,7 @@ def is_empty_and_create(path: str, action: str) -> None: def create_project(target_path: str, name: str) -> None: copytree( - os.path.join(os.environ['IDF_PATH'], 'examples', 'get-started', 'sample_project'), + os.path.join(os.environ['IDF_PATH'], 'tools', 'templates', 'sample_project'), target_path, copy_function=copy, dirs_exist_ok=True, @@ -49,7 +49,6 @@ def create_project(target_path: str, name: str) -> None: os.rename(os.path.join(main_folder, 'main.c'), os.path.join(main_folder, '.'.join((name, 'c')))) replace_in_file(os.path.join(main_folder, 'CMakeLists.txt'), 'main', name) replace_in_file(os.path.join(target_path, 'CMakeLists.txt'), 'main', name) - os.remove(os.path.join(target_path, 'README.md')) def create_component(target_path: str, name: str) -> None: diff --git a/examples/get-started/sample_project/CMakeLists.txt b/tools/templates/sample_project/CMakeLists.txt similarity index 100% rename from examples/get-started/sample_project/CMakeLists.txt rename to tools/templates/sample_project/CMakeLists.txt diff --git a/examples/get-started/sample_project/main/CMakeLists.txt b/tools/templates/sample_project/main/CMakeLists.txt similarity index 100% rename from examples/get-started/sample_project/main/CMakeLists.txt rename to tools/templates/sample_project/main/CMakeLists.txt diff --git a/examples/get-started/sample_project/main/main.c b/tools/templates/sample_project/main/main.c similarity index 100% rename from examples/get-started/sample_project/main/main.c rename to tools/templates/sample_project/main/main.c