aboutsummaryrefslogtreecommitdiff
path: root/repo/packages/c/consul/xmake.lua
blob: 82bd803b6bc5d6e96faa3ef7fe15bf0490f19657 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
-- this package only provides the consul binary, to be used for testing hub functionality

package("consul")
    set_homepage("https://www.consul.io/")
    set_description("Consul is a service networking solution to connect and secure services across any runtime platform and public or private cloud.")
       
    if is_plat("windows") then
        add_urls("https://releases.hashicorp.com/consul/$(version)/consul_$(version)_windows_amd64.zip")
        add_versions("1.22.0", "c31fb78490d7b5cd883a1df749b191ad01ee1f0a830b3d815fc4466045ee6270")
    elseif is_plat("linux") then
        add_urls("https://releases.hashicorp.com/consul/$(version)/consul_$(version)_linux_amd64.zip")
        add_versions("1.22.0", "9891495a2defabc3d637b376c66550e9879102868fbe6456a9a683067ae20ae9")
    elseif is_plat("macosx") then   
        if is_arch("arm64") then
            add_urls("https://releases.hashicorp.com/consul/$(version)/consul_$(version)_darwin_arm64.zip")
            add_versions("1.22.0", "6d9d58a2364d2ac23c816d6eb463ffcd10c568c547268fad310dc4299ac483e5")
        else
            add_urls("https://releases.hashicorp.com/consul/$(version)/consul_$(version)_darwin_amd64.zip")
            add_versions("1.22.0", "eb949ef495d53c1a08d9564105e742ed9eb93ef4f05abafaa4c479b3895bb4b8")
        end
    end

    on_install(function (package)
        if is_plat("windows") then
            os.cp("consul.exe", package:installdir("bin"))
        else 
            os.cp("consul", package:installdir("bin"))
        end
    end)

    on_test(function (package)
        -- Skip binary verification when cross-compiling (e.g. Windows target on Linux host)
        if package:is_cross() then
            return
        end
        if is_plat("windows") then
            os.run("%s version", package:installdir("bin", "consul.exe"))
        elseif is_plat("linux") then
            -- this should include macosx as well, but needs more logic to differentiate arm64 vs
            -- amd64 since arm64 binary won't run on amd64 macs. arm64 macs have Rosetta though so
            -- they can run the amd64 binary.
            os.run("%s version", package:installdir("bin", "consul"))
        end
    end)