-
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MakeUnicodeFiles.java option #636
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,13 +7,19 @@ | |
import com.ibm.icu.text.NumberFormat; | ||
import com.ibm.icu.text.RuleBasedCollator; | ||
import com.ibm.icu.text.UnicodeSet; | ||
import com.ibm.icu.util.OutputInt; | ||
import com.ibm.icu.util.ULocale; | ||
import com.ibm.icu.util.VersionInfo; | ||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
import java.io.StringWriter; | ||
import java.io.UncheckedIOException; | ||
import java.lang.reflect.Field; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.StandardCopyOption; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.BitSet; | ||
|
@@ -53,7 +59,64 @@ public class MakeUnicodeFiles { | |
static boolean DEBUG = false; | ||
|
||
public static void main(String[] args) throws IOException { | ||
|
||
boolean clean = Arrays.asList(args).contains("-c"); | ||
|
||
if (clean) { | ||
|
||
// Remove the bin file so that changes to the dev directory aren't ignored | ||
// The index unicode properties (eg Alphabetic.bin) don't need to be removed | ||
// because they are rebuilt if the source files change | ||
|
||
File binFile = | ||
new File( | ||
Settings.Output.GEN_DIR + "BIN", | ||
markusicu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"UCD_Data" + Settings.latestVersion + ".bin"); | ||
binFile.delete(); | ||
|
||
// remove the old files in the output directory | ||
|
||
Files.walk(Path.of(Settings.Output.GEN_DIR + "UCD")) | ||
markusicu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.sorted(Comparator.reverseOrder()) | ||
.map(Path::toFile) | ||
.forEach(File::delete); | ||
} | ||
|
||
generateFile(); | ||
|
||
if (clean) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find it surprising/confusing that the "clean" option should also drive copying the files back to the input. It would be better to make another new option like "--changesToInput" . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ping -- I really think it would be better to make a second option, with another readable option name (not just renaming the Java variable) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't disagree with @markusicu but from the standpoint of practicality, do we see ourselves or anyone else using one option without the other? |
||
|
||
// Copy the important changed files to dev directory | ||
|
||
Path sourceBase = Path.of(Settings.Output.GEN_DIR + "UCD/" + Settings.latestVersion); | ||
markusicu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Path targetBase = | ||
Settings.UnicodeTools.DataDir.UCD.asPath(Settings.LATEST_VERSION_INFO); | ||
OutputInt fileCount = new OutputInt(); // for use in forEach, can't be just int. | ||
Files.walk(sourceBase) | ||
.filter( | ||
x -> | ||
!x.toFile().isDirectory() | ||
&& !x.getFileName().toString().startsWith("ZZZ-") | ||
&& !x.getParent() | ||
.getFileName() | ||
.toString() | ||
.equals("cldr") | ||
&& !x.getParent() | ||
.getFileName() | ||
.toString() | ||
.equals("extra")) | ||
.forEach( | ||
x -> { | ||
Path targetDir = targetBase.resolve(sourceBase.relativize(x)); | ||
System.out.println(++fileCount.value + ") Moving:\t" + x + "\tto\t" + targetDir); | ||
try { | ||
Files.move(x, targetDir, StandardCopyOption.REPLACE_EXISTING); | ||
} catch (IOException e) { | ||
throw new UncheckedIOException(e); | ||
} | ||
}); | ||
System.out.println(fileCount + " file(s) copied to " + targetBase); | ||
} | ||
System.out.println("DONE"); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about a more self-explanatory option string, something like "--cleanBin" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping -- longer option names make reading and documenting command lines much easier