From fd84a1333a9b2c17a8347ef0b21859624c9869f9 Mon Sep 17 00:00:00 2001 From: asteinb Date: Mon, 16 Apr 2018 12:03:20 -0700 Subject: Independently parse assets This is the first step in processing assets completely seperately from resources. RELNOTES: none PiperOrigin-RevId: 193076991 --- .../lib/rules/android/ParsedAndroidAssets.java | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/main/java/com/google/devtools/build/lib/rules/android/ParsedAndroidAssets.java (limited to 'src/main/java/com/google/devtools/build/lib/rules/android/ParsedAndroidAssets.java') 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); + } +} -- cgit v1.2.3