Browse Source

vslol: more robust error checking.

legacy
Sam Hocevar sam 12 years ago
parent
commit
dd120a2eec
3 changed files with 36 additions and 28 deletions
  1. +3
    -3
      tools/vslol/AssemblyInfo.cs
  2. +31
    -23
      tools/vslol/MenuGenerateCompilers.cs
  3. +2
    -2
      tools/vslol/source.extension.vsixmanifest

+ 3
- 3
tools/vslol/AssemblyInfo.cs View File

@@ -4,7 +4,7 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;


[assembly: AssemblyTitle("VsLol")] [assembly: AssemblyTitle("VsLol")]
[assembly: AssemblyDescription("VsSDK reference sample for Menus and Commands")]
[assembly: AssemblyDescription("Lol Engine Productivity Tools")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Lol")] [assembly: AssemblyCompany("Lol")]
[assembly: AssemblyProduct("VsLol")] [assembly: AssemblyProduct("VsLol")]
@@ -20,5 +20,5 @@ using System.Runtime.InteropServices;
// The following GUID is for the ID of the typelib if this project is exposed to COM // The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("58968f91-edb8-4a4c-9f4f-ba39fdb4a21a")] [assembly: Guid("58968f91-edb8-4a4c-9f4f-ba39fdb4a21a")]


[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]

+ 31
- 23
tools/vslol/MenuGenerateCompilers.cs View File

@@ -94,11 +94,11 @@ namespace Lol.VisualStudio.Plugin
cmd.ClearOutputPane(); cmd.ClearOutputPane();
cmd.WriteToOutputPane("------ Build started: Generating Compilers ------\n"); cmd.WriteToOutputPane("------ Build started: Generating Compilers ------\n");


int scanner_count = 0, parser_count = 0;
int scanner_count = 0, parser_count = 0, error_count = 0;


foreach (Project project in cmd.projects) foreach (Project project in cmd.projects)
{ {
cmd.WriteToOutputPane("Project " + project.FullName + "\n");
cmd.WriteToOutputPane("Project " + project.Name + "\n");


string project_path = Path.GetDirectoryName(project.FullName); string project_path = Path.GetDirectoryName(project.FullName);


@@ -128,45 +128,47 @@ namespace Lol.VisualStudio.Plugin


if (item.Name.EndsWith("-scanner.l")) if (item.Name.EndsWith("-scanner.l"))
{ {
cmd.WriteToOutputPane(" flex.exe " + filename + "\n");
cmd.WriteToOutputPane("flex.exe " + filename + "\n");


string basename = Path.GetFileName(filename.Substring(0, filename.LastIndexOf("-scanner.l"))); string basename = Path.GetFileName(filename.Substring(0, filename.LastIndexOf("-scanner.l")));
cmd.Run(project_path,
flex_path + "\\bin\\flex.exe",
"-v -o "
+ "generated/" + basename + "-scanner.cpp "
+ filename,
"");
if (!cmd.Run(project_path,
flex_path + "\\bin\\flex.exe",
"-v -o "
+ "generated/" + basename + "-scanner.cpp "
+ filename,
""))
++error_count;


++scanner_count; ++scanner_count;
} }


if (item.Name.EndsWith("-parser.y")) if (item.Name.EndsWith("-parser.y"))
{ {
cmd.WriteToOutputPane(" bison.exe " + filename + "\n");
cmd.WriteToOutputPane("bison.exe " + filename + "\n");


string basename = Path.GetFileName(filename.Substring(0, filename.LastIndexOf("-parser.y"))); string basename = Path.GetFileName(filename.Substring(0, filename.LastIndexOf("-parser.y")));
cmd.Run(project_path,
bison_path + "\\bin\\bison.exe",
"-v -o "
+ "generated/" + basename + "-parser.cpp "
+ "--defines=generated/" + basename + "-parser.h "
+ "-d "
+ "-b "
+ "generated/" + basename + " "
+ filename,
"BISON_PKGDATADIR=" + bison_path + "\\share\\bison");
if (!cmd.Run(project_path,
bison_path + "\\bin\\bison.exe",
"-v -o "
+ "generated/" + basename + "-parser.cpp "
+ "--defines=generated/" + basename + "-parser.h "
+ "-d "
+ "-b "
+ "generated/" + basename + " "
+ filename,
"BISON_PKGDATADIR=" + bison_path + "\\share\\bison"))
++error_count;


++parser_count; ++parser_count;
} }
} }
} }


cmd.WriteToOutputPane(string.Format("========== Done. {0} scanner(s), {1} parser(s) ==========\n",
scanner_count, parser_count));
cmd.WriteToOutputPane(string.Format("========== Done: {0} scanner(s), {1} parser(s), {2} error(s) ==========\n",
scanner_count, parser_count, error_count));
} }


void Run(string directory, string executable, string arguments, string env)
bool Run(string directory, string executable, string arguments, string env)
{ {
System.Diagnostics.Process p = new System.Diagnostics.Process(); System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = executable; p.StartInfo.FileName = executable;
@@ -193,12 +195,18 @@ namespace Lol.VisualStudio.Plugin
p.WaitForExit(); p.WaitForExit();
WriteToOutputPane(output); WriteToOutputPane(output);
if (p.ExitCode != 0) if (p.ExitCode != 0)
{
WriteToOutputPane("Error: " + executable + " exited with code " + p.ExitCode + "\n"); WriteToOutputPane("Error: " + executable + " exited with code " + p.ExitCode + "\n");
return false;
}
} }
catch (Exception e) catch (Exception e)
{ {
WriteToOutputPane("Error: failed to launch " + executable + "\n"); WriteToOutputPane("Error: failed to launch " + executable + "\n");
return false;
} }

return true;
} }


private void ClearOutputPane() private void ClearOutputPane()


+ 2
- 2
tools/vslol/source.extension.vsixmanifest View File

@@ -3,8 +3,8 @@
<Identifier Id="VsLol.Sample"> <Identifier Id="VsLol.Sample">
<Name>VsLol</Name> <Name>VsLol</Name>
<Author>Lol</Author> <Author>Lol</Author>
<Version>0.0</Version>
<Description xml:space="preserve">Lol Engine productivity tools.</Description>
<Version>1.0.0.1</Version>
<Description xml:space="preserve">Lol Engine Productivity Tools.</Description>
<Locale>1033</Locale> <Locale>1033</Locale>
<InstalledByMsi>false</InstalledByMsi> <InstalledByMsi>false</InstalledByMsi>
<SupportedProducts> <SupportedProducts>


Loading…
Cancel
Save