summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Lamarche <benoitlamarche@google.com>2015-05-29 12:57:50 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-05-29 12:57:50 +0000
commit2600fe54c29949048100051f92f40f3082c84b76 (patch)
tree615e42cbc45914b6deafdcc9ed1625cb58e63f4e
parentcd6fbff263a0460c7cd1ffd55fe60774aad62da1 (diff)
parentd2fca07d45ff05f2f2881d756ba4939fd24096e8 (diff)
downloadtoolchain_jack-2600fe54c29949048100051f92f40f3082c84b76.zip
toolchain_jack-2600fe54c29949048100051f92f40f3082c84b76.tar.gz
toolchain_jack-2600fe54c29949048100051f92f40f3082c84b76.tar.bz2
Merge "Use CaseInsesitiveFS for all library output dirs" into ub-jack-brest
-rw-r--r--jack/src/com/android/jack/Options.java4
-rw-r--r--jack/src/com/android/jack/library/InputJackLibraryCodec.java18
-rw-r--r--sched/src/com/android/sched/util/codec/CaseInsensitiveDirectFSCodec.java103
-rw-r--r--sched/src/com/android/sched/vfs/CaseInsensitiveFS.java26
4 files changed, 143 insertions, 8 deletions
diff --git a/jack/src/com/android/jack/Options.java b/jack/src/com/android/jack/Options.java
index dd4e4d6..ed05863 100644
--- a/jack/src/com/android/jack/Options.java
+++ b/jack/src/com/android/jack/Options.java
@@ -46,8 +46,8 @@ import com.android.jack.transformations.renamepackage.PackageRenamer;
import com.android.jack.util.ClassNameCodec;
import com.android.jack.util.filter.Filter;
import com.android.sched.util.RunnableHooks;
+import com.android.sched.util.codec.CaseInsensitiveDirectFSCodec;
import com.android.sched.util.codec.DirectDirOutputVFSCodec;
-import com.android.sched.util.codec.DirectFSCodec;
import com.android.sched.util.codec.DirectoryCodec;
import com.android.sched.util.codec.InputFileOrDirectoryCodec;
import com.android.sched.util.codec.InputStreamOrDirectoryCodec;
@@ -190,7 +190,7 @@ public class Options {
@Nonnull
public static final PropertyId<VFS> LIBRARY_OUTPUT_DIR = PropertyId.create(
"jack.library.output.dir", "Output folder for library",
- new DirectFSCodec(Existence.MUST_EXIST)).requiredIf(GENERATE_JACK_LIBRARY
+ new CaseInsensitiveDirectFSCodec(Existence.MUST_EXIST)).requiredIf(GENERATE_JACK_LIBRARY
.getValue().isTrue().and(LIBRARY_OUTPUT_CONTAINER_TYPE.is(Container.DIR)));
diff --git a/jack/src/com/android/jack/library/InputJackLibraryCodec.java b/jack/src/com/android/jack/library/InputJackLibraryCodec.java
index 61479d6..3da05c9 100644
--- a/jack/src/com/android/jack/library/InputJackLibraryCodec.java
+++ b/jack/src/com/android/jack/library/InputJackLibraryCodec.java
@@ -19,9 +19,11 @@ package com.android.jack.library;
import com.android.jack.LibraryException;
import com.android.sched.util.RunnableHooks;
import com.android.sched.util.codec.CodecContext;
+import com.android.sched.util.codec.MessageDigestCodec;
import com.android.sched.util.codec.ParsingException;
import com.android.sched.util.codec.StringCodec;
import com.android.sched.util.config.ConfigurationError;
+import com.android.sched.util.config.MessageDigestFactory;
import com.android.sched.util.file.CannotCreateFileException;
import com.android.sched.util.file.CannotSetPermissionException;
import com.android.sched.util.file.Directory;
@@ -34,11 +36,14 @@ import com.android.sched.util.file.InputZipFile;
import com.android.sched.util.file.NoSuchFileException;
import com.android.sched.util.file.NotFileOrDirectoryException;
import com.android.sched.util.file.WrongPermissionException;
+import com.android.sched.vfs.CaseInsensitiveFS;
import com.android.sched.vfs.DirectFS;
import com.android.sched.vfs.ReadZipFS;
import com.android.sched.vfs.VFS;
+import com.android.sched.vfs.WrongVFSFormatException;
import java.io.File;
+import java.security.Provider.Service;
import java.util.Collections;
import java.util.List;
import java.util.zip.ZipException;
@@ -51,6 +56,9 @@ import javax.annotation.Nonnull;
*/
public class InputJackLibraryCodec implements StringCodec<InputJackLibrary> {
+ @Nonnull
+ private final MessageDigestCodec messageDigestCodec = new MessageDigestCodec();
+
@Override
@Nonnull
public InputJackLibrary parseString(@Nonnull CodecContext context, @Nonnull String string) {
@@ -61,6 +69,7 @@ public class InputJackLibraryCodec implements StringCodec<InputJackLibrary> {
}
}
+ @SuppressWarnings("resource")
@Override
@CheckForNull
public InputJackLibrary checkString(@Nonnull CodecContext context, @Nonnull String string)
@@ -70,12 +79,19 @@ public class InputJackLibraryCodec implements StringCodec<InputJackLibrary> {
Directory workingDirectory = context.getWorkingDirectory();
File dirOrZip = FileOrDirectory.getFileFromWorkingDirectory(workingDirectory, string);
if (dirOrZip.isDirectory()) {
- vfs = new DirectFS(new Directory(workingDirectory,
+ DirectFS directFS = new DirectFS(new Directory(workingDirectory,
string,
context.getRunnableHooks(),
Existence.MUST_EXIST,
Permission.READ | Permission.WRITE,
ChangePermission.NOCHANGE), Permission.READ | Permission.WRITE);
+ try {
+ Service service = messageDigestCodec.checkString(context, "SHA");
+ vfs = new CaseInsensitiveFS(directFS, /* nbGroup = */ 2, /* szGroup = */ 2,
+ new MessageDigestFactory(service), /* debug = */ false);
+ } catch (WrongVFSFormatException e) {
+ vfs = directFS;
+ }
} else {
RunnableHooks hooks = context.getRunnableHooks();
assert hooks != null;
diff --git a/sched/src/com/android/sched/util/codec/CaseInsensitiveDirectFSCodec.java b/sched/src/com/android/sched/util/codec/CaseInsensitiveDirectFSCodec.java
new file mode 100644
index 0000000..7567dfe
--- /dev/null
+++ b/sched/src/com/android/sched/util/codec/CaseInsensitiveDirectFSCodec.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.sched.util.codec;
+
+import com.android.sched.util.config.ConfigurationError;
+import com.android.sched.util.config.MessageDigestFactory;
+import com.android.sched.util.file.FileOrDirectory.Existence;
+import com.android.sched.vfs.CaseInsensitiveFS;
+import com.android.sched.vfs.DirectFS;
+import com.android.sched.vfs.VFS;
+import com.android.sched.vfs.WrongVFSFormatException;
+
+import java.security.Provider.Service;
+import java.util.List;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+
+/**
+ * This {@link StringCodec} is used to create an instance of a {@link CaseInsensitiveFS} backed by a
+ * {@link DirectFS}.
+ */
+public class CaseInsensitiveDirectFSCodec implements StringCodec<VFS> {
+
+ @Nonnull
+ private final DirectFSCodec codec;
+ @Nonnull
+ private final MessageDigestCodec messageDigestCodec = new MessageDigestCodec();
+
+ public CaseInsensitiveDirectFSCodec() {
+ codec = new DirectFSCodec();
+ }
+
+ public CaseInsensitiveDirectFSCodec(@Nonnull Existence mustExist) {
+ codec = new DirectFSCodec(mustExist);
+ }
+
+ @Override
+ @Nonnull
+ public VFS parseString(@Nonnull CodecContext context, @Nonnull String string) {
+ try {
+ return checkString(context, string);
+ } catch (ParsingException e) {
+ throw new ConfigurationError(e);
+ }
+ }
+
+ @Override
+ @CheckForNull
+ public VFS checkString(@Nonnull CodecContext context, @Nonnull String string)
+ throws ParsingException {
+ try {
+ Service service = messageDigestCodec.checkString(context, "SHA");
+ return new CaseInsensitiveFS(codec.checkString(context, string), /* nbGroup = */ 2,
+ /* szGroup = */ 2, new MessageDigestFactory(service), /* debug = */ false);
+ } catch (WrongVFSFormatException e) {
+ throw new ParsingException(e);
+ }
+ }
+
+ @Override
+ @Nonnull
+ public String getUsage() {
+ return codec.getUsage();
+ }
+
+ @Override
+ @Nonnull
+ public String getVariableName() {
+ return codec.getVariableName();
+ }
+
+ @Override
+ @Nonnull
+ public List<ValueDescription> getValueDescriptions() {
+ return codec.getValueDescriptions();
+ }
+
+ @Override
+ @Nonnull
+ public String formatValue(@Nonnull VFS data) {
+ return codec.formatValue(data);
+ }
+
+ @Override
+ public void checkValue(@Nonnull CodecContext context, @Nonnull VFS data) {
+ codec.checkValue(context, data);
+ }
+}
diff --git a/sched/src/com/android/sched/vfs/CaseInsensitiveFS.java b/sched/src/com/android/sched/vfs/CaseInsensitiveFS.java
index 2c4bb61..7aff7cc 100644
--- a/sched/src/com/android/sched/vfs/CaseInsensitiveFS.java
+++ b/sched/src/com/android/sched/vfs/CaseInsensitiveFS.java
@@ -81,10 +81,11 @@ public class CaseInsensitiveFS extends BaseVFS<CaseInsensitiveVDir, CaseInsensit
"sched.vfs.case-insensitive.debug",
"generate an index file '" + DEBUG_NAME + "' for debugging purpose").addDefaultValue(false);
- private final int nbGroup = ThreadConfig.get(NB_GROUP).intValue();
- private final int szGroup = ThreadConfig.get(SZ_GROUP).intValue();
- private final MessageDigestFactory mdf = ThreadConfig.get(ALGO);
- private final boolean debug = ThreadConfig.get(DEBUG).booleanValue();
+ private final int nbGroup;
+ private final int szGroup;
+ @Nonnull
+ private final MessageDigestFactory mdf;
+ private final boolean debug;
@Nonnull
private final CaseInsensitiveVDir root = new CaseInsensitiveVDir(this, null, "");
@@ -191,8 +192,14 @@ public class CaseInsensitiveFS extends BaseVFS<CaseInsensitiveVDir, CaseInsensit
@Nonnull
private final BaseVFS<BaseVDir, BaseVFile> vfs;
- @SuppressWarnings("unchecked")
public CaseInsensitiveFS(@Nonnull VFS vfs) throws WrongVFSFormatException {
+ this(vfs, ThreadConfig.get(NB_GROUP).intValue(), ThreadConfig.get(SZ_GROUP).intValue(),
+ ThreadConfig.get(ALGO), ThreadConfig.get(DEBUG).booleanValue());
+ }
+
+ @SuppressWarnings("unchecked")
+ public CaseInsensitiveFS(@Nonnull VFS vfs, int nbGroup, int szGroup,
+ @Nonnull MessageDigestFactory mdf, boolean debug) throws WrongVFSFormatException {
this.vfs = (BaseVFS<BaseVDir, BaseVFile>) vfs;
Set<Capabilities> capabilities = EnumSet.copyOf(vfs.getCapabilities());
@@ -200,6 +207,15 @@ public class CaseInsensitiveFS extends BaseVFS<CaseInsensitiveVDir, CaseInsensit
capabilities.add(Capabilities.UNIQUE_ELEMENT);
this.capabilities = Collections.unmodifiableSet(capabilities);
+ this.nbGroup = nbGroup;
+ this.szGroup = szGroup;
+ this.mdf = mdf;
+ this.debug = false;
+
+ initVFS();
+ }
+
+ private void initVFS() throws WrongVFSFormatException {
LineNumberReader reader = null;
VFile file = null;
try {