aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/java/buck-ios-support/java/com/facebook/buck/apple/FileTypes.java
blob: 1ea0c04831f64c335e5c3069a109570bf2bd01bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
 * Copyright 2014-present Facebook, Inc.
 *
 * 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.facebook.buck.apple;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;

/**
 * File types used in Apple targets.
 */
public final class FileTypes {

  // Utility class. Do not instantiate.
  private FileTypes() { }

  /**
   * Map of file extension to Apple UTI (Uniform Type Identifier).
   */
  public static final ImmutableMap<String, String> FILE_EXTENSION_TO_UTI =
      ImmutableMap.<String, String>builder()
          .put("a", "archive.ar")
          .put("app", "wrapper.application")
          .put("appex", "wrapper.app-extension")
          .put("bdic", "file")
          .put("bin", "archive.macbinary")
          .put("bmp", "image.bmp")
          .put("bundle", "wrapper.cfbundle")
          .put("c", "sourcecode.c.c")
          .put("cc", "sourcecode.cpp.cpp")
          .put("cpp", "sourcecode.cpp.cpp")
          .put("css", "text.css")
          .put("cxx", "sourcecode.cpp.cpp")
          .put("dart", "sourcecode")
          .put("dylib", "compiled.mach-o.dylib")
          .put("exp", "sourcecode.exports")
          .put("framework", "wrapper.framework")
          .put("fsh", "sourcecode.glsl")
          .put("gyp", "sourcecode")
          .put("gypi", "text")
          .put("h", "sourcecode.c.h")
          .put("hxx", "sourcecode.cpp.h")
          .put("icns", "image.icns")
          .put("java", "sourcecode.java")
          .put("jar", "archive.jar")
          .put("jpeg", "image.jpeg")
          .put("jpg", "image.jpeg")
          .put("js", "sourcecode.javascript")
          .put("json", "text.json")
          .put("m", "sourcecode.c.objc")
          .put("mm", "sourcecode.cpp.objcpp")
          .put("nib", "wrapper.nib")
          .put("o", "compiled.mach-o.objfile")
          .put("octest", "wrapper.cfbundle")
          .put("pdf", "image.pdf")
          .put("pl", "text.script.perl")
          .put("plist", "text.plist.xml")
          .put("pm", "text.script.perl")
          .put("png", "image.png")
          .put("proto", "text")
          .put("py", "text.script.python")
          .put("r", "sourcecode.rez")
          .put("rez", "sourcecode.rez")
          .put("rtf", "text.rtf")
          .put("s", "sourcecode.asm")
          .put("storyboard", "file.storyboard")
          .put("strings", "text.plist.strings")
          .put("tif", "image.tiff")
          .put("tiff", "image.tiff")
          .put("tcc", "sourcecode.cpp.cpp")
          .put("ttf", "file")
          .put("vsh", "sourcecode.glsl")
          .put("xcassets", "folder.assetcatalog")
          .put("xcconfig", "text.xcconfig")
          .put("xcodeproj", "wrapper.pb-project")
          .put("xcdatamodel", "wrapper.xcdatamodel")
          .put("xcdatamodeld", "wrapper.xcdatamodeld")
          .put("xctest", "wrapper.cfbundle")
          .put("xib", "file.xib")
          .put("y", "sourcecode.yacc")
          .put("zip", "archive.zip")
          .build();

  /**
   * Set of UTIs which only work as "lastKnownFileType" and not "explicitFileType"
   * in a PBXFileReference.
   *
   * Yes, really. Because Xcode.
   */
  public static final ImmutableSet<String> EXPLICIT_FILE_TYPE_BROKEN_UTIS =
    ImmutableSet.of("file.xib");

  /**
   * Multimap of Apple UTI (Uniform Type Identifier) to file extension(s).
   */
  public static final ImmutableMultimap<String, String> UTI_TO_FILE_EXTENSIONS;

  static {
    // Invert the map of (file extension -> UTI) pairs to
    // (UTI -> [file extension 1, ...]) pairs.
    ImmutableMultimap.Builder<String, String> builder = ImmutableMultimap.builder();
    for (ImmutableMap.Entry<String, String> entry : FILE_EXTENSION_TO_UTI.entrySet()) {
      builder.put(entry.getValue(), entry.getKey());
    }
    UTI_TO_FILE_EXTENSIONS = builder.build();
  }
}