forked from platformio/platformio-core
Fixed an issue when "main.cpp" was generated for a new project for 8-bit development platforms // Resolve #3872
This commit is contained in:
@ -31,6 +31,7 @@ PlatformIO Core 5
|
|||||||
|
|
||||||
- Ensure that a serial port is ready before running unit tests on a remote target (`issue #3742 <https://github.com/platformio/platformio-core/issues/3742>`_)
|
- Ensure that a serial port is ready before running unit tests on a remote target (`issue #3742 <https://github.com/platformio/platformio-core/issues/3742>`_)
|
||||||
- Fixed an error "Unknown development platform" when running unit tests on a clean machine (`issue #3901 <https://github.com/platformio/platformio-core/issues/3901>`_)
|
- Fixed an error "Unknown development platform" when running unit tests on a clean machine (`issue #3901 <https://github.com/platformio/platformio-core/issues/3901>`_)
|
||||||
|
- Fixed an issue when "main.cpp" was generated for a new project for 8-bit development platforms (`issue #3872 <https://github.com/platformio/platformio-core/issues/3872>`_)
|
||||||
|
|
||||||
5.1.1 (2021-03-17)
|
5.1.1 (2021-03-17)
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -200,10 +200,10 @@ class ProjectRPC:
|
|||||||
await PIOCoreRPC.call(
|
await PIOCoreRPC.call(
|
||||||
args, options={"cwd": project_dir, "force_subprocess": True}
|
args, options={"cwd": project_dir, "force_subprocess": True}
|
||||||
)
|
)
|
||||||
return self._generate_project_main(project_dir, framework)
|
return self._generate_project_main(project_dir, board, framework)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _generate_project_main(project_dir, framework):
|
def _generate_project_main(project_dir, board, framework):
|
||||||
main_content = None
|
main_content = None
|
||||||
if framework == "arduino":
|
if framework == "arduino":
|
||||||
main_content = "\n".join(
|
main_content = "\n".join(
|
||||||
@ -238,10 +238,25 @@ class ProjectRPC:
|
|||||||
)
|
)
|
||||||
if not main_content:
|
if not main_content:
|
||||||
return project_dir
|
return project_dir
|
||||||
|
|
||||||
|
is_cpp_project = True
|
||||||
|
pm = PlatformPackageManager()
|
||||||
|
try:
|
||||||
|
board = pm.board_config(board)
|
||||||
|
platforms = board.get("platforms", board.get("platform"))
|
||||||
|
if not isinstance(platforms, list):
|
||||||
|
platforms = [platforms]
|
||||||
|
c_based_platforms = ["intel_mcs51", "ststm8"]
|
||||||
|
is_cpp_project = not (set(platforms) & set(c_based_platforms))
|
||||||
|
except exception.PlatformioException:
|
||||||
|
pass
|
||||||
|
|
||||||
with fs.cd(project_dir):
|
with fs.cd(project_dir):
|
||||||
config = ProjectConfig()
|
config = ProjectConfig()
|
||||||
src_dir = config.get_optional_dir("src")
|
src_dir = config.get_optional_dir("src")
|
||||||
main_path = os.path.join(src_dir, "main.cpp")
|
main_path = os.path.join(
|
||||||
|
src_dir, "main.%s" % ("cpp" if is_cpp_project else "c")
|
||||||
|
)
|
||||||
if os.path.isfile(main_path):
|
if os.path.isfile(main_path):
|
||||||
return project_dir
|
return project_dir
|
||||||
if not os.path.isdir(src_dir):
|
if not os.path.isdir(src_dir):
|
||||||
|
Reference in New Issue
Block a user