Skip to content

Commit 43763a5

Browse files
authored
Improve code fixing IDF version on build (#3066)
***NO_CI***
1 parent 20bd71d commit 43763a5

File tree

8 files changed

+90
-37
lines changed

8 files changed

+90
-37
lines changed

CMake/binutils.ESP32.cmake

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -602,20 +602,33 @@ macro(nf_add_idf_as_library)
602602

603603
include(${IDF_PATH_CMAKED}/tools/cmake/idf.cmake)
604604

605-
# "fix" the reported version so it doesn't show '-dirty'
605+
# if needed, "fix" the reported version so it doesn't show '-dirty'
606606
# this is because we could be deleting some files and tweaking others in the IDF
607607
get_property(MY_IDF_VER TARGET __idf_build_target PROPERTY IDF_VER)
608-
string(REPLACE "-dirty" "" MY_IDF_VER_FIXED "${MY_IDF_VER}")
609-
set_property(TARGET __idf_build_target PROPERTY IDF_VER ${MY_IDF_VER_FIXED})
610-
set(IDF_VER_FIXED ${MY_IDF_VER_FIXED} CACHE INTERNAL "IDF version as CMake var")
611608

612-
# for COMPILE DEFINITIONS it's a bit more work
613-
get_property(IDF_COMPILE_DEFINITIONS TARGET __idf_build_target PROPERTY COMPILE_DEFINITIONS )
609+
# sanity check
610+
if(${MY_IDF_VER} STREQUAL "")
611+
message(FATAL_ERROR "Couldn't get IDF version from target __idf_build_target")
612+
endif()
614613

615-
string(REPLACE "-dirty" "" IDF_COMPILE_DEFINITIONS_FIXED "${IDF_COMPILE_DEFINITIONS}")
616-
set_property(TARGET __idf_build_target PROPERTY COMPILE_DEFINITIONS ${IDF_COMPILE_DEFINITIONS_FIXED})
617-
618-
message(STATUS "Fixed IDF version. Is now: ${MY_IDF_VER_FIXED}")
614+
message(STATUS "Current IDF version is: ${MY_IDF_VER}")
615+
616+
string(FIND ${MY_IDF_VER} "-dirty" MY_IDF_VER_DIRTY)
617+
if(${MY_IDF_VER_DIRTY} GREATER -1)
618+
619+
# found '-dirty' in the version string
620+
string(REPLACE "-dirty" "" MY_IDF_VER_FIXED "${MY_IDF_VER}")
621+
set_property(TARGET __idf_build_target PROPERTY IDF_VER ${MY_IDF_VER_FIXED})
622+
set(IDF_VER_FIXED ${MY_IDF_VER_FIXED} CACHE INTERNAL "IDF version as CMake var")
623+
624+
# for COMPILE DEFINITIONS it's a bit more work
625+
get_property(IDF_COMPILE_DEFINITIONS TARGET __idf_build_target PROPERTY COMPILE_DEFINITIONS )
626+
627+
string(REPLACE "-dirty" "" IDF_COMPILE_DEFINITIONS_FIXED "${IDF_COMPILE_DEFINITIONS}")
628+
set_property(TARGET __idf_build_target PROPERTY COMPILE_DEFINITIONS ${IDF_COMPILE_DEFINITIONS_FIXED})
629+
630+
message(STATUS "Fixed IDF version. Is now: ${MY_IDF_VER_FIXED}")
631+
endif()
619632

620633
# check for SDK config from build options
621634
if(SDK_CONFIG_FILE)

azure-pipelines-nightly.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -558,39 +558,46 @@ jobs:
558558
IDF_PATH: "D:/a/1/s/esp-idf"
559559
PIP_CACHE_DIR: $(Pipeline.Workspace)/.pip
560560
TargetPlatform: "esp32"
561+
IDF_TAG: "v5.2.3"
561562

562563
steps:
563564
- checkout: self
564-
- checkout: esp32_idf
565-
fetchDepth: 1
565+
path: s/nf-interpreter
566566

567+
- template: azure-pipelines-templates/checkout-idf.yml
568+
parameters:
569+
repoDirectory: '$(Agent.BuildDirectory)/s'
567570
- template: azure-pipelines-templates/build-preparations.yml
568571
parameters:
569-
repoDirectory: '$(Build.SourcesDirectory)\nf-interpreter'
572+
repoDirectory: '$(Agent.BuildDirectory)/s/nf-interpreter'
570573
- template: azure-pipelines-templates/nb-gitversioning.yml
571574
parameters:
572-
repoDirectory: '$(Build.SourcesDirectory)\nf-interpreter'
575+
repoDirectory: '$(Agent.BuildDirectory)/s/nf-interpreter'
573576
- template: azure-pipelines-templates/download-install-esp32-build-components.yml
574577
- template: azure-pipelines-templates/download-install-ninja.yml
575578
parameters:
576-
repoDirectory: '$(Build.SourcesDirectory)\nf-interpreter'
579+
repoDirectory: '$(Agent.BuildDirectory)/s/nf-interpreter'
577580
- template: azure-pipelines-templates/build-espressif-esp32-targets.yml
578-
581+
parameters:
582+
repoDirectory: '$(Agent.BuildDirectory)/s/nf-interpreter'
583+
partitionsDirectory: '$(Agent.BuildDirectory)/s/nf-interpreter/targets/ESP32/_IDF/$(IDF_Target)'
579584
- task: CopyFiles@2
580585
condition: succeeded()
581586
displayName: Copying bootloader
582587
inputs:
583-
sourceFolder: '$(Build.SourcesDirectory)\nf-interpreter\build\bootloader'
588+
sourceFolder: '$(Agent.BuildDirectory)/s/nf-interpreter/build/bootloader'
584589
Contents: |
585590
bootloader.bin
586591
TargetFolder: '$(Build.ArtifactStagingDirectory)\$(TargetPublishName)'
587592
flattenFolders: true
588593
ignoreMakeDirErrors: true
589594

590595
- template: azure-pipelines-templates/copy-sdkconfig.yml
596+
parameters:
597+
repoDirectory: '$(Agent.BuildDirectory)/s/nf-interpreter'
591598
- template: azure-pipelines-templates/pack-publish-artifacts.yml
592599
parameters:
593-
buildDirectory: '$(Build.SourcesDirectory)\nf-interpreter\build'
600+
buildDirectory: '$(Agent.BuildDirectory)/s/nf-interpreter/build'
594601
- template: azure-pipelines-templates/publish-cloudsmith.yml
595602
- template: azure-pipelines-templates/publish-sdkconfig.yml
596603

azure-pipelines-templates/build-espressif-esp32-targets.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ steps:
1414
parameters:
1515
repoDirectory: ${{ parameters.repoDirectory }}
1616

17-
- task: Cache@2
18-
displayName: Cache IDF components
19-
inputs:
20-
key: 'esp-idf-components-cache | 5_2_3'
21-
path: $(Agent.BuildDirectory)/s/esp-idf/components
22-
cacheHitVar: ESP32_COMPONENTS_RESTORED
23-
2417
- task: CMake@1
2518
condition: succeeded()
2619
displayName: Setup build with CMake
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) .NET Foundation and Contributors
2+
# See LICENSE file in the project root for full license information.
3+
4+
parameters:
5+
- name: repoDirectory
6+
type: string
7+
default: $(Agent.BuildDirectory)/s
8+
9+
steps:
10+
11+
- task: Cache@2
12+
displayName: Cache IDF repository
13+
inputs:
14+
key: 'esp-idf | "$(IDF_TAG)"'
15+
path: $(Agent.BuildDirectory)/s/esp-idf
16+
cacheHitVar: ESP32_IDF_REPO_RESTORED
17+
18+
- task: PowerShell@2
19+
displayName: Checkout IDF repository
20+
condition: ne(variables.ESP32_IDF_REPO_RESTORED, 'true')
21+
inputs:
22+
targetType: "inline"
23+
script: |
24+
# create directory for IDF, ignore if it already exists
25+
New-Item -Path ${{ parameters.repoDirectory }} -ItemType "directory" -ErrorAction SilentlyContinue
26+
# move to the build sources directory
27+
Set-Location -Path ${{ parameters.repoDirectory }}
28+
git clone --recurse-submodules --shallow-submodules --single-branch --depth 1 --branch $(IDF_TAG) https://github.com/espressif/esp-idf

azure-pipelines-templates/copy-sdkconfig.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# Copyright (c) .NET Foundation and Contributors
22
# See LICENSE file in the project root for full license information.
33

4+
parameters:
5+
- name: repoDirectory
6+
type: string
7+
default: $(Build.SourcesDirectory)\nf-interpreter
8+
49
steps:
510
- task: CopyFiles@2
611
condition: succeeded()
712
displayName: Copying SDKCONFIG
813
inputs:
9-
sourceFolder: '$(Build.SourcesDirectory)\nf-interpreter'
14+
sourceFolder: "${{ parameters.repoDirectory }}"
1015
Contents: |
1116
sdkconfig
1217
TargetFolder: '$(Build.ArtifactStagingDirectory)\$(TargetPublishName)_sdkconfig'

azure-pipelines-templates/download-install-esp32-build-components.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ steps:
66
- task: Cache@2
77
displayName: Cache ESP32 tools
88
inputs:
9-
key: "esp32_tools | 5_2_3"
10-
restoreKeys: 5_2_3
9+
key: 'esp32_tools | "$(IDF_TAG)"'
1110
path: $(UserProfile)\.espressif\tools
1211
cacheHitVar: ESP32_TOOLS_CACHE_RESTORED
1312

azure-pipelines.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ resources:
4848
type: github
4949
name: espressif/esp-idf
5050
endpoint: nanoframework
51-
ref: 'refs/tags/v5.2.3'
51+
ref: refs/tags/v5.2.3
5252
- repository: mscorlib
5353
type: github
5454
name: nanoframework/CoreLibrary
@@ -557,39 +557,46 @@ jobs:
557557
IDF_PATH: "D:/a/1/s/esp-idf"
558558
PIP_CACHE_DIR: $(Pipeline.Workspace)/.pip
559559
TargetPlatform: "esp32"
560+
IDF_TAG: "v5.2.3"
560561

561562
steps:
562563
- checkout: self
563-
- checkout: esp32_idf
564-
fetchDepth: 1
564+
path: s/nf-interpreter
565565

566+
- template: azure-pipelines-templates/checkout-idf.yml
567+
parameters:
568+
repoDirectory: '$(Agent.BuildDirectory)/s'
566569
- template: azure-pipelines-templates/build-preparations.yml
567570
parameters:
568-
repoDirectory: '$(Build.SourcesDirectory)\nf-interpreter'
571+
repoDirectory: '$(Agent.BuildDirectory)/s/nf-interpreter'
569572
- template: azure-pipelines-templates/nb-gitversioning.yml
570573
parameters:
571-
repoDirectory: '$(Build.SourcesDirectory)\nf-interpreter'
574+
repoDirectory: '$(Agent.BuildDirectory)/s/nf-interpreter'
572575
- template: azure-pipelines-templates/download-install-esp32-build-components.yml
573576
- template: azure-pipelines-templates/download-install-ninja.yml
574577
parameters:
575-
repoDirectory: '$(Build.SourcesDirectory)\nf-interpreter'
578+
repoDirectory: '$(Agent.BuildDirectory)/s/nf-interpreter'
576579
- template: azure-pipelines-templates/build-espressif-esp32-targets.yml
577-
580+
parameters:
581+
repoDirectory: '$(Agent.BuildDirectory)/s/nf-interpreter'
582+
partitionsDirectory: '$(Agent.BuildDirectory)/s/nf-interpreter/targets/ESP32/_IDF/$(IDF_Target)'
578583
- task: CopyFiles@2
579584
condition: succeeded()
580585
displayName: Copying bootloader
581586
inputs:
582-
sourceFolder: '$(Build.SourcesDirectory)\nf-interpreter\build\bootloader'
587+
sourceFolder: '$(Agent.BuildDirectory)/s/nf-interpreter/build/bootloader'
583588
Contents: |
584589
bootloader.bin
585590
TargetFolder: '$(Build.ArtifactStagingDirectory)\$(TargetPublishName)'
586591
flattenFolders: true
587592
ignoreMakeDirErrors: true
588593

589594
- template: azure-pipelines-templates/copy-sdkconfig.yml
595+
parameters:
596+
repoDirectory: '$(Agent.BuildDirectory)/s/nf-interpreter'
590597
- template: azure-pipelines-templates/pack-publish-artifacts.yml
591598
parameters:
592-
buildDirectory: '$(Build.SourcesDirectory)\nf-interpreter\build'
599+
buildDirectory: '$(Agent.BuildDirectory)/s/nf-interpreter/build'
593600
- template: azure-pipelines-templates/publish-cloudsmith.yml
594601
- template: azure-pipelines-templates/publish-sdkconfig.yml
595602

targets/ESP32/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,4 @@ add_subdirectory(_nanoCLR)
167167
if(USE_NETWORKING_OPTION)
168168
add_subdirectory(_Network)
169169
endif()
170+

0 commit comments

Comments
 (0)