Skip to content

Commit

Permalink
improve install cocosim script to take into account no access to the …
Browse files Browse the repository at this point in the history
…internet
  • Loading branch information
hbourbouh committed Sep 24, 2020
1 parent e6972ea commit 524cbf0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
18 changes: 11 additions & 7 deletions scripts/install_cocosim_lib.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,21 @@ function install_cocosim_lib(force)
force = false;
end
if install_cocosim_already_run && ~force
fprintf('Install CoCoSim external libraries is already run and will be ignored.\nTo force it run "install_cocosim_lib(true)" in your Matlab Command Window.\n')
return;
end
PWD = pwd;
scripts_path = fileparts(mfilename('fullpath'));
cocosim_path = fileparts(scripts_path);
%% install binaries: Zustre, Kind2, Lustrec, Z3 ...
install_tools(cocosim_path);

%% the following requires internet access.
[status, ~] = system('ping -c1 -q google.com');
if status
%No netwrok connexion
fprintf(['No interent connexion. Repository will not be updated and '...
'\n External libraries should be manually added.'])
fprintf(['No interent connexion. Repository will not be updated.\n'...
'If it''s your first run of CoCoSim, external libraries should be manually added if you don''t have access to the internet.\n'])
return;
end
[status, ~] = system('git help');
Expand All @@ -81,16 +88,13 @@ function install_cocosim_lib(force)
'setenv(''PATH'', [getenv(''PATH'') '';C:\\Program Files\\Git\\cmd''])\n'])
return;
end
scripts_path = fileparts(mfilename('fullpath'));
cocosim_path = fileparts(scripts_path);
%% update cocosim
updateRepo(cocosim_path)
%% copy files from cocosim in github
copyCoCoFiles(force, cocosim_path);
%% copy file from external libraries : Autolayout, cmd_timeout, html_lib
copyExternalLibFiles(force, cocosim_path);
%% install binaries: Zustre, Kind2, Lustrec, Z3 ...
install_tools(cocosim_path);


cd(PWD);
end
Expand Down Expand Up @@ -284,7 +288,7 @@ function copyExternalLibFiles(force, cocosim_path)
% catch ME
% switch ME.identifier
% case 'MATLAB:fileread:cannotOpenFile'
% fprintf('Patch failed: Can''t open file %s', file_path);
% fprintf('Patch failed: Can''t open file %s\n', file_path);
% otherwise
% rethrow(ME)
% end
Expand Down
14 changes: 10 additions & 4 deletions start_cocosim.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,18 @@ function start_cocosim( )
disp('... Starting cocoSim configuration')
[cocoSim_root, ~, ~] = fileparts(mfilename('fullpath'));
addpath(fullfile(cocoSim_root, 'scripts'));
% Enable this to update cocosim repo, or call it directly from workspace
display_msg_path = fullfile(cocoSim_root, 'src', 'external', 'cocosim_iowa', 'utils', 'display_msg.m');
if ~exist(display_msg_path, 'file')
% external libraries are missing

% Update CoCoSim Repo
%display_msg_path = fullfile(cocoSim_root, 'src', 'external', 'cocosim_iowa', 'utils', 'display_msg.m');
%if ~exist(display_msg_path, 'file')
% external libraries are missing
try
install_cocosim_lib();
catch
fprintf('Install CoCoSim external libraries failed. Ignore it if your CoCoSim has all required files.')
end
%end

cocosim_config;
warning('off');
sl_refresh_customizations;
Expand Down
1 change: 1 addition & 0 deletions tools/tools_config.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
end
if tools_config_already_run && ~isempty(LUSTREC) && ~isempty(KIND2)...
&& ~isempty(Z3) && ~isempty(YICES2)
fprintf('Tools config is already run and will be ignored.\nTo force it run "tools_config" in your Matlab Command Window.\n')
%already run
else
[tools_root, ~, ~] = fileparts(which('tools_config')); %fileparts(mfilename('fullpath'));
Expand Down

0 comments on commit 524cbf0

Please sign in to comment.