-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_gcs_organized.m
51 lines (38 loc) · 1.38 KB
/
build_gcs_organized.m
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
function build_gcs_organized()
% Written by David Rebhuhn, 10-24-2014
%
% This function builds the currently selected SIMULINK system with the
% SIMULINK real time coder, saving all generated code to a sub-directory
% called 'ProjectBuildFiles'. This does this independently of what the
% present working directory (pwd) is in order to minimize the number of
% times useless or redundant files are generated.
%
% Put this in the directory you want to generate
% ProjectBuildFiles/YOURPROJECT into. This function will automatically
% generate a folder with your compiled code in it named after the system.
oldDirectory = pwd;
project_name = gcs;
[filePath, ~, ~] = fileparts(mfilename('fullpath'));
% The following function locates all of the build files for a given model
% to a sub folder of this program. This feature helps avoid building
% project files where we don't want them.
saveDir = fullfile(filePath, 'ProjectBuildFiles',project_name);
disp(['Saving to ',saveDir]);
% Creates a sub-folder in builds if it needs to be created
if exist(saveDir,'dir') ~= 7
mkdir(saveDir)
end
addpath(saveDir);
% Changes directory to this folder
cd(saveDir);
try
% Builds the last selected system.
rtwbuild(gcs);
catch err
% Returns to the original directory in the event of a failure.
cd(oldDirectory);
rethrow(err);
end
% Returns to the original directory.
cd(oldDirectory);
end