Extract compiled .a library files from ESP-IDF projects and generate binary-only projects
Project description
ESP-IDF Binary Pack
ESP-IDF Project Prebuilt Library Packaging Tool - Converts source code projects into prebuilt library projects.
Features
- ๐ฆ Automatic Library Extraction: Extracts
.alibrary files from built ESP-IDF projects. - ๐ง Smart Component Classification: Automatically identifies prebuilt components, managed components, etc.
- ๐๏ธ Clear Directory Structure: Separates prebuilt components from source components.
- ๐ Automatic Linking Configuration: Generates correct
CMakeLists.txtand manages dependencies.
Directory Structure
The generated project contains the following directories:
your_project_binary/
โโโ CMakeLists.txt # Root configuration, automatically sets EXTRA_COMPONENT_DIRS
โโโ sdkconfig # SDK configuration
โโโ main/ # Main directory (stub, links to prebuilt main)
โ โโโ CMakeLists.txt
โ โโโ main.c
โโโ components/ # Non-prebuilt components
โ โโโ managed_component1/ # ESP Component Manager components (if not packed)
โ โโโ excluded_component/ # Manually excluded components
โ โโโ prebuilt_component/ # Originally prebuilt components (already had .a)
โโโ prebuild_components/ # Prebuilt components generated by this tool
โโโ main/ # main prebuilt library
โ โโโ CMakeLists.txt
โ โโโ libmain.a
โโโ component1/
โ โโโ CMakeLists.txt
โ โโโ libcomponent1.a
โโโ component2/
โโโ CMakeLists.txt
โโโ libcomponent2.a
Usage
1. Build Original Project
cd your_project
idf.py build
2. Run Packaging Script
First, install the package:
pip install esp-binary-pack
Then run the tool using the esp-binary-pack command:
# Basic usage
esp-binary-pack
# Exclude components (keep as source)
esp-binary-pack --exclude comp1,comp2
# Specify output directory
esp-binary-pack --output-dir my_output
# Extract headers
esp-binary-pack --extract-headers
# Specify build directory (default is 'build')
esp-binary-pack --build-dir build_esp32s3
# Pack managed components as libraries
esp-binary-pack --pack-managed-components
3. Build Generated Project
cd your_project_binary
idf.py build
Command Line Arguments
| Argument | Description | Default |
|---|---|---|
--exclude |
Components to exclude (comma separated), kept as source | - |
--include |
Components to force include (comma separated) | - |
--output-dir |
Output directory name | {project_name}_binary |
--idf-path |
Path to IDF_PATH | Read from environment |
--extract-headers |
Extract header files to include directory | false |
--build-dir |
Build directory to read from | build |
--pack-managed-components |
Pack managed components as libraries instead of copying source | false |
Component Classification
The script automatically identifies and classifies components:
1. Prebuilt Components โ prebuild_components/
- User components (non-ESP-IDF official).
.alibrary files extracted by the script.- Managed components if
--pack-managed-componentsis enabled.
2. Source Components โ components/
- Managed Components: From ESP Component Manager (if
--pack-managed-componentsis disabled). - Excluded Components: Specified via
--exclude. - Original Prebuilt Components: Components that were already prebuilt (contained
.afiles). - No-Lib Components: Components where no corresponding
.afile was found.
3. Main Component
- Prebuilt (
prebuild_components/): If the original project'smaincomponent is compiled (has a library file), it is placed inprebuild_components/main/. Themain/directory will then contain a stub. - Source (
main/): If the original project'smaincomponent is NOT compiled (no library file found), the original source component is kept inmain/.
Recent Updates
2026-01-11
- Main Component Handling:
libmain.ais now placed inprebuild_components/main/, and themaindirectory contains a stub. - Directory Restructuring: Managed components moved to
components/, prebuilt libraries toprebuild_components/. - Auto Configuration:
EXTRA_COMPONENT_DIRSis automatically configured.
File Exclusion Rules
When copying components as source, the following are automatically excluded:
| Pattern | Reason |
|---|---|
build/ |
Build output directory |
.git/ |
Version control |
*.o |
Compiled object files |
*.d |
Make dependency files |
*.pyc |
Python compiled files |
__pycache__/ |
Python cache directory |
.DS_Store |
macOS system file |
Note: .a files are not excluded when copying source components, to preserve any original prebuilt libraries.
Dependencies
- Python 3.6+
- ESP-IDF Environment
- Built ESP-IDF Project (requires
build/project_description.json)
Troubleshooting
Issue: Library file not found for a component
Solution:
- Ensure project is fully built:
idf.py build. - Check if the component's library exists in
build/esp-idf/. - Use
--excludeto keep the component as source.
Issue: Generated project fails to compile
Solution:
- Check
EXTRA_COMPONENT_DIRSinCMakeLists.txt. - Ensure all dependent components are included.
- Check
components/for missing managed components.
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file esp_binary_pack-1.0.3-py3-none-any.whl.
File metadata
- Download URL: esp_binary_pack-1.0.3-py3-none-any.whl
- Upload date:
- Size: 31.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
464cd77e80ad3f3490bee397e9fc29480074722c255d64feee629c92df52b50a
|
|
| MD5 |
fa7ba43c897c8677069d931c60e1c29e
|
|
| BLAKE2b-256 |
1216475d86b3954de8a5db6c1b6465f57e19218d5a83ac98ba61ac74dda8f5a6
|