Skip to content

Commit

Permalink
Merge branch 'main' into test-pipeline-build
Browse files Browse the repository at this point in the history
  • Loading branch information
networkfusion authored Jun 23, 2024
2 parents 1a485dc + 4e6c5c3 commit 57f18b4
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 202 deletions.
39 changes: 2 additions & 37 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,9 @@ jobs:
else
{
# build NOT from PR
Write-Host "Build NOT from PR, commit ID: $env:Build_SourceVersion"
# get PR associated with commit
$prUrl = "https://api.github.com/repos/$env:Build_Repository_Name/commits/$env:Build_SourceVersion/pulls"
$commit = Invoke-RestMethod -Uri $prUrl -ContentType "application/json" -Headers @{"Accept"="application/vnd.github.groot-preview+json"} -Method GET
if($commit -ne $null)
{
# there is a PR, check labels
$updateDependents = $commit.labels | where {$_.Name -eq 'CI: Update Dependents'}
if($updateDependents -ne $null)
{
$update = $true
}
}
Write-Host "Build NOT from PR, commit ID: $env:Build_SourceVersion"
}
}
# set variable to foward to jobs
echo "##vso[task.setvariable variable=RUN_UPDATE_DEPENDENTS;isOutput=true]$update"
}
name: BuildOptions
displayName: Evaluate build options
Expand Down Expand Up @@ -187,8 +169,6 @@ jobs:
value: 'Release'
- name: solution
value: 'nanoFirmwareFlasher.sln'
- name: run_update_dependents
value: $[dependencies.Check_Build_Options.outputs['BuildOptions.RUN_UPDATE_DEPENDENTS']]

steps:

Expand Down Expand Up @@ -473,21 +453,6 @@ jobs:
{ "label" : "Type: documentation", "displayName" : "Documentation", "state" : "closed" }
]
# update dependents
- task: PowerShell@2
condition: >-
or(
eq(variables['System.PullRequest.PullRequestId'], ''),
eq(variables['UPDATE_DEPENDENTS'], 'true'),
eq(variables['run_update_dependents'], 'true')
)
displayName: Update dependent tools
inputs:
targetType: filePath
filePath: azure-pipelines/update-dependents.ps1
env:
GH_TOKEN: $(GitHubToken)

##################################
# report build failure to Discord
- job: Report_Build_Failure
Expand Down
118 changes: 0 additions & 118 deletions azure-pipelines/update-dependents.ps1

This file was deleted.

Binary file modified lib/jlink/JLink.exe
Binary file not shown.
Binary file modified lib/jlink/JLink_x64.dll
Binary file not shown.
Binary file modified lib/jlinkLinux/JLinkExe
Binary file not shown.
Binary file modified lib/jlinkMac/JLinkExe
Binary file not shown.
125 changes: 78 additions & 47 deletions nanoFirmwareFlasher.Library/JLinkCli.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,13 @@ public ExitCodes ExecuteFlashBinFiles(
IList<string> addresses,
string probeId)
{
// check file existence
if (files.Any(f => !File.Exists(f)))
List<string> shadowFiles = [];

var processFileResult = ProcessFilePaths(files, shadowFiles);

if (processFileResult != ExitCodes.OK)
{
return ExitCodes.E5004;
return processFileResult;
}

// perform check on address(es)
Expand Down Expand Up @@ -179,10 +182,6 @@ public ExitCodes ExecuteFlashBinFiles(
}
}

List<string> shadowFiles = [];

ProcessFilePaths(files, shadowFiles);

// erase flash
if (DoMassErase)
{
Expand Down Expand Up @@ -281,42 +280,20 @@ public ExitCodes ExecuteFlashBinFiles(

Console.ForegroundColor = ConsoleColor.White;

return ExitCodes.OK;
}

private void ProcessFilePaths(IList<string> files, List<string> shadowFiles)
{
// J-Link can't handle diacritc chars
// developer note: reported to Segger (Case: 60276735) and can be removed if this is fixed/improved
foreach (string binFile in files)
// be nice and clean up shadow files
try
{
// make sure path is absolute
var binFilePath = Utilities.MakePathAbsolute(
Environment.CurrentDirectory,
binFile);

if (!binFilePath.IsNormalized(NormalizationForm.FormD)
|| binFilePath.Contains(' '))
foreach (string shadowFile in shadowFiles)
{
var tempFile = Path.Combine(
Environment.GetEnvironmentVariable("TEMP", EnvironmentVariableTarget.Machine),
Path.GetFileName(binFilePath));

// copy file to shadow file
File.Copy(
binFilePath,
tempFile,
true);

shadowFiles.Add(tempFile);
}
else
{
// copy file to shadow list
shadowFiles.Add(binFile);
File.Delete(shadowFile);
}

}
catch (Exception)
{
// ignore any exception here
}

return ExitCodes.OK;
}

/// <summary>
Expand All @@ -329,15 +306,14 @@ public ExitCodes ExecuteFlashHexFiles(
IList<string> files,
string probeId)
{
// check file existence
if (files.Any(f => !File.Exists(f)))
{
return ExitCodes.E5004;
}

List<string> shadowFiles = [];

ProcessFilePaths(files, shadowFiles);
var processFileResult = ProcessFilePaths(files, shadowFiles);

if (processFileResult != ExitCodes.OK)
{
return processFileResult;
}

// erase flash
if (DoMassErase)
Expand Down Expand Up @@ -445,10 +421,23 @@ public ExitCodes ExecuteFlashHexFiles(

Console.ForegroundColor = ConsoleColor.White;

// be nice and clean up shadow files
try
{
foreach (string shadowFile in shadowFiles)
{
File.Delete(shadowFile);
}
}
catch (Exception)
{
// ignore any exception here
}

return ExitCodes.OK;
}

public void ShowCLIOutput(string cliOutput)
internal void ShowCLIOutput(string cliOutput)
{
// show CLI output, if verbosity is diagnostic
if (Verbosity == VerbosityLevel.Diagnostic)
Expand Down Expand Up @@ -531,5 +520,47 @@ internal static string RunJLinkCLI(string cmdFile, string arguments = null)

return jlinkCli.StandardOutput.ReadToEnd();
}

private ExitCodes ProcessFilePaths(IList<string> files, List<string> shadowFiles)
{
// J-Link can't handle diacritc chars
// developer note: reported to Segger (Case: 60276735) and can be removed if this is fixed/improved
foreach (string binFile in files)
{
// make sure path is absolute
var binFilePath = Utilities.MakePathAbsolute(
Environment.CurrentDirectory,
binFile);

// check file existence
if (!File.Exists(binFilePath))
{
return ExitCodes.E5004;
}

if (!binFilePath.IsNormalized(NormalizationForm.FormD)
|| binFilePath.Contains(' '))
{
var tempFile = Path.Combine(
Environment.GetEnvironmentVariable("TEMP", EnvironmentVariableTarget.Machine),
Path.GetFileName(binFilePath));

// copy file to shadow file
File.Copy(
binFilePath,
tempFile,
true);

shadowFiles.Add(tempFile);
}
else
{
// copy file to shadow list
shadowFiles.Add(binFilePath);
}
}

return ExitCodes.OK;
}
}
}
1 change: 1 addition & 0 deletions nanoFirmwareFlasher.Tool/nanoFirmwareFlasher.Tool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<Platforms>AnyCPU;x64</Platforms>
<RuntimeIdentifiers>any</RuntimeIdentifiers>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>12.0</LangVersion>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<RestoreLockedMode Condition="'$(TF_BUILD)' == 'True' or '$(ContinuousIntegrationBuild)' == 'True'">true</RestoreLockedMode>
</PropertyGroup>
Expand Down

0 comments on commit 57f18b4

Please sign in to comment.