Skip to content

Commit 1adc366

Browse files
author
Erik McClure
committed
v0.1.0 commit
1 parent 70f22b4 commit 1adc366

26 files changed

+1161
-939
lines changed

.gitignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
/innative-test/Win32/
3030
/innative-loader/Win32/
3131
/innative-stub/Win32/
32-
/innative-setup/obj/
33-
/innative-setup/IncludeFileList.wxs
34-
/innative-setup/ScriptFileList.wxs
35-
/innative-setup/CoreFileList.wxs
32+
/innative-runtime-setup/obj/
33+
/innative-sdk-setup/obj/
34+
/innative-sdk-setup/IncludeFileList.wxs
35+
/innative-sdk-setup/ScriptFileList.wxs
36+
/innative-sdk-setup/CoreFileList.wxs
3637
/.vs/

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ else
2727
CPPFLAGS += -DNDEBUG -march=native -O3
2828
endif
2929

30-
debug: innative-env innative innative-cmd innative-test
31-
all: innative-env innative innative-cmd innative-test
30+
debug: innative-env innative innative-cmd innative-test innative-stub
31+
all: innative-env innative innative-cmd innative-test innative-stub
3232

33-
clean: innative-env-clean innative-clean innative-cmd-clean innative-test-clean
33+
clean: innative-env-clean innative-clean innative-cmd-clean innative-test-clean innative-stub-clean
3434
#$(RM) -r $(LIBDIR)
3535
#$(RM) -r $(BINDIR)
3636
$(RM) -r $(OBJDIR)
@@ -56,10 +56,11 @@ dist: all
5656
mv innative-posix-runtime-x64/* innative-posix-sdk-x64/bin/
5757
rm -r innative-posix-runtime-x64/
5858
cp bin/innative-test innative-posix-sdk-x64/bin/
59+
cp bin/innative-stub.a innative-posix-sdk-x64/bin/
5960
cp include/innative/*.h innative-posix-sdk-x64/include/innative/
6061
cp scripts/*.wat innative-posix-sdk-x64/scripts/
6162
cp scripts/*.wasm innative-posix-sdk-x64/scripts/
62-
cp spec/test/core/* innative-posix-sdk-x64/spec/test/core/
63+
cp spec/test/core/*.wast innative-posix-sdk-x64/spec/test/core/
6364
tar -czf innative-posix-sdk-x64.tar.gz innative-posix-sdk-x64/
6465
rm -r innative-posix-sdk-x64/
6566

@@ -78,3 +79,4 @@ include innative-env/Makefile
7879
include innative/Makefile
7980
include innative-cmd/Makefile
8081
include innative-test/Makefile
82+
include innative-stub/Makefile

README.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Precompiled binaries for common platforms are provided in [releases](https://git
1515
### Command Line Utility
1616
The inNative SDK comes with a command line utility with many useful features for webassembly developers.
1717

18-
Usage: innative-cmd [-r] [-c] [-i] [-u] [-v] [-f FLAG...] [-l FILE] [-L FILE] [-o FILE] [-a FILE] [-d PATH] [-s [FILE]] [-w [MODULE:]FUNCTION] FILE...
18+
Usage: innative-cmd [-r] [-c] [-i [lite]] [-u] [-v] [-f FLAG...] [-l FILE] [-L FILE] [-o FILE] [-a FILE] [-d PATH] [-j PATH] [-s [FILE]] [-w [MODULE:]FUNCTION] FILE...
1919
-r : Run the compiled result immediately and display output. Requires a start function.
2020
-f <FLAG>: Set a supported flag to true. Flags:
2121
sandbox, homogenize, llvm, strict, whitelist, multithreaded, library, noinit, debug, check_stack_overflow, check_float_trunc, check_memory_access, check_indirect_call, check_int_division, disable_tail_call
@@ -25,11 +25,12 @@ The inNative SDK comes with a command line utility with many useful features for
2525
-o <FILE> : Sets the output path for the resulting executable or library.
2626
-a <FILE> : Specifies an alternative linker to use instead of LLD.
2727
-d <PATH> : Sets the directory that contains the SDK library and data files.
28+
-j <PATH> : Sets the directory for temporary object files and intermediate compilation results.
2829
-e <MODULE> : Sets the environment/system module name. Any functions with the module name will have the module name stripped when linking with C functions.
2930
-s [<FILE>] : Serializes all modules to .wat files. <FILE> can specify the output if only one module is present.
3031
-w <[MODULE:]FUNCTION> : whitelists a given C import, does name-mangling if the module is specified.
31-
-c : Assumes the input files are actually LLVM IR files and compiles them into a single webassembly module.
32-
-i : Installs this innative SDK to the host operating system.
32+
-g : Instead of compiling immediately, creates a loader embedded with all the modules, environments, and settings, which compiles the modules on-demand when run. -c : Assumes the input files are actually LLVM IR files and compiles them into a single webassembly module.
33+
-i [lite]: Installs this SDK to the host operating system. On Windows, also updates file associations unless 'lite' is specified.
3334
-u : Uninstalls and deregisters this SDK from the host operating system.
3435
-v : Turns on verbose logging.
3536

@@ -43,7 +44,7 @@ LLVM uses CMake to build, but CMake currently has issues with the nested LLD pro
4344
All build steps start with `git submodule update --init --recursive`. This is **mandatory** because of nested git submodules that the project relies on. If you get errors, be sure to double check that you have acquired `llvm`, `llvm/tools/lld`, `spec`, and `spec/document/core/util/katex`.
4445

4546
### Windows
46-
Regardless of whether you are using Visual Studio 2017 or 2019, **make sure you have the v141_xp toolkit installed**, first. Run `build-llvm.ps1` if you have Visual Studio 2019, or run `build-llvm.ps1 2017` if you have Visual Studio 2017, and wait for it to complete. If the script was successful, open `innative.sln` in Visual Studio and build the project, or run `msbuild innative.sln`. **Visual Studio 2019 broke MSBuild outside the developer prompt, so you'll have to open the .sln file and manually compile Debug and MinSizeRel yourself, or run `build-llvm.ps1` inside a developer prompt.**
47+
Regardless of whether you are using Visual Studio 2017 or 2019, **make sure you have the v141_xp toolkit installed**, first. Run `build-llvm.ps1` if you have Visual Studio 2019, or run `build-llvm.ps1 2017` if you have Visual Studio 2017, and wait for it to complete. If the script was successful, open `innative.sln` in Visual Studio and build the project, or run `msbuild innative.sln`. **Visual Studio 2019 broke MSBuild outside the developer prompt, so you'll have to open the .sln file and manually compile Debug and MinSizeRel yourself.**
4748

4849
The script downloads a portable cmake and python3 into the `bin` directory. If you would rather run the commands yourself, have existing installations of cmake/python, or want to modify the LLVM compilation flags, you can run the commands for your version of Visual Studio yourself:
4950

@@ -88,9 +89,9 @@ A prebuilt version of this image is [available here](https://cloud.docker.com/u/
8889

8990
## Targeting inNative
9091

91-
No compiler fully supports inNative, because current WebAssembly compilers target *web embeddings* and make assumptions about which functions are available. For now, try building webassembly modules that have no dependencies, as these can always be run on any webassembly implementation. True C interop is provided via two special compiler functions, `_innative_to_c` and `_innative_from_c`. These can be used to acquire C pointers to WebAssembly memory to pass to other functions, and to convert C pointers into a form that can be manipulated by WebAssembly. **However**, it is not possible to safely manipulate outside memory pointers, so `_innative_` pointers can only be accessed when not in strict mode.
92+
No compiler fully supports inNative, because current WebAssembly compilers target *web embeddings* and make assumptions about which functions are available. For now, try building webassembly modules that have no dependencies, as these can always be run on any webassembly implementation. True C interop is provided via two special compiler functions, `_innative_to_c` and `_innative_from_c`. These can be used to acquire C pointers to WebAssembly memory to pass to other functions, and to convert C pointers into a form that can be manipulated by WebAssembly. **However**, it is not possible to safely manipulate outside memory pointers, so `_innative_` pointers can only be accessed when not in strict mode. inNative also provides a [custom `cref` extension](https://github.com/innative-sdk/innative/wiki/inNative-cref-Extension) that automatically converts WebAssembly indexes into C pointers for external C functions.
9293

93-
The host-object proposal will make it easier to target native C environments, and hopefully compilers will make it easier to target non-web embeddings of WebAssembly.
94+
The [WebIDL bindings proposal](https://github.com/WebAssembly/webidl-bindings) will make it easier to target native C environments, and hopefully compilers will make it easier to target non-web embeddings of WebAssembly.
9495

9596
## Embedding inNative
9697

@@ -99,24 +100,29 @@ inNative is compiled as either a dynamic or static library, and can be integrate
99100
// Create the environment, setting the dynamic library flag
100101
IRExports exports;
101102
innative_runtime(&exports);
102-
Environment* env = (*exports.CreateEnvironment)(1, 0, argv[0]);
103-
env->flags |= ENV_DLL; // Add ENV_NO_INIT if you want to manually initialize and cleanup the DLL.
103+
Environment* env = (*exports.CreateEnvironment)(1, 0, (!argc ? 0 : argv[0]));
104+
env->flags |= ENV_LIBRARY; // Add ENV_NO_INIT if you want to manually initialize and cleanup the DLL.
104105

105106
// Add the script you want to compile
106107
int err;
107108
(*exports.AddModule)(env, "your_script.wasm", 0, "your_script", &err);
108109

109110
// Add the default static library and any additional libraries you want to expose to the script
110-
int err = (*exports.AddEmbedding)(env, 0, (void*)INNATIVE_DEFAULT_ENVIRONMENT, 0);
111-
111+
err = (*exports.AddEmbedding)(env, 0, (void*)INNATIVE_DEFAULT_ENVIRONMENT, 0);
112+
113+
err = (*exports.FinalizeEnvironment)(env);
114+
112115
// Compile and dynamically load the result
113116
err = (*exports.Compile)(env, "your_script.out");
114-
void* assembly = (*exports.LoadAssembly)(flags, "your_script.out");
117+
void* assembly = (*exports.LoadAssembly)("your_script.out");
115118

116-
// Destroy environment
119+
// Destroy environment (no longer needed after compilation is completed)
117120
(*exports.DestroyEnvironment)(env);
118121

119122
// Load functions and execute
120123
void (*update_entity)(int) = (void (*)(int))(*exports.LoadFunction)(assembly, "your_module", "update_entity");
121124

122-
(*update_entity)(0);
125+
(*update_entity)(0);
126+
127+
// Free assembly once finished
128+
(*exports.FreeAssembly)(assembly);

include/innative/path.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace innative {
3535
const char* start = _path.c_str();
3636
const char* pos = strchr(start, SEPERATOR);
3737
#ifdef IN_PLATFORM_WIN32
38-
return pos != nullptr && pos == start + 2 && pos[-1] == ':';
38+
return (start[0] == SEPERATOR && start[1] == SEPERATOR) || (pos != nullptr && pos == start + 2 && pos[-1] == ':');
3939
#elif defined(IN_PLATFORM_POSIX)
4040
return pos != nullptr && pos == start;
4141
#endif

innative-loader/loader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ int main(int argc, char** argv)
126126
#endif
127127

128128
// Then create the runtime environment with the module count.
129-
Environment* env = (*exports.CreateEnvironment)(modules, maxthreads, argv[0]);
129+
Environment* env = (*exports.CreateEnvironment)(modules, maxthreads, (!argc ? 0 : argv[0]));
130130
if(!env)
131131
{
132132
fprintf(stderr, "Unknown error creating environment.\n");

innative-runtime-setup/Product.wxs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
3+
<?if $(var.Platform)="x86" ?>
4+
<?define ProgramFilesFolder="ProgramFilesFolder" ?>
5+
<?define Win64="no" ?>
6+
<?elseif $(var.Platform)="x64" ?>
7+
<?define ProgramFilesFolder="ProgramFiles64Folder" ?>
8+
<?define Win64="yes" ?>
9+
<?else ?>
10+
<?error Unknown value for Platform variable ?>
11+
<?endif ?>
12+
13+
<?define Version="0.1.0" ?>
14+
<Product
15+
Id="6A27F179-BADF-4580-821D-2892F229F335"
16+
Name="inNative Runtime v$(var.Version)"
17+
Language="1033"
18+
Version="$(var.Version).0"
19+
Manufacturer="Black Sphere Studios"
20+
UpgradeCode="aac979e9-ba48-44c0-aea8-40fef1176d57">
21+
22+
<Package
23+
Description='inNative Runtime Installer $(var.Platform)'
24+
Comments="Performs a full installation of the inNative Runtime"
25+
Manufacturer="Black Sphere Studios"
26+
InstallerVersion="300"
27+
Compressed="yes"
28+
InstallScope="perMachine"
29+
InstallPrivileges="elevated"
30+
Platform="$(var.Platform)"/>
31+
32+
<MediaTemplate EmbedCab="yes" CompressionLevel="high"/>
33+
<WixVariable Id="WixUILicenseRtf" Value="../innative-sdk-setup/LICENSE.rtf" />
34+
<WixVariable Id="WixUIBannerBmp" Value="../innative-sdk-setup/innative-banner.png" />
35+
<WixVariable Id="WixUIDialogBmp" Value="../innative-sdk-setup/innative-panel.png" />
36+
37+
<Directory Id="TARGETDIR" Name="SourceDir">
38+
<Directory Id="$(var.ProgramFilesFolder)">
39+
<Directory Id="INNATIVEFOLDER" Name="inNative">
40+
<Directory Id="INSTALLFOLDER" Name="Runtime v$(var.Version)"/>
41+
</Directory>
42+
</Directory>
43+
</Directory>
44+
45+
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
46+
<UIRef Id="WixUI_InstallDir" />
47+
48+
<ComponentGroup Id="inNativeBinGroup" Directory="INSTALLFOLDER">
49+
<Component Id="inNativeBin" Guid="48f2f751-ecf6-4f3e-8cb3-848df261404e">
50+
<File Id="innative.cmd.exe" Name="innative-cmd.exe" Source="$(var.innative.TargetDir)innative-cmd.exe" KeyPath="yes" Checksum="yes"/>
51+
<File Id="innative.cmd.d.exe" Name="innative-cmd-d.exe" Source="$(var.innative.TargetDir)innative-cmd-d.exe" Checksum="yes"/>
52+
<File Id="innative.d.dll" Name="innative-d.dll" Source="$(var.innative.TargetDir)innative-d.dll"/>
53+
<File Id="innative.env.d.lib" Name="innative-env-d.lib" Source="$(var.innative.TargetDir)innative-env-d.lib"/>
54+
<File Id="innative.env.lib" Name="innative-env.lib" Source="$(var.innative.TargetDir)innative-env.lib"/>
55+
<File Id="innative.s.d.lib" Name="innative-s-d.lib" Source="$(var.innative.TargetDir)innative-s-d.lib"/>
56+
<File Id="innative.s.lib" Name="innative-s.lib" Source="$(var.innative.TargetDir)innative-s.lib"/>
57+
<File Id="innative.dll" Name="innative.dll" Source="$(var.innative.TargetDir)innative.dll"/>
58+
</Component>
59+
</ComponentGroup>
60+
61+
<Feature Id="inNativeRuntime" Title="inNative Runtime" Level="1">
62+
<ComponentGroupRef Id="inNativeBinGroup" />
63+
</Feature>
64+
65+
<CustomAction Id="Installer" Execute="deferred" Impersonate="yes" Return="check" FileKey="innative.cmd.exe" ExeCommand="-i" SuppressModularization="yes" />
66+
<CustomAction Id="Uninstaller" Execute="deferred" Impersonate="yes" Return="check" FileKey="innative.cmd.exe" ExeCommand="-u" SuppressModularization="yes" />
67+
68+
<InstallExecuteSequence>
69+
<Custom Action="Installer" After="InstallFiles" Overridable="yes">NOT REMOVE~="ALL"</Custom>
70+
<Custom Action="Uninstaller" Before="RemoveFiles" Overridable="yes">REMOVE~="ALL"</Custom>
71+
</InstallExecuteSequence>
72+
</Product>
73+
74+
<!-- For unknown reasons, these custom actions must be in this exact order, in their own fragment, or they won't be sequenced properly -->
75+
</Wix>

innative-runtime-setup/en-us.wxl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<WixLocalization Culture="en-us" xmlns="http://schemas.microsoft.com/wix/2006/localization">
3+
<String Id="WelcomeDlgDescription" Overridable="yes">Welcome to the inNative Runtime installer. This will install the inNative Runtime and run WebAssembly files with the inNative command line tool.</String>
4+
</WixLocalization>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="EnsureWixToolsetInstalled" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6+
<ProductVersion>3.10</ProductVersion>
7+
<ProjectGuid>1d10e371-391d-4147-8dec-28250adb318a</ProjectGuid>
8+
<SchemaVersion>2.0</SchemaVersion>
9+
<OutputName>innative-windows-runtime</OutputName>
10+
<OutputType>Package</OutputType>
11+
</PropertyGroup>
12+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
13+
<OutputName>innative-windows-runtime-x86-d</OutputName>
14+
<OutputPath>$(SolutionDir)bin32\</OutputPath>
15+
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
18+
<OutputName>innative-windows-runtime-x86</OutputName>
19+
<OutputPath>$(SolutionDir)bin32\</OutputPath>
20+
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
21+
</PropertyGroup>
22+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
23+
<OutputName>innative-windows-runtime-x64-d</OutputName>
24+
<OutputPath>$(SolutionDir)bin\</OutputPath>
25+
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
28+
<OutputName>innative-windows-runtime-x64</OutputName>
29+
<OutputPath>$(SolutionDir)bin\</OutputPath>
30+
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Compile Include="Product.wxs" />
34+
</ItemGroup>
35+
<ItemGroup>
36+
<ProjectReference Include="..\innative\innative.vcxproj">
37+
<Name>innative</Name>
38+
<Project>{8b15928a-757d-4280-b90f-4d4e90d37f60}</Project>
39+
<Private>True</Private>
40+
<DoNotHarvest>True</DoNotHarvest>
41+
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
42+
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
43+
</ProjectReference>
44+
</ItemGroup>
45+
<ItemGroup>
46+
<WixExtension Include="WixUIExtension">
47+
<HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
48+
<Name>WixUIExtension</Name>
49+
</WixExtension>
50+
</ItemGroup>
51+
<ItemGroup>
52+
<EmbeddedResource Include="en-us.wxl" />
53+
</ItemGroup>
54+
<Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
55+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets') " />
56+
<Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' ">
57+
<Error Text="The WiX Toolset v3.11 (or newer) build tools must be installed to build this project. To download the WiX Toolset, see http://wixtoolset.org/releases/" />
58+
</Target>
59+
</Project>
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<Directory Id="TARGETDIR" Name="SourceDir">
3838
<Directory Id="$(var.ProgramFilesFolder)">
3939
<Directory Id="INNATIVEFOLDER" Name="inNative">
40-
<Directory Id="INSTALLFOLDER" Name="SDK">
40+
<Directory Id="INSTALLFOLDER" Name="SDK v$(var.Version)">
4141
<Directory Id="BINFOLDER" Name="bin" />
4242
<Directory Id="PARENTINCLUDEFOLDER" Name="include">
4343
<Directory Id="INCLUDEFOLDER" Name="innative" />
@@ -75,6 +75,10 @@
7575
<File Id="innative.s.d.pdb" Name="innative-s-d.pdb" Source="$(var.innative.TargetDir)innative-s-d.pdb"/>
7676
<File Id="innative.s.lib" Name="innative-s.lib" Source="$(var.innative.TargetDir)innative-s.lib"/>
7777
<File Id="innative.s.pdb" Name="innative-s.pdb" Source="$(var.innative.TargetDir)innative-s.pdb"/>
78+
<File Id="innative.stub.d.lib" Name="innative-stub-d.lib" Source="$(var.innative.TargetDir)innative-stub-d.lib"/>
79+
<File Id="innative.stub.d.pdb" Name="innative-stub-d.pdb" Source="$(var.innative.TargetDir)innative-stub-d.pdb"/>
80+
<File Id="innative.stub.lib" Name="innative-stub.lib" Source="$(var.innative.TargetDir)innative-stub.lib"/>
81+
<File Id="innative.stub.pdb" Name="innative-stub.pdb" Source="$(var.innative.TargetDir)innative-stub.pdb"/>
7882
<File Id="innative.dll" Name="innative.dll" Source="$(var.innative.TargetDir)innative.dll"/>
7983
<File Id="innative.exp" Name="innative.exp" Source="$(var.innative.TargetDir)innative.exp"/>
8084
<File Id="innative.lib" Name="innative.lib" Source="$(var.innative.TargetDir)innative.lib"/>

0 commit comments

Comments
 (0)