Skip to content

Commit 2583712

Browse files
committed
Get windows stub working
(Yeah, I know I'm committing the cardinal sin of committing binary files. It's 370kb.)
1 parent 0808854 commit 2583712

9 files changed

+223
-44
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ test.py
2727
testing/bin
2828
work
2929
zamples
30+
misc/windowsexecutablestub/Debug
31+
misc/windowsexecutablestub/Release
32+
*.sdf
33+
*.suo

misc/windowsexecutablestub/Main.cpp

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// This file is a silly hack. Don't do this when you grow up, kids.
2+
// It's copied along with the mode and inserted into exported windows
3+
// application folders.
4+
// ALL IT DOES is look for the file lib/run.cmd (well, lib\run.cmd), make
5+
// sure it exists, and launch it; it only exists so that we can have a
6+
// pretty icon for our application.
7+
8+
#define _UNICODE
9+
10+
#include "strsafe.h"
11+
#include <Windows.h>
12+
#include <cstdlib>
13+
14+
// MAXIMUM POSSIBLE filename length on windows, apparently. Memory is cheap.
15+
#define NAMEBUF_LENGTH 32767
16+
17+
int WINAPI WinMain(
18+
_In_ HINSTANCE hInstance,
19+
_In_ HINSTANCE hPrevInstance,
20+
_In_ LPSTR lpCmdLine,
21+
_In_ int nCmdShow
22+
)
23+
{
24+
WCHAR *namebuf = new WCHAR[NAMEBUF_LENGTH];
25+
26+
// Gets the name of the running executable file.
27+
GetModuleFileNameW(NULL, namebuf, NAMEBUF_LENGTH);
28+
29+
// If our buffer is somehow not big enough.
30+
if (GetLastError() != ERROR_SUCCESS) {
31+
MessageBoxW(
32+
NULL, // No parent window
33+
L"I can't figure out where I am. Something is terribly wrong.\r\n"
34+
L"Try running the lib/run.cmd file directly.", // Message string
35+
L"Sketchy Behavior", // Title
36+
MB_OK
37+
);
38+
exit(EXIT_FAILURE);
39+
}
40+
41+
// Concatenate executable directory and \..\lib\run.cmd; \.. is the easiest
42+
// way to access a parent directory without messing with strings
43+
HRESULT err = StringCbCatW(namebuf, NAMEBUF_LENGTH, L"\\..\\lib\\run.cmd");
44+
// Might fail. Somehow.
45+
if (FAILED(err)) {
46+
MessageBoxW(
47+
NULL,
48+
L"I can't figure out where I am. Something is terribly wrong.\r\n"
49+
L"Try running the lib/run.cmd file directly.",
50+
L"Sketchy Behavior",
51+
MB_OK
52+
);
53+
exit(EXIT_FAILURE);
54+
}
55+
56+
// Check if lib/run.cmd exists
57+
WIN32_FIND_DATAW fileData;
58+
HANDLE handle = FindFirstFileW(namebuf, &fileData);
59+
int found = handle != INVALID_HANDLE_VALUE;
60+
61+
// Oh no!
62+
if (!found) {
63+
MessageBoxW(
64+
NULL,
65+
L"I can't find the file \"lib\\run.cmd\", which I need to run your sketch.\r\n"
66+
L"Make sure you copy the *entire* application.windows64 / application.windows32\r\n"
67+
L"folders whenever you move your sketch around.",
68+
L"Sketchy Behavior",
69+
MB_OK
70+
);
71+
exit(EXIT_FAILURE);
72+
}
73+
FindClose(handle);
74+
75+
ShellExecuteW(
76+
NULL, // No parent window (again)
77+
L"open", // The "open" verb launches applications
78+
namebuf, // File to launch
79+
L"", // No parameters
80+
L"", // Current directory
81+
SW_HIDE // Hide the .cmd window that pops up - don't worry, Processing is still shown!
82+
);
83+
84+
exit(EXIT_SUCCESS);
85+
}
86+

misc/windowsexecutablestub/sketch.ico

362 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 ICON "sketch.ico"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Express 2013 for Windows Desktop
4+
VisualStudioVersion = 12.0.21005.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "windowsexecutablestub", "windowsexecutablestub.vcxproj", "{24CA1A54-0BDF-4849-83BC-DCDE2189E8AF}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Win32 = Debug|Win32
11+
Release|Win32 = Release|Win32
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{24CA1A54-0BDF-4849-83BC-DCDE2189E8AF}.Debug|Win32.ActiveCfg = Debug|Win32
15+
{24CA1A54-0BDF-4849-83BC-DCDE2189E8AF}.Debug|Win32.Build.0 = Debug|Win32
16+
{24CA1A54-0BDF-4849-83BC-DCDE2189E8AF}.Release|Win32.ActiveCfg = Release|Win32
17+
{24CA1A54-0BDF-4849-83BC-DCDE2189E8AF}.Release|Win32.Build.0 = Release|Win32
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
</ItemGroup>
13+
<PropertyGroup Label="Globals">
14+
<ProjectGuid>{24CA1A54-0BDF-4849-83BC-DCDE2189E8AF}</ProjectGuid>
15+
<RootNamespace>windowsexecutablestub</RootNamespace>
16+
</PropertyGroup>
17+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
18+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
19+
<ConfigurationType>Application</ConfigurationType>
20+
<UseDebugLibraries>true</UseDebugLibraries>
21+
<PlatformToolset>v120</PlatformToolset>
22+
<CharacterSet>MultiByte</CharacterSet>
23+
</PropertyGroup>
24+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
25+
<ConfigurationType>Application</ConfigurationType>
26+
<UseDebugLibraries>false</UseDebugLibraries>
27+
<PlatformToolset>v120</PlatformToolset>
28+
<WholeProgramOptimization>true</WholeProgramOptimization>
29+
<CharacterSet>MultiByte</CharacterSet>
30+
</PropertyGroup>
31+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
32+
<ImportGroup Label="ExtensionSettings">
33+
</ImportGroup>
34+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
35+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
36+
</ImportGroup>
37+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
38+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
39+
</ImportGroup>
40+
<PropertyGroup Label="UserMacros" />
41+
<PropertyGroup />
42+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
43+
<ClCompile>
44+
<WarningLevel>Level3</WarningLevel>
45+
<Optimization>Disabled</Optimization>
46+
<SDLCheck>true</SDLCheck>
47+
</ClCompile>
48+
<Link>
49+
<GenerateDebugInformation>true</GenerateDebugInformation>
50+
</Link>
51+
</ItemDefinitionGroup>
52+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
53+
<ClCompile>
54+
<WarningLevel>Level3</WarningLevel>
55+
<Optimization>MaxSpeed</Optimization>
56+
<FunctionLevelLinking>true</FunctionLevelLinking>
57+
<IntrinsicFunctions>true</IntrinsicFunctions>
58+
<SDLCheck>true</SDLCheck>
59+
</ClCompile>
60+
<Link>
61+
<GenerateDebugInformation>true</GenerateDebugInformation>
62+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
63+
<OptimizeReferences>true</OptimizeReferences>
64+
</Link>
65+
</ItemDefinitionGroup>
66+
<ItemGroup>
67+
<ClCompile Include="Main.cpp" />
68+
</ItemGroup>
69+
<ItemGroup>
70+
<ResourceCompile Include="windowsexecutablestub.rc" />
71+
</ItemGroup>
72+
<ItemGroup>
73+
<Image Include="sketch.ico" />
74+
</ItemGroup>
75+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
76+
<ImportGroup Label="ExtensionTargets">
77+
</ImportGroup>
78+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="Main.cpp">
19+
<Filter>Source Files</Filter>
20+
</ClCompile>
21+
</ItemGroup>
22+
<ItemGroup>
23+
<ResourceCompile Include="windowsexecutablestub.rc">
24+
<Filter>Resource Files</Filter>
25+
</ResourceCompile>
26+
</ItemGroup>
27+
<ItemGroup>
28+
<Image Include="sketch.ico">
29+
<Filter>Resource Files</Filter>
30+
</Image>
31+
</ItemGroup>
32+
</Project>
Binary file not shown.

runtime/c_src/launcher.c

-44
This file was deleted.

0 commit comments

Comments
 (0)