Skip to content

Commit

Permalink
managementtools: Add setup function for LexActivator SDK and runtime …
Browse files Browse the repository at this point in the history
…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...
  • Loading branch information
kleinerm committed Nov 25, 2024
1 parent 613627f commit f7a15b7
Showing 1 changed file with 101 additions and 0 deletions.
101 changes: 101 additions & 0 deletions managementtools/downloadlexactivator.m
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f7a15b7

Please sign in to comment.