diff options
author | asteinb <asteinb@google.com> | 2018-04-16 12:03:20 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-04-16 12:04:37 -0700 |
commit | fd84a1333a9b2c17a8347ef0b21859624c9869f9 (patch) | |
tree | b20991b30e34ef27a2a9abff81fc5719fd1f0995 /src/main/java/com/google/devtools/build/lib/rules/android/ParsedAndroidAssets.java | |
parent | 835814895fffef00fe88658f91e4550dc61546cf (diff) |
Independently parse assets
This is the first step in processing assets completely seperately from resources.
RELNOTES: none
PiperOrigin-RevId: 193076991
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/android/ParsedAndroidAssets.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/android/ParsedAndroidAssets.java | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ParsedAndroidAssets.java b/src/main/java/com/google/devtools/build/lib/rules/android/ParsedAndroidAssets.java new file mode 100644 index 0000000000..6a83642483 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/rules/android/ParsedAndroidAssets.java @@ -0,0 +1,67 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// 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.google.devtools.build.lib.rules.android; + +import com.google.devtools.build.lib.actions.Artifact; +import com.google.devtools.build.lib.analysis.RuleContext; +import com.google.devtools.build.lib.cmdline.Label; +import java.util.Objects; + +/** Parsed Android assets which can be merged together with assets from dependencies. */ +public class ParsedAndroidAssets extends AndroidAssets implements MergableAndroidData { + private final Artifact symbols; + private final Label label; + + public static ParsedAndroidAssets parseFrom(RuleContext ruleContext, AndroidAssets assets) + throws InterruptedException { + return new AndroidResourceParsingActionBuilder(ruleContext) + .setOutput(ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_ASSET_SYMBOLS)) + .build(assets); + } + + public static ParsedAndroidAssets of(AndroidAssets assets, Artifact symbols, Label label) { + return new ParsedAndroidAssets(assets, symbols, label); + } + + private ParsedAndroidAssets(AndroidAssets other, Artifact symbols, Label label) { + super(other); + this.symbols = symbols; + this.label = label; + } + + @Override + public Label getLabel() { + return label; + } + + @Override + public Artifact getSymbols() { + return symbols; + } + + @Override + public boolean equals(Object object) { + if (!super.equals(object)) { + return false; + } + + ParsedAndroidAssets other = (ParsedAndroidAssets) object; + return symbols.equals(other.symbols) && label.equals(other.label); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), symbols, label); + } +} |