style: format python files with isort and double-quote-string-fixer
This commit is contained in:
@@ -6,11 +6,11 @@
|
||||
#
|
||||
# Then emits the new 'idf-info' event which has information read from IDF
|
||||
# build system, that other extensions can use to generate relevant data.
|
||||
import json
|
||||
import os.path
|
||||
import shutil
|
||||
import sys
|
||||
import subprocess
|
||||
import json
|
||||
import sys
|
||||
|
||||
# this directory also contains the dummy IDF project
|
||||
project_path = os.path.abspath(os.path.dirname(__file__))
|
||||
@@ -23,7 +23,7 @@ def setup(app):
|
||||
# Setup some common paths
|
||||
|
||||
try:
|
||||
build_dir = os.environ["BUILDDIR"] # TODO see if we can remove this
|
||||
build_dir = os.environ['BUILDDIR'] # TODO see if we can remove this
|
||||
except KeyError:
|
||||
build_dir = os.path.dirname(app.doctreedir.rstrip(os.sep))
|
||||
|
||||
@@ -43,7 +43,7 @@ def setup(app):
|
||||
except KeyError:
|
||||
idf_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))
|
||||
|
||||
app.add_config_value('docs_root', os.path.join(idf_path, "docs"), 'env')
|
||||
app.add_config_value('docs_root', os.path.join(idf_path, 'docs'), 'env')
|
||||
app.add_config_value('idf_path', idf_path, 'env')
|
||||
app.add_config_value('build_dir', build_dir, 'env') # not actually an IDF thing
|
||||
app.add_event('idf-info')
|
||||
@@ -55,43 +55,43 @@ def setup(app):
|
||||
|
||||
|
||||
def generate_idf_info(app, config):
|
||||
print("Running CMake on dummy project to get build info...")
|
||||
print('Running CMake on dummy project to get build info...')
|
||||
build_dir = os.path.dirname(app.doctreedir.rstrip(os.sep))
|
||||
cmake_build_dir = os.path.join(build_dir, "build_dummy_project")
|
||||
idf_py_path = os.path.join(app.config.idf_path, "tools", "idf.py")
|
||||
print("Running idf.py...")
|
||||
cmake_build_dir = os.path.join(build_dir, 'build_dummy_project')
|
||||
idf_py_path = os.path.join(app.config.idf_path, 'tools', 'idf.py')
|
||||
print('Running idf.py...')
|
||||
idf_py = [sys.executable,
|
||||
idf_py_path,
|
||||
"-B",
|
||||
'-B',
|
||||
cmake_build_dir,
|
||||
"-C",
|
||||
'-C',
|
||||
project_path,
|
||||
"-D",
|
||||
"SDKCONFIG={}".format(os.path.join(build_dir, "dummy_project_sdkconfig"))
|
||||
'-D',
|
||||
'SDKCONFIG={}'.format(os.path.join(build_dir, 'dummy_project_sdkconfig'))
|
||||
]
|
||||
|
||||
# force a clean idf.py build w/ new sdkconfig each time
|
||||
# (not much slower than 'reconfigure', avoids any potential config & build versioning problems
|
||||
shutil.rmtree(cmake_build_dir, ignore_errors=True)
|
||||
print("Starting new dummy IDF project... ")
|
||||
print('Starting new dummy IDF project... ')
|
||||
|
||||
if (app.config.idf_target in PREVIEW_TARGETS):
|
||||
subprocess.check_call(idf_py + ["--preview", "set-target", app.config.idf_target])
|
||||
subprocess.check_call(idf_py + ['--preview', 'set-target', app.config.idf_target])
|
||||
else:
|
||||
subprocess.check_call(idf_py + ["set-target", app.config.idf_target])
|
||||
subprocess.check_call(idf_py + ['set-target', app.config.idf_target])
|
||||
|
||||
print("Running CMake on dummy project...")
|
||||
subprocess.check_call(idf_py + ["reconfigure"])
|
||||
print('Running CMake on dummy project...')
|
||||
subprocess.check_call(idf_py + ['reconfigure'])
|
||||
|
||||
with open(os.path.join(cmake_build_dir, "project_description.json")) as f:
|
||||
with open(os.path.join(cmake_build_dir, 'project_description.json')) as f:
|
||||
project_description = json.load(f)
|
||||
if project_description["target"] != app.config.idf_target:
|
||||
if project_description['target'] != app.config.idf_target:
|
||||
# this shouldn't really happen unless someone has been moving around directories inside _build, as
|
||||
# the cmake_build_dir path should be target-specific
|
||||
raise RuntimeError(("Error configuring the dummy IDF project for {}. " +
|
||||
"Target in project description is {}. " +
|
||||
"Is build directory contents corrupt?")
|
||||
.format(app.config.idf_target, project_description["target"]))
|
||||
raise RuntimeError(('Error configuring the dummy IDF project for {}. ' +
|
||||
'Target in project description is {}. ' +
|
||||
'Is build directory contents corrupt?')
|
||||
.format(app.config.idf_target, project_description['target']))
|
||||
app.emit('idf-info', project_description)
|
||||
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user