summaryrefslogtreecommitdiff
path: root/exports/generate_lib.ps1
diff options
context:
space:
mode:
authorStevenWdV <stevenwdv@gmail.com>2022-01-24 14:59:25 +0100
committerStevenWdV <stevenwdv@gmail.com>2022-01-24 16:24:57 +0100
commite544c6fa9e15e7277da79e2464243e90b2706b8c (patch)
treede6613747e0e34a799089d4677f9833a85748712 /exports/generate_lib.ps1
parentaab2e4b966c82b67eb0e204060e5ea6cd4ea15cf (diff)
Cleanup
Added variables to Makefiles to specify custom exports/ directory; Split exception classes in Java & C#; Added more comments; Renamed library and Go package; Removed real (pure) tests; Added generate_lib.ps1 to generate import .lib for Windows (Swift); Moved built Go libraries to exports/lib/; Switch to hopefully faster Swift GitHub Action.
Diffstat (limited to 'exports/generate_lib.ps1')
-rw-r--r--exports/generate_lib.ps130
1 files changed, 30 insertions, 0 deletions
diff --git a/exports/generate_lib.ps1 b/exports/generate_lib.ps1
new file mode 100644
index 0000000..ac452ca
--- /dev/null
+++ b/exports/generate_lib.ps1
@@ -0,0 +1,30 @@
+<#
+.SYNOPSIS
+ Generate .lib import library file for specified .dll file.
+.NOTES
+ Requires dumpbin & lib, may need to execute through VS developer shell.
+#>
+
+param (
+ [string]$DllPath
+)
+
+# Compatible with both Windows PowerShell and PowerShell Core
+
+$ErrorActionPreference = "Stop"
+
+$dll = Get-Item $DllPath
+$def = Join-Path $dll.Directory "$( $dll.BaseName ).def"
+$lib = Join-Path $dll.Directory "$( $dll.BaseName ).lib"
+$machine = (dumpbin /nologo /headers $dll.FullName |
+ Select-String -AllMatches 'machine \((.+)\)').Matches[0].Groups[1].Value
+
+"LIBRARY $( $dll.BaseName )`nEXPORTS`n" + (
+(dumpbin /nologo /exports $dll.FullName |
+ Select-String -AllMatches '\d+\s+\d+\s+[0-9A-Z]+\s+(\S+)').Matches |
+ % { $_.Groups[1].Value } |
+ where { $_[0] -ne '_' } | # Skip _cgo_dummy_export
+Out-String) |
+ Set-Content $def
+
+lib /machine:$machine /def:"$def" /out:"$lib"