1
0
Fork 0
mirror of https://github.com/sbrl/Nibriboard.git synced 2018-01-10 21:33:49 +00:00

Pull the whole build system apart and put it back together again. It's a lot more flexible now :P

This commit is contained in:
Starbeamrainbowlabs 2017-11-09 21:30:03 +00:00
parent d0b0b7c775
commit 9ce8f70be0
11 changed files with 3472 additions and 203 deletions

8
.gitignore vendored
View file

@ -1,6 +1,12 @@
# Don't include the project of the client's javascript build process # Don't include the product of the client's javascript build process
Nibriboard/ClientFiles/NibriClient.js Nibriboard/ClientFiles/NibriClient.js
# ....or ghostwriter backup files
*.backup
# ...or saved ripplespaces
*.zip
# We don't want temporary files created by ...browserify? # We don't want temporary files created by ...browserify?
# # I'm not sure where in npm they come from, but we don't want them anyhow :P # # I'm not sure where in npm they come from, but we don't want them anyhow :P
*.tmp *.tmp

View file

@ -182,6 +182,6 @@
<!----------------> <!---------------->
<link rel="stylesheet" href="Nibri.css" /> <link rel="stylesheet" href="Nibri.css" />
<script src="NibriClient.js" charset="utf-8"></script> <script src="nibriclient.bundle.js" charset="utf-8"></script>
</head> </head>
</html> </html>

File diff suppressed because it is too large Load diff

View file

@ -16,8 +16,7 @@
}, },
"devDependencies": { "devDependencies": {
"acorn": "^4.0.11", "acorn": "^4.0.11",
"esprima": "^3.1.3", "webpack": "^3.8.1"
"rollupify": "^0.3.8"
}, },
"config": { "config": {
"bundle_file": "NibriClient.js" "bundle_file": "NibriClient.js"
@ -25,7 +24,7 @@
"scripts": { "scripts": {
"test": "echo There aren\\'t any tests yet!", "test": "echo There aren\\'t any tests yet!",
"prebuild": "./validate.sh", "prebuild": "./validate.sh",
"build": "browserify $npm_package_main -t rollupify -o $npm_package_config_bundle_file" "build": "node_modules/webpack/bin/webpack.js --config webpack.config.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View file

@ -1,21 +1,33 @@
#!/usr/bin/env bash #!/usr/bin/env bash
counter_filename=$(mktemp -p /dev/shm/ -t bash.XXXXXXXXX.tmp); function validate_file {
echo 0 >${counter_filename}; filename=$1;
find . -name "*.js" -not -path "./node_modules/*" | while read filename;
do
validate_result=$(node_modules/.bin/acorn --module --silent $filename 2>&1); validate_result=$(node_modules/.bin/acorn --module --silent $filename 2>&1);
validate_exit_code=$?; validate_exit_code=$?;
validate_output=$([[ ${validate_exit_code} -eq 0 ]] && echo ok || echo ${validate_result}); validate_output=$([[ ${validate_exit_code} -eq 0 ]] && echo ok || echo ${validate_result});
echo ${filename}: ${validate_output} echo ${filename}: ${validate_output}
# TODO: Use /dev/shm here since apparently while is in a subshell, so it can't modify variables in the main program O.o # Use /dev/shm here since apparently while is in a subshell, so it can't modify variables in the main program O.o
if ! [ ${validate_exit_code} -eq 0 ]; then if ! [ ${validate_exit_code} -eq 0 ]; then
error_count=$(cat ${counter_filename}); error_count=$(cat ${counter_filename});
echo incrementing ${error_count} \($(expr ${error_count} + 1)\); echo incrementing ${error_count} \($(expr ${error_count} + 1)\);
echo $(expr ${error_count} + 1) >${counter_filename}; echo $(expr ${error_count} + 1) >${counter_filename};
fi fi
}
counter_filename=$(mktemp -p /dev/shm/ -t bash.XXXXXXXXX.tmp);
echo 0 >${counter_filename};
# Parallelisation trick from https://stackoverflow.com/a/33058618/1460422
find . -name "*.js" -not -path "./node_modules/*" | while read filename;
do
validate_file "${filename}" &
# Run at most the number of CPU cores jobs at once
[ $( jobs | wc -l ) -ge $( nproc ) ] && wait
done done
wait
error_count=$(cat ${counter_filename}); error_count=$(cat ${counter_filename});
echo echo

View file

@ -0,0 +1,13 @@
var output_dir = "../obj/client_dist";
var fs = require("fs"),
path = require("path");
module.exports = {
entry: "./index.js",
devtool: "source-map",
output: {
path: path.resolve(__dirname, output_dir),
filename: "nibriclient.bundle.js"
}
};

View file

@ -1,156 +1,173 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="BeforeBuild;Build" ToolsVersion="4.0">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{B7F806D9-9C50-4BA8-A803-0FC2EC5F5932}</ProjectGuid> <ProjectGuid>{B7F806D9-9C50-4BA8-A803-0FC2EC5F5932}</ProjectGuid>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<RootNamespace>Nibriboard</RootNamespace> <RootNamespace>Nibriboard</RootNamespace>
<AssemblyName>Nibriboard</AssemblyName> <AssemblyName>Nibriboard</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath> <OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants> <DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<ExternalConsole>true</ExternalConsole> <ExternalConsole>true</ExternalConsole>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
<CustomCommands> <Externalconsole>true</Externalconsole>
<CustomCommands> </PropertyGroup>
<Command> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<type>BeforeBuild</type> <Optimize>true</Optimize>
<command>npm run build</command> <OutputPath>bin\Release</OutputPath>
<workingdir>${ProjectDir}/ClientFiles</workingdir> <ErrorReport>prompt</ErrorReport>
</Command> <WarningLevel>4</WarningLevel>
<Command> <ExternalConsole>true</ExternalConsole>
<type>BeforeBuild</type> <PlatformTarget>x86</PlatformTarget>
<command>msbuild</command> </PropertyGroup>
<workingdir>${ProjectDir}/lib/GlidingSquirrel/GlidingSquirrel</workingdir> <!-- References -->
</Command> <ItemGroup>
</CustomCommands> <Reference Include="System"/>
</CustomCommands> <Reference Include="MimeSharp">
<Externalconsole>true</Externalconsole> <HintPath>..\packages\MimeSharp.1.0.0\lib\MimeSharp.dll</HintPath>
</PropertyGroup> </Reference>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> <Reference Include="System.Drawing"/>
<Optimize>true</Optimize> <Reference Include="Newtonsoft.Json">
<OutputPath>bin\Release</OutputPath> <HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<ErrorReport>prompt</ErrorReport> <Package>monodevelop</Package>
<WarningLevel>4</WarningLevel> </Reference>
<ExternalConsole>true</ExternalConsole> <Reference Include="SharpCompress">
<PlatformTarget>x86</PlatformTarget> <HintPath>..\packages\SharpCompress.0.18.2\lib\net45\SharpCompress.dll</HintPath>
</PropertyGroup> </Reference>
<ItemGroup> <Reference Include="NCuid">
<Reference Include="System" /> <HintPath>..\packages\NCuid.1.0.0\lib\net40\NCuid.dll</HintPath>
<Reference Include="MimeSharp"> </Reference>
<HintPath>..\packages\MimeSharp.1.0.0\lib\MimeSharp.dll</HintPath> </ItemGroup>
</Reference> <ItemGroup>
<Reference Include="System.Drawing" /> <ProjectReference Include="lib\GlidingSquirrel\GlidingSquirrel\GlidingSquirrel.csproj">
<Reference Include="Newtonsoft.Json"> <Project>{476D3588-4FEE-4C75-874F-214E26B8AC1A}</Project>
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> <Name>GlidingSquirrel</Name>
<Package>monodevelop</Package> <IncludeInPackage>false</IncludeInPackage>
</Reference> </ProjectReference>
<Reference Include="SharpCompress"> </ItemGroup>
<HintPath>..\packages\SharpCompress.0.18.2\lib\net45\SharpCompress.dll</HintPath>
</Reference> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets"/>
<Reference Include="NCuid">
<HintPath>..\packages\NCuid.1.0.0\lib\net40\NCuid.dll</HintPath> <Target Name="BeforeBuild">
</Reference> <Exec IgnoreExitCode="true" WorkingDirectory="$(SolutionDir)" Command="git submodule update --init"/>
</ItemGroup> <MakeDir Directories="$(ProjectDir)/obj/client_dist" />
<ItemGroup>
<ProjectReference Include="lib\GlidingSquirrel\GlidingSquirrel\GlidingSquirrel.csproj"> <Message Importance="high" Text="------[ Gliding Squirrel ]------"/>
<Project>{476D3588-4FEE-4C75-874F-214E26B8AC1A}</Project> <MSBuild Projects="$(ProjectDir)/lib/GlidingSquirrel/GlidingSquirrel/GlidingSquirrel.csproj" Properties="Configuration=$(Configuration)"/>
<Name>GlidingSquirrel</Name> <Message Importance="high" Text="----------[ npm build ]----------"/>
<IncludeInPackage>false</IncludeInPackage> <Exec WorkingDirectory="$(ProjectDir)/ClientFiles" Command="npm run build"/>
</ProjectReference>
</ItemGroup> <Message Importance="high" Text="---[ additional client files ]---"/>
<ItemGroup>
<Compile Include="Program.cs" /> <CreateItem Include="$(ProjectDir)/ClientFiles/**/*.html;$(ProjectDir)/ClientFiles/**/*.css;$(ProjectDir)/ClientFiles/**/*.svg;$(ProjectDir)/ClientFiles/**/*.png;$(ProjectDir)/ClientFiles/**/*.ico" Exclude="$(ProjectDir)/ClientFiles/node_modules/**/*.*">
<Compile Include="Properties\AssemblyInfo.cs" /> <Output TaskParameter="Include" ItemName="StaticClientFiles" />
<Compile Include="RippleSpace\Plane.cs" /> </CreateItem>
<Compile Include="RippleSpace\Chunk.cs" />
<Compile Include="RippleSpace\LocationReference.cs" /> <Copy SourceFiles="@(StaticClientFiles)" DestinationFolder="$(ProjectDir)/obj/client_dist/%(RecursiveDir)" />
<Compile Include="RippleSpace\ChunkReference.cs" />
<Compile Include="RippleSpace\DrawnLine.cs" /> <Message Importance="high" Text="Generating embedded resource directives"/>
<Compile Include="RippleSpace\Reference.cs" /> <CreateItem Include="$(ProjectDir)/obj/client_dist/**/*.*">
<Compile Include="NibriboardServer.cs" /> <Output ItemName="EmbeddedResource" TaskParameter="Include"/>
<Compile Include="Log.cs" /> </CreateItem>
<Compile Include="Utilities\EmbeddedFiles.cs" /> </Target>
<Compile Include="Env.cs" />
<Compile Include="RippleSpace\RippleSpaceManager.cs" />
<Compile Include="Client\NibriClient.cs" /> <ItemGroup>
<Compile Include="Client\ClientSettings.cs" /> <Compile Include="Program.cs"/>
<Compile Include="Utilities\PointExtensions.cs" /> <Compile Include="Properties\AssemblyInfo.cs"/>
<Compile Include="Utilities\JsonUtilities.cs" /> <Compile Include="RippleSpace\Plane.cs"/>
<Compile Include="Client\Messages\Message.cs" /> <Compile Include="RippleSpace\Chunk.cs"/>
<Compile Include="Client\Messages\HandshakeRequestMessage.cs" /> <Compile Include="RippleSpace\LocationReference.cs"/>
<Compile Include="Client\Messages\CursorPositionMessage.cs" /> <Compile Include="RippleSpace\ChunkReference.cs"/>
<Compile Include="RippleSpace\ClientState.cs" /> <Compile Include="RippleSpace\DrawnLine.cs"/>
<Compile Include="Utilities\Rectangle.cs" /> <Compile Include="RippleSpace\Reference.cs"/>
<Compile Include="Utilities\Vector2.cs" /> <Compile Include="NibriboardServer.cs"/>
<Compile Include="Client\Messages\ClientStatesMessage.cs" /> <Compile Include="Log.cs"/>
<Compile Include="Utilities\ColourHSL.cs" /> <Compile Include="Utilities\EmbeddedFiles.cs"/>
<Compile Include="Utilities\ToStringJsonConverter.cs" /> <Compile Include="Env.cs"/>
<Compile Include="Client\Messages\HandshakeResponseMessage.cs" /> <Compile Include="RippleSpace\RippleSpaceManager.cs"/>
<Compile Include="Client\Messages\ShutdownMessage.cs" /> <Compile Include="Client\NibriClient.cs"/>
<Compile Include="Client\Messages\IdleDisconnectMessage.cs" /> <Compile Include="Client\ClientSettings.cs"/>
<Compile Include="Client\Messages\HeartbeatMessage.cs" /> <Compile Include="Utilities\PointExtensions.cs"/>
<Compile Include="Client\Messages\ChunkUpdateMessage.cs" /> <Compile Include="Utilities\JsonUtilities.cs"/>
<Compile Include="Client\Messages\PlaneChangeMessage.cs" /> <Compile Include="Client\Messages\Message.cs"/>
<Compile Include="Client\Messages\ExceptionMessage.cs" /> <Compile Include="Client\Messages\HandshakeRequestMessage.cs"/>
<Compile Include="Utilities\ChunkTools.cs" /> <Compile Include="Client\Messages\CursorPositionMessage.cs"/>
<Compile Include="Client\Messages\ChunkUpdateRequestMessage.cs" /> <Compile Include="RippleSpace\ClientState.cs"/>
<Compile Include="Client\ChunkCache.cs" /> <Compile Include="Utilities\Rectangle.cs"/>
<Compile Include="Client\Messages\LinePartMessage.cs" /> <Compile Include="Utilities\Vector2.cs"/>
<Compile Include="Client\LineIncubator.cs" /> <Compile Include="Client\Messages\ClientStatesMessage.cs"/>
<Compile Include="Client\Messages\LineCompleteMessage.cs" /> <Compile Include="Utilities\ColourHSL.cs"/>
<Compile Include="Client\Messages\ErrorMessage.cs" /> <Compile Include="Utilities\ToStringJsonConverter.cs"/>
<Compile Include="Client\Messages\PlaneChangeOkMessage.cs" /> <Compile Include="Client\Messages\HandshakeResponseMessage.cs"/>
<Compile Include="Client\RawChunkReference.cs" /> <Compile Include="Client\Messages\ShutdownMessage.cs"/>
<Compile Include="Client\Messages\LinePartReflectionMessage.cs" /> <Compile Include="Client\Messages\IdleDisconnectMessage.cs"/>
<Compile Include="Client\Messages\LineCompleteReflectionMessage.cs" /> <Compile Include="Client\Messages\HeartbeatMessage.cs"/>
<Compile Include="Client\Messages\LineStartMessage.cs" /> <Compile Include="Client\Messages\ChunkUpdateMessage.cs"/>
<Compile Include="Client\Messages\LineStartReflectionMessage.cs" /> <Compile Include="Client\Messages\PlaneChangeMessage.cs"/>
<Compile Include="Utilities\CalcPaths.cs" /> <Compile Include="Client\Messages\ExceptionMessage.cs"/>
<Compile Include="RippleSpace\PlaneInfo.cs" /> <Compile Include="Utilities\ChunkTools.cs"/>
<Compile Include="Utilities\BinaryIO.cs" /> <Compile Include="Client\Messages\ChunkUpdateRequestMessage.cs"/>
<Compile Include="Client\Messages\ViewportUpdateMessage.cs" /> <Compile Include="Client\ChunkCache.cs"/>
<Compile Include="NibriboardApp.cs" /> <Compile Include="Client\Messages\LinePartMessage.cs"/>
<Compile Include="Utilities\LineSimplifier.cs" /> <Compile Include="Client\LineIncubator.cs"/>
</ItemGroup> <Compile Include="Client\Messages\LineCompleteMessage.cs"/>
<ItemGroup> <Compile Include="Client\Messages\ErrorMessage.cs"/>
<EmbeddedResource Include="ClientFiles\index.html" /> <Compile Include="Client\Messages\PlaneChangeOkMessage.cs"/>
<EmbeddedResource Include="ClientFiles\NibriClient.js" /> <Compile Include="Client\RawChunkReference.cs"/>
<EmbeddedResource Include="ClientFiles\Nibri.css" /> <Compile Include="Client\Messages\LinePartReflectionMessage.cs"/>
<EmbeddedResource Include="ClientFiles\favicon.ico" /> <Compile Include="Client\Messages\LineCompleteReflectionMessage.cs"/>
<EmbeddedResource Include="ClientFiles\nibriboard.svg" /> <Compile Include="Client\Messages\LineStartMessage.cs"/>
<EmbeddedResource Include="ClientFiles\images\transparent-square-tiles.png" /> <Compile Include="Client\Messages\LineStartReflectionMessage.cs"/>
<EmbeddedResource Include="ClientFiles\images\icons\brush.png" /> <Compile Include="Utilities\CalcPaths.cs"/>
<EmbeddedResource Include="ClientFiles\images\icons\pan.png" /> <Compile Include="RippleSpace\PlaneInfo.cs"/>
<EmbeddedResource Include="ClientFiles\images\icons\point.png" /> <Compile Include="Utilities\BinaryIO.cs"/>
</ItemGroup> <Compile Include="Client\Messages\ViewportUpdateMessage.cs"/>
<ItemGroup> <Compile Include="NibriboardApp.cs"/>
<Folder Include="RippleSpace\" /> <Compile Include="Utilities\LineSimplifier.cs"/>
<Folder Include="Utilities\" /> </ItemGroup>
<Folder Include="ClientFiles\" /> <!--
<Folder Include="Client\" /> <ItemGroup>
<Folder Include="Client\Messages\" /> <EmbeddedResource Include="ClientFiles\index.html" />
</ItemGroup> <EmbeddedResource Include="ClientFiles\NibriClient.js" />
<ItemGroup> <EmbeddedResource Include="ClientFiles\Nibri.css" />
<None Include="packages.config" /> <EmbeddedResource Include="ClientFiles\favicon.ico" />
<None Include="ClientFiles\index.js" /> <EmbeddedResource Include="ClientFiles\nibriboard.svg" />
</ItemGroup> <EmbeddedResource Include="ClientFiles\images\transparent-square-tiles.png" />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <EmbeddedResource Include="ClientFiles\images\icons\brush.png" />
<ProjectExtensions> <EmbeddedResource Include="ClientFiles\images\icons\pan.png" />
<MonoDevelop> <EmbeddedResource Include="ClientFiles\images\icons\point.png" />
<Properties> </ItemGroup>
<Policies> -->
<DotNetNamingPolicy ResourceNamePolicy="FileFormatDefault" DirectoryNamespaceAssociation="PrefixedHierarchical" /> <ItemGroup>
</Policies> <Folder Include="RippleSpace\"/>
</Properties> <Folder Include="Utilities\"/>
</MonoDevelop> <Folder Include="ClientFiles\"/>
</ProjectExtensions> <Folder Include="Client\"/>
<Folder Include="Client\Messages\"/>
</ItemGroup>
<ItemGroup>
<None Include="packages.config"/>
<None Include="ClientFiles\index.js"/>
</ItemGroup>
<!-- MonoDevelop settings -->
<ProjectExtensions>
<MonoDevelop>
<Properties>
<Policies>
<DotNetNamingPolicy ResourceNamePolicy="FileFormatDefault" DirectoryNamespaceAssociation="PrefixedHierarchical"/>
</Policies>
</Properties>
</MonoDevelop>
</ProjectExtensions>
</Project> </Project>

View file

@ -108,7 +108,7 @@ namespace Nibriboard
{ {
response.ResponseCode = HttpResponseCode.NotFound; response.ResponseCode = HttpResponseCode.NotFound;
response.ContentType = "text/plain"; response.ContentType = "text/plain";
await response.SetBody($"Can't find expandedFilePath."); await response.SetBody($"Can't find '{expandedFilePath}'.");
logRequest(request, response); logRequest(request, response);
return; return;
} }

View file

@ -48,7 +48,7 @@ namespace Nibriboard
// HTTP Server setup // HTTP Server setup
appServer = new NibriboardApp(new NibriboardAppStartInfo() { appServer = new NibriboardApp(new NibriboardAppStartInfo() {
FilePrefix = "Nibriboard.ClientFiles", FilePrefix = "Nibriboard.obj.client_dist",
ClientSettings = clientSettings, ClientSettings = clientSettings,
SpaceManager = planeManager SpaceManager = planeManager
}, IPAddress.Any, Port); }, IPAddress.Any, Port);

View file

@ -22,3 +22,9 @@ An infinite whiteboard for recording those big ideas.
- Future reference: Libraries I am considering - Future reference: Libraries I am considering
- [Paper.js](http://paperjs.org/) - Client-side rendering - [Paper.js](http://paperjs.org/) - Client-side rendering
- [IotWeb](http://sensaura.org/pages/tools/iotweb/) - Underlying HTTP / WebSocket server - [IotWeb](http://sensaura.org/pages/tools/iotweb/) - Underlying HTTP / WebSocket server
## Useful Links
- MSBuild:
- [`Exec` task](https://docs.microsoft.com/en-gb/visualstudio/msbuild/exec-task)
- [Dynamic wildcarded embedded resources](https://ayende.com/blog/4446/how-to-setup-dynamic-groups-in-msbuild-without-visual-studio-ruining-them)

3
package-lock.json generated Normal file
View file

@ -0,0 +1,3 @@
{
"lockfileVersion": 1
}