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