diff options
author | Benoit Lamarche <benoitlamarche@google.com> | 2015-05-07 19:27:15 +0200 |
---|---|---|
committer | Benoit Lamarche <benoitlamarche@google.com> | 2015-05-29 12:07:12 +0200 |
commit | d2fca07d45ff05f2f2881d756ba4939fd24096e8 (patch) | |
tree | ac0d16a02477b718d2dcf3405b31f4403675b2f3 /sched/src/com/android/sched | |
parent | fc023a96016b05d8906bed57761de19f5d5d095a (diff) | |
download | toolchain_jack-d2fca07d45ff05f2f2881d756ba4939fd24096e8.tar.gz toolchain_jack-d2fca07d45ff05f2f2881d756ba4939fd24096e8.tar.bz2 toolchain_jack-d2fca07d45ff05f2f2881d756ba4939fd24096e8.zip |
Use CaseInsesitiveFS for all library output dirs
Bug: 18750643
(cherry picked from commit 1751a7aba3ae72251ea8b83592967034a6f8996c)
Change-Id: Ifb600f8c0f3213631be91c0a080afe6d5d93e1b6
Diffstat (limited to 'sched/src/com/android/sched')
-rw-r--r-- | sched/src/com/android/sched/util/codec/CaseInsensitiveDirectFSCodec.java | 103 | ||||
-rw-r--r-- | sched/src/com/android/sched/vfs/CaseInsensitiveFS.java | 26 |
2 files changed, 124 insertions, 5 deletions
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 00000000..7567dfe6 --- /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 2c4bb61d..7aff7ccd 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 { |