-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpremake5.lua
More file actions
136 lines (116 loc) · 4.08 KB
/
Copy pathpremake5.lua
File metadata and controls
136 lines (116 loc) · 4.08 KB
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
126
127
128
129
130
131
132
133
134
135
136
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
-- Try to query erl first as it is the most reliable cross-platform method.
-- This works on Mac, Linux, and Windows if erl is in PATH.
-- Note: we pass -noshell first to prevent tty/shell initialization crashes on some platforms.
local erl_ei_path = exec("erl -noshell -eval \"io:format(\\\"~s~n\\\", [code:lib_dir(erl_interface)]), halt().\"")
if erl_ei_path ~= nil and erl_ei_path ~= "" and not erl_ei_path:find("io:format") and not erl_ei_path:find("not found") and not erl_ei_path:find("is not recognized") and not erl_ei_path:find("usage") then
local clean_path = erl_ei_path:gsub("^%s*(.-)%s*$", "%1")
if clean_path ~= "" then
return clean_path
end
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-*/ 2>/dev/null | 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-*/ 2>/dev/null | head -n 1")
end
-- installed via official instructions / docker image
if os.target() == "linux" then
-- return "/usr/lib/erlang/lib/erl_interface-3.10.4/"
local ei_path = exec("ls -td -- /usr/local/lib/erlang/lib/erl_interface-*/ 2>/dev/null | head -n 1")
if ei_path ~= nil and ei_path ~= "" then
return ei_path
end
return exec("ls -td -- /usr/lib/erlang/lib/erl_interface-*/ 2>/dev/null | 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"