Skip to content

Commit d6a0bec

Browse files
committed
fix(chore): Add generate-all script + ignore temp files
1 parent ab8364d commit d6a0bec

File tree

3 files changed

+131
-1
lines changed

3 files changed

+131
-1
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,7 @@ dkms.conf
5555
components/**/build
5656
components/**/sdkconfig
5757
components/**/sdkconfig.old
58+
59+
# generation script temp files
60+
esp_wifi_preprocessed.h
61+
default.esp32*

components/esp_wifi_remote/scripts/generate_and_check.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
1+
# SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
22
# SPDX-License-Identifier: Apache-2.0
33
import argparse
44
import glob
@@ -88,6 +88,14 @@ def exec_cmd(what, out_file=None):
8888
def preprocess(idf_path, header):
8989
project_dir = os.path.join(idf_path, 'examples', 'wifi', 'getting_started', 'station')
9090
build_dir = os.path.join(project_dir, 'build')
91+
92+
# Clean up build artifacts
93+
if os.path.exists(build_dir):
94+
shutil.rmtree(build_dir)
95+
sdkconfig = os.path.join(project_dir, 'sdkconfig')
96+
if os.path.exists(sdkconfig):
97+
os.remove(sdkconfig)
98+
9199
subprocess.check_call(['idf.py', '-B', build_dir, 'reconfigure'], cwd=project_dir)
92100
build_commands_json = os.path.join(build_dir, 'compile_commands.json')
93101
with open(build_commands_json, 'r', encoding='utf-8') as f:
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#!/bin/bash
2+
3+
# Exit on any error
4+
set -e
5+
6+
# Configuration
7+
IDF_PATH=${IDF_PATH:-""}
8+
REMOTE="github"
9+
WIFI_REMOTE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
10+
SCRIPTS_DIR="${WIFI_REMOTE_DIR}/scripts"
11+
12+
# Master branch configuration
13+
# Update this when a new major version is released
14+
MASTER_VERSION="6.0"
15+
MASTER_BRANCH="master"
16+
17+
# Default to processing both branches and tags
18+
VERSION_TYPE="all"
19+
20+
# Parse command line arguments
21+
while [[ $# -gt 0 ]]; do
22+
case $1 in
23+
--type)
24+
VERSION_TYPE="$2"
25+
shift 2
26+
;;
27+
*)
28+
echo "Unknown option: $1"
29+
echo "Usage: $0 [--type {all|branches|tags}]"
30+
exit 1
31+
;;
32+
esac
33+
done
34+
35+
# Validate version type
36+
if [[ ! "$VERSION_TYPE" =~ ^(all|branches|tags)$ ]]; then
37+
echo "Error: Invalid version type. Must be one of: all, branches, tags"
38+
exit 1
39+
fi
40+
41+
# Check if IDF_PATH is set
42+
if [ -z "$IDF_PATH" ]; then
43+
echo "Error: IDF_PATH environment variable is not set"
44+
exit 1
45+
fi
46+
47+
# Function to process a version
48+
process_version() {
49+
local version_dir=$1
50+
local version_name=$(basename "$version_dir")
51+
52+
echo "Processing version: $version_name"
53+
54+
# Create a new subshell for processing this version
55+
(
56+
# Determine if this is a branch or tag version
57+
if [[ $version_name =~ ^idf_v[0-9]+\.[0-9]+$ ]]; then
58+
# Skip if we're only processing tags
59+
if [[ "$VERSION_TYPE" == "tags" ]]; then
60+
echo "Skipping branch version (tags only mode): $version_name"
61+
return
62+
fi
63+
# Branch version (e.g., idf_v5.4)
64+
local version_num="${version_name#idf_v}"
65+
local branch
66+
if [[ "$version_num" == "$MASTER_VERSION" ]]; then
67+
branch="$MASTER_BRANCH"
68+
echo "Using master branch for version $version_num"
69+
else
70+
branch="release/v$version_num"
71+
fi
72+
echo "Checking out branch: $branch"
73+
git fetch "$REMOTE" "$branch"
74+
git checkout "$REMOTE/$branch"
75+
elif [[ $version_name =~ ^idf_tag_v[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]; then
76+
# Skip if we're only processing branches
77+
if [[ "$VERSION_TYPE" == "branches" ]]; then
78+
echo "Skipping tag version (branches only mode): $version_name"
79+
return
80+
fi
81+
# Tag version (e.g., idf_tag_v5.4.1 or idf_tag_v5.4)
82+
local tag="${version_name#idf_tag_}"
83+
echo "Checking out tag: $tag"
84+
git fetch "$REMOTE" "$tag" --tags
85+
git checkout "$tag"
86+
else
87+
echo "Skipping unknown version format: $version_name"
88+
return
89+
fi
90+
91+
# Update submodules
92+
echo "Updating submodules..."
93+
git submodule update --init --recursive --force
94+
95+
# Install and export ESP-IDF
96+
echo "Installing ESP-IDF..."
97+
./install.sh
98+
source export.sh
99+
100+
# Generate and check
101+
echo "Generating files..."
102+
cd "$SCRIPTS_DIR"
103+
python generate_and_check.py
104+
)
105+
}
106+
107+
# Main execution
108+
echo "Starting generation for all versions..."
109+
cd "$IDF_PATH"
110+
111+
# Find all version directories
112+
for version_dir in "$WIFI_REMOTE_DIR"/idf_*; do
113+
if [ -d "$version_dir" ]; then
114+
process_version "$version_dir"
115+
fi
116+
done
117+
118+
echo "All versions processed successfully!"

0 commit comments

Comments
 (0)