1
0
Fork 0

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,5 +1,5 @@
<?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>
@ -19,20 +19,6 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<ExternalConsole>true</ExternalConsole> <ExternalConsole>true</ExternalConsole>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
<CustomCommands>
<CustomCommands>
<Command>
<type>BeforeBuild</type>
<command>npm run build</command>
<workingdir>${ProjectDir}/ClientFiles</workingdir>
</Command>
<Command>
<type>BeforeBuild</type>
<command>msbuild</command>
<workingdir>${ProjectDir}/lib/GlidingSquirrel/GlidingSquirrel</workingdir>
</Command>
</CustomCommands>
</CustomCommands>
<Externalconsole>true</Externalconsole> <Externalconsole>true</Externalconsole>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
@ -43,12 +29,13 @@
<ExternalConsole>true</ExternalConsole> <ExternalConsole>true</ExternalConsole>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
</PropertyGroup> </PropertyGroup>
<!-- References -->
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System"/>
<Reference Include="MimeSharp"> <Reference Include="MimeSharp">
<HintPath>..\packages\MimeSharp.1.0.0\lib\MimeSharp.dll</HintPath> <HintPath>..\packages\MimeSharp.1.0.0\lib\MimeSharp.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing"/>
<Reference Include="Newtonsoft.Json"> <Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Package>monodevelop</Package> <Package>monodevelop</Package>
@ -67,60 +54,88 @@
<IncludeInPackage>false</IncludeInPackage> <IncludeInPackage>false</IncludeInPackage>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets"/>
<Target Name="BeforeBuild">
<Exec IgnoreExitCode="true" WorkingDirectory="$(SolutionDir)" Command="git submodule update --init"/>
<MakeDir Directories="$(ProjectDir)/obj/client_dist" />
<Message Importance="high" Text="------[ Gliding Squirrel ]------"/>
<MSBuild Projects="$(ProjectDir)/lib/GlidingSquirrel/GlidingSquirrel/GlidingSquirrel.csproj" Properties="Configuration=$(Configuration)"/>
<Message Importance="high" Text="----------[ npm build ]----------"/>
<Exec WorkingDirectory="$(ProjectDir)/ClientFiles" Command="npm run build"/>
<Message Importance="high" Text="---[ additional client files ]---"/>
<CreateItem Include="$(ProjectDir)/ClientFiles/**/*.html;$(ProjectDir)/ClientFiles/**/*.css;$(ProjectDir)/ClientFiles/**/*.svg;$(ProjectDir)/ClientFiles/**/*.png;$(ProjectDir)/ClientFiles/**/*.ico" Exclude="$(ProjectDir)/ClientFiles/node_modules/**/*.*">
<Output TaskParameter="Include" ItemName="StaticClientFiles" />
</CreateItem>
<Copy SourceFiles="@(StaticClientFiles)" DestinationFolder="$(ProjectDir)/obj/client_dist/%(RecursiveDir)" />
<Message Importance="high" Text="Generating embedded resource directives"/>
<CreateItem Include="$(ProjectDir)/obj/client_dist/**/*.*">
<Output ItemName="EmbeddedResource" TaskParameter="Include"/>
</CreateItem>
</Target>
<ItemGroup> <ItemGroup>
<Compile Include="Program.cs" /> <Compile Include="Program.cs"/>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs"/>
<Compile Include="RippleSpace\Plane.cs" /> <Compile Include="RippleSpace\Plane.cs"/>
<Compile Include="RippleSpace\Chunk.cs" /> <Compile Include="RippleSpace\Chunk.cs"/>
<Compile Include="RippleSpace\LocationReference.cs" /> <Compile Include="RippleSpace\LocationReference.cs"/>
<Compile Include="RippleSpace\ChunkReference.cs" /> <Compile Include="RippleSpace\ChunkReference.cs"/>
<Compile Include="RippleSpace\DrawnLine.cs" /> <Compile Include="RippleSpace\DrawnLine.cs"/>
<Compile Include="RippleSpace\Reference.cs" /> <Compile Include="RippleSpace\Reference.cs"/>
<Compile Include="NibriboardServer.cs" /> <Compile Include="NibriboardServer.cs"/>
<Compile Include="Log.cs" /> <Compile Include="Log.cs"/>
<Compile Include="Utilities\EmbeddedFiles.cs" /> <Compile Include="Utilities\EmbeddedFiles.cs"/>
<Compile Include="Env.cs" /> <Compile Include="Env.cs"/>
<Compile Include="RippleSpace\RippleSpaceManager.cs" /> <Compile Include="RippleSpace\RippleSpaceManager.cs"/>
<Compile Include="Client\NibriClient.cs" /> <Compile Include="Client\NibriClient.cs"/>
<Compile Include="Client\ClientSettings.cs" /> <Compile Include="Client\ClientSettings.cs"/>
<Compile Include="Utilities\PointExtensions.cs" /> <Compile Include="Utilities\PointExtensions.cs"/>
<Compile Include="Utilities\JsonUtilities.cs" /> <Compile Include="Utilities\JsonUtilities.cs"/>
<Compile Include="Client\Messages\Message.cs" /> <Compile Include="Client\Messages\Message.cs"/>
<Compile Include="Client\Messages\HandshakeRequestMessage.cs" /> <Compile Include="Client\Messages\HandshakeRequestMessage.cs"/>
<Compile Include="Client\Messages\CursorPositionMessage.cs" /> <Compile Include="Client\Messages\CursorPositionMessage.cs"/>
<Compile Include="RippleSpace\ClientState.cs" /> <Compile Include="RippleSpace\ClientState.cs"/>
<Compile Include="Utilities\Rectangle.cs" /> <Compile Include="Utilities\Rectangle.cs"/>
<Compile Include="Utilities\Vector2.cs" /> <Compile Include="Utilities\Vector2.cs"/>
<Compile Include="Client\Messages\ClientStatesMessage.cs" /> <Compile Include="Client\Messages\ClientStatesMessage.cs"/>
<Compile Include="Utilities\ColourHSL.cs" /> <Compile Include="Utilities\ColourHSL.cs"/>
<Compile Include="Utilities\ToStringJsonConverter.cs" /> <Compile Include="Utilities\ToStringJsonConverter.cs"/>
<Compile Include="Client\Messages\HandshakeResponseMessage.cs" /> <Compile Include="Client\Messages\HandshakeResponseMessage.cs"/>
<Compile Include="Client\Messages\ShutdownMessage.cs" /> <Compile Include="Client\Messages\ShutdownMessage.cs"/>
<Compile Include="Client\Messages\IdleDisconnectMessage.cs" /> <Compile Include="Client\Messages\IdleDisconnectMessage.cs"/>
<Compile Include="Client\Messages\HeartbeatMessage.cs" /> <Compile Include="Client\Messages\HeartbeatMessage.cs"/>
<Compile Include="Client\Messages\ChunkUpdateMessage.cs" /> <Compile Include="Client\Messages\ChunkUpdateMessage.cs"/>
<Compile Include="Client\Messages\PlaneChangeMessage.cs" /> <Compile Include="Client\Messages\PlaneChangeMessage.cs"/>
<Compile Include="Client\Messages\ExceptionMessage.cs" /> <Compile Include="Client\Messages\ExceptionMessage.cs"/>
<Compile Include="Utilities\ChunkTools.cs" /> <Compile Include="Utilities\ChunkTools.cs"/>
<Compile Include="Client\Messages\ChunkUpdateRequestMessage.cs" /> <Compile Include="Client\Messages\ChunkUpdateRequestMessage.cs"/>
<Compile Include="Client\ChunkCache.cs" /> <Compile Include="Client\ChunkCache.cs"/>
<Compile Include="Client\Messages\LinePartMessage.cs" /> <Compile Include="Client\Messages\LinePartMessage.cs"/>
<Compile Include="Client\LineIncubator.cs" /> <Compile Include="Client\LineIncubator.cs"/>
<Compile Include="Client\Messages\LineCompleteMessage.cs" /> <Compile Include="Client\Messages\LineCompleteMessage.cs"/>
<Compile Include="Client\Messages\ErrorMessage.cs" /> <Compile Include="Client\Messages\ErrorMessage.cs"/>
<Compile Include="Client\Messages\PlaneChangeOkMessage.cs" /> <Compile Include="Client\Messages\PlaneChangeOkMessage.cs"/>
<Compile Include="Client\RawChunkReference.cs" /> <Compile Include="Client\RawChunkReference.cs"/>
<Compile Include="Client\Messages\LinePartReflectionMessage.cs" /> <Compile Include="Client\Messages\LinePartReflectionMessage.cs"/>
<Compile Include="Client\Messages\LineCompleteReflectionMessage.cs" /> <Compile Include="Client\Messages\LineCompleteReflectionMessage.cs"/>
<Compile Include="Client\Messages\LineStartMessage.cs" /> <Compile Include="Client\Messages\LineStartMessage.cs"/>
<Compile Include="Client\Messages\LineStartReflectionMessage.cs" /> <Compile Include="Client\Messages\LineStartReflectionMessage.cs"/>
<Compile Include="Utilities\CalcPaths.cs" /> <Compile Include="Utilities\CalcPaths.cs"/>
<Compile Include="RippleSpace\PlaneInfo.cs" /> <Compile Include="RippleSpace\PlaneInfo.cs"/>
<Compile Include="Utilities\BinaryIO.cs" /> <Compile Include="Utilities\BinaryIO.cs"/>
<Compile Include="Client\Messages\ViewportUpdateMessage.cs" /> <Compile Include="Client\Messages\ViewportUpdateMessage.cs"/>
<Compile Include="NibriboardApp.cs" /> <Compile Include="NibriboardApp.cs"/>
<Compile Include="Utilities\LineSimplifier.cs" /> <Compile Include="Utilities\LineSimplifier.cs"/>
</ItemGroup> </ItemGroup>
<!--
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="ClientFiles\index.html" /> <EmbeddedResource Include="ClientFiles\index.html" />
<EmbeddedResource Include="ClientFiles\NibriClient.js" /> <EmbeddedResource Include="ClientFiles\NibriClient.js" />
@ -132,23 +147,25 @@
<EmbeddedResource Include="ClientFiles\images\icons\pan.png" /> <EmbeddedResource Include="ClientFiles\images\icons\pan.png" />
<EmbeddedResource Include="ClientFiles\images\icons\point.png" /> <EmbeddedResource Include="ClientFiles\images\icons\point.png" />
</ItemGroup> </ItemGroup>
-->
<ItemGroup> <ItemGroup>
<Folder Include="RippleSpace\" /> <Folder Include="RippleSpace\"/>
<Folder Include="Utilities\" /> <Folder Include="Utilities\"/>
<Folder Include="ClientFiles\" /> <Folder Include="ClientFiles\"/>
<Folder Include="Client\" /> <Folder Include="Client\"/>
<Folder Include="Client\Messages\" /> <Folder Include="Client\Messages\"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config"/>
<None Include="ClientFiles\index.js" /> <None Include="ClientFiles\index.js"/>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- MonoDevelop settings -->
<ProjectExtensions> <ProjectExtensions>
<MonoDevelop> <MonoDevelop>
<Properties> <Properties>
<Policies> <Policies>
<DotNetNamingPolicy ResourceNamePolicy="FileFormatDefault" DirectoryNamespaceAssociation="PrefixedHierarchical" /> <DotNetNamingPolicy ResourceNamePolicy="FileFormatDefault" DirectoryNamespaceAssociation="PrefixedHierarchical"/>
</Policies> </Policies>
</Properties> </Properties>
</MonoDevelop> </MonoDevelop>

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
}