From f7a15b76245f669dbb55a43049296d3888f7e9d5 Mon Sep 17 00:00:00 2001 From: Mario Kleiner Date: Mon, 25 Nov 2024 10:55:40 +0100 Subject: [PATCH] managementtools: Add setup function for LexActivator SDK and runtime libs. The new function downloadlexactivator(alsosdk, cleanupafter); downloads the zip files with the LexActivator SDK and runtime libraries from our license management provider Cryptlex. Then it unzips the files and moves the proper SDK header/include files and Windows import library into place to allow compiling/linking/building mex files with LexActivatore license management support. This is done (for local or CI builds) if the parameter 'alsosdk' is set to 1. Otherwise ths SDK is skipped and only the runtime libraries are installed, e.g., for inclusion into a PTB release zip file. Downloaded zip files and temporary directories are deleted on success or failure if 'cleanupafter' is set to 1, otherwise files are kept. Typical uses: 1. For local build machine setup or setup of CI build, call downloadlexactivator(1, 1); or downloadlexactivator(1, 0); to keep local backups of the files for backups/documentation etc. 2. For building a zip file with only the Psychtoolbox folder as part of an official public PTB release triggered by the maintainer, or a MLTBX file, call downloadlexactivator(0, 1); to only put the runtime libraries into the to-be-zipped-up Psychtoolbox folder, ie. into the Psychtoolbox/PsychBasic/PsychPlugins folder and its Intel64 and ARM64 subfolders. This is an initial workable release. The name and location of this function file may change, or not. Not yet sure about the best place... --- managementtools/downloadlexactivator.m | 101 +++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 managementtools/downloadlexactivator.m diff --git a/managementtools/downloadlexactivator.m b/managementtools/downloadlexactivator.m new file mode 100644 index 000000000..17eb08cb4 --- /dev/null +++ b/managementtools/downloadlexactivator.m @@ -0,0 +1,101 @@ +function downloadlexactivator(alsosdk, cleanupafter) +% downloadlexactivator([alsosdk=0][, cleanupafter=0]) +% +% Download latest Cryptlex LexActivator client SDK and runtime libraries for +% macOS, Windows and Linux. Unzip them, then copy SDK files and runtime libraries +% into proper folders next to or inside Psychtoolbox. +% +% alsosdk = 0 to only install runtime libraries into Psychtoolbox PsychPlugins +% folders. 1 = Also install header files and import libs to allow to +% build license managed mex files. +% +% cleanupafter = 0 Don't clean up after setup. 1 = Delete all zip and temp files. +% + +% History: +% +% 25-Nov-2025 mk Written. Starting off for v3.30.3 SDK and runtimes. +% + + if nargin < 1 || isempty(alsosdk) + alsosdk = 0; + end + + if nargin < 2 || isempty(cleanupafter) + cleanupafter = 0; + end + + % On Octave, tell rmdir() to not prompt for confirmation for all rmdir() + % calls from within this function and subfunctions: + if IsOctave + confirm_recursive_rmdir(0, "local"); + end + + try + dogetit('Win', './lextmp/windows/'); + dogetit('Mac', './lextmp/macos/'); + dogetit('Linux', './lextmp/linux/'); + catch + if cleanupafter + delete('LexActivator*.zip'); + rmdir('./lextmp', 's'); + end + + psychrethrow(lasterror); + end + + if alsosdk + % Move header include files into place, next to the Psychtoolbox-3 main folder: + s1 = copyfile('./lextmp/linux/headers/*.h', [PsychtoolboxRoot '../../'], 'f'); + + % Move Windows import lib into place, next to the Psychtoolbox-3 main folder: + s2 = copyfile('./lextmp/windows/libs/vc16/x64/LexActivator.lib', [PsychtoolboxRoot '../../'], 'f'); + + if ~s1 || ~s2 + error('Copy of LexActivator SDK files failed!'); + end + end + + % Move Windows DLL into PsychPlugins/Intel64/ folder: + s1 = copyfile('./lextmp/windows/libs/vc16/x64/LexActivator.dll', [PsychtoolboxRoot 'PsychBasic/PsychPlugins/Intel64/'], 'f'); + + % Move Linux 64-Bit Intel shared library into PsychPlugins/Intel64/ folder: + s2 = copyfile('./lextmp/linux/libs/gcc/amd64/libLexActivator.so', [PsychtoolboxRoot 'PsychBasic/PsychPlugins/Intel64/'], 'f'); + + % Move Linux 64-Bit ARM shared library into PsychPlugins/ARM64/ folder: + s3 = copyfile('./lextmp/linux/libs/gcc/arm64/libLexActivator.so', [PsychtoolboxRoot 'PsychBasic/PsychPlugins/ARM64/'], 'f'); + + % Move macOS 64-Bit dylib into PsychPlugins/ folder: + s4 = copyfile('./lextmp/macos/libs/clang/universal/libLexActivator.dylib', [PsychtoolboxRoot 'PsychBasic/PsychPlugins/'], 'f'); + + if ~s1 || ~s2 || ~s3 || ~s4 + error('Copy of at least one LexActivator runtime library failed!'); + end + + if cleanupafter + delete('LexActivator*.zip'); + rmdir('./lextmp', 's'); + end + + fprintf('LexActivator installation completed successfully.\n'); +end + +function dogetit(lextype, target) + % Base download url: + url = 'https://dl.cryptlex.com/downloads'; + + % Version of the SDK and runtime to fetch: + lexversion = 'v3.30.3'; + + % Assemble zip file name: + lexzipname = ['LexActivator-' lextype '.zip'] + + % Download zip file: + [f, s] = urlwrite([url '/' lexversion '/' lexzipname], lexzipname); + if ~s + error('LexActivator download failed for %s to %s', lextype, lexzipname); + end + + % Unzip to temp folder: + unzip(lexzipname, target); +end