class {{ formula_class }} < Formula {%- if desc %} desc "{{ desc }}" {%- endif %} {%- if homepage %} homepage "{{ homepage }}" {%- endif %} version "{{ inner.app_version }}" {#- #} {%- if arm64_macos.id or x86_64_macos.id %} if OS.mac? {#- If arm64/x86_64 builds are the same, skip the Hardware::CPU.type if statement #} {%- if arm64_macos.id == x86_64_macos.id %} url "{{ inner.base_url }}/{{ arm64_macos.id }}" {%- if arm64_macos_sha256 %} sha256 "{{ arm64_macos_sha256 }}" {%- endif %} {%- else %} {%- if arm64_macos.id %} if Hardware::CPU.arm? url "{{ inner.base_url }}/{{ arm64_macos.id }}" {%- if arm64_macos_sha256 %} sha256 "{{ arm64_macos_sha256 }}" {%- endif %} end {%- endif %} {%- if x86_64_macos.id %} if Hardware::CPU.intel? url "{{ inner.base_url }}/{{ x86_64_macos.id }}" {%- if x86_64_macos_sha256 %} sha256 "{{ x86_64_macos_sha256 }}" {%- endif %} end {%- endif %} {%- endif %} end {%- endif %} {#- #} {%- if arm64_linux.id or x86_64_linux.id %} if OS.linux? {%- if arm64_linux.id %} if Hardware::CPU.arm? url "{{ inner.base_url }}/{{ arm64_linux.id }}" {%- if arm64_linux %} sha256 "{{ arm64_linux_sha256 }}" {%- endif %} end {%- endif %} {%- if x86_64_linux.id %} if Hardware::CPU.intel? url "{{ inner.base_url }}/{{ x86_64_linux.id }}" {%- if x86_64_linux_sha256 %} sha256 "{{ x86_64_linux_sha256 }}" {%- endif %} end {%- endif %} end {%- endif %} {#- #} {%- if license %} license {{ license }} {%- endif %} {%- if dependencies|length > 0 %} {% for dep in dependencies %} depends_on "{{ dep }}" {%- endfor %} {%- endif %} BINARY_ALIASES = {{ inner.bin_aliases | tojson(indent=2) | indent(2) }} def target_triple cpu = Hardware::CPU.arm? ? "aarch64" : "x86_64" os = OS.mac? ? "apple-darwin" : "unknown-linux-gnu" "#{cpu}-#{os}" end def install_binary_aliases! BINARY_ALIASES[target_triple.to_sym].each do |source, dests| dests.each do |dest| bin.install_symlink bin/source.to_s => dest end end end def install {%- if arm64_macos.executables or arm64_macos.cdylibs %} if OS.mac? && Hardware::CPU.arm? {%- if arm64_macos.executables %} bin.install {% for binary in arm64_macos.executables %}"{{ binary }}"{{ ", " if not loop.last else "" }}{% endfor %} {%- endif %} {%- if arm64_macos.cdylibs and "cdylib" in install_libraries %} lib.install {% for library in arm64_macos.cdylibs %}"{{ library }}"{{ ", " if not loop.last else "" }}{% endfor %} {%- endif %} {%- if arm64_macos.cstaticlibs and "cstaticlib" in install_libraries %} lib.install {% for library in arm64_macos.cstaticlibs %}"{{ library }}"{{ ", " if not loop.last else "" }}{% endfor %} {%- endif %} end {%- endif %} {%- if x86_64_macos.executables or x86_64_macos.cdylibs %} if OS.mac? && Hardware::CPU.intel? {%- if x86_64_macos.executables %} bin.install {% for binary in x86_64_macos.executables %}"{{ binary }}"{{ ", " if not loop.last else "" }}{% endfor %} {%- endif %} {%- if x86_64_macos.cdylibs and "cdylib" in install_libraries %} lib.install {% for library in x86_64_macos.cdylibs %}"{{ library }}"{{ ", " if not loop.last else "" }}{% endfor %} {%- endif %} {%- if x86_64_macos.cstaticlibs and "cstaticlib" in install_libraries %} lib.install {% for library in x86_64_macos.cstaticlibs %}"{{ library }}"{{ ", " if not loop.last else "" }}{% endfor %} {%- endif %} end {%- endif %} {%- if arm64_linux.executables or arm64_linux.cdylibs %} if OS.linux? && Hardware::CPU.arm? {%- if arm64_linux.executables %} bin.install {% for binary in arm64_linux.executables %}"{{ binary }}"{{ ", " if not loop.last else "" }}{% endfor %} {%- endif %} {%- if arm64_linux.cdylibs and "cdylib" in install_libraries %} lib.install {% for library in arm64_linux.cdylibs %}"{{ library }}"{{ ", " if not loop.last else "" }}{% endfor %} {%- endif %} {%- if arm64_linux.cstaticlibs and "cstaticlib" in install_libraries %} lib.install {% for library in arm64_linux.cstaticlibs %}"{{ library }}"{{ ", " if not loop.last else "" }}{% endfor %} {%- endif %} end {%- endif %} {%- if x86_64_linux.executables %} if OS.linux? && Hardware::CPU.intel? {%- if x86_64_linux.executables %} bin.install {% for binary in x86_64_linux.executables %}"{{ binary }}"{{ ", " if not loop.last else "" }}{% endfor %} {%- endif %} {%- if x86_64_linux.cdylibs and "cdylib" in install_libraries %} lib.install {% for library in x86_64_linux.cdylibs %}"{{ library }}"{{ ", " if not loop.last else "" }}{% endfor %} {%- endif %} {%- if x86_64_linux.cstaticlibs and "cstaticlib" in install_libraries %} lib.install {% for library in x86_64_linux.cstaticlibs %}"{{ library }}"{{ ", " if not loop.last else "" }}{% endfor %} {%- endif %} end {% endif %} install_binary_aliases! # Homebrew will automatically install these, so we don't need to do that doc_files = Dir["README.*", "readme.*", "LICENSE", "LICENSE.*", "CHANGELOG.*"] leftover_contents = Dir["*"] - doc_files # Install any leftover files in pkgshare; these are probably config or # sample files. pkgshare.install(*leftover_contents) unless leftover_contents.empty? end end