?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 32

Line No. Rev Author Line
1 32 kaklik /*********************************************************************
2 *
3 * Application Launch Point and CLI for MPFS21
4 *
5 *********************************************************************
6 * FileName: Program.cs
7 * Dependencies: Microsoft .NET Framework 2.0
8 * Processor: x86
9 * Complier: Microsoft Visual C# 2008 Express Edition
10 * Company: Microchip Technology, Inc.
11 *
12 * Software License Agreement
13 *
14 * This software is owned by Microchip Technology Inc. ("Microchip")
15 * and is supplied to you for use exclusively as described in the
16 * associated software agreement. This software is protected by
17 * software and other intellectual property laws. Any use in
18 * violation of the software license may subject the user to criminal
19 * sanctions as well as civil liability. Copyright 2008 Microchip
20 * Technology Inc. All rights reserved.
21 *
22 *
23 * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT
24 * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT
25 * LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A
26 * PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
27 * MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR
28 * CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF
29 * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
30 * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE
31 * THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER
32 * SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT
33 * (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE.
34 *
35 *
36 * Author Date Comment
37 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38 * Elliott Wood 4/17/2008 Original
39 ********************************************************************/
40 using System;
41 using System.Collections.Generic;
42 using System.Windows.Forms;
43 using System.Drawing;
44 using Microchip;
45  
46 namespace MPFS21
47 {
48  
49 static class Program
50 {
51  
52 /// <summary>
53 /// The main entry point for the application.
54 /// </summary>
55 [STAThread]
56 static void Main(String[] args)
57 {
58 // If no arguments, show the GUI
59 if (args.Length == 0)
60 {
61 Application.EnableVisualStyles();
62 Application.SetCompatibleTextRenderingDefault(false);
63 Application.Run(new MPFS21Form());
64 }
65 // Operate in command line mode
66 else
67 {
68  
69 // Make sure we got at least 3 parameters
70 if (args.Length < 3)
71 {
72 MessageBox.Show(
73 "Usage: MPFS2 [options] <SourceDir> <ProjectDir> <OutputFile>\n" +
74 " /BIN\t\t(/b)\t: Output a BIN image (Default)\n" +
75 " /C18\t\t(/c)\t: Output a C18 image\n" +
76 " /ASM30\t(/s)\t: Output an ASM30 image\n" +
77 " /C32\t\t(/x)\t: Output a C32 image\n" +
78 " /classic\t\t(/1)\t: MPFSClassic format\n" +
79 " /mpfs2\t\t(/2)\t: MPFS2 format (Default)\n" +
80 " /reserve #\t(/r #)\t: Reserved space for Classic BINs (Default 64)\n" +
81 " /html \"...\"\t(/h)\t: Dynamic file types (\"*.htm, *.html, *.xml, *.cgi\")\n" +
82 " /xgzip \"...\"\t(/z)\t: Non-compressible types (\"snmp.bib, *.inc\")\n\n" +
83 "SourceDir, ProjectDir, and OutputFile are required and should be enclosed in quotes.\n" +
84 "OutputFile is placed relative to ProjectDir and *CANNOT* be a full path name.",
85 "MPFS2 Console Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
86 return;
87 }
88  
89 // Locate the parameters
90 String sourceDir = args[args.Length - 3];
91 String projectDir = args[args.Length - 2];
92 String outputFile = args[args.Length - 1];
93  
94 // Set up some defaults
95 MPFSOutputFormat fmt = MPFSOutputFormat.BIN;
96 byte version = 2;
97 int reserveBlock = 64;
98 String htmlTypes = "*.htm, *.html, *.xml, *.cgi";
99 String noGZipTypes = "*.inc, snmp.bib";
100  
101 // Process each command line argument
102 for(int i =0; i < args.Length - 3; i++)
103 {
104 String arg = args[i].ToLower();
105  
106 // Check for output format parameters
107 if(arg == "/bin" || arg == "/b")
108 fmt = MPFSOutputFormat.BIN;
109 else if(arg == "/c18" || arg == "/c")
110 fmt = MPFSOutputFormat.C18;
111 else if(arg == "/asm30" || arg == "/s")
112 fmt = MPFSOutputFormat.ASM30;
113 else if(arg == "/c32" || arg == "/x")
114 fmt = MPFSOutputFormat.C32;
115 else if(arg == "/classic" || arg == "/1")
116 version = 1;
117 else if(arg == "/mpfs2" || arg == "/2")
118 version = 2;
119  
120 // Check for string parameters
121 else if(arg == "/reserve" || arg == "/r")
122 reserveBlock = Convert.ToInt32(args[++i]);
123 else if(arg == "/html" || arg == "/h")
124 htmlTypes = args[++i];
125 else if(arg == "/xgzip" || arg == "/z")
126 noGZipTypes = args[++i];
127  
128 else
129 {
130 MessageBox.Show("The command-line option \""+arg+"\" was not recognized.",
131 "MPFS2 Console Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
132 return;
133 }
134 }
135  
136 // Set up an appropriate builder
137 MPFSBuilder builder;
138 // This is a dummy string , will be initialized when MDD is supported from command line
139 String dummy = "Dummy";
140 if (version == 2)
141 {
142 builder = new MPFS2Builder(projectDir, outputFile);
143 ((MPFS2Builder)builder).DynamicTypes = htmlTypes;
144 ((MPFS2Builder)builder).NonGZipTypes = noGZipTypes;
145 }
146 else
147 {
148 builder = new MPFSClassicBuilder(projectDir, outputFile);
149 ((MPFSClassicBuilder)builder).ReserveBlock = (UInt32)reserveBlock;
150 }
151  
152 // Add the files to the image and generate the image
153 builder.AddDirectory(sourceDir, "");
154  
155 // Generate the image and trap errors
156 if (!builder.Generate(fmt))
157 {
158 LogWindow dlg = new LogWindow();
159 dlg.Image = SystemIcons.Error;
160 dlg.Message = "An error was encountered during generation.";
161 dlg.Log = builder.Log;
162 dlg.ShowDialog();
163 return;
164 }
165 }
166 }
167 }
168 }
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3