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

« back to all changes in this revision

Viewing changes to src/plugins/scriptedwizard/resources/avr/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
// Code::Blocks new project wizard script
 
4
//
 
5
// Project: Atmel AVR project
 
6
// Author:  Brian Sidebotham
 
7
//
 
8
////////////////////////////////////////////////////////////////////////////////
 
9
 
 
10
// Global Vars
 
11
Processor <- _T("");     // The chosen processor
 
12
AvrHex <- false;         // produce Hex file from ELF output ?
 
13
AvrSrec <- false;                          // produce Motorola S-Record files?
 
14
AvrBin <- false;                           // produce Binary image files?
 
15
AvrLss <- false;         // produce extended list file from ELF output?
 
16
AvrMap <- false;         // produce Symbol Map file from ELF output?
 
17
AvrExtMem <- false;      // Locate .data in on-board SRAM, or external SRAM
 
18
AvrExtMemAddr <- ""      // The external memory address
 
19
AvrSize <- false;        // Run avr-size after the build 
 
20
AvrF_CPU <- false;           // Define F_CPU?
 
21
AvrF_CPUValue <- _T(""); // F_CPU textual value
 
22
 
 
23
function BeginWizard()
 
24
{
 
25
    local wiz_type = Wizard.GetWizardType();
 
26
 
 
27
    if (wiz_type == wizProject)
 
28
    {
 
29
        local intro_msg = _T("Welcome to the new Atmel AVR project wizard!\n" +
 
30
                             "This wizard will guide you to create a new Atmel AVR project.\n\n" +
 
31
                             "When you 're ready to proceed, please click \"Next\"...");
 
32
 
 
33
        Wizard.AddInfoPage(_T("AtmelAVRIntro"), intro_msg);
 
34
        Wizard.AddProjectPathPage();
 
35
        Wizard.AddCompilerPage(_T("GNU AVR GCC Compiler"), _T("avr*"), false, true);
 
36
        Wizard.AddPage(_T("processorChoice"));        
 
37
    }
 
38
    else
 
39
        print(wiz_type);
 
40
}
 
41
 
 
42
function GetFilesDir()
 
43
{
 
44
    local result = _T("avr/files");
 
45
    return result;
 
46
}
 
47
 
 
48
////////////////////////////////////////////////////////////////////////////////
 
49
// Processor choice page
 
50
////////////////////////////////////////////////////////////////////////////////
 
51
 
 
52
 
 
53
function OnLeave_processorChoice(fwd)
 
54
{
 
55
    if (fwd)
 
56
    {
 
57
        Processor = Wizard.GetComboboxStringSelection(_T("comboboxProc"));
 
58
        AvrHex = Wizard.IsCheckboxChecked(_T("checkboxHex"));
 
59
        AvrSrec = Wizard.IsCheckboxChecked(_T("checkboxSrec"));
 
60
        AvrBin = Wizard.IsCheckboxChecked(_T("checkboxBin"));
 
61
        AvrMap = Wizard.IsCheckboxChecked(_T("checkboxMap"));
 
62
        AvrLss = Wizard.IsCheckboxChecked(_T("checkboxLss"));
 
63
        AvrExtMem = Wizard.IsCheckboxChecked(_T("checkboxExtMem"));
 
64
        AvrExtMemAddr = Wizard.GetTextControlValue(_T("textctrlExtMem"));        
 
65
        AvrSize = Wizard.IsCheckboxChecked(_T("checkboxAvrSize"));
 
66
        AvrF_CPU = Wizard.IsCheckboxChecked(_T("checkboxF_CPU"));
 
67
        AvrF_CPUValue = Wizard.GetTextControlValue(_T("textctrlF_CPU"));
 
68
    }
 
69
    return true;
 
70
}
 
71
 
 
72
function SetupProject(project)
 
73
{   
 
74
    // Linker options 
 
75
                local lo_map = ::wxString();
 
76
                local lo_extmem = ::wxString();
 
77
    
 
78
    // Post Build steps
 
79
    local pb_avrsize = ::wxString();
 
80
    local pb_eephex = ::wxString();
 
81
    local pb_hex = ::wxString();
 
82
    local pb_eepbin = ::wxString();
 
83
    local pb_bin = ::wxString();
 
84
    local pb_eepsrec = ::wxString();
 
85
    local pb_srec = ::wxString();    
 
86
        
 
87
                // Post build commands  
 
88
                pb_eephex = _T("avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O ihex $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.hex");
 
89
                pb_hex = _T("avr-objcopy -O ihex -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).hex");
 
90
                pb_eepbin = _T("avr-objcopy --no-change-warnings --j .eeprom --change-section-lma .eeprom=0 -O binary $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.bin");
 
91
                pb_bin = _T("avr-objcopy -O binary -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).bin");
 
92
                pb_eepsrec = _T("avr-objcopy --no-change-warnings -j .eeprom --change-section-lma .eeprom=0 -O srec $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).eep.srec");
 
93
                pb_srec = _T("avr-objcopy -O srec -R .eeprom -R .eesafe $(TARGET_OUTPUT_FILE) $(TARGET_OUTPUT_FILE).srec");
 
94
 
 
95
                // avr-size is compiled with patches under winavr to produce a fancy output
 
96
                // which displays the percentage of memory used by the application for the 
 
97
                // target mcu. However, this option is not available under standard binutils
 
98
                // avr-size.
 
99
                if (PLATFORM_MSW == PLATFORM)
 
100
                        pb_avrsize = _T("avr-size --mcu=") + Processor + _T(" --format=avr $(TARGET_OUTPUT_FILE)");
 
101
                else
 
102
                        pb_avrsize = _T("avr-size $(TARGET_OUTPUT_FILE)");
 
103
 
 
104
                // Setup the linker options
 
105
                lo_map = _T("-Wl,-Map=$(TARGET_OUTPUT_FILE).map,--cref");
 
106
                
 
107
                // Get external memory start address
 
108
                lo_extmem = _T("-Wl,--section-start=.data=") + AvrExtMemAddr;
 
109
                                
 
110
    // Project compiler options
 
111
    WarningsOn(project, Wizard.GetCompilerID());
 
112
                project.AddCompilerOption(_T("-mmcu=") + Processor);
 
113
                
 
114
                if (AvrF_CPU)
 
115
                        project.AddCompilerOption(_T("-DF_CPU=") + AvrF_CPUValue);
 
116
                        
 
117
                // Project linker options
 
118
                project.AddLinkerOption(_T("-mmcu=") + Processor);
 
119
                
 
120
                if (AvrMap)
 
121
                        project.AddLinkerOption(lo_map);
 
122
                
 
123
                if (AvrExtMem)
 
124
                        project.AddLinkerOption(lo_extmem);
 
125
                
 
126
                // Project post-build steps 
 
127
                if (AvrSize)
 
128
                        project.AddCommandsAfterBuild(pb_avrsize);
 
129
                                        
 
130
                if (AvrHex)
 
131
                {
 
132
                        project.AddCommandsAfterBuild(pb_hex);
 
133
                        project.AddCommandsAfterBuild(pb_eephex);
 
134
                }
 
135
 
 
136
                if (AvrSrec)
 
137
                {
 
138
                        project.AddCommandsAfterBuild(pb_srec);
 
139
                        project.AddCommandsAfterBuild(pb_eepsrec);
 
140
                }
 
141
 
 
142
                if (AvrBin)
 
143
                {
 
144
                        project.AddCommandsAfterBuild(pb_bin);
 
145
                        project.AddCommandsAfterBuild(pb_eepbin);
 
146
                }
 
147
 
 
148
                                        
 
149
    // Debug build target
 
150
    local target = project.GetBuildTarget(Wizard.GetDebugName());
 
151
    if (!IsNull(target))
 
152
    {
 
153
        target.SetTargetType(ttConsoleOnly);
 
154
        target.SetTargetFilenameGenerationPolicy(tgfpPlatformDefault, tgfpNone);
 
155
        target.SetOutputFilename(Wizard.GetDebugOutputDir() + Wizard.GetProjectName() + _T(".elf"));
 
156
        DebugSymbolsOn(target, Wizard.GetCompilerID());
 
157
    }
 
158
 
 
159
    // Release build target
 
160
    target = project.GetBuildTarget(Wizard.GetReleaseName());
 
161
    if (!IsNull(target))
 
162
                {
 
163
                        target.SetTargetType(ttConsoleOnly);
 
164
                        target.SetTargetFilenameGenerationPolicy(tgfpPlatformDefault, tgfpNone);
 
165
                        target.SetOutputFilename(Wizard.GetReleaseOutputDir() + Wizard.GetProjectName() + _T(".elf"));
 
166
                        OptimizationsOn(target, Wizard.GetCompilerID());
 
167
                }
 
168
                
 
169
    return true;
 
170
}