aboutsummaryrefslogtreecommitdiff
path: root/xmake.lua
blob: 49989615c1df41facdb572c40a1e8bded9bc8d9c (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
add_requires(
    "vcpkg::doctest", 
    "vcpkg::spdlog", 
    "vcpkg::gsl-lite", 
    "vcpkg::asio", 
    "vcpkg::cpr", 
    "vcpkg::xxhash", 
    "vcpkg::robin-map", 
    "vcpkg::lz4", 
    "vcpkg::fmt", 
    "vcpkg::cxxopts", 
    "vcpkg::mimalloc", 
    "vcpkg::sol2", 
    "vcpkg::sentry-native", 
    "vcpkg::json11",
    "vcpkg::lua", 
    "vcpkg::curl", 
    "vcpkg::zlib", 
    "vcpkg::zstd", 
    "vcpkg::http-parser")

add_rules("mode.debug", "mode.release")

if is_mode("release") then
    set_optimize("smallest")
    if is_plat("windows") then
        add_ldflags("/LTCG")
    end
end

if is_mode("debug") then
    add_defines("DEBUG")
end

if is_mode("debug") then
    add_defines("ZEN_WITH_TESTS=1")
else
    add_defines("ZEN_WITH_TESTS=0")
end

if is_os("windows") then
    add_defines("_CRT_SECURE_NO_WARNINGS", "_UNICODE", "UNICODE", "_WIN32_WINNT=0x0A00")
    -- add_ldflags("/MAP")
end

add_defines("USE_SENTRY=1")
add_defines("ZEN_USE_MIMALLOC=1")

option("vfs")
    set_showmenu(true)
    set_description("Enable VFS functionality")
    add_defines("ZEN_WITH_VFS")
option_end()

option("httpsys")
    set_default(true)
    set_showmenu(true)
    set_description("Enable http.sys server")
    add_defines("ZEN_WITH_HTTPSYS")
option_end()

add_defines("UNICODE", "_CONSOLE")

set_warnings("allextra", "error")
set_languages("cxx20")

-- always generate debug information
set_symbols("debug")

includes("zencore", "zencore-test")
includes("zenhttp")
includes("zenstore", "zenstore-test")
includes("zenutil")
includes("zenserver", "zenserver-test")
includes("zen")

task("bundle")
  on_run(function()
    import("detect.tools.find_zip")
    import("detect.tools.find_7z")

    -- copy files 
    local dirs = {
      binaries = "./build/windows/x64/release",
      bundles = "./build/bundles",
      bundle = "./build/bundles/zenzerver-win64"
    }

    local files = {
      dirs.binaries .. "/zenserver.exe",
      dirs.binaries .. "/zenserver.pdb",
      "./vcpkg_installed/x64-windows-static/tools/sentry-native/crashpad_handler.exe"
    }

    os.mkdir(dirs.bundles)
    os.mkdir(dirs.bundle)

    for _,file in ipairs(files) do
      printf("copy '%s' -> '%s'\n", file, dirs.bundle)
      os.cp(file, dirs.bundle)
    end

    -- create archive
    local bundle_name = "zenserver-win64.zip"

    local zip_cmd = find_7z()
    assert(zip_cmd)

    local zip_args = {}
    table.insert(zip_args, "a")
    table.insert(zip_args, dirs.bundles .. "/" .. bundle_name)
    table.insert(zip_args, dirs.bundle .. "/*.*")

    printf("creating bundle '%s'...", dirs.bundles .. "/" .. bundle_name)
    os.runv(zip_cmd, zip_args)
    os.rm(dirs.bundle)
    
    printf(" Ok!")
  end)

  set_menu {
    usage = "xmake bundle",
    description = "Create zip bundle from binaries",
    options = {}
  }