summaryrefslogtreecommitdiff
path: root/make/install.lua
blob: 3da8983d249df59ef4e0fe1f800b04e325ca511f (plain)
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
local fs = require 'bee.filesystem'
local sp = require 'bee.subprocess'

local is_macos = package.cpath:sub(-3) == '.so'

local platform = require "bee.platform"

local CWD = fs.current_path()

local output = CWD / 'server' / 'bin'
local bindir = CWD / 'build' / 'msvc' / 'bin'

local lib_ext = ".dll"
local exc_ext = ".exe"

if is_macos then
    bindir = CWD / 'build' / 'macos' / 'bin'
    lib_ext = ".so"
    exc_ext = ""
end

if platform.OS == "Linux" then
    bindir = CWD / 'build' / 'linux' / 'bin'
    lib_ext = ".so"
    exc_ext = ""
end

fs.create_directories(output)
fs.copy_file(bindir / 'lni'..lib_ext, output / 'lni'..lib_ext, true)
fs.copy_file(bindir / 'lpeglabel'..lib_ext, output / 'lpeglabel'..lib_ext, true)
fs.copy_file(bindir / 'bee'..lib_ext, output / 'bee'..lib_ext, true)
fs.copy_file(bindir / 'lua'..exc_ext, output / 'lua-language-server'..exc_ext, true)

if not is_macos and platform.OS ~= "Linux" then
    fs.copy_file(bindir / 'lua54'..lib_ext, output / 'lua54'..lib_ext, true)
end

if not is_macos and platform.OS ~= "Linux" then
    local process = assert(sp.spawn {
        bindir / 'rcedit.exe',
        output / 'lua-language-server.exe',
        '--set-icon',
        CWD / 'images' / 'icon.ico'
    })
    assert(process:wait())

    local msvc_crt = dofile 'make/msvc_crt.lua'
    msvc_crt('x86', output)
end