From 6996bead0931685f323bfe76ea20f55854d5a902 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Sat, 12 Nov 2016 16:41:41 +0100 Subject: [PATCH] DroidFish, CuckooChessEngine: Don't fork when building book files. This makes the build work even if "java" is not in the path. --- CuckooChessEngine/build_binbook.xml | 5 +++-- CuckooChessEngine/src/chess/Book.java | 13 ++++++++----- DroidFish/build_eco.xml | 7 +++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/CuckooChessEngine/build_binbook.xml b/CuckooChessEngine/build_binbook.xml index 523d0f9..cff808c 100644 --- a/CuckooChessEngine/build_binbook.xml +++ b/CuckooChessEngine/build_binbook.xml @@ -2,8 +2,9 @@ + classname="chess.Book"> + + diff --git a/CuckooChessEngine/src/chess/Book.java b/CuckooChessEngine/src/chess/Book.java index 58a7bd1..af5f6f8 100644 --- a/CuckooChessEngine/src/chess/Book.java +++ b/CuckooChessEngine/src/chess/Book.java @@ -19,6 +19,7 @@ package chess; import java.io.BufferedReader; +import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -188,8 +189,10 @@ public class Book { /** Creates the book.bin file. */ public static void main(String[] args) throws IOException { - List binBook = createBinBook(); - FileOutputStream out = new FileOutputStream("src/book.bin"); + String inFile = args[0]; + String outFile = args[1]; + List binBook = createBinBook(inFile); + FileOutputStream out = new FileOutputStream(outFile); int bookLen = binBook.size(); byte[] binBookA = new byte[bookLen]; for (int i = 0; i < bookLen; i++) @@ -197,11 +200,11 @@ public class Book { out.write(binBookA); out.close(); } - - public static List createBinBook() { + + public static List createBinBook(String inFileName) { List binBook = new ArrayList(0); try { - InputStream inStream = new Object().getClass().getResourceAsStream("/book.txt"); + InputStream inStream = new FileInputStream(inFileName); InputStreamReader inFile = new InputStreamReader(inStream); BufferedReader inBuf = new BufferedReader(inFile); LineNumberReader lnr = new LineNumberReader(inBuf); diff --git a/DroidFish/build_eco.xml b/DroidFish/build_eco.xml index a21263f..0efe845 100644 --- a/DroidFish/build_eco.xml +++ b/DroidFish/build_eco.xml @@ -2,10 +2,9 @@ - - + classname="org.petero.droidfish.buildtools.EcoBuilder"> + +