diff --git a/.github/workflows/Build VI packages.yml b/.github/workflows/Build VI packages.yml deleted file mode 100644 index d9ebecab..00000000 --- a/.github/workflows/Build VI packages.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Build icon editor VIPs - -on: - pull_request: - branches: - - 'develop' - workflow_call: - workflow_dispatch: - -jobs: - Build_VI_Packages: - name: Build VI Packages - runs-on: self-hosted - - steps: - - name: Checkout code - uses: actions/checkout@v1.0.0 - - name: Add token to LabVIEW ${{ vars.MinimumSupportedLVVersion }} (64-bit) ini file - run: | - g-cli --lv-ver ${{ vars.MinimumSupportedLVVersion }} --arch 64 -v "${{ vars.RelativePath }}\Tooling\deployment\Create_LV_INI_Token.vi" -- LabVIEW Localhost.LibraryPaths "${{ vars.RelativePath }}" - - name: Modify VIPB to use LabVIEW ${{ vars.VIP_LVVersion }} (64-bit) - run: | - g-cli --lv-ver ${{ vars.MinimumSupportedLVVersion }} --arch 64 -v "${{ vars.RelativePath }}\Tooling\deployment\Modify_VIPB_LabVIEW_Version.vi" -- "${{ vars.RelativePath }}\Tooling\deployment\NI Icon editor.vipb" "${{ vars.VIP_LVVersion_A }} (64-bit)" - - name: Run Unit tests LabVIEW ${{ vars.MinimumSupportedLVVersion }} (64-bit) - run: | - g-cli --lv-ver ${{ vars.MinimumSupportedLVVersion }} --arch 64 -v "${{ vars.RelativePath }}\Tooling\Run all tests CLI.vi" - - name: Build lv_icon.lvlibp for LabVIEW ${{ vars.MinimumSupportedLVVersion }} (64-bit) - run: | - g-cli --lv-ver ${{ vars.MinimumSupportedLVVersion }} --arch 64 lvbuildspec -- -av -p "${{ vars.RelativePath }}\lv_icon_editor.lvproj" -b "Editor Packed Library" - - name: Switch VIPM target to LabVIEW ${{ vars.VIP_LVVersion }} (64-bit) - run: | - g-cli --lv-ver ${{ vars.MinimumSupportedLVVersion }} --arch 64 -v "${{ vars.RelativePath }}\Tooling\Deployment\Switch_VIPM_Target.vi" -- "${{ vars.VIP_LVVersion_A }} (64-bit)" - - name: Close LabVIEW ${{ vars.MinimumSupportedLVVersion }} (64-bit) - run: | - g-cli --lv-ver ${{ vars.MinimumSupportedLVVersion }} --arch 64 QuitLabVIEW - - name: Build LabVIEW ${{ vars.VIP_LVVersion }} (64-bit) VI Package - run: | - g-cli --lv-ver ${{ vars.VIP_LVVersion }} --arch 64 -v vipb -- -av -b "${{ vars.RelativePath }}\Tooling\deployment\NI Icon editor.vipb" -av - - name: Close LabVIEW ${{ vars.VIP_LVVersion }} (64-bit) - run: | - g-cli --lv-ver ${{ vars.VIP_LVVersion }} --arch 64 QuitLabVIEW - - name: Add token to LabVIEW ${{ vars.MinimumSupportedLVVersion }} (64-bit) ini file - run: | - g-cli --lv-ver ${{ vars.MinimumSupportedLVVersion }} --arch 32 -v "${{ vars.RelativePath }}\Tooling\deployment\Create_LV_INI_Token.vi" -- LabVIEW Localhost.LibraryPaths "${{ vars.RelativePath }}" - - name: Modify VIPB to use LabVIEW ${{ vars.VIP_LVVersion }} (32-bit) - run: | - g-cli --lv-ver ${{ vars.MinimumSupportedLVVersion }} --arch 32 -v "${{ vars.RelativePath }}\Tooling\deployment\Modify_VIPB_LabVIEW_Version.vi" -- "${{ vars.RelativePath }}\Tooling\deployment\NI Icon editor.vipb" "${{ vars.VIP_LVVersion_A }}" - - name: Run Unit tests LabVIEW ${{ vars.MinimumSupportedLVVersion }} (32-bit) - run: | - g-cli --lv-ver ${{ vars.MinimumSupportedLVVersion }} --arch 32 -v "${{ vars.RelativePath }}\Tooling\Run all tests CLI.vi" - - name: Build lv_icon.lvlibp for LabVIEW ${{ vars.MinimumSupportedLVVersion }} (32-bit) - run: | - g-cli --lv-ver ${{ vars.MinimumSupportedLVVersion }} --arch 32 lvbuildspec -- -av -p "${{ vars.RelativePath }}\lv_icon_editor.lvproj" -b "Editor Packed Library" - - name: Switch VIPM target to LabVIEW ${{ vars.VIP_LVVersion }} (32-bit) - run: | - g-cli --lv-ver ${{ vars.MinimumSupportedLVVersion }} --arch 32 -v "${{ vars.RelativePath }}\Tooling\Deployment\Switch_VIPM_Target.vi" -- "${{ vars.VIP_LVVersion_A }}" - - name: Close LabVIEW ${{ vars.MinimumSupportedLVVersion }} (32-bit) - run: | - g-cli --lv-ver ${{ vars.MinimumSupportedLVVersion }} --arch 32 QuitLabVIEW - - name: Build LabVIEW ${{ vars.VIP_LVVersion }} (32-bit) VI Package - run: | - g-cli --lv-ver ${{ vars.VIP_LVVersion }} --arch 32 -v vipb -- -av -b "${{ vars.RelativePath }}\Tooling\deployment\NI Icon editor.vipb" -av - - name: Close LabVIEW ${{ vars.VIP_LVVersion }} (32-bit) - run: | - g-cli --lv-ver ${{ vars.VIP_LVVersion }} --arch 32 QuitLabVIEW diff --git a/.github/workflows/Run unit tests and build b/.github/workflows/Run unit tests and build new file mode 100644 index 00000000..836b44a6 --- /dev/null +++ b/.github/workflows/Run unit tests and build @@ -0,0 +1,85 @@ +# .github/workflows/build-and-test.yml + +name: Build and Test LabVIEW Project + +on: + push: + branches: + - develop + +jobs: + build-and-test: + name: Build and Test the Icon Editor + runs-on: [self-hosted, iconeditor] + + env: + build_id: ${{ github.run_number }} + build_revision: ${{ steps.get_revision.outputs.build_revision }} + build_version: 1.0.${{ env.build_id }}.${{ env.build_revision }} + RelativePath: ${{ github.workspace }} + RelativePathScripts: ${{ github.workspace }}/pipeline/scripts + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Get Build Revision + id: get_revision + shell: bash + run: | + # Path to store the build revision counter + COUNTER_FILE="${GITHUB_WORKSPACE}/.github/buildCounter.txt" + echo "Counter file path: $COUNTER_FILE" + + # Initialize the counter file if it doesn't exist + if [ ! -f "$COUNTER_FILE" ]; then + echo "Counter file not found. Initializing to 1." + echo "1" > "$COUNTER_FILE" + fi + + # Read the current value + build_revision=$(cat "$COUNTER_FILE") + echo "Current build_revision: $build_revision" + + # Increment the counter + new_build_revision=$((build_revision + 1)) + echo "New build_revision: $new_build_revision" + + # Save the new value back to the file + echo "$new_build_revision" > "$COUNTER_FILE" + + # Set the output variable + echo "::set-output name=build_revision::$build_revision" + + # For debugging + ls -la "${GITHUB_WORKSPACE}/.github" + cat "$COUNTER_FILE" + + - name: Set agent into development mode + shell: pwsh + working-directory: ${{ env.RelativePathScripts }} + run: | + .\Set_Development_Mode.ps1 -RelativePath "${{ env.RelativePath }}" + + - name: Test and Build the Icon Editor + shell: pwsh + working-directory: ${{ env.RelativePathScripts }} + env: + build_id: ${{ env.build_id }} + build_revision: ${{ env.build_revision }} + build_version: ${{ env.build_version }} + run: | + .\Build.ps1 -RelativePath "${{ env.RelativePath }}" -AbsolutePathScripts "${{ env.RelativePathScripts }}" + + - name: Restore agent from development mode + shell: pwsh + working-directory: ${{ env.RelativePathScripts }} + run: | + .\RevertDevelopmentMode.ps1 -RelativePath "${{ env.RelativePath }}" + + - name: Commit and Push Build Counter + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: 'Increment build revision to ${{ env.build_revision }}' + file_pattern: '.github/buildCounter.txt' \ No newline at end of file diff --git a/Tooling/PrepareIESource.vi b/Tooling/PrepareIESource.vi index 331fe47d..2603d8a1 100644 Binary files a/Tooling/PrepareIESource.vi and b/Tooling/PrepareIESource.vi differ diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 667d1b2f..2e72110e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,10 +3,11 @@ trigger: include: - main - develop + - users/svelderrain/ci-cd # Use forward slashes for branch names name: $(Build.BuildID) -pool: +pool: name: "Default" demands: "iconeditor -equals true" @@ -14,16 +15,32 @@ variables: build_id: $(Build.BuildID) build_revision: $[counter('buildCounter',1)] build_version: '1.0.$(Build.BuildID).$(build_revision)' - RelativePath: '$(Build.Repository.LocalPath)' - RelativePathScripts: '$(Build.Repository.LocalPath)\pipeline\scripts' # Consistently using backslashes + RelativePath: '$(Build.SourcesDirectory)' + RelativePathScripts: '$(Build.SourcesDirectory)\pipeline\scripts' stages: - stage: BuildAndTest displayName: Build and Test LabVIEW Project jobs: - job: ExecuteScripts - displayName: Execute Build.ps1 via powershell + displayName: Execute Scripts steps: - - script: | - powershell -NoProfile -ExecutionPolicy Bypass -File "$(Build.Repository.LocalPath)\pipeline\scripts\Build.ps1" -RelativePath "$(RelativePath)" -RelativePathScripts "$(RelativePathScripts)" - displayName: Test and build the icon editor + - task: PowerShell@2 + displayName: 'Set agent into development mode' + inputs: + filePath: '$(RelativePathScripts)\Set_Development_Mode.ps1' + arguments: '-RelativePath "$(RelativePath)"' + workingDirectory: '$(RelativePathScripts)' + failOnStderr: true + errorActionPreference: 'Stop' + + - task: PowerShell@2 + displayName: 'Test and Build the Icon Editor' + inputs: + filePath: '$(RelativePathScripts)\Build.ps1' + arguments: > + -RelativePath "$(RelativePath)" + -AbsolutePathScripts "$(RelativePathScripts)" + workingDirectory: '$(RelativePathScripts)' + failOnStderr: true + errorActionPreference: 'Stop' \ No newline at end of file diff --git a/pipeline/scripts/AddTokenToLabVIEW.ps1 b/pipeline/scripts/AddTokenToLabVIEW.ps1 index 34d131fe..bdd3a012 100644 --- a/pipeline/scripts/AddTokenToLabVIEW.ps1 +++ b/pipeline/scripts/AddTokenToLabVIEW.ps1 @@ -8,7 +8,7 @@ param( # Construct the command $script = @" -g-cli --lv-ver $MinimumSupportedLVVersion --arch $SupportedBitness -v $RelativePath\Tooling\deployment\Create_LV_INI_Token.vi" -- LabVIEW Localhost.LibraryPaths "$RelativePath" +g-cli --lv-ver $MinimumSupportedLVVersion --arch $SupportedBitness -v "$RelativePath\Tooling\deployment\Create_LV_INI_Token.vi" -- "LabVIEW" "Localhost.LibraryPaths" "$RelativePath" "@ Write-Output "Executing the following command:" @@ -20,7 +20,7 @@ try { # Check the exit code of the executed command if ($LASTEXITCODE -eq 0) { - Write-Host "Unzip vi.lib/LabVIEW Icon API from LabVIEW $MinimumSupportedLVVersion ($SupportedBitness-bit) and remove localhost.library path from ini file" + Write-Host "Create localhost.library path from ini file" } } catch { Write-Host "" diff --git a/pipeline/scripts/Build.ps1 b/pipeline/scripts/Build.ps1 index e345b9dd..d07b7519 100644 --- a/pipeline/scripts/Build.ps1 +++ b/pipeline/scripts/Build.ps1 @@ -1,9 +1,10 @@ +# .\Build.ps1 -RelativePath "C:\labview-icon-editor" -AbsolutePathScripts "C:\labview-icon-editor\pipeline\scripts" param( [Parameter(Mandatory = $true)] [string]$RelativePath, [Parameter(Mandatory = $true)] - [string]$RelativePathScripts + [string]$AbsolutePathScripts ) # Helper function to check for file or directory existence @@ -18,64 +19,92 @@ function Assert-PathExists { } } +# Helper function to execute scripts sequentially +function Execute-Script { + param( + [string]$ScriptPath, + [string]$Arguments + ) + Write-Host "Executing: $ScriptPath $Arguments" -ForegroundColor Cyan + try { + # Build and execute the command + $command = "& `"$ScriptPath`" $Arguments" + Invoke-Expression $command + + # Check for errors in the script execution + if ($LASTEXITCODE -ne 0) { + Write-Host "Error occurred while executing: $ScriptPath with arguments: $Arguments. Exit code: $LASTEXITCODE" -ForegroundColor Red + exit $LASTEXITCODE + } + } catch { + Write-Host "Error occurred while executing: $ScriptPath with arguments: $Arguments. Exiting." -ForegroundColor Red + exit 1 + } +} + # Main script logic try { # Validate required paths Assert-PathExists $RelativePath "RelativePath" Assert-PathExists "$RelativePath\resource\plugins" "Plugins folder" - Assert-PathExists $RelativePathScripts "Scripts folder" + Assert-PathExists $AbsolutePathScripts "Scripts folder" # Clean up .lvlibp files in the plugins folder Write-Host "Cleaning up old .lvlibp files in plugins folder..." -ForegroundColor Yellow - $PluginFiles = Get-ChildItem -Path "`"$RelativePath\resource\plugins`"" -Filter '*.lvlibp' -ErrorAction SilentlyContinue + $PluginFiles = Get-ChildItem -Path "$RelativePath\resource\plugins" -Filter '*.lvlibp' -ErrorAction SilentlyContinue if ($PluginFiles) { $PluginFiles | Remove-Item -Force Write-Host "Deleted .lvlibp files from plugins folder." -ForegroundColor Green } else { Write-Host "No .lvlibp files found to delete." -ForegroundColor Cyan } + # Set development mode # Apply dependencies for LV 2021 - Write-Host "Applying dependencies for LabVIEW 2021..." -ForegroundColor Yellow - Start-Process powershell -ArgumentList "-ExecutionPolicy Bypass -File `"$RelativePathScripts\Applyvipc.ps1`" -MinimumSupportedLVVersion 2021 -SupportedBitness 32 -RelativePath `"$RelativePath`" -VIPCPath `"Tooling\deployment\Dependencies.vipc`" -VIP_LVVersion 2021" -NoNewWindow -Wait + Execute-Script "$($AbsolutePathScripts)\Applyvipc.ps1" ` + "-MinimumSupportedLVVersion 2021 -SupportedBitness 32 -RelativePath `"$RelativePath`" -VIPCPath `"Tooling\deployment\Dependencies.vipc`" -VIP_LVVersion 2021" - # Add token to LabVIEW - Write-Host "Adding token to LabVIEW..." -ForegroundColor Yellow - Start-Process powershell -ArgumentList "-ExecutionPolicy Bypass -File `"$RelativePathScripts\AddTokenToLabVIEW.ps1`" -MinimumSupportedLVVersion 2021 -SupportedBitness 32 -RelativePath `"$RelativePath`"" -NoNewWindow -Wait + # Run Unit Tests + Execute-Script "$($AbsolutePathScripts)\RunUnitTests.ps1" ` + "-MinimumSupportedLVVersion 2021 -SupportedBitness 32 -RelativePath `"$RelativePath`"" + + # Build LV Library + Execute-Script "$($AbsolutePathScripts)\Build_lvlibp.ps1" ` + "-MinimumSupportedLVVersion 2021 -SupportedBitness 32 -RelativePath `"$RelativePath`"" - # Close LabVIEW - Write-Host "Closing LabVIEW..." -ForegroundColor Yellow - Start-Process powershell -ArgumentList "-ExecutionPolicy Bypass -File `"$RelativePathScripts\Close_LabVIEW.ps1`" -MinimumSupportedLVVersion 2021 -SupportedBitness 32" -NoNewWindow -Wait - # Prepare LabVIEW source - Write-Host "Preparing LabVIEW source..." -ForegroundColor Yellow - Start-Process powershell -ArgumentList "-ExecutionPolicy Bypass -File `"$RelativePathScripts\Prepare_LabVIEW_source.ps1`" -MinimumSupportedLVVersion 2021 -SupportedBitness 32 -RelativePath `"$RelativePath`" -LabVIEW_Project 'lv_icon_editor' -Build_Spec 'Editor Packed Library'" -NoNewWindow -Wait + # Close LabVIEW + Execute-Script "$($AbsolutePathScripts)\Close_LabVIEW.ps1" ` + "-MinimumSupportedLVVersion 2021 -SupportedBitness 32" - # Close LabVIEW again - Write-Host "Closing LabVIEW again..." -ForegroundColor Yellow - Start-Process powershell -ArgumentList "-ExecutionPolicy Bypass -File `"$RelativePathScripts\Close_LabVIEW.ps1`" -MinimumSupportedLVVersion 2021 -SupportedBitness 32" -NoNewWindow -Wait + # Rename the file after build + Execute-Script "$($AbsolutePathScripts)\Rename-File.ps1" ` + "-CurrentFilename `"$RelativePath\resource\plugins\lv_icon.lvlibp`" -NewFilename 'lv_icon_x86.lvlibp'" + + # Apply dependencies for LV 2021 + Execute-Script "$($AbsolutePathScripts)\Applyvipc.ps1" ` + "-MinimumSupportedLVVersion 2021 -SupportedBitness 64 -RelativePath `"$RelativePath`" -VIPCPath `"Tooling\deployment\Dependencies.vipc`" -VIP_LVVersion 2021" # Run Unit Tests - Write-Host "Running unit tests..." -ForegroundColor Yellow - Start-Process powershell -ArgumentList "-ExecutionPolicy Bypass -File `"$RelativePathScripts\RunUnitTests.ps1`" -MinimumSupportedLVVersion 2021 -SupportedBitness 32 -RelativePath `"$RelativePath`"" -NoNewWindow -Wait + Execute-Script "$($AbsolutePathScripts)\RunUnitTests.ps1" ` + "-MinimumSupportedLVVersion 2021 -SupportedBitness 64 -RelativePath `"$RelativePath`"" # Build LV Library - Write-Host "Building LabVIEW library (.lvlibp)..." -ForegroundColor Yellow - Start-Process powershell -ArgumentList "-ExecutionPolicy Bypass -File `"$RelativePathScripts\Build_lvlibp.ps1`" -MinimumSupportedLVVersion 2021 -SupportedBitness 32 -RelativePath `"$RelativePath`"" -NoNewWindow -Wait - - # Restore LabVIEW source setup - Write-Host "Restoring LabVIEW source setup..." -ForegroundColor Yellow - Start-Process powershell -ArgumentList "-ExecutionPolicy Bypass -File `"$RelativePathScripts\RestoreSetupLVSource.ps1`" -MinimumSupportedLVVersion 2021 -SupportedBitness 32 -RelativePath `"$RelativePath`" -LabVIEW_Project 'lv_icon_editor' -Build_Spec 'Editor Packed Library'" -NoNewWindow -Wait - - # Close LabVIEW - Write-Host "Finalizing by closing LabVIEW..." -ForegroundColor Yellow - Start-Process powershell -ArgumentList "-ExecutionPolicy Bypass -File `"$RelativePathScripts\Close_LabVIEW.ps1`" -MinimumSupportedLVVersion 2021 -SupportedBitness 32" -NoNewWindow -Wait + Execute-Script "$($AbsolutePathScripts)\Build_lvlibp.ps1" ` + "-MinimumSupportedLVVersion 2021 -SupportedBitness 64 -RelativePath `"$RelativePath`"" # Rename the file after build - Write-Host "Renaming built library file..." -ForegroundColor Yellow - Start-Process powershell -ArgumentList "-ExecutionPolicy Bypass -File `"$RelativePathScripts\Rename-File.ps1`" -CurrentFilename `"$RelativePath\resource\plugins\lv_icon.lvlibp`" -NewFilename 'lv_icon_x86.lvlibp'" -NoNewWindow -Wait + Execute-Script "$($AbsolutePathScripts)\Rename-File.ps1" ` + "-CurrentFilename `"$RelativePath\resource\plugins\lv_icon.lvlibp`" -NewFilename 'lv_icon_x64.lvlibp'" + + # Build VI Package + Execute-Script "$($AbsolutePathScripts)\build_vip.ps1" ` + "-SupportedBitness 64 -RelativePath `"$RelativePath`" -VIPBPath `"Tooling\deployment\NI Icon editor.vipb`" -VIP_LVVersion 2021 -MinimumSupportedLVVersion 2021" - # Success message + # Close LabVIEW + Execute-Script "$($AbsolutePathScripts)\Close_LabVIEW.ps1" ` + "-MinimumSupportedLVVersion 2021 -SupportedBitness 64" + Write-Host "All scripts executed successfully!" -ForegroundColor Green } catch { Write-Host "An unexpected error occurred during script execution: $($_.Exception.Message)" -ForegroundColor Red diff --git a/pipeline/scripts/RestoreSetupLVSource.ps1 b/pipeline/scripts/Cleanup.ps1 similarity index 100% rename from pipeline/scripts/RestoreSetupLVSource.ps1 rename to pipeline/scripts/Cleanup.ps1 diff --git a/pipeline/scripts/Close_LabVIEW.ps1 b/pipeline/scripts/Close_LabVIEW.ps1 index 475d0885..7ca5bd12 100644 --- a/pipeline/scripts/Close_LabVIEW.ps1 +++ b/pipeline/scripts/Close_LabVIEW.ps1 @@ -26,4 +26,4 @@ try { exit 1 } -Write-Host "Close LabVIEW $MinimumSupportedLVVersion ($SupportedBitness-bit)" .ps1 +Write-Host "Close LabVIEW $MinimumSupportedLVVersion ($SupportedBitness-bit)" diff --git a/pipeline/scripts/Prepare_LabVIEW_source.ps1 b/pipeline/scripts/Prepare_LabVIEW_source.ps1 index 720f4c67..734dddd7 100644 --- a/pipeline/scripts/Prepare_LabVIEW_source.ps1 +++ b/pipeline/scripts/Prepare_LabVIEW_source.ps1 @@ -1,29 +1,52 @@ -#Example: .\Prepare_LabVIEW_source.ps1 -MinimumSupportedLVVersion "2021" -SupportedBitness "64" -RelativePath "C:\labview-icon-editor" -LabVIEW_Project "lv_icon_editor" -Build_Spec "Editor Packed Library" +# Example usage: +# .\Prepare_LabVIEW_source.ps1 -MinimumSupportedLVVersion "2021" -SupportedBitness "64" -RelativePath "C:\labview icon editor" -LabVIEW_Project "lv_icon_editor" -Build_Spec "Editor Packed Library" + param( + [Parameter(Mandatory = $true)] [string]$MinimumSupportedLVVersion, + + [Parameter(Mandatory = $true)] + [ValidateSet("32", "64", IgnoreCase = $true)] [string]$SupportedBitness, + + [Parameter(Mandatory = $true)] + [ValidateScript({ Test-Path $_ })] [string]$RelativePath, + + [Parameter(Mandatory = $true)] [string]$LabVIEW_Project, + + [Parameter(Mandatory = $true)] [string]$Build_Spec ) +# Ensure paths with spaces are enclosed in double quotes +$escapedRelativePath = "`"$RelativePath`"" +$escapedLabVIEWProjectPath = "`"$RelativePath\$LabVIEW_Project.lvproj`"" +$escapedBuildSpec = "`"$Build_Spec`"" + # Construct the command $script = @" -g-cli --lv-ver $MinimumSupportedLVVersion --arch $SupportedBitness "$RelativePath\Tooling\PrepareIESource.vi" -- "$RelativePath\$LabVIEW_Project.lvproj" "$Build_Spec" +g-cli --lv-ver $MinimumSupportedLVVersion --arch $SupportedBitness -v `"$RelativePath\Tooling\PrepareIESource.vi`" -- LabVIEW Localhost.LibraryPaths `"$RelativePath\$LabVIEW_Project.lvproj`" $Build_Spec "@ Write-Output "Executing the following command:" Write-Output $script -# Execute the command and check for errors try { + # Execute the command and check for errors Invoke-Expression $script - # Check the exit code of the executed command + # Check the exit code if ($LASTEXITCODE -eq 0) { - Write-Host "Zip and delete vi.lib\LabVIEW Icon API from LabVIEW $MinimumSupportedLVVersion ($SupportedBitness-bit)" .ps1 + Write-Host "Success: Process completed." + Write-Host "Unzipping vi.lib/LabVIEW Icon API from LabVIEW $MinimumSupportedLVVersion ($SupportedBitness-bit)." + Write-Host "Removing localhost.library path from ini file." + } else { + throw "Error: Command execution failed with exit code $LASTEXITCODE." } } catch { - Write-Host "Prepare LabVIEW source" - exit 0 -} \ No newline at end of file + Write-Error "An error occurred during execution: $_" + Write-Error "Please check the parameters and ensure the command is valid." + exit 1 +} diff --git a/pipeline/scripts/RevertDevelopmentMode.ps1 b/pipeline/scripts/RevertDevelopmentMode.ps1 new file mode 100644 index 00000000..5f603437 --- /dev/null +++ b/pipeline/scripts/RevertDevelopmentMode.ps1 @@ -0,0 +1,69 @@ +# Example usage: +# .\RevertDevelopmentMode.ps1 -RelativePath "C:\labview-icon-editor" + +param( + [Parameter(Mandatory = $true)] + [string]$RelativePath +) + +# Define LabVIEW project name +$LabVIEW_Project = 'lv_icon_editor' + +# Determine the directory where this script is located +$ScriptDirectory = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition +Write-Host "Script Directory: $ScriptDirectory" + +# Helper function to execute scripts and stop on error +function Execute-Script { + param( + [string]$ScriptCommand + ) + Write-Host "Executing: $ScriptCommand" + try { + # Execute the command + Invoke-Expression $ScriptCommand -ErrorAction Stop + + # Check for errors in the script execution + if ($LASTEXITCODE -ne 0) { + Write-Error "Error occurred while executing: $ScriptCommand. Exit code: $LASTEXITCODE" + exit $LASTEXITCODE + } + } catch { + Write-Error "Error occurred while executing: $ScriptCommand. Exiting." + Write-Error $_.Exception.Message + exit 1 + } +} + +# Sequential script execution with error handling +try { + # Build the script paths + $RestoreScript = Join-Path -Path $ScriptDirectory -ChildPath 'RestoreSetupLVSource.ps1' + $CloseScript = Join-Path -Path $ScriptDirectory -ChildPath 'Close_LabVIEW.ps1' + + # Restore setup for LabVIEW 2021 (32-bit) + $Command1 = "& `"$RestoreScript`" -MinimumSupportedLVVersion 2021 -SupportedBitness 32 -RelativePath `"$RelativePath`" -LabVIEW_Project `"$LabVIEW_Project`" -Build_Spec `'Editor Packed Library`'" + + Execute-Script $Command1 + + # Close LabVIEW 2021 (32-bit) + $Command2 = "& `"$CloseScript`" -MinimumSupportedLVVersion 2021 -SupportedBitness 32" + + Execute-Script $Command2 + + # Restore setup for LabVIEW 2021 (64-bit) + $Command3 = "& `"$RestoreScript`" -MinimumSupportedLVVersion 2021 -SupportedBitness 64 -RelativePath `"$RelativePath`" -LabVIEW_Project `"$LabVIEW_Project`" -Build_Spec `'Editor Packed Library`'" + + Execute-Script $Command3 + + # Close LabVIEW 2021 (64-bit) + $Command4 = "& `"$CloseScript`" -MinimumSupportedLVVersion 2021 -SupportedBitness 64" + + Execute-Script $Command4 + +} catch { + Write-Error "An unexpected error occurred during script execution: $($_.Exception.Message)" + exit 1 +} + +Write-Host "All scripts executed successfully." -ForegroundColor Green diff --git a/pipeline/scripts/DevelopmentMode.ps1 b/pipeline/scripts/Set_Development_Mode.ps1 similarity index 85% rename from pipeline/scripts/DevelopmentMode.ps1 rename to pipeline/scripts/Set_Development_Mode.ps1 index e91e2cf0..41771f78 100644 --- a/pipeline/scripts/DevelopmentMode.ps1 +++ b/pipeline/scripts/Set_Development_Mode.ps1 @@ -1,6 +1,6 @@ # Example usage: -# .\DevelopmentMode.ps1 -RelativePath "C:\labview-icon-editor" +# .\Set_Development_Mode.ps1 -RelativePath "C:\labview-icon-editor" param( [string]$RelativePath @@ -21,7 +21,7 @@ function Execute-Script { } # Sequential script execution with error handling try { - Execute-Script "Get-ChildItem -Path 'C:\labview-icon-editor\resource\plugins' -Filter '*.lvlibp' | Remove-Item -Force" + Execute-Script "Get-ChildItem -Path '$RelativePath\resource\plugins' -Filter '*.lvlibp' | Remove-Item -Force" Execute-Script ".\AddTokenToLabVIEW.ps1 -MinimumSupportedLVVersion 2021 -SupportedBitness 32 -RelativePath '$RelativePath'" Execute-Script ".\Prepare_LabVIEW_source.ps1 -MinimumSupportedLVVersion 2021 -SupportedBitness 32 -RelativePath '$RelativePath' -LabVIEW_Project 'lv_icon_editor' -Build_Spec 'Editor Packed Library'" Execute-Script ".\Close_LabVIEW.ps1 -MinimumSupportedLVVersion 2021 -SupportedBitness 32" @@ -34,4 +34,4 @@ try { exit 1 } -Write-Host "All scripts executed successfully." .ps1 +Write-Host "All scripts executed successfully." diff --git a/pipeline/scripts/build_vip.ps1 b/pipeline/scripts/build_vip.ps1 index decdbfbb..afe2d91f 100644 --- a/pipeline/scripts/build_vip.ps1 +++ b/pipeline/scripts/build_vip.ps1 @@ -1,6 +1,5 @@ # Example usage: # .\build_vip.ps1 --lv-ver 2021 --arch 64 -SupportedBitness "64" -RelativePath "C:\labview-icon-editor" -VIPBPath "Tooling\deployment\NI Icon editor.vipb" -MinimumSupportedLVVersion 2021 - param ( [string]$SupportedBitness, [string]$RelativePath, @@ -8,46 +7,49 @@ param ( [string]$MinimumSupportedLVVersion ) -# Construct VIP_LVVersion_A -if ($MinimumSupportedLVVersion -eq "2021" -and $SupportedBitness -eq "64") { - $VIP_LVVersion_A = "21.0 (64-bit)" -} elseif ($MinimumSupportedLVVersion -eq "2021" -and $SupportedBitness -eq "32") { - $VIP_LVVersion_A = "21.0" -} elseif ($MinimumSupportedLVVersion -eq "2022" -and $SupportedBitness -eq "64") { - $VIP_LVVersion_A = "22.3 (64-bit)" -} elseif ($MinimumSupportedLVVersion -eq "2022" -and $SupportedBitness -eq "32") { - $VIP_LVVersion_A = "22.3" -} elseif ($MinimumSupportedLVVersion -eq "2023" -and $SupportedBitness -eq "64") { - $VIP_LVVersion_A = "23.3 (64-bit)" -} elseif ($MinimumSupportedLVVersion -eq "2023" -and $SupportedBitness -eq "32") { - $VIP_LVVersion_A = "23.3" -} elseif ($MinimumSupportedLVVersion -eq "2024" -and $SupportedBitness -eq "64") { - $VIP_LVVersion_A = "24.3 (64-bit)" -} elseif ($MinimumSupportedLVVersion -eq "2024" -and $SupportedBitness -eq "32") { - $VIP_LVVersion_A = "24.3" -} else { - Write-Output "Unsupported VIP_LVVersion or SupportedBitness" +# Resolve paths for consistency +try { + $ResolvedRelativePath = Resolve-Path -Path $RelativePath -ErrorAction Stop + $ResolvedVIPBPath = Join-Path -Path $ResolvedRelativePath -ChildPath $VIPBPath -ErrorAction Stop +} catch { + Write-Error "Error resolving paths. Ensure RelativePath and VIPBPath are valid." exit 1 } - Write-Output "Building VI Package for $MinimumSupportedLVVersion" + +# Construct VIP_LVVersion_A based on parameters +switch ("$MinimumSupportedLVVersion-$SupportedBitness") { + "2021-64" { $VIP_LVVersion_A = "21.0 (64-bit)" } + "2021-32" { $VIP_LVVersion_A = "21.0" } + "2022-64" { $VIP_LVVersion_A = "22.3 (64-bit)" } + "2022-32" { $VIP_LVVersion_A = "22.3" } + "2023-64" { $VIP_LVVersion_A = "23.3 (64-bit)" } + "2023-32" { $VIP_LVVersion_A = "23.3" } + "2024-64" { $VIP_LVVersion_A = "24.3 (64-bit)" } + "2024-32" { $VIP_LVVersion_A = "24.3" } + default { + Write-Error "Unsupported MinimumSupportedLVVersion or SupportedBitness." + exit 1 + } +} + +Write-Output "Building VI Package for LabVIEW $VIP_LVVersion_A..." + # Construct the script for execution $script = @" - -g-cli --lv-ver $MinimumSupportedLVVersion --arch $SupportedBitness "$RelativePath\Tooling\deployment\Modify_VIPB_LabVIEW_Version.vi" -- "$RelativePath\Tooling\deployment\NI Icon editor.vipb" "$VIP_LVVersion_A" -g-cli --lv-ver $MinimumSupportedLVVersion --arch $SupportedBitness "$RelativePath\Tooling\deployment\BuildVIP.vi" -- "$RelativePath\Tooling\deployment\NI Icon editor.vipb" "$VIP_LVVersion_A" +g-cli --lv-ver $MinimumSupportedLVVersion --arch $SupportedBitness "$ResolvedRelativePath\Tooling\deployment\Modify_VIPB_LabVIEW_Version.vi" -- "$ResolvedVIPBPath" "$VIP_LVVersion_A" +g-cli --lv-ver $MinimumSupportedLVVersion --arch $SupportedBitness "$ResolvedRelativePath\Tooling\deployment\BuildVIP.vi" -- "$ResolvedVIPBPath" "$VIP_LVVersion_A" g-cli --lv-ver $MinimumSupportedLVVersion --arch $SupportedBitness QuitLabVIEW - "@ # Output the script for debugging -Write-Output "Executing the following command:" +Write-Output "Executing the following commands:" Write-Output $script -# Execute the script +# Execute the script and handle potential errors try { Invoke-Expression $script - Write-Host "Build $RelativePath\Tooling\deployment\NI Icon editor.vipb" .ps1 + Write-Host "Successfully built VI package: $ResolvedVIPBPath" } catch { - Write-Error "An error occurred while executing the command." + Write-Error "An error occurred while executing the build commands." exit 1 } diff --git a/vi.lib/LabVIEW Icon API/Launch Icon Editor.vi b/vi.lib/LabVIEW Icon API/Launch Icon Editor.vi index a6f6fb84..24a7f95f 100644 Binary files a/vi.lib/LabVIEW Icon API/Launch Icon Editor.vi and b/vi.lib/LabVIEW Icon API/Launch Icon Editor.vi differ