aboutsummaryrefslogtreecommitdiff
path: root/src/zen/xmake.lua
blob: c4084231d8aed3917a69c8ece0ddc07770000406 (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
-- Copyright Epic Games, Inc. All Rights Reserved.

target("zen")
    set_kind("binary")
    add_headerfiles("**.h")
    add_files("**.cpp")
    add_files("zen.cpp", {unity_ignored  = true })
    add_rules("utils.bin2c", {extensions = {".zip"}})
    add_files(path.join(os.projectdir(), get_config("builddir") or get_config("buildir") or "build", "zen-frontend/zen-html.zip"))
    add_deps("zencore", "zenhttp", "zenremotestore", "zenstore", "zenutil")
    add_deps("zencompute", "zennet", "zentelemetry")
    add_deps("cxxopts", "fmt", "raw_pdb", "tourist")
    add_packages("json11")
    add_includedirs(".")
    add_defines("ZEN_EMBED_ZEN_HTML_ZIP=1")
    set_symbols("debug")

    on_load(function(target)
        local html_dir = path.join(os.projectdir(), "src/zen/frontend/html")
        local zip_dir = path.join(os.projectdir(), get_config("builddir") or get_config("buildir") or "build", "zen-frontend")
        local zip_path = path.join(zip_dir, "zen-html.zip")

        -- Check if zip needs regeneration
        local need_update = not os.isfile(zip_path)
        if not need_update then
            local zip_mtime = os.mtime(zip_path)
            for _, file in ipairs(os.files(path.join(html_dir, "**"))) do
                if os.mtime(file) > zip_mtime then
                    need_update = true
                    break
                end
            end
        end

        if need_update then
            print("Regenerating zen trace viewer frontend zip...")

            os.tryrm(zip_path)
            os.mkdir(zip_dir)

            import("detect.tools.find_7z")
            local cmd_7z = find_7z()
            if cmd_7z then
                os.execv(cmd_7z, {"a", "-bso0", zip_path, path.join(html_dir, "*")})
            else
                import("detect.tools.find_zip")
                local zip_cmd = find_zip()
                if zip_cmd then
                    local oldir = os.cd(html_dir)
                    os.execv(zip_cmd, {"-r", "-q", zip_path, "."})
                    os.cd(oldir)
                else
                    raise("Unable to find a suitable zip tool (need 7z or zip)")
                end
            end
        end
    end)

    if is_plat("windows") then
        add_files("zen.rc")
        add_ldflags("/subsystem:console,5.02", {force = true})
        if not (get_config("toolchain") or ""):find("clang") then
            add_ldflags("/LTCG")
        end
    end

    if is_plat("macosx") then
        add_ldflags("-framework CoreFoundation")
        add_ldflags("-framework Foundation")
        add_ldflags("-framework Security")
        add_ldflags("-framework SystemConfiguration")
    end