-
Notifications
You must be signed in to change notification settings - Fork 0
/
premake5.lua
121 lines (102 loc) · 3.14 KB
/
premake5.lua
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
function exec(command)
local handle = io.popen(command)
local result = handle:read("*a")
handle:close()
return result
end
-- This function assumes, the latest Erlang has been the last to have been installed.
-- If this is not so, make sure, the desired one has the latest modified date.
-- If a custom ei location is supplied (--ei=<path>), it is returned
function find_ei()
if _OPTIONS["ei"] then
return _OPTIONS["ei"]
end
-- installed via Homebrew
if os.target() == "macosx" then
-- return "/usr/local/Cellar/erlang/21.2.4/lib/erlang/lib/erl_interface-3.10.4/"
local ei_path = exec("ls -td -- /opt/homebrew/Cellar/erlang/*/lib/erlang/lib/erl_interface-*/ | head -n 1")
if ei_path ~= nil and ei_path ~= "" then
return ei_path
end
return exec("ls -td -- /usr/local/Cellar/erlang/*/lib/erlang/lib/erl_interface-*/ | head -n 1")
end
-- installed via official instructions
if os.target() == "linux" then
-- return "/usr/lib/erlang/lib/erl_interface-3.10.4/"
return exec("ls -td -- /usr/lib/erlang/lib/erl_interface-*/ | head -n 1")
end
-- installed via official instructions / chocolatey
if os.target() == "windows" then
-- return "C:\Program Files\erl10.1\lib\erl_interface-3.10.4\"
return exec("src\\find_latest_erl_interface\\find_latest_erl_interface")
end
end
newoption {
trigger = "ei",
description = "Supply a custom path to the erl_interface directory (must include include, lib)"
}
-------------------
workspace "otp_pony_node"
configurations { "Debug", "Release" }
-- build files location
location("build" .. "/" .. os.target() .. "/" .. (_ACTION or ''))
-- output file locations
objdir ("obj/%{cfg.system}/%{prj.name}")
targetdir (".")
filter "configurations:Debug"
symbols "On"
filter "configurations:Release"
symbols "On"
optimize "On"
filter "action:gmake"
linkoptions { "-std=c++11" }
buildoptions { "-std=c++11" } --, "-stdlib=libc++"
filter {}
ei_dir = find_ei():gsub("^%s*(.-)%s*$", "%1")
print("ei_dir: "..ei_dir)
filter "system:macosx or system:linux"
-- todo detect/configure
includedirs {
ei_dir .. "/include",
}
libdirs {
ei_dir .. "/lib",
}
defines {
"_REENTRANT"
}
targetextension ".so"
filter "system:windows"
-- todo detect/configure
includedirs {
ei_dir .. "\\include",
}
libdirs {
ei_dir .. "\\lib",
}
links {
"ws2_32.lib"
}
buildoptions {
"/NODEFAULTLIB",
"/MT",
}
linkoptions {
"/WHOLEARCHIVE"
}
defines {
"__WIN32__"
}
filter {}
-------------
project "otp_pony_node_c"
kind "SharedLib"
language "C++"
defines {
"BUILDING_OPN_API"
}
files {
"src/otp_pony_node_c/*.cpp",
"src/otp_pony_node_c/*.h",
}
links "ei"