summarylogtreecommitdiffstats
path: root/generate-manifest-ttl.py
diff options
context:
space:
mode:
authorOSAMC2022-11-19 14:35:17 +0000
committerChristopher Arndt2022-11-19 14:35:17 +0000
commiteb1e91d646e34d93c00635f959a39405b68888a4 (patch)
treebc549e617473ffc8c1461ebcb4404166253cf372 /generate-manifest-ttl.py
parenta840f2a13f49338133d039a87015e8ea60471eea (diff)
downloadaur-eb1e91d646e34d93c00635f959a39405b68888a4.tar.gz
feat: import and update package 'ot-simian' from AUR (#119)
Diffstat (limited to 'generate-manifest-ttl.py')
-rw-r--r--generate-manifest-ttl.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/generate-manifest-ttl.py b/generate-manifest-ttl.py
new file mode 100644
index 000000000000..ca114eba29db
--- /dev/null
+++ b/generate-manifest-ttl.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+
+import sys
+from ctypes import byref, c_char_p, c_int, cdll, create_string_buffer
+from os.path import join
+
+
+def extractLV2ManifestFromBinary(binaryPath: str, outputDir: str, binaryName: str):
+ print("*** Extract LV2 manifest from binary...", file=sys.stderr);
+ lib = cdll.LoadLibrary(binaryPath)
+
+ if not lib.GenerateManifestFromClient:
+ return "Couldn't find the symbol GenerateManifestFromClient in the plug-in"
+
+ gen_manifest = lib.GenerateManifestFromClient
+ gen_manifest.restype = c_int
+ gen_manifest.argtypes =[c_char_p, c_int, c_char_p, c_int]
+
+ # How much bytes do we need for the manifest?
+ c_binaryName = c_char_p(binaryName.encode("utf-8"))
+ manifestLen: int = gen_manifest(None, 0, c_binaryName, len(binaryName));
+
+ # Generate the manifest again, this time copy it in a properly sized buffer.
+ manifestBuf: c_char_p = create_string_buffer(manifestLen)
+ manifestLen = gen_manifest(manifestBuf, manifestLen, c_binaryName, len(binaryName))
+ lv2Manifest: str = manifestBuf.value.decode("utf-8");
+
+ # write manifest
+ manifestPath: str = join(outputDir, "manifest.ttl")
+
+ with open(manifestPath, "w") as fp:
+ fp.write(lv2Manifest)
+
+ print( " => Written {} bytes to {}.".format(len(lv2Manifest), manifestPath), file=sys.stderr)
+
+
+if __name__ == '__main__':
+ sys.exit(extractLV2ManifestFromBinary(*sys.argv[1:]) or 0)