]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/commitdiff
Added hook for file copying in code generation folder. Using 4 spaces identation...
authorCarlos Jenkins <carlos@jenkins.co.cr>
Mon, 13 May 2013 11:53:16 +0000 (13:53 +0200)
committerCarlos Jenkins <carlos@jenkins.co.cr>
Mon, 13 May 2013 11:53:16 +0000 (13:53 +0200)
rpp/rpp/rpp_make_rtw_hook.m [new file with mode: 0644]
rpp/rpp/rpp_select_callback_handler.m

diff --git a/rpp/rpp/rpp_make_rtw_hook.m b/rpp/rpp/rpp_make_rtw_hook.m
new file mode 100644 (file)
index 0000000..ba3fb8e
--- /dev/null
@@ -0,0 +1,98 @@
+% Copyright (C) 2013 Czech Technical University in Prague\r
+%\r
+% Authors:\r
+%      - Carlos Jenkins <carlos@jenkins.co.cr>\r
+%\r
+% This program is free software; you can redistribute it and/or modify\r
+% it under the terms of the GNU General Public License as published by\r
+% the Free Software Foundation; either version 2 of the License, or\r
+% (at your option) any later version.\r
+%\r
+% This program is distributed in the hope that it will be useful,\r
+% but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+% GNU General Public License for more details.\r
+%\r
+% You should have received a copy of the GNU General Public License\r
+% along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+%\r
+% File : rpp_make_rtw_hook.m\r
+% Abstract:\r
+%       This file is hook file that invoke target-specific functions or\r
+%       executables at specified points in the build process. In particular,\r
+%       this file handle the copying of required files before the compilation\r
+%       stage.\r
+%       Reference: rtw_ug.pdf p. 1066-1072 and 1131\r
+\r
+\r
+function rpp_make_rtw_hook(hookMethod, modelName, rtwRoot, templateMakefile, ...\r
+                           buildOpts, buildArgs)\r
+\r
+    switch hookMethod\r
+        case 'error'\r
+            % Called if an error occurs anywhere during the build. If no error\r
+            % occurs during the build, then this hook will not be called. Valid\r
+            % arguments at this stage are hookMethod and modelName. This enables\r
+            % cleaning up any static or global data used by this hook file.\r
+            disp(['### Build procedure for model: ''', modelName, ...\r
+                  ''' aborted due to an error.']);\r
+\r
+        case 'entry'\r
+            % Called at start of code generation process (before anything\r
+            % happens).\r
+            % Valid arguments at this stage are hookMethod, modelName, and\r
+            % buildArgs.\r
+\r
+        case 'before_tlc'\r
+            % Called just prior to invoking TLC Compiler (actual code\r
+            % generation).\r
+            % Valid arguments at this stage are hookMethod, modelName, and\r
+            % buildArgs.\r
+\r
+        case 'after_tlc'\r
+            % Called just after to invoking TLC Compiler (actual code\r
+            % generation).\r
+            % Valid arguments at this stage are hookMethod, modelName, and\r
+            % buildArgs.\r
+\r
+            % FIXME: Implement model tasking mode check?\r
+\r
+        case 'before_make'\r
+            % Called after code generation is complete, and just prior to\r
+            % kicking off make process (assuming code generation only is not\r
+            % selected). All arguments are valid at this stage.\r
+\r
+            % Copy extra makefiles and library files to code generation\r
+            % directory\r
+            i_write_rpp_files();\r
+\r
+        case 'after_make'\r
+            % Called after make process is complete. All arguments are valid at\r
+            % this stage.\r
+\r
+            % FIXME: Implement here download to RPP hardware.\r
+            % Use buildArgs to check if download is requested.\r
+\r
+        case 'exit'\r
+            % Called at the end of the build process.  All arguments are valid\r
+            % at this stage.\r
+            disp(['### Successful completion of build ', ...\r
+                  'procedure for model: ', modelName]);\r
+\r
+    end\r
+\r
+\r
+function i_write_rpp_files\r
+\r
+    lCodeGenFolder = Simulink.fileGenControl('getConfig').CodeGenFolder;\r
+    buildAreaDstFolder = fullfile(lCodeGenFolder, 'slprj');\r
+\r
+    % Copy the RPP version of target_tools.mk into the build area\r
+    tgtToolsFile = 'target_tools.mk';\r
+    targetToolsFolder = fileparts(mfilename('fullpath'));\r
+    srcFile = fullfile(targetToolsFolder, tgtToolsFile);\r
+    dstFile = fullfile(buildAreaDstFolder, tgtToolsFile);\r
+    copyfile(srcFile, dstFile, 'f');\r
+    % Make sure the file is not read-only\r
+    fileattrib(dstFile, '+w');\r
+\r
index 68200f8b1981c220d2a4e43afb5ac1fd38810719..eea923d17951b3f6aed9ef49fe805fb201e9de6b 100644 (file)
 
 function rpp_select_callback_handler(hDlg, hSrc)
 
-  % The target is model reference compliant
-  slConfigUISetVal(hDlg, hSrc, 'ModelReferenceCompliant', 'on');
-  slConfigUISetEnabled(hDlg, hSrc, 'ModelReferenceCompliant', false);
+    % The target is model reference compliant
+    slConfigUISetVal(hDlg, hSrc, 'ModelReferenceCompliant', 'on');
+    slConfigUISetEnabled(hDlg, hSrc, 'ModelReferenceCompliant', false);
 
-  % Hardware being used is the production hardware
-  slConfigUISetVal(hDlg, hSrc, 'ProdEqTarget', 'on');
+    % Hardware being used is the production hardware
+    slConfigUISetVal(hDlg, hSrc, 'ProdEqTarget', 'on');
 
-  % Set the target language to C and disable modification
-  slConfigUISetVal(hDlg, hSrc, 'TargetLang', 'C');
-  slConfigUISetEnabled(hDlg, hSrc, 'TargetLang', 0);
+    % Set the target language to C and disable modification
+    slConfigUISetVal(hDlg, hSrc, 'TargetLang', 'C');
+    slConfigUISetEnabled(hDlg, hSrc, 'TargetLang', 0);
 
-  % Set the TargetLibSuffix
-  slConfigUISetVal(hDlg, hSrc, 'TargetLibSuffix', '.a');
+    % Set the TargetLibSuffix
+    slConfigUISetVal(hDlg, hSrc, 'TargetLibSuffix', '.a');
 
-  % For real-time builds, we must generate ert_main.c
-  slConfigUISetVal(hDlg, hSrc, 'ERTCustomFileTemplate', 'rpp_file_process.tlc');
+    % For real-time builds, we must generate ert_main.c
+    slConfigUISetVal(hDlg, hSrc, 'ERTCustomFileTemplate', 'rpp_file_process.tlc');