Skip to content

Commit 2f71f35

Browse files
committed
Temp fix for ESP-Insights on C6
1 parent 31d4f9d commit 2f71f35

File tree

3 files changed

+128
-20
lines changed

3 files changed

+128
-20
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
cmake_minimum_required(VERSION 3.5)
44

55
set(RMAKER_PATH ${CMAKE_SOURCE_DIR}/components/esp-rainmaker)
6-
set(EXTRA_COMPONENT_DIRS ${RMAKER_PATH}/components/esp-insights/components ${CMAKE_SOURCE_DIR}/components/esp-insights/components ${RMAKER_PATH}/components)
6+
set(EXTRA_COMPONENT_DIRS ${RMAKER_PATH}/components/esp-insights/components ${RMAKER_PATH}/components)
77

88
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
99
project(arduino-lib-builder)

tools/get_projbuild_gitconfig.py

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# This file is expected to be present in ${COMPONENT_DIR}
2+
# accessed from components/esp_insights/CMakeLists.txt
3+
# Used in:
4+
# 1. Project ESP Insights build package tar file
5+
6+
#from __future__ import unicode_literals
7+
import os
8+
import sys
9+
import json
10+
import subprocess
11+
from builtins import range, str
12+
from io import open
13+
14+
# Input project directory from CMakeLists.txt
15+
PROJ_DIR=sys.argv[1]
16+
# Input project name
17+
PROJ_NAME=sys.argv[2]
18+
# Input project version
19+
PROJ_VER=sys.argv[3]
20+
# Input custom config filename from CMakeLists.txt
21+
FILENAME=sys.argv[4]
22+
# Input IDF_PATH from CMakeLists.txt
23+
IDF_PATH=sys.argv[5]
24+
# Input target
25+
TARGET=sys.argv[6]
26+
27+
NEWLINE = "\n"
28+
29+
CONFIG = {}
30+
31+
# Set Config
32+
33+
# Set current directory i.e Set ${COMPONENT_DIR} as current directory
34+
CURR_DIR = os.getcwd()
35+
36+
def _change_dir(dirname):
37+
# Change directory
38+
os.chdir(dirname)
39+
40+
41+
def _set_submodule_cfg(submodules, repo_name):
42+
# Set config for submodules
43+
CFG_TITLE = "submodules"
44+
NAME_STR = "name"
45+
VERSION_STR = "version"
46+
CONFIG[repo_name][CFG_TITLE] = []
47+
48+
if submodules:
49+
# Get the submodule name and version
50+
submodules_list = submodules.strip().split(NEWLINE)
51+
for i in range(0, len(submodules_list), 2):
52+
name = submodules_list[i].split('\'')[1]
53+
version = submodules_list[i+1]
54+
submodule_json = { NAME_STR: name, VERSION_STR: version }
55+
CONFIG[repo_name][CFG_TITLE].append(submodule_json)
56+
57+
58+
def run_cmd(command, get_basename=False):
59+
try:
60+
resp = subprocess.check_output(command, shell=True).strip().decode('utf-8')
61+
if get_basename:
62+
resp = os.path.basename(resp)
63+
return resp
64+
except subprocess.CalledProcessError:
65+
raise Exception("ERROR: Please check command : {}".format(command))
66+
67+
def set_cfg(config_name):
68+
# Set config for ESP-IDF Repo
69+
if config_name == "esp-idf":
70+
# Get repo name (for IDF repo)
71+
REPO_CMD='git rev-parse --show-toplevel'
72+
repo_name = run_cmd(REPO_CMD, get_basename=True)
73+
CONFIG[repo_name] = {}
74+
75+
# Get commit HEAD
76+
GITHEAD_STR = "HEAD"
77+
HEAD='git describe --always --tags --dirty'
78+
head_ver = run_cmd(HEAD)
79+
CONFIG[repo_name][GITHEAD_STR] = head_ver
80+
81+
# Get submodule latest refs
82+
SUBMODULE = 'git submodule foreach git describe --always --tags --dirty'
83+
submodules = run_cmd(SUBMODULE)
84+
_set_submodule_cfg(submodules, repo_name)
85+
elif config_name == "toolchain":
86+
# Set config for Toolchain Version
87+
arch_target = "xtensa-" + TARGET
88+
if TARGET == "esp32c3" or TARGET == "esp32c2" or TARGET == "esp32h2" or TARGET == "esp32c6":
89+
arch_target = "riscv32-esp"
90+
# Get toolchain version
91+
TOOLCHAIN_STR = "toolchain"
92+
TOOLCHAIN = arch_target + '-elf-gcc --version'
93+
toolchain = run_cmd(TOOLCHAIN)
94+
CONFIG[TOOLCHAIN_STR] = toolchain.strip().split(NEWLINE)[0]
95+
96+
# Set project details - name and version
97+
def set_project_details():
98+
# Set project name and version
99+
CONFIG['project'] = {}
100+
CONFIG['project']['name'] = PROJ_NAME
101+
CONFIG['project']['version'] = PROJ_VER
102+
103+
try:
104+
with open(FILENAME, "w+", encoding="utf-8") as output_file:
105+
# ESP-IDF REPO CONFIG
106+
# Change to ESP-IDF Directory
107+
_change_dir(IDF_PATH)
108+
set_cfg("esp-idf")
109+
110+
# Change back to ${COMPONENT_DIR}
111+
_change_dir(CURR_DIR)
112+
113+
# Set project name and version
114+
set_project_details()
115+
116+
# GET TOOLCHAIN VERSION
117+
set_cfg("toolchain")
118+
119+
output_file.write(str(json.dumps(CONFIG, indent=4, sort_keys=True)))
120+
121+
except Exception as e:
122+
# Remove config file created if error occurs
123+
os.system("rm " + FILENAME)
124+
sys.exit(e)

tools/update-components.sh

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -113,25 +113,9 @@ else
113113
git -C "$AR_COMPS/esp-rainmaker" submodule update --init --recursive
114114
fi
115115
if [ $? -ne 0 ]; then exit 1; fi
116-
if [ -d "$AR_COMPS/esp-rainmaker/components/esp-insights/components/cbor" ]; then
117-
mv "$AR_COMPS/esp-rainmaker/components/esp-insights/components/cbor" "$AR_COMPS/esp-rainmaker/components/esp-insights/components/cbor2"
118-
fi
119-
120-
#
121-
# CLONE/UPDATE ESP-INSIGHTS
122-
#
123-
echo "Updating ESP-Insights..."
124-
if [ ! -d "$AR_COMPS/esp-insights" ]; then
125-
git clone $INSIGHTS_REPO_URL "$AR_COMPS/esp-insights" && \
126-
git -C "$AR_COMPS/esp-insights" submodule update --init --recursive
127-
else
128-
git -C "$AR_COMPS/esp-insights" fetch && \
129-
git -C "$AR_COMPS/esp-insights" pull --ff-only && \
130-
git -C "$AR_COMPS/esp-insights" submodule update --init --recursive
131-
fi
132-
if [ $? -ne 0 ]; then exit 1; fi
133-
if [ -d "$AR_COMPS/esp-insights/components/cbor" ]; then
134-
mv "$AR_COMPS/esp-insights/components/cbor" "$AR_COMPS/esp-insights/components/cbor2"
116+
if [ -f "$AR_COMPS/esp-rainmaker/components/esp-insights/components/esp_insights/scripts/get_projbuild_gitconfig.py" ] && [ `cat "$AR_COMPS/esp-rainmaker/components/esp-insights/components/esp_insights/scripts/get_projbuild_gitconfig.py" | grep esp32c6 | wc -l` == "0" ]; then
117+
echo "Overwriting 'get_projbuild_gitconfig.py'"
118+
cp -f "tools/get_projbuild_gitconfig.py" "$AR_COMPS/esp-rainmaker/components/esp-insights/components/esp_insights/scripts/get_projbuild_gitconfig.py"
135119
fi
136120

137121
#

0 commit comments

Comments
 (0)