excalidrawz 1.2.5
[Homebrew/homebrew-cask.git] / Casks / a / android-ndk.rb
blob93902d848e67e27cb69b36d3e7d6ba8968724a5d
1 cask "android-ndk" do
2   version "27c"
3   sha256 "7ec95a80d91cda7b4b69401d5c4a4c285fed729811fdf7ceba5739bc9d81e36b"
5   url "https://dl.google.com/android/repository/android-ndk-r#{version}-darwin.dmg",
6       verified: "dl.google.com/android/repository/"
7   name "Android NDK"
8   desc "Toolset to implement parts of Android apps in native code"
9   homepage "https://developer.android.com/ndk/index.html"
11   livecheck do
12     url "https://developer.android.com/ndk/downloads"
13     regex(/Latest\b(?!\s+Beta|\s+Pre-Release).*?r(\d+[a-z]?)/i)
14   end
16   # shim script (https://github.com/Homebrew/homebrew-cask/issues/18809)
17   shimscript = "#{staged_path}/ndk_exec.sh"
18   preflight do
19     Pathname.new("#{HOMEBREW_PREFIX}/share").mkpath
21     build = File.read("#{staged_path}/source.properties").match(/(?<=Pkg.Revision\s=\s\d\d.\d.)\d+/)
22     FileUtils.ln_sf("#{staged_path}/AndroidNDK#{build}.app/Contents/NDK", "#{HOMEBREW_PREFIX}/share/android-ndk")
24     File.write shimscript, <<~EOS
25       #!/bin/bash
26       readonly executable="#{staged_path}/AndroidNDK#{build}.app/Contents/NDK/$(basename ${0})"
27       test -f "${executable}" && exec "${executable}" "${@}"
28     EOS
29   end
31   %w[
32     ndk-build
33     ndk-depends
34     ndk-gdb
35     ndk-stack
36     ndk-which
37   ].each { |link_name| binary shimscript, target: link_name }
39   uninstall delete: "#{HOMEBREW_PREFIX}/share/android-ndk"
41   # No zap stanza required
43   caveats <<~EOS
44     You may want to add to your profile:
45        'export ANDROID_NDK_HOME="#{HOMEBREW_PREFIX}/share/android-ndk"'
46   EOS
47 end