~ubuntu-branches/ubuntu/hardy/codeblocks/hardy-backports

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Michael Casadevall
  • Date: 2008-07-17 04:39:23 UTC
  • Revision ID: james.westby@ubuntu.com-20080717043923-gmsy5cwkdjswghkm
Tags: upstream-8.02
ImportĀ upstreamĀ versionĀ 8.02

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
////////////////////////////////////////////////////////////////////////////////
 
2
//
 
3
// Lightfeather project wizard
 
4
//
 
5
////////////////////////////////////////////////////////////////////////////////
 
6
 
 
7
// globals
 
8
LFPath <- _T("");
 
9
LFQuickProject <- false;
 
10
 
 
11
//options
 
12
LF_NVidiaCg <- GetConfigManager().Read(_T("/lf_project_wizard/options/cgshaders"), true);
 
13
LF_NGPlant <- GetConfigManager().Read(_T("/lf_project_wizard/options/ngplant"), true);
 
14
LF_Net <- GetConfigManager().Read(_T("/lf_project_wizard/options/net"), false);
 
15
LF_WxCanvas <- GetConfigManager().Read(_T("/lf_project_wizard/options/wxcanvas"), false);
 
16
LF_LocalConfig <- GetConfigManager().Read(_T("/lf_project_wizard/options/localconfig"), false);
 
17
// TODO: lf-static
 
18
 
 
19
function BeginWizard()
 
20
{
 
21
    // intro text
 
22
    local intro_msg = _T("Welcome to the new Lightfeather project wizard!\n\n" +
 
23
                        "This wizard will guide you to create a new project\n" +
 
24
                        "using the Lightfeather 3D rendering engine.\n\n" +
 
25
                        "When you 're ready to proceed, please click \"Next\"...");
 
26
 
 
27
    // "select LF path" text
 
28
    local lfpath_descr = _T("Please select the location of Lightfeather on your computer.\n" +
 
29
                              "This is the top-level folder where Lightfeather was installed\n(unpacked).\n");
 
30
 
 
31
    // "select LF project to generate" text
 
32
    local lfprjtype_descr = _T("Please select the type of project to generate.");
 
33
    local lfprj_choices = _T("Structured with C++ classes;Quick single-file testbed");
 
34
 
 
35
    Wizard.AddInfoPage(_T("LFIntro"), intro_msg);
 
36
    Wizard.AddProjectPathPage();
 
37
    Wizard.AddGenericSelectPathPage(_T("LFPath"), lfpath_descr, _T("Please select Lightfeather's location:"), _T(""));
 
38
    Wizard.AddGenericSingleChoiceListPage(_T("LFPrjType"), lfprjtype_descr, lfprj_choices, 0);
 
39
    Wizard.AddPage(_T("LfOptions"));
 
40
//    Wizard.AddCompilerPage(_T(""), _T("gcc*"), true, false); // no target selections
 
41
    Wizard.SetCompilerDefault(_T("gcc"));
 
42
    Wizard.SetDebugTargetDefaults(true, _T("Debug"), _T("Debug/"), _T("Debug/"));
 
43
    Wizard.SetReleaseTargetDefaults(false, _T(""), _T(""), _T(""));
 
44
}
 
45
 
 
46
////////////////////////////////////////////////////////////////////////////////
 
47
// Lightfeather's path page
 
48
////////////////////////////////////////////////////////////////////////////////
 
49
 
 
50
function OnLeave_LFPath(fwd)
 
51
{
 
52
    if (fwd)
 
53
    {
 
54
        // error string
 
55
        local error =_T("The path you entered seems valid, but this wizard " +
 
56
                        "can't locate Lightfeather's files in it...");
 
57
 
 
58
        local dir         = Wizard.GetTextControlValue(_T("txtFolder")); // txtFolder is the text control in GenericSelectPathPage
 
59
        local dir_nomacro = ReplaceMacros(dir, true);
 
60
        
 
61
        // check for include files
 
62
        if (!IO.FileExists(dir_nomacro + _T("/include/lf/Lightfeather.h")))
 
63
        {
 
64
            ShowError(error);
 
65
            return false;
 
66
        }
 
67
 
 
68
        LFPath = dir;
 
69
    }
 
70
    return true;
 
71
}
 
72
 
 
73
////////////////////////////////////////////////////////////////////////////////
 
74
// Project type to create
 
75
////////////////////////////////////////////////////////////////////////////////
 
76
 
 
77
function OnLeave_LFPrjType(fwd)
 
78
{
 
79
    if (fwd)
 
80
    {
 
81
        LFQuickProject = Wizard.GetListboxSelection(_T("GenericChoiceList")) == 1;
 
82
    }
 
83
    return true;
 
84
}
 
85
 
 
86
////////////////////////////////////////////////////////////////////////////////
 
87
// Lightfeather options
 
88
////////////////////////////////////////////////////////////////////////////////
 
89
 
 
90
function OnEnter_LfOptions(fwd)
 
91
{
 
92
        Wizard.CheckCheckbox(_T("chkCG"), LF_NVidiaCg);
 
93
        Wizard.CheckCheckbox(_T("chkNG"), LF_NGPlant);
 
94
        Wizard.CheckCheckbox(_T("chkNet"), LF_Net);
 
95
        Wizard.CheckCheckbox(_T("chkWx"), LF_WxCanvas);
 
96
        Wizard.CheckCheckbox(_T("chkLocalConfig"), LF_LocalConfig);
 
97
}
 
98
 
 
99
function OnLeave_LfOptions(fwd)
 
100
{
 
101
        LF_NVidiaCg = Wizard.IsCheckboxChecked(_T("chkCG"));
 
102
        LF_NGPlant = Wizard.IsCheckboxChecked(_T("chkNG"));
 
103
        LF_Net = Wizard.IsCheckboxChecked(_T("chkNet"));
 
104
        LF_WxCanvas = Wizard.IsCheckboxChecked(_T("chkWx"));
 
105
        LF_LocalConfig = Wizard.IsCheckboxChecked(_T("chkLocalConfig"));
 
106
 
 
107
        GetConfigManager().Write(_T("/lf_project_wizard/options/cgshaders"), LF_NVidiaCg);
 
108
        GetConfigManager().Write(_T("/lf_project_wizard/options/ngplant"), LF_NGPlant);
 
109
        GetConfigManager().Write(_T("/lf_project_wizard/options/net"), LF_Net);
 
110
        GetConfigManager().Write(_T("/lf_project_wizard/options/wxcanvas"), LF_WxCanvas);
 
111
        GetConfigManager().Write(_T("/lf_project_wizard/options/localconfig"), LF_LocalConfig);
 
112
 
 
113
    return true;
 
114
}
 
115
 
 
116
// return the files this project contains
 
117
function GetFilesDir()
 
118
{
 
119
    local ret = _T("lf/files/common;");
 
120
    if (LFQuickProject)
 
121
        ret = ret + _T("lf/files/quick");
 
122
    else
 
123
        ret = ret + _T("lf/files/structured");
 
124
    return ret;
 
125
}
 
126
 
 
127
// setup the already created project
 
128
function SetupProject(project)
 
129
{
 
130
    // set a variable to reference lf's dir
 
131
    project.SetVar(_T("lf"), LFPath, false);
 
132
 
 
133
        // set defaults for all targets
 
134
        if (PLATFORM != PLATFORM_MSW)
 
135
        {
 
136
            project.AddCompilerOption(_T("-fPIC"));
 
137
            project.AddCompilerOption(_T("-DPIC"));
 
138
        }
 
139
    project.AddCompilerOption(_T("-DPNG_NO_ASSEMBLER_CODE"));
 
140
    
 
141
    if (LF_NVidiaCg)
 
142
    {
 
143
        if (PLATFORM == PLATFORM_MSW)
 
144
        {
 
145
                        project.AddIncludeDir(_T("$(lf)/ext/Cg/include"));
 
146
                        project.AddLibDir(_T("$(lf)/ext/Cg/lib/windows"));
 
147
        }
 
148
                project.AddCompilerOption(_T("-DHAVE_CG"));
 
149
    }
 
150
    if (LF_NGPlant)
 
151
    {
 
152
        if (PLATFORM == PLATFORM_MSW)
 
153
                        project.AddLibDir(_T("$(lf)/ext/ngplant/lib/devcpp"));
 
154
                else if (PLATFORM == PLATFORM_GTK)
 
155
                {
 
156
                        project.AddLibDir(_T("$(lf)/ext/ngplant/lib/linux"));
 
157
                        project.AddLibDir(_T("$(lf)/ext/ngplant/lib/linux64"));
 
158
                }
 
159
                else
 
160
                        project.AddLibDir(_T("$(lf)/ext/ngplant/lib/mac"));
 
161
                project.AddIncludeDir(_T("$(lf)/ext/ngplant/include"));
 
162
                project.AddCompilerOption(_T("-DHAVE_NGPLANT"));
 
163
    }
 
164
    if (LF_Net)
 
165
                project.AddCompilerOption(_T("-DHAVE_NETWORK"));
 
166
    if (LF_WxCanvas)
 
167
    {
 
168
        if (PLATFORM == PLATFORM_GTK)
 
169
        {
 
170
                        project.AddCompilerOption(_T("`wx-config --cxxflags`"));
 
171
                        project.AddLinkerOption(_T("`wx-config --libs gl`"));
 
172
        }
 
173
                project.AddCompilerOption(_T("-DLF_HAVE_WX"));
 
174
    }
 
175
        if (LF_LocalConfig)
 
176
                project.AddCompilerOption(_T("-DHAVE_LOCAL_LF_CONFIG"));
 
177
        
 
178
    project.AddIncludeDir(_T("$(lf)/include"));
 
179
 
 
180
    // first rename "default" target (index 0 - could do it by name too) to "Debug"
 
181
    project.RenameBuildTarget(0, _T("Debug"));
 
182
 
 
183
    local debugTarget = project.GetBuildTarget(0);
 
184
    debugTarget.SetTargetType(ttConsoleOnly);
 
185
 
 
186
    // and now duplicate it to create the rest of the targets
 
187
    // (easier than creating new targets and adding files manually)
 
188
    project.DuplicateBuildTarget(0, _T("Release"));
 
189
    project.DuplicateBuildTarget(0, _T("Standard"));
 
190
 
 
191
    local releaseTarget = project.GetBuildTarget(1);
 
192
    local standardTarget = project.GetBuildTarget(2);
 
193
 
 
194
    // Debug
 
195
    TargetFinalSetup(debugTarget, "Debug", true, false);
 
196
 
 
197
    // Release
 
198
    TargetFinalSetup(releaseTarget, "Release", false, false);
 
199
 
 
200
    // Standard
 
201
    TargetFinalSetup(standardTarget, "Standard", true, false);
 
202
 
 
203
    return true;
 
204
}
 
205
 
 
206
function TargetFinalSetup(target, dir, isDebug, isLib)
 
207
{
 
208
        // just setup the different things per-target
 
209
    target.SetOutputFilename(_T("bin/" + dir + "/") + Wizard.GetProjectTitle());
 
210
    target.SetObjectOutput(_T("bin/obj/" + dir));
 
211
    
 
212
    target.AddLibDir(_T("$(lf)/bin/" + dir));
 
213
    
 
214
    target.AddLinkLib(_T("Lightfeather"));
 
215
    
 
216
    if (isDebug)
 
217
    {
 
218
        target.AddCompilerOption(_T("-g"));
 
219
        target.AddCompilerOption(_T("-DDEBUG"));
 
220
    }
 
221
    else
 
222
    {
 
223
        target.AddCompilerOption(_T("-O2"));
 
224
        target.AddCompilerOption(_T("-s"));
 
225
    }
 
226
    
 
227
    if (isLib)
 
228
    {
 
229
                if (LF_NVidiaCg)
 
230
                {
 
231
                        target.AddLinkLib(_T("Cg"));
 
232
                        target.AddLinkLib(_T("CgGL"));
 
233
                }
 
234
        target.AddLinkLib(_T("GL"));
 
235
        target.AddLinkLib(_T("GLU"));
 
236
        target.AddLinkLib(_T("Xxf86vm"));
 
237
        target.AddLinkLib(_T("pthread"));
 
238
    }
 
239
}