Skip to content

Commit

Permalink
added a gui-variant to toss error message in windows boxes, "compile"…
Browse files Browse the repository at this point in the history
… right click item
  • Loading branch information
mabako committed Aug 27, 2014
1 parent bc52977 commit 291db7e
Show file tree
Hide file tree
Showing 11 changed files with 675 additions and 157 deletions.
96 changes: 96 additions & 0 deletions setup/Product.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="e8383948-d479-40bb-a40d-1cb2be3d2075" Name="Squirrel Compiler" Language="1033" Version="1.0.0.0" Manufacturer="mabako" UpgradeCode="6085e488-28f3-44b6-beec-7b54b2c94edb">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />

<Feature Id="SquirrelCompiler" Title="Squirrel Compiler" Level="1" ConfigurableDirectory="INSTALLFOLDER">
<ComponentGroupRef Id="SquirrelCompiler" />
</Feature>

<UI Id='xxx'>
<TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
<TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
<TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />

<Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
<Property Id="WixUI_Mode" Value="Minimal" />

<DialogRef Id="ErrorDlg" />
<DialogRef Id="FatalError" />
<DialogRef Id="FilesInUse" />
<DialogRef Id="MsiRMFilesInUse" />
<DialogRef Id="PrepareDlg" />
<DialogRef Id="ProgressDlg" />
<DialogRef Id="ResumeDlg" />
<DialogRef Id="UserExit" />
<DialogRef Id="WelcomeDlg" />

<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>

<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>

<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>

<Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>

<Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
<Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
<Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>

<Property Id="ARPNOMODIFY" Value="yes" Secure="yes" />
<UIRef Id="WixUI_Common" />

<Property Id="NUTEXT">
<RegistrySearch Id="NutFile" Root="HKCR" Key=".nut" Type="raw"/>
</Property>
</UI>
</Product>

<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Squirrel Compiler" />
</Directory>
</Directory>
</Fragment>

<Fragment>
<ComponentGroup Id="SquirrelCompiler" Directory="INSTALLFOLDER">
<Component>
<File Source="$(var.sq-compiler.TargetPath)" Id="sqcompiler" />
</Component>
<Component>
<File Source="$(var.sq-compiler-gui.TargetPath)" Id="sqcompilergui" />
</Component>

<Component>
<Condition>NOT NUTEXT</Condition>
<RegistryKey Root="HKCR" Key=".nut">
<RegistryValue Action="write" Value="nut_auto_file" Type="string"/>
</RegistryKey>
<RegistryKey Root="HKCR"
Key="nut_auto_file\shell\compile">
<RegistryValue Action="write" Value="Compile" Type="string" />
<RegistryKey Key="command">
<RegistryValue Action="write" Type="string"
Value="&quot;[#sqcompilergui]&quot; %1"/>
</RegistryKey>
</RegistryKey>
</Component>
<Component>
<Condition>NUTEXT</Condition>
<RegistryKey Root="HKCR"
Key="[NUTEXT]\shell\compile">
<RegistryValue Action="write" Value="Compile" Type="string" />
<RegistryKey Key="command">
<RegistryValue Action="write" Type="string"
Value="&quot;[#sqcompilergui]&quot; %1"/>
</RegistryKey>
</RegistryKey>
</Component>
</ComponentGroup>
</Fragment>
</Wix>
63 changes: 63 additions & 0 deletions setup/setup.wixproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>3.8</ProductVersion>
<ProjectGuid>c25b50a8-5af7-4438-81b2-0065c0385c64</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>sqc</OutputName>
<OutputType>Package</OutputType>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<CompilerAdditionalOptions>
</CompilerAdditionalOptions>
<LinkerAdditionalOptions>
</LinkerAdditionalOptions>
</PropertyGroup>
<ItemGroup>
<Compile Include="Product.wxs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\sq-compiler-gui\sq-compiler-gui.vcxproj">
<Name>sq-compiler-gui</Name>
<Project>{ff5a97bc-9da6-453c-a249-0ff3d1be278f}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
<ProjectReference Include="..\sq-compiler\sq-compiler.vcxproj">
<Name>sq-compiler</Name>
<Project>{18961dcf-d6c7-4b18-a466-c397ac3c555c}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<WixExtension Include="WixUIExtension">
<HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
<Name>WixUIExtension</Name>
</WixExtension>
</ItemGroup>
<Import Project="$(WixTargetsPath)" />
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Wix.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
82 changes: 82 additions & 0 deletions sq-compiler-gui.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#include <sstream>
#include <string>
#include <squirrel.h>
#include <sqstdio.h>
#include <Windows.h>

bool bKnownError = false;

void compile_error_handler(HSQUIRRELVM v, const SQChar* desc, const SQChar* source, SQInteger line, SQInteger column)
{
bKnownError = true;

std::stringstream out;
out << "Error in " << source << " on line " << line << " column " << column << ": " << desc << std::endl;
MessageBox(NULL, out.str().c_str(), "Squirrel Compiler", MB_OK | MB_ICONERROR);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
std::string infile(lpCmdLine);
std::stringstream out;

if (infile.length() < 3)
{
OPENFILENAME ofn;
char szFile[260];

// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = NULL;
ofn.lpstrFile = szFile;
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "Squirrel Files (*.nut)\0*.nut\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

if (GetOpenFileName(&ofn) == TRUE)
infile = ofn.lpstrFile;
else
return 1;
}

// open vm
HSQUIRRELVM v = sq_open(1024);
if (!v) {
MessageBox(NULL, "Error: Could not open Squirrel VM", "Squirrel Compiler", MB_OK | MB_ICONERROR);
return 2;
}

// set compile error handler
sq_setcompilererrorhandler(v, compile_error_handler);

// compile source file
if (SQ_FAILED(sqstd_loadfile(v, infile.c_str(), SQTrue))) {
if (!bKnownError)
{
out << "Error: Could not compile source file " << infile << std::endl;
MessageBox(NULL, out.str().c_str(), "Squirrel Compiler", MB_OK | MB_ICONERROR);
}

sq_close(v);

return 3;
}

// serialize closure containing the source
std::string outfile(infile.c_str());
outfile = outfile.substr(0, outfile.length() - 4) + ".out";
if (SQ_FAILED(sqstd_writeclosuretofile(v, outfile.c_str()))) {
MessageBox(NULL, "Error: Could not serialize closure", "Squirrel Compiler", MB_OK | MB_ICONERROR);
}

// clean up.
sq_close(v);

return 0;
}
115 changes: 115 additions & 0 deletions sq-compiler-gui/sq-compiler-gui.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{FF5A97BC-9DA6-453C-A249-0FF3D1BE278F}</ProjectGuid>
<RootNamespace>sqcompilergui</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>../squirrel/include</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
<AdditionalIncludeDirectories>../squirrel/include</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\sq-compiler-gui.cpp" />
<ClCompile Include="..\squirrel\sqstdlib\sqstdblob.cpp" />
<ClCompile Include="..\squirrel\sqstdlib\sqstdio.cpp" />
<ClCompile Include="..\squirrel\sqstdlib\sqstdstream.cpp" />
<ClCompile Include="..\squirrel\squirrel\sqapi.cpp" />
<ClCompile Include="..\squirrel\squirrel\sqbaselib.cpp" />
<ClCompile Include="..\squirrel\squirrel\sqclass.cpp" />
<ClCompile Include="..\squirrel\squirrel\sqcompiler.cpp" />
<ClCompile Include="..\squirrel\squirrel\sqdebug.cpp" />
<ClCompile Include="..\squirrel\squirrel\sqfuncstate.cpp" />
<ClCompile Include="..\squirrel\squirrel\sqlexer.cpp" />
<ClCompile Include="..\squirrel\squirrel\sqmem.cpp" />
<ClCompile Include="..\squirrel\squirrel\sqobject.cpp" />
<ClCompile Include="..\squirrel\squirrel\sqstate.cpp" />
<ClCompile Include="..\squirrel\squirrel\sqtable.cpp" />
<ClCompile Include="..\squirrel\squirrel\sqvm.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\squirrel\include\sqstdblob.h" />
<ClInclude Include="..\squirrel\include\sqstdio.h" />
<ClInclude Include="..\squirrel\include\squirrel.h" />
<ClInclude Include="..\squirrel\sqstdlib\sqstdstream.h" />
<ClInclude Include="..\squirrel\squirrel\sqarray.h" />
<ClInclude Include="..\squirrel\squirrel\sqclass.h" />
<ClInclude Include="..\squirrel\squirrel\sqclosure.h" />
<ClInclude Include="..\squirrel\squirrel\sqcompiler.h" />
<ClInclude Include="..\squirrel\squirrel\sqfuncproto.h" />
<ClInclude Include="..\squirrel\squirrel\sqfuncstate.h" />
<ClInclude Include="..\squirrel\squirrel\sqlexer.h" />
<ClInclude Include="..\squirrel\squirrel\sqobject.h" />
<ClInclude Include="..\squirrel\squirrel\sqopcodes.h" />
<ClInclude Include="..\squirrel\squirrel\sqpcheader.h" />
<ClInclude Include="..\squirrel\squirrel\sqstate.h" />
<ClInclude Include="..\squirrel\squirrel\sqstring.h" />
<ClInclude Include="..\squirrel\squirrel\sqtable.h" />
<ClInclude Include="..\squirrel\squirrel\squserdata.h" />
<ClInclude Include="..\squirrel\squirrel\squtils.h" />
<ClInclude Include="..\squirrel\squirrel\sqvm.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Loading

0 comments on commit 291db7e

Please sign in to comment.