• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1if ! which mvn >/dev/null; then
2  echo -e '\033[01;31mMaven is not installed / configured.\033[00m'
3  exit 1
4fi
5
6if ! which mono >/dev/null; then
7  echo -e '\033[01;31mMono platform is not installed / configured.\033[00m'
8  exit 1
9fi
10
11if ! which nuget >/dev/null; then
12  echo -e '\033[01;31mNuGet compiler is not installed / configured.\033[00m'
13  exit 1
14fi
15
16if ! which mcs >/dev/null; then
17  echo -e '\033[01;31mC# compiler is not installed / configured.\033[00m'
18  exit 1
19fi
20
21rm -rf build
22mkdir build
23cd build
24
25#-------------------------------------------------------------------------------
26
27echo -e '\033[01;33mFetching Sharpen sources.\033[00m'
28
29git clone https://github.com/stanislaw89/sharpen.git
30cd sharpen
31git checkout 4f609ed42862a1f9aab1be00374ff86534a5e6d6 || exit 1
32
33#-------------------------------------------------------------------------------
34
35echo -e '\n\033[01;33mCompiling Sharpen.\033[00m'
36
37mvn clean package -DskipTests
38mvn dependency:copy -Dartifact=junit:junit:4.12 -DoutputDirectory=..
39cd ..
40cp sharpen/target/sharpencore-0.0.1-SNAPSHOT-jar-with-dependencies.jar ./sharpen.jar
41
42#-------------------------------------------------------------------------------
43
44echo -e '\n\033[01;33mTranspiling.\033[00m'
45
46cd ..
47java -jar build/sharpen.jar ../java/org/brotli/dec/ -cp build/junit-4.12.jar @sharpen.cfg
48
49#-------------------------------------------------------------------------------
50
51echo -e '\n\033[01;33mPatching.\033[00m'
52
53# TODO: detect "dead" files, that are not generated by sharpen anymore.
54cp -r build/generated/* ./
55
56# Reflection does not work without Sharpen.cs
57rm org/brotli/dec/EnumTest.cs
58
59PATTERN='\/\/ \<\{\[INJECTED CODE\]\}\>'
60CODE=$(<org/brotli/dec/BrotliInputStream.cs)
61REPLACEMENT=$(<injected_code.txt)
62echo "${CODE//$PATTERN/$REPLACEMENT}" > org/brotli/dec/BrotliInputStream.cs
63
64#-------------------------------------------------------------------------------
65
66echo -e '\n\033[01;33mDowloading dependencies.\033[00m'
67
68cd build
69nuget install NUnit -Version 3.6.1
70nuget install NUnit.ConsoleRunner -Version 3.6.1
71cd ..
72
73#-------------------------------------------------------------------------------
74
75echo -e '\n\033[01;33mCompiling generated code.\033[00m'
76
77SOURCES=`find org/brotli -type file ! -path "*Test.cs"`
78TESTS_SOURCES=`find org/brotli -type file -path "*Test.cs"`
79
80mcs $SOURCES -target:library -out:build/brotlidec.dll
81mcs $SOURCES $TESTS_SOURCES -target:library -out:build/brotlidec_test.dll -r:build/NUnit.3.6.1/lib/net45/nunit.framework.dll
82
83#-------------------------------------------------------------------------------
84
85echo -e '\n\033[01;33mRunning tests.\033[00m'
86
87export MONO_PATH=$MONO_PATH:`pwd`/build/NUnit.3.6.1/lib/net45
88mono --debug build/NUnit.ConsoleRunner.3.6.1/tools/nunit3-console.exe build/brotlidec_test.dll
89
90#-------------------------------------------------------------------------------
91
92echo -e '\n\033[01;33mCleanup.\033[00m'
93rm TestResult.xml
94rm -rf build
95