Commit 16e1c7bd authored by Laurent Le Brun's avatar Laurent Le Brun Committed by GitHub
Browse files

Merge pull request #9 from eldritchconundrum/master

I merged the sources you sent me, fixed compilation on Linux, and added a way to run the tests.
parents 5875ccb3 281ef2ef
......@@ -9,10 +9,10 @@
<OutputType>Exe</OutputType>
<RootNamespace>glsl_minifier</RootNamespace>
<AssemblyName>shader_minifier</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<Name>Shader Minifier</Name>
<TargetFrameworkProfile />
<TargetFSharpCoreVersion>4.4.0.0</TargetFSharpCoreVersion>
<TargetFSharpCoreVersion>2.3.0.0</TargetFSharpCoreVersion>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
......@@ -60,46 +60,24 @@
<None Include="App.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Content Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Reference Include="FParsec">
<HintPath>packages\FParsec.1.0.2\lib\net40-client\FParsec.dll</HintPath>
<Private>True</Private>
<HintPath>lib\FParsec.dll</HintPath>
</Reference>
<Reference Include="FParsecCS">
<HintPath>packages\FParsec.1.0.2\lib\net40-client\FParsecCS.dll</HintPath>
<Private>True</Private>
<HintPath>lib\FParsecCS.dll</HintPath>
</Reference>
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>True</Private>
</Reference>
<Reference Include="FSharp.PowerPack">
<HintPath>packages\FSPowerPack.Core.Community.2.0.0.0\lib\Net40\FSharp.PowerPack.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="FSharp.PowerPack.Linq">
<HintPath>packages\FSPowerPack.Linq.Community.2.0.0.0\lib\Net40\FSharp.PowerPack.Linq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="FSharp.PowerPack.Metadata">
<HintPath>packages\FSPowerPack.Metadata.Community.2.0.0.0\lib\Net40\FSharp.PowerPack.Metadata.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="FSharp.PowerPack.Parallel.Seq">
<HintPath>packages\FSPowerPack.Parallel.Seq.Community.2.0.0.0\lib\Net40\FSharp.PowerPack.Parallel.Seq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<Private>True</Private>
<SpecificVersion>True</SpecificVersion>
</Reference>
<Reference Include="System">
<Private>True</Private>
<HintPath>lib\FSharp.PowerPack.dll</HintPath>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
<Private>True</Private>
</Reference>
</ItemGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
......
* Get a proper test suite. Seriously.
* Update to F# 3.0 (not tried, maybe it already works).
* Update to FParsec 1.0. This requires a couple of easy changes in
parse.fs.
* Simplify the release process. Ideally, we should get a single .exe file
that works both on Microsoft .NET and on Mono.
* Some antivirus (eg. Avast) don't like Shader Minifier. No idea why.
* Performance. I suspect that using StringBuffer in the printer would
drastically improve performance.
......
#! /bin/bash
references='-r lib/FParsec.dll -r lib/FParsecCS.dll -r lib/FSharp.PowerPack.dll'
fsharpc --standalone $references src/{ast.fs,printer.fs,cGen.fs,renamer.fs,rewriter.fs,parse.fs,main.fs} -o shader_minifier.exe
@echo off
"C:\Program Files (x86)\Microsoft SDKs\F#\4.0\Framework\v4.0\fsc.exe" -o:shader_minifier.exe --noframework --optimize+ -r:D:\Laurent\Shader_Minifier\Shader_Minifier\lib\FParsec.dll -r:D:\Laurent\Shader_Minifier\Shader_Minifier\lib\FParsecCS.dll -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v2.0\2.3.0.0\FSharp.Core.dll" -r:D:\Laurent\Shader_Minifier\Shader_Minifier\lib\FSharp.PowerPack.dll -r:C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" -r:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll --target:exe --warn:3 --warnaserror:76 --vserrors --LCID:1033 --utf8output --fullpaths --flaterrors --highentropyva- --sqmsessionguid:e89d638f-5243-4e0b-bd3d-2c4d190d1bae --standalone src\ast.fs src\printer.fs src\cGen.fs src\renamer.fs src\rewriter.fs src\parse.fs src\main.fs
File added
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FParsec" version="1.0.2" targetFramework="net45" />
<package id="FSPowerPack.Community" version="3.0.0.0" targetFramework="net45" />
<package id="FSPowerPack.Core.Community" version="2.0.0.0" targetFramework="net45" />
<package id="FSPowerPack.Linq.Community" version="2.0.0.0" targetFramework="net45" />
<package id="FSPowerPack.Metadata.Community" version="2.0.0.0" targetFramework="net45" />
<package id="FSPowerPack.Parallel.Seq.Community" version="2.0.0.0" targetFramework="net45" />
</packages>
\ No newline at end of file
module tests
open System
open System.IO
open System.Diagnostics
let outFilename = Path.Combine(Path.GetTempPath(), "shader_code.h")
let testFiles = Directory.GetFiles("tests/", "*.*", SearchOption.AllDirectories)
let () =
let stopwatch = Stopwatch.StartNew()
printfn "Running %i tests..." (testFiles.Length)
let failedTestCount = ref 0
for filename in testFiles do
let p = Process.Start("./shader_minifier.exe",
String.concat " " [ filename; "-o"; outFilename ])
p.WaitForExit()
if p.ExitCode <> 0 then
printfn "*** error while testing %s: program returned %i" filename p.ExitCode
failedTestCount := !failedTestCount + 1
printfn "\n"
printfn "%i tests run in %i seconds, %i failed." testFiles.Length (int(stopwatch.Elapsed.TotalSeconds)) !failedTestCount
()
#! /bin/bash
references='-r lib/FParsec.dll -r lib/FParsecCS.dll -r lib/FSharp.PowerPack.dll'
fsharpc --standalone $references src/{ast.fs,printer.fs,cGen.fs,renamer.fs,rewriter.fs,parse.fs,main.fs,tests.fs} -o tests.exe && ./tests.exe || echo "tests.exe failed."
void f() {
if (1) {
return 2;
} else {;}
return 3;
}
void do_something() {}
void f() {
do_something();
}
......@@ -7,7 +7,7 @@ float f4 = float((2+3) * (4+5*6) - (7-8));
float f5 = (2.+f1) * (4.+f2*6.) - (7.-f3);
float f6 = -------5.;
float n = 1. / (f1 + f2 + f3)
float n = 1. / (f1 + f2 + f3);
float o = 1. / (f4 * f5 * f6);
gl_FragColor=vec4(n,o,n,0.);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment