1{
2 lib,
3 stdenvNoCC,
4 fetchzip,
5 autoPatchelfHook,
6 libcxx,
7}:
8
9stdenvNoCC.mkDerivation rec {
10 pname = "aapt";
11 version = "8.4.1-11315950";
12
13 src =
14 let
15 urlAndHash =
16 if stdenvNoCC.hostPlatform.isLinux then
17 {
18 url = "https://dl.google.com/android/maven2/com/android/tools/build/aapt2/${version}/aapt2-${version}-linux.jar";
19 hash = "sha256-eSQaZrRtb5aCG320hrXAL256fxa/oMhBC4hcTA1KRxs=";
20 }
21 else if stdenvNoCC.hostPlatform.isDarwin then
22 {
23 url = "https://dl.google.com/android/maven2/com/android/tools/build/aapt2/${version}/aapt2-${version}-osx.jar";
24 hash = "sha256-LUihNjase79JbUkHDb10A5d6pJ+VXDVfv7m09hkL8kY=";
25 }
26 else
27 throw "Unsupport platform: ${stdenvNoCC.system}";
28 in
29 fetchzip (
30 urlAndHash
31 // {
32 extension = "zip";
33 stripRoot = false;
34 }
35 );
36
37 nativeBuildInputs = lib.optionals stdenvNoCC.hostPlatform.isLinux [ autoPatchelfHook ];
38 buildInputs = lib.optionals stdenvNoCC.hostPlatform.isLinux [ libcxx ];
39
40 installPhase = ''
41 runHook preInstall
42
43 install -D aapt2 $out/bin/aapt2
44
45 runHook postInstall
46 '';
47
48 meta = {
49 description = "Build tool that compiles and packages Android app's resources";
50 mainProgram = "aapt2";
51 homepage = "https://developer.android.com/tools/aapt2";
52 license = lib.licenses.asl20;
53 maintainers = with lib.maintainers; [ linsui ];
54 teams = [ lib.teams.android ];
55 platforms = lib.platforms.unix;
56 badPlatforms = [
57 # The linux executable only supports x86_64
58 "aarch64-linux"
59 ];
60 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
61 };
62}