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

« back to all changes in this revision

Viewing changes to src/plugins/scriptedwizard/resources/sdl/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
// SDL project wizard
 
4
//
 
5
////////////////////////////////////////////////////////////////////////////////
 
6
 
 
7
// globals (used under windows only)
 
8
SDLPathDefault    <- _T("$(#sdl)");
 
9
SDLPathDefaultInc <- _T("$(#sdl.include)");
 
10
SDLPathDefaultLib <- _T("$(#sdl.lib)");
 
11
SDLPath           <- _T("");
 
12
 
 
13
function BeginWizard()
 
14
{
 
15
    local intro_msg = _T("Welcome to the new SDL project wizard!\n\n" +
 
16
                         "This wizard will guide you to create a new project\n" +
 
17
                         "using the SDL graphics library.\n\n" +
 
18
                         "When you 're ready to proceed, please click \"Next\"...");
 
19
 
 
20
    local sdlpath_descr = _T("Please select the location of SDL on your computer.\n" +
 
21
                             "This is the top-level folder where SDL was installed (unpacked).\n" +
 
22
                             "To help you, this folder must contain the subfolders\n" +
 
23
                             "\"include\" and \"lib\".");
 
24
 
 
25
    Wizard.AddInfoPage(_T("SDLIntro"), intro_msg);
 
26
    Wizard.AddProjectPathPage();
 
27
    if (PLATFORM == PLATFORM_MSW)
 
28
        Wizard.AddGenericSelectPathPage(_T("SDLPath"), sdlpath_descr, _T("Please select SDL's location:"), SDLPathDefault);
 
29
    Wizard.AddCompilerPage(_T(""), _T("*"), true, true);
 
30
}
 
31
 
 
32
////////////////////////////////////////////////////////////////////////////////
 
33
// SDL's path page
 
34
////////////////////////////////////////////////////////////////////////////////
 
35
 
 
36
function OnLeave_SDLPath(fwd)
 
37
{
 
38
    if (fwd)
 
39
    {
 
40
        local dir         = Wizard.GetTextControlValue(_T("txtFolder")); // txtFolder is the text control in GenericSelectPathPage
 
41
        local dir_nomacro = VerifyDirectory(dir);
 
42
 
 
43
        if (dir_nomacro.IsEmpty())
 
44
            return false;
 
45
 
 
46
        // verify include dependencies
 
47
        local dir_nomacro_inc = GetCompilerIncludeDir(dir, SDLPathDefault, SDLPathDefaultInc);
 
48
        if (dir_nomacro_inc.IsEmpty())
 
49
            return false;
 
50
        if (!VerifyFile(dir_nomacro_inc, _T("SDL.h"), _T("SDL's include")))
 
51
            return false;
 
52
 
 
53
        // verify library dependencies
 
54
        local dir_nomacro_lib = GetCompilerLibDir(dir, SDLPathDefault, SDLPathDefaultLib);
 
55
        if (dir_nomacro_lib.IsEmpty())
 
56
            return false;
 
57
 
 
58
        if (!VerifyLibFile(dir_nomacro_lib, _T("SDLmain"), _T("SDL's")))
 
59
            return false;
 
60
 
 
61
        if (!VerifyLibFile(dir_nomacro_lib, _T("SDL.dll"), _T("SDL's")))
 
62
            return false;
 
63
 
 
64
        SDLPath = dir; // Remember the original selection.
 
65
 
 
66
        local is_macro = _T("");
 
67
 
 
68
        // try to resolve the include directory as macro
 
69
        is_macro = GetCompilerIncludeMacro(dir, SDLPathDefault, SDLPathDefaultInc);
 
70
        if (is_macro.IsEmpty())
 
71
        {
 
72
            // not possible -> use the real inc path we had computed instead
 
73
            SDLPathDefaultInc = dir_nomacro_inc;
 
74
        }
 
75
 
 
76
        // try to resolve the library directory as macro
 
77
        is_macro = GetCompilerLibMacro(dir, SDLPathDefault, SDLPathDefaultLib);
 
78
        if (is_macro.IsEmpty())
 
79
        {
 
80
            // not possible -> use the real lib path we had computed instead
 
81
            SDLPathDefaultLib = dir_nomacro_lib;
 
82
        }
 
83
    }
 
84
    return true;
 
85
}
 
86
 
 
87
// return the files this project contains
 
88
function GetFilesDir()
 
89
{
 
90
    return _T("sdl/files");
 
91
}
 
92
 
 
93
// setup the already created project
 
94
function SetupProject(project)
 
95
{
 
96
    if (PLATFORM == PLATFORM_MSW)
 
97
    {
 
98
        project.AddIncludeDir(SDLPathDefaultInc);
 
99
        project.AddLibDir(SDLPathDefaultLib);
 
100
 
 
101
        // add link libraries
 
102
        project.AddLinkLib(_T("mingw32"));
 
103
        project.AddLinkLib(_T("SDLmain"));
 
104
        project.AddLinkLib(_T("SDL.dll"));
 
105
        project.AddLinkLib(_T("user32"));
 
106
        project.AddLinkLib(_T("gdi32"));
 
107
        project.AddLinkLib(_T("winmm"));
 
108
        project.AddLinkLib(_T("dxguid"));
 
109
    }
 
110
    else if (PLATFORM == PLATFORM_MAC)
 
111
    {
 
112
        //project.AddCompilerOption(_T("-D_GNU_SOURCE=1 -D_THREAD_SAFE"));
 
113
        project.AddLinkerOption(_T("-framework SDL"));
 
114
        // libSDLmain.a does not exist by default, needs to be built from SDLMain.m:
 
115
        project.AddLinkLib(_T("SDLmain"));
 
116
 
 
117
        project.AddLinkerOption(_T("-framework Cocoa")); // SDL dependency
 
118
    }
 
119
    else
 
120
    {
 
121
        // unix way
 
122
        project.AddCompilerOption(_T("`sdl-config --cflags`"));
 
123
        project.AddLinkerOption(_T("`sdl-config --libs`"));
 
124
    }
 
125
 
 
126
    // enable compiler warnings (project-wide)
 
127
    WarningsOn(project, Wizard.GetCompilerID());
 
128
 
 
129
    // Debug
 
130
    local target = project.GetBuildTarget(Wizard.GetDebugName());
 
131
    if (!IsNull(target))
 
132
    {
 
133
        target.SetTargetType(ttConsoleOnly); // ttConsoleOnly: console for debugging
 
134
        target.SetOutputFilename(Wizard.GetDebugOutputDir() + Wizard.GetProjectName() + DOT_EXT_EXECUTABLE);
 
135
        // enable generation of debugging symbols for target
 
136
        DebugSymbolsOn(target, Wizard.GetCompilerID());
 
137
    }
 
138
 
 
139
    // Release
 
140
    target = project.GetBuildTarget(Wizard.GetReleaseName());
 
141
    if (!IsNull(target))
 
142
    {
 
143
        target.SetTargetType(ttExecutable); // ttExecutable: no console
 
144
        target.SetOutputFilename(Wizard.GetReleaseOutputDir() + Wizard.GetProjectName() + DOT_EXT_EXECUTABLE);
 
145
        // enable optimizations for target
 
146
        OptimizationsOn(target, Wizard.GetCompilerID());
 
147
    }
 
148
 
 
149
    return true;
 
150
}