Skip to content

Commit

Permalink
updates to stc v8
Browse files Browse the repository at this point in the history
  • Loading branch information
PTKu committed Dec 5, 2024
1 parent dac0a8e commit 8620207
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 52 deletions.
61 changes: 31 additions & 30 deletions src/AXSharp.compiler/src/AXSharp.Compiler/LegalAcrobatics.cs
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
using CliWrap;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using CliWrap;
using static AXSharp.Compiler.AxProject;

namespace AXSharp.Compiler
namespace AXSharp.Compiler;

public static class LegalAcrobatics
{
public static class LegalAcrobatics
{
private static IEnumerable<Assembly> AXAssemblies { get; set; }

public static string? StcVersion { get; private set; }

public static async Task LegalComplianceAcrobatics(string entryAssemblyLocation)
{
/*
We need this to comply with the Siemens legal requirement to allow only users that have access
to simatic-ax to some APIs.
*/

var stcapipath = Path.GetFullPath(Path.Combine(entryAssemblyLocation, $".apax//.apax//packages//@ax//{GetStcNameByPlatform()}//bin//"));

if(!Directory.Exists(stcapipath))
{
await ApaxInstallLegalAcrobatics(entryAssemblyLocation);
}
var stcapipath = Path.GetFullPath(Path.Combine(entryAssemblyLocation,
$".apax//.apax//packages//@ax//{GetStcNameByPlatform()}//bin//"));

if (!Directory.Exists(stcapipath)) await ApaxInstallLegalAcrobatics(entryAssemblyLocation);

SetupAssemblyResolverLegalAcrobatics(entryAssemblyLocation);
}

static IEnumerable<Assembly> AXAssemblies { get; set; }


static void SetupAssemblyResolverLegalAcrobatics(string entryAssemblyLocation)
private static void SetupAssemblyResolverLegalAcrobatics(string entryAssemblyLocation)
{
var axAssemblies = new List<Assembly>();

foreach (var assemblyFile in Directory.EnumerateFiles(
Path.GetFullPath(Path.Combine(entryAssemblyLocation, $".apax//.apax//packages//@ax//{GetStcNameByPlatform()}//bin//")), "*.dll"))
{
Path.GetFullPath(Path.Combine(entryAssemblyLocation,
$".apax//.apax//packages//@ax//{GetStcNameByPlatform()}//bin//")), "*.dll"))
try
{
axAssemblies.Add(Assembly.LoadFile(assemblyFile));
}
catch (System.BadImageFormatException)
catch (BadImageFormatException)
{
// We just ignore this...there might be some libraries that we just cannot load, but we do not need them.
}
}

AXAssemblies = axAssemblies;

StcVersion = AXAssemblies.FirstOrDefault()?.GetName().Version?.ToString();



AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
}

static async Task ApaxInstallLegalAcrobatics(string entryAssemblyLocation)
private static async Task ApaxInstallLegalAcrobatics(string entryAssemblyLocation)
{
var stdOutBuffer = new StringBuilder();
var stdErrBuffer = new StringBuilder();
Expand All @@ -71,7 +71,7 @@ static async Task ApaxInstallLegalAcrobatics(string entryAssemblyLocation)
.WithStandardErrorPipe(PipeTarget.ToStringBuilder(stdErrBuffer))
.ExecuteAsync();
}
catch(Exception ex)
catch (Exception ex)
{
Log.Logger.Error("There was a problem restoring apax packages.", ex);
}
Expand All @@ -82,12 +82,13 @@ static async Task ApaxInstallLegalAcrobatics(string entryAssemblyLocation)
}
}

static Assembly? CurrentDomain_AssemblyResolve(object? sender, ResolveEventArgs args)
private static Assembly? CurrentDomain_AssemblyResolve(object? sender, ResolveEventArgs args)
{
return AXAssemblies.FirstOrDefault(p => p.FullName == args.Name);
}

static string GetStcNameByPlatform()
=> RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "stc-linux-x64" : "stc-win-x64";
}
}
private static string GetStcNameByPlatform()
{
return RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "stc-linux-x64" : "stc-win-x64";
}
}
4 changes: 2 additions & 2 deletions src/AXSharp.compiler/src/ixc/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ private static void DisplayInfo()
"THIRD PARTY LICENSES CAN BE FOUND AT \n" +
"https://github.com/ix-ax/axsharp/blob/master/notices.md");

Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine("ATTENTION: This version requires the usage of `apax sld` v0.14.2 or later!");

Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine($"Using version '{LegalAcrobatics.StcVersion}' of stc.");
Console.ForegroundColor = originalColor;

if (int.Parse(GitVersionInformation.Major) < 1 || string.IsNullOrEmpty(GitVersionInformation.PreReleaseLabel))
Expand Down
37 changes: 18 additions & 19 deletions src/apax/apax-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,56 @@
"name": "s",
"version": "0.0.0",
"devDependencies": {
"@ax/stc": "7.1.81"
"@ax/stc": "8.0.17"
}
},
"packages": {
"@ax/stc": {
"name": "@ax/stc",
"version": "7.1.81",
"integrity": "sha512-1UTt8x3dca10TrUv5zdzulnVvJlb6zqc7UJJXTVP9+slwxqcTCedt1Pmch1JAHpBDdrnGh1MRBpH8egFsEJ8Gg==",
"resolved": "https://registry.simatic-ax.siemens.io/@ax/stc/-/stc-7.1.81.tgz",
"version": "8.0.17",
"integrity": "sha512-Ym2uWEmfrkhm2Z/ODujUwQOiAwQ2p0fv9hLTJGL+zwYMjAwja71JayMLSOO+cX0gv8VexrxISDa66jouT+XySA==",
"resolved": "https://registry.simatic-ax.siemens.io/@ax/stc/-/stc-8.0.17.tgz",
"dependencies": {
"@ax/stc-win-x64": "7.1.81",
"@ax/stc-linux-x64": "7.1.81"
"@ax/stc-win-x64": "8.0.17",
"@ax/stc-linux-x64": "8.0.17"
}
},
"@ax/stc-win-x64": {
"name": "@ax/stc-win-x64",
"version": "7.1.81",
"integrity": "sha512-JRbpVh3SL1GoEsbfoJ52/1BSU082HjS1t64N2N5x1sg+X3bC0waAG6Sjub03D+fOPSAHKS5e/Lgd0p7WLedCPQ==",
"resolved": "https://registry.simatic-ax.siemens.io/@ax/stc-win-x64/-/stc-win-x64-7.1.81.tgz",
"version": "8.0.17",
"integrity": "sha512-vOnWIY+dLfASN2s7exuy7pQU/KKTp9ej3uMn86vLTXtjF5YUECInNYOM9kY6hQdnJFJH6RirxzbiRJftjvLHuw==",
"resolved": "https://registry.simatic-ax.siemens.io/@ax/stc-win-x64/-/stc-win-x64-8.0.17.tgz",
"os": [
"win32"
],
"cpu": [
"x64"
],
"dependencies": {
"@ax/st-docs": "7.1.81"
"@ax/st-docs": "8.0.17"
}
},
"@ax/stc-linux-x64": {
"name": "@ax/stc-linux-x64",
"version": "7.1.81",
"integrity": "sha512-gHajdPn05TMvwCBg/pyHlZmMByNIo5mlQ36AvTm+YaupoxwaJfzX9QIR7mWQ/RbJ4ycaxKwaxgh5H1eG7MCAcg==",
"resolved": "https://registry.simatic-ax.siemens.io/@ax/stc-linux-x64/-/stc-linux-x64-7.1.81.tgz",
"version": "8.0.17",
"integrity": "sha512-BnpkLdkExZ6n6wyKHprrCPfQOu4FK6FTTt8ieVbrjOwABSJxez3ls9GBEpUOJKxqJa05epbR2nIHYoOO1pFKtQ==",
"resolved": "https://registry.simatic-ax.siemens.io/@ax/stc-linux-x64/-/stc-linux-x64-8.0.17.tgz",
"os": [
"linux"
],
"cpu": [
"x64"
],
"dependencies": {
"@ax/st-docs": "7.1.81"
"@ax/st-docs": "8.0.17"
}
},
"@ax/st-docs": {
"name": "@ax/st-docs",
"version": "7.1.81",
"integrity": "sha512-7ps4hmJoHkSjhK0jH4mCu03qsCALSy9pe/FMWdNfBQMXt7PEq7uN4LML0r8orDlyOQgVb2vOcvorZ+n0EtrgKw==",
"resolved": "https://registry.simatic-ax.siemens.io/@ax/st-docs/-/st-docs-7.1.81.tgz",
"dependencies": {},
"deprecated": ""
"version": "8.0.17",
"integrity": "sha512-bvMaT+GcSwF9ahzqI+wHBlCDfASqnJTDHwuBgVuR68u3R9cLaoOLnosw4HBoJRlBxWyooKB9bn+u++jRaekRNg==",
"resolved": "https://registry.simatic-ax.siemens.io/@ax/st-docs/-/st-docs-8.0.17.tgz",
"dependencies": {}
}
},
"workspaces": {}
Expand Down
2 changes: 1 addition & 1 deletion src/apax/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ targets:
- "1500"
- axunit-llvm
devDependencies:
"@ax/stc": 7.1.81
"@ax/stc": 8.0.17
installStrategy: strict
apaxVersion: 3.1.1

0 comments on commit 8620207

Please sign in to comment.