Permalink
Browse files

Merge pull request #88 from Expro/master

Add a simple example and starter project that can be used when building JSIL applications.
  • Loading branch information...
2 parents 68c8d47 + b444828 commit 703cefdbb4379dec2f8e708f9ad8a741765c0fab @kg kg committed May 18, 2012
@@ -0,0 +1,111 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <!-- REQUIRED: Core modules of JSIL. //-->
+ <script src="./Libraries/JSIL.Core.js" type="text/javascript"></script>
+ <script src="./Libraries/JSIL.Bootstrap.js" type="text/javascript"></script>
+
+ <!--
+ REQUIRED: Include application manifest here. Manifest contains information
+ about assemblies referenced by Your application and their JavaScript counterparts.
+ //-->
+ <script src="./Scripts/SimpleProject.exe.manifest.js" type="text/javascript"></script>
+ </head>
+
+ <!--
+ REQUIRED: Assigns 'onLoad()' function to global 'onload' event. 'onLoad()' function
+ is JSIL predeclared function. Once document is loaded, JSIL will be intialized automatically.
+ Alternatively, onLoad() function can be executed manually from inside of the body, but it is required
+ to execute it BEFOR any other JSIL functions.
+ //-->
+ <body onload="onLoad()">
+ <!--
+ OPTIONAL: Workaround for Chrome bug. If Chrome is detected, four empty DIV elements
+ are created and attached to body, one for each JSIL asset type, reflected by ID.
+ //-->
+ <script type="text/javascript">
+ if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1)
+ {
+ var scripts = document.createElement("div");
+ scripts.id = "scripts";
+ document.body.appendChild(scripts);
+
+ var images = document.createElement("div");
+ images.id = "images";
+ document.body.appendChild(images);
+
+ var sounds = document.createElement("div");
+ sounds.id = "sounds";
+ document.body.appendChild(sounds);
+
+ var fonts = document.createElement("div");
+ fonts.id = "fonts";
+ document.body.appendChild(fonts);
+ }
+ </script>
+
+ <!--
+ REQUIRED: Canvas element with ID "canvas" is required by JSIL.Browser.js. Any drawing is performed on this element.
+ //-->
+ <canvas id="canvas"></canvas>
+
+ <!--
+ OPTIONAL/RECOMMENDED: Element with id "log" is an output for any console text stream (Out/Error). In theory,
+ as long as there is no text to display, everything should work jsut fine, but since JSIL displays all
+ error and info messages here, it is highly recommended to include this element.
+ //-->
+ <div id="log" style="font-family: Consolas, Courier New, monospace"></div>
+
+ <!--
+ REQUIRED: Core module of JSIL, MUST be included AFTER canvas element.
+ //-->
+ <script src="./Libraries/JSIL.Browser.js" type="text/javascript"></script>
+
+ <script type="text/javascript">
+ /*
+ * OPTIONAL: Configures paths to JSIL assets.
+ *
+ * scriptRoot - relative path to scripts (compiled assemblies)
+ * libraryRoot - relative path to native JavasScript scripts
+ * fileRoot - relative path to file assets
+ * contentRoot - relative path to XNA content assets
+ */
+ var scriptRoot = "./Scripts/";
+ var libraryRoot = "./Libraries/";
+ var fileRoot = "./Files/";
+ var contentRoot = "./Content/";
+
+ /*
+ * REQUIRED: Defines all assets required by Your application. Assets are loaded befor code execution.
+ * Each asset is pair of strings, describing its type and file name. Declare as empty array if no assets.
+ *
+ * Example (from Demos\Mannux.html):
+ * var assetsToLoad =
+ * [
+ * ["Library", "System.Drawing.js"],
+ * ["Library", "JSIL.IO.js"],
+ * ["File", "Data/Maps/test.map"],
+ * ["File", "tabby.txt"]
+ * ];
+ */
+ var assetsToLoad = [];
+
+ /*
+ * REQUIRED: Function executed on start of JSIL application. Name must be equal to "runMain()".
+ * $asm00 is variable declared in manifest, referencing assembly with entry point.
+ */
+ function runMain()
+ {
+ /* OPTIONAL: Removes pre-execution log (console) messages. */
+ document.getElementById("log").innerHTML = "";
+
+ /*
+ * REQUIRED: Runs application from entry point. Alternatively, You can create any object
+ * that is responsible for executing content of application and use it.
+ */
+ var asm = JSIL.GetAssembly("SimpleProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
+ asm.MyNamespace.Program.Main([]);
+ }
+ </script>
+ </body>
+</html>
View
@@ -0,0 +1,26 @@
+/*
+ * Project: Simple project for JSIL
+ *
+ * Description: Minimal JSIL project, configured to run out-of-box (out-of-git?). Each non-obvious line
+ * of C#/HTML/JavaScript code is described, however, how/why it works is discovered
+ * by trail-and-error approach, no guarantees on correctness.
+ * To use it in Your application, simply copy entire folder and add Your own content,
+ * feel free to remove this header once You did it.
+ *
+ * License: Enjoy without any limitations.
+ *
+ * Author: Maciej "Expro" Grabowski
+ * E-mail: mds.expro@gmail.com | maciejgrabowski@hotmail.com
+ */
+using System;
+
+namespace MyNamespace
+{
+ class Program
+ {
+ public static void Main(string[] args)
+ {
+ Console.WriteLine("It works!");
+ }
+ }
+}
@@ -0,0 +1,31 @@
+#region Using directives
+
+using System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+#endregion
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("SimpleProject")]
+[assembly: AssemblyDescription("Simple project for JSIL")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("MyCompany")]
+[assembly: AssemblyProduct("SimpleProject")]
+[assembly: AssemblyCopyright("Copyleft 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// This sets the default COM visibility of types in the assembly to invisible.
+// If you need to expose a type to COM, use [ComVisible(true)] on that type.
+[assembly: ComVisible(false)]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all the values or you can use the default the Revision and
+// Build Numbers by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0")]
View
@@ -0,0 +1,30 @@
+Project: Simple project for JSIL
+
+Description: Minimal JSIL project, configured to run out-of-box (out-of-git?). Each non-obvious line
+ of C#/HTML/JavaScript code is described, however, how/why it works is discovered
+ by trail-and-error approach, no guarantees on correctness.
+ To use it in Your application, simply compile solution, copy entire folder and add Your own content.
+ Feel free to remove this file once You did it.
+
+License: Enjoy without any limitations.
+
+Author: Maciej "Expro" Grabowski
+E-mail: mds.expro@gmail.com | maciejgrabowski@hotmail.com
+
+What-is-what:
+ ".\Compiler\" - place for JSIL compiler.
+ ".\Build\" - compiled content of your application.
+ ".\Build\index.html" - web page responsible for execution of Your application.
+ ".\Build\Scripts\" - place for compiled assemblies (scripts) of your application,
+ filed automatically by post-build event.
+ ".\Build\Libraries\" - place for JSIL and JavaScript libraries.
+ ".\Build\Files\" - place for file assets.
+ ".\Build\Content\" - place for XNA content assets.
+
+How-To:
+ 1. Compile JSIL solution ("Release" build recommended for speed).
+ 2. Create new, empty solution for your application, copy and add "SimpleProject" into it.
+ 3. Create symbolic links for ".\Compiler\" (pointing to directory with JSILc.exe), and for ".\Build\Libraries\"
+ (pointing to JSIL "Libraries" directory). Alternatively, copy compiler and libraries manually - however,
+ You will need to keep them in sync on Your own.
+ 4. Fill solution with content.
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
+ <PropertyGroup>
+ <ProjectGuid>{37344DA6-BB3C-44FF-9A55-72D662112B90}</ProjectGuid>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>MyNamespace</RootNamespace>
+ <AssemblyName>SimpleProject</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <SourceAnalysisOverrideSettingsFile>C:\Users\Expro\AppData\Roaming\ICSharpCode/SharpDevelop4\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
+ <SignAssembly>False</SignAssembly>
+ <DelaySign>False</DelaySign>
+ <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
+ <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
+ <NoStdLib>False</NoStdLib>
+ <WarningLevel>4</WarningLevel>
+ <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ <RunCodeAnalysis>False</RunCodeAnalysis>
+ <RunSourceAnalysis>False</RunSourceAnalysis>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Platform)' == 'x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <RegisterForComInterop>False</RegisterForComInterop>
+ <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
+ <BaseAddress>4194304</BaseAddress>
+ <FileAlignment>4096</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+ <OutputPath>bin\</OutputPath>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>Full</DebugType>
+ <Optimize>False</Optimize>
+ <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <StartAction>Project</StartAction>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+ <OutputPath>bin\Release\</OutputPath>
+ <DebugSymbols>False</DebugSymbols>
+ <DebugType>None</DebugType>
+ <Optimize>True</Optimize>
+ <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
+ <DefineConstants>TRACE</DefineConstants>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Build" />
+ <Folder Include="Build\Content" />
+ <Folder Include="Build\Files" />
+ <Folder Include="Build\Libraries" />
+ <Folder Include="Build\Scripts" />
+ <Folder Include="Compiler" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Build\index.html" />
+ <None Include="Read.me" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
+ <PropertyGroup>
+ <PostBuildEvent>cd "$(ProjectDir)Compiler"
+JSILc.exe "$(TargetPath)" -o="$(ProjectDir)Build\Scripts"</PostBuildEvent>
+ </PropertyGroup>
+</Project>

0 comments on commit 703cefd

Please sign in to comment.