-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_d3dmatlab.m
More file actions
179 lines (159 loc) · 5.07 KB
/
make_d3dmatlab.m
File metadata and controls
179 lines (159 loc) · 5.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
function make_d3dmatlab(basedir,varargin)
%MAKE_D3DMATLAB Prepare Delft3D-MATLAB toolbox for distribution
% Prepare the files for distribution as Delft3D-MATLAB toolbox.
%
% MAKE_D3DMATLAB(BASEDIR)
% Use specified directory instead of current directory as base directory
%----- LGPL --------------------------------------------------------------------
%
% Copyright (C) 2011-2026 Stichting Deltares.
%
% This library is free software; you can redistribute it and/or
% modify it under the terms of the GNU Lesser General Public
% License as published by the Free Software Foundation version 2.1.
%
% This library is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
% Lesser General Public License for more details.
%
% You should have received a copy of the GNU Lesser General Public
% License along with this library; if not, see <http://www.gnu.org/licenses/>.
%
% contact: delft3d.support@deltares.nl
% Stichting Deltares
% P.O. Box 177
% 2600 MH Delft, The Netherlands
%
% All indications and logos of, and references to, "Delft3D" and "Deltares"
% are registered trademarks of Stichting Deltares, and remain the property of
% Stichting Deltares. All rights reserved.
%
%-------------------------------------------------------------------------------
% http://www.deltaressystems.com
% $HeadURL$
% $Id$
curdir = pwd;
addpath(curdir)
%
% comment lines for
% consistency with
% make_quickplot and
% make_ecoplot
%
if nargin>0
cd(basedir);
end
err = [];
try
localmake(varargin{:});
catch err
end
if nargin>0
cd(curdir);
end
rmpath(curdir)
if ~isempty(err)
rethrow(err)
end
function localmake(varargin)
if ~exist('progsrc','dir')
error('Cannot locate source folder "progsrc".')
end
sourcedir=[pwd,filesep,'progsrc'];
% set defaults
[qpversion,hash,repo_url] = get_qpversion;
T = now;
% overrule using input arguments
for i = 1:2:length(varargin)
switch (varargin{i})
case 'version'
qpversion = varargin{i+1};
case 'url'
repo_url = varargin{i+1};
case 'hash'
hash = varargin{i+1};
case 'time'
T = varargin{i+1};
case 'release'
release = varargin{i+1};
otherwise
error('Unknown argument: %s',varargin{i})
end
end
tdir = 'delft3d_matlab';
targetname = 'Delft3D-MATLAB interface';
targetdir = [pwd,filesep,tdir];
if ~exist(targetdir, 'dir')
fprintf('Creating %s directory ...\n', tdir);
mkdir(tdir);
end
cd(tdir)
% diary make_quickplot_diary % no diary to avoid clutter in the distribution folder ...
fprintf('Copying files ...\n');
exportsrc(sourcedir,targetdir)
fprintf('Including netCDF files ...\n');
if ~exist('netcdf','dir')
mkdir('netcdf');
end
copyfile('../../../../third_party_open/netcdf/matlab/netcdfAll-4.1.jar','netcdf')
if ~exist('netcdf/mexnc','dir')
mkdir('netcdf/mexnc');
exportsrc('../../../../third_party_open/netcdf/matlab/mexnc', 'netcdf/mexnc')
end
if ~exist('netcdf/snctools','dir')
mkdir('netcdf/snctools');
exportsrc('../../../../third_party_open/netcdf/matlab/snctools', 'netcdf/snctools')
end
% strip off the platform flag (binaries for Windows and Linux are included)
% ... but don't strip of (changed)
% ... the platform is the last string between brackets
brackets = strfind(qpversion,'(');
qpversion = qpversion(1:max(brackets)-2);
% for the progress statement add the platform statement
qpversion_ = [qpversion, ' (all platforms)'];
DateStr = datestr(floor(T));
DateTimeStr = datestr(T);
fprintf('\nBuilding %s version %s\n\n', targetname, qpversion_);
fprintf('Current date and time : %s\n', DateTimeStr);
fprintf('Modifying files ...\n');
fstrrep([targetdir,filesep,'d3d_qp.m'], '<VERSION>', qpversion)
fstrrep([targetdir,filesep,'d3d_qp.m'], '<CREATIONDATE>', DateTimeStr)
fstrrep([targetdir,filesep,'d3d_qp.m'], '<GITHASH>', hash)
fstrrep([targetdir,filesep,'d3d_qp.m'], '<GITREPO>', repo_url)
fstrrep([targetdir,filesep,'Contents.m'], '<VERSION>', qpversion)
fstrrep([targetdir,filesep,'Contents.m'], '<RELEASE>', release)
fstrrep([targetdir,filesep,'Contents.m'], '<CREATIONDATE>', DateStr) % MATLAB toolboxes don't have a time stamp
fprintf('Add source information to all files ...\n');
Keywords.HeadURL = ['Source ', repo_url, ': ', hash];
Keywords.Id = ['Release ', release, ': ', DateTimeStr];
process_keywords(targetdir, Keywords)
fprintf('Cleaning up directory ...\n');
X = {'*.asv'
'*.bak'
'*.scc'
'bin'
'compileonly'};
cleanup(X)
fprintf('Removing unneeded subdirectories ...\n');
X = {'org'};
cleanup(X)
cd ..
fprintf('Finished.\n');
function exportsrc(sourcedir,targetdir)
d = dir(sourcedir);
for i = 1:length(d)
source = [sourcedir filesep d(i).name];
target = [targetdir filesep d(i).name];
if d(i).isdir
switch d(i).name
case {'.','..'}
% skip
otherwise
mkdir(target);
exportsrc(source,target)
end
else
copyfile(source,target)
end
end