I downloaded a script that allows you to combine Platformio and STM32CubeMX. This script includes third-party libraries such as LwIP. However, Import(“env “) on line 18 is not defined. What does it do and how do I fix the error? I have provided a part of the code that demonstrates the error.
# Author: Joachim Baumann
# Version: 1.0.2
#
# This script is based on the information for advanced scripting provided
# by platformio
# https://docs.platformio.org/en/latest/projectconf/advanced_scripting.html
#
# We try to get all needed information from the .cproject file, collect all
# source directories from that to create the src_filter and read platformio's
# own board definition to glean the cpu type.
import shutil
from os import mkdir, makedirs, path, rename, symlink, walk, listdir, unlink
import SCons.Errors
import xml.etree.ElementTree as ET
import re
Import("env")
project_dir = env["PROJECT_DIR"]
log_name = "SETUP_CUBEMX"
lib_directory = "lib/"
# The project option containing the directory in which CubeMX resides
# try:
# repository_location = env.GetProjectOption("custom_repo_location")
# except:
# repository_location = "~"
# pass
#repository_location = path.expanduser(repository_location)
# print("%s: Using the following repository location: '%s'"
# % (log_name, repository_location))
# set the project source dir
env["PROJECT_SRC_DIR"] = project_dir
# We simply take the first extra library dependency
try:
linked_resources_dir = path.join(
lib_directory, env.GetProjectOption("lib_deps")[0])
except:
raise SCons.Errors.BuildError(
errstr="%s Error: The option 'lib_deps' is not set"
% log_name)
Link to github: https://github.com/jbaumann/pio_and_stm32cubeide.git
3