~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/plugins/scriptedwizard/resources/matlab_csf/wizard.script

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
////////////////////////////////////////////////////////////////////////////////
 
2
//
 
3
// Matlab S-Function project wizard
 
4
//
 
5
////////////////////////////////////////////////////////////////////////////////
 
6
 
 
7
// globals
 
8
MatlabPath <- _T("");
 
9
 
 
10
function BeginWizard()
 
11
{
 
12
  local intro_msg = _T("Welcome to the new Matlab C-S-Function project wizard!\n\n" +
 
13
                       "This wizard will guide you to create a new project\n" +
 
14
                       "creating a Matlab C-S-Function using the GCC\n" +
 
15
                       "or Matlab LCC compiler.\n\n" +
 
16
                       "For GCC you must have converted the Matlab DLL's into\n" +
 
17
                       "GCC compatible libraries using the DLLTOOL before.\n" +
 
18
                       "This wizard expects the GCC libraries at the location:\n" +
 
19
                       "[MATLAB]/extern/lib/win32/gcc\n\n" +
 
20
                       "When you're ready to proceed, please click \"Next\"...");
 
21
 
 
22
  local matlabpath_descr = _T("Please select the location of Matlab on your computer.\n" +
 
23
                              "This is the top-level folder where Matlab was installed.");
 
24
 
 
25
  Wizard.AddInfoPage(_T("MatlabCSFIntro"), intro_msg); // intro
 
26
  Wizard.AddProjectPathPage();
 
27
  Wizard.AddCompilerPage(_T(""), _T("gcc;lcc"), true, false); // compiler selection but no path selection
 
28
  Wizard.AddGenericSelectPathPage(_T("MatlabPath"), matlabpath_descr, _T("Please select Matlab's location:"), _T("$(#matlab)"));
 
29
  Wizard.AddPage(_T("MatlabHint"));
 
30
}
 
31
 
 
32
////////////////////////////////////////////////////////////////////////////////
 
33
// Matlab's path page
 
34
////////////////////////////////////////////////////////////////////////////////
 
35
 
 
36
function OnLeave_MatlabPath(fwd)
 
37
{
 
38
  if (fwd)
 
39
  {
 
40
    local dir         = Wizard.GetTextControlValue(_T("txtFolder")); // txtFolder is the text control in GenericSelectPathPage
 
41
    local dir_nomacro = ReplaceMacros(dir, true);
 
42
    if (!IO.DirectoryExists(dir_nomacro))
 
43
    {
 
44
      ShowError(_T("Please select a valid path to Matlab..."));
 
45
      return false;
 
46
    }
 
47
    // Verify Matlab extern includes
 
48
    if (!IO.DirectoryExists(dir_nomacro + _T("/extern/include")))
 
49
    {
 
50
      ShowError(_T("The Matlab path you entered seems valid, but this wizard\n" +
 
51
                   "can't locate the Matlab extern include path in the sub-directory /extern/include"));
 
52
      return false;
 
53
    }
 
54
    // Verify Matlab extern tmwtypes.h (Simulink types)
 
55
    if (!IO.FileExists(dir_nomacro + _T("/extern/include/tmwtypes.h")))
 
56
    {
 
57
      ShowError(_T("The Matlab extern path seems valid, but this wizard\n" +
 
58
                   "can't locate the Matlab twmtypes.h in it."));
 
59
      return false;
 
60
    }
 
61
    // Verify Simulink includes
 
62
    if (!IO.DirectoryExists(dir_nomacro + _T("/simulink/include")))
 
63
    {
 
64
      ShowError(_T("The Matlab path you entered seems valid, but this wizard\n" +
 
65
                   "can't locate the Simulink include path in the sub-directory\n"
 
66
                   "/simulink/include"));
 
67
      return false;
 
68
    }
 
69
    // Verify Matlab extern tmwtypes.h (Simulink types)
 
70
    if (!IO.FileExists(dir_nomacro + _T("/simulink/include/simstruc.h")))
 
71
    {
 
72
      ShowError(_T("The Matlab-Simulink include path seems valid, but this wizard\n" +
 
73
                   "can't locate the Matlab simstruc.h in it."));
 
74
      return false;
 
75
    }
 
76
 
 
77
    if (Wizard.GetCompilerID().Matches(_T("lcc")))
 
78
    {
 
79
      // Verify LCC includes
 
80
      if (!IO.DirectoryExists(dir_nomacro + _T("/sys/lcc/include")))
 
81
      {
 
82
        ShowError(_T("The Matlab path you entered seems valid, but this wizard\n" +
 
83
                     "can't locate the LCC include path in the sub-directory\n" +
 
84
                     "/sys/lcc/include"));
 
85
        return false;
 
86
      }
 
87
      // Verify LCC libraries
 
88
      if (!IO.DirectoryExists(dir_nomacro + _T("/extern/lib/win32/lcc")))
 
89
      {
 
90
        ShowError(_T("The Matlab path you entered seems valid, but this wizard\n" +
 
91
                     "can't locate the LCC library path in the sub-directory\n" +
 
92
                     "/extern/lib/win32/lcc"));
 
93
        return false;
 
94
      }
 
95
    }
 
96
    else if (Wizard.GetCompilerID().Matches(_T("gcc")))
 
97
    {
 
98
      // Verify GCC libraries
 
99
      if (!IO.DirectoryExists(dir_nomacro + _T("/extern/lib/win32/gcc")))
 
100
      {
 
101
        ShowError(_T("The Matlab path you entered seems valid, but this wizard\n" +
 
102
                     "can't locate the GCC library path in the sub-directory\n" +
 
103
                     "/extern/lib/win32/gcc"));
 
104
        return false;
 
105
      }
 
106
    }
 
107
 
 
108
    MatlabPath = dir;
 
109
  }
 
110
  return true;
 
111
}
 
112
 
 
113
// return the files this project contains
 
114
function GetFilesDir()
 
115
{
 
116
  local result = _T("matlab_csf/files");
 
117
  if (Wizard.GetCompilerID().Matches(_T("lcc")))
 
118
    result += _T(";matlab_csf/lccstub");
 
119
 
 
120
  return result;
 
121
}
 
122
 
 
123
// setup the already created project
 
124
function SetupProject(project)
 
125
{
 
126
  // enable compiler warnings (project-wide)
 
127
  if (Wizard.GetCompilerID().Matches(_T("lcc")))
 
128
  {
 
129
    if (!CompilerFactory.IsValidCompilerID(_T("lcc")))
 
130
    {
 
131
      ShowError(_T("The wizard has detected that your version of Code::Blocks does not\n" +
 
132
                   "support the LCC compiler which is required for this project.\n" +
 
133
                   "The wizard cannot continue. Please update Code::Blocks."));
 
134
      return false;
 
135
    }
 
136
 
 
137
    // set project options for LCC
 
138
    project.SetModeForPCH(pchSourceDir);
 
139
    project.AddCompilerOption(_T("-Zp8"));              // 8 byte alignment
 
140
    project.AddCompilerOption(_T("-noregistrylookup")); // do not query the registry for libpath
 
141
 
 
142
    project.AddLinkerOption(_T("-s"));
 
143
    project.AddLinkerOption(_T("-tmpdir \".\""));
 
144
    project.AddLinkerOption(_T("-libpath ") + MatlabPath + _T("\\extern\\lib\\win32\\lcc"));
 
145
    project.AddLinkerOption(MatlabPath + _T("\\extern\\lib\\win32\\lcc\\mexFunction.def"));
 
146
  }
 
147
  else if (Wizard.GetCompilerID().Matches(_T("gcc")))
 
148
  {
 
149
    // set project options for GCC
 
150
    project.SetModeForPCH(pchSourceDir);
 
151
    project.AddCompilerOption(_T("-malign-double"));    // 8 byte alignment
 
152
    project.AddCompilerOption(_T("-fno-exceptions"));   // exception free code
 
153
 
 
154
    project.AddLinkerOption(_T("-shared"));
 
155
    project.AddLinkerOption(_T("-Wl,--out-implib=sfuntmpl")+DOT_EXT_STATICLIB);
 
156
    project.AddLibDir(MatlabPath + _T("/extern/lib/win32/gcc"));
 
157
  }
 
158
  else
 
159
  {
 
160
    ShowError(_T("The selected compiler is not compatible with Matlab.\n" +
 
161
                 "The wizard cannot continue."));
 
162
    return false;
 
163
  }
 
164
 
 
165
  // set common project options (the same for both compilers)
 
166
  project.AddCompilerOption(_T("-DNDEBUG"));
 
167
  project.AddCompilerOption(_T("-DMATLAB_MEX_FILE"));
 
168
 
 
169
  project.AddIncludeDir(MatlabPath + _T("\\extern\\include"));
 
170
  project.AddIncludeDir(MatlabPath + _T("\\simulink\\include"));
 
171
 
 
172
  project.AddLinkLib(_T("libmx"));
 
173
  project.AddLinkLib(_T("libmex"));
 
174
  project.AddLinkLib(_T("libmatlb"));
 
175
  project.AddLinkLib(_T("libmat"));
 
176
 
 
177
  // Debug
 
178
  local target = project.GetBuildTarget(Wizard.GetDebugName());
 
179
  if (!IsNull(target))
 
180
  {
 
181
    target.SetTargetType(ttDynamicLib);
 
182
    // the s-function DLL must have the same name as the file/function
 
183
    target.SetOutputFilename(_T("sfuntmpl") + DOT_EXT_DYNAMICLIB);
 
184
    target.SetWorkingDir(_T("."));
 
185
 
 
186
    if (Wizard.GetCompilerID().Matches(_T("lcc")))
 
187
    {
 
188
      // It only works that way because the LCC resource compiler does not
 
189
      // support creating it's "object files" (*.res) in any sub-directory
 
190
      target.SetObjectOutput(_T(".")); //
 
191
    }
 
192
  }
 
193
 
 
194
  // Release
 
195
  target = project.GetBuildTarget(Wizard.GetReleaseName());
 
196
  if (!IsNull(target))
 
197
  {
 
198
    target.SetTargetType(ttDynamicLib);
 
199
    // the s-function DLL must have the same name as the file/function
 
200
    target.SetOutputFilename(_T("sfuntmpl") + DOT_EXT_DYNAMICLIB);
 
201
    target.SetWorkingDir(_T("."));
 
202
 
 
203
    if (Wizard.GetCompilerID().Matches(_T("lcc")))
 
204
    {
 
205
      // It only works that way because the LCC resource compiler does not
 
206
      // support creating it's "object files" (*.res) in any sub-directory
 
207
      target.SetObjectOutput(_T(".")); //
 
208
    }
 
209
  }
 
210
 
 
211
  return true;
 
212
}