forked from elua/elua
-
Notifications
You must be signed in to change notification settings - Fork 2
/
rfs_server.lua
43 lines (37 loc) · 1.5 KB
/
rfs_server.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
local args = { ... }
local b = require "utils.build"
local builder = b.new_builder( ".build/rfs_server" )
local utils = b.utils
-- Set builder options BEFORE calling builder:init
builder:add_option( 'sim', 'run under the eLua simulator', false )
builder:init( args )
builder:set_build_mode( builder.BUILD_DIR_LINEARIZED )
local sim = builder:get_option( 'sim' )
sim = sim and 1 or 0
local flist, socklib
local cdefs = "RFS_STANDALONE_MODE"
local mainname = sim == 0 and 'main.c' or 'main_sim.c'
local exeprefix = ""
if utils.is_windows() then
if sim == 1 then
print "SIM target not supported under Windows"
os.exit( 1 )
end
flist = "main.c server.c os_io_win32.c log.c net_win32.c serial_win32.c deskutils.c rfs_transports.c"
cdefs = cdefs .. " WIN32_BUILD"
exeprefix = ".exe"
socklib = 'ws2_32'
else
flist = mainname .. " server.c os_io_posix.c log.c net_posix.c serial_posix.c deskutils.c rfs_transports.c"
end
local output = sim == 0 and 'rfs_server' or 'rfs_sim_server'
local local_include = "rfs_server_src inc/remotefs inc"
local full_files = utils.prepend_path( flist, 'rfs_server_src' ) .. " src/remotefs/remotefs.c src/eluarpc.c"
local compcmd = builder:compile_cmd{ flags = "-m32 -O0 -Wall -g", defines = cdefs, includes = local_include }
local linkcmd = builder:link_cmd{ flags = "-m32", libraries = socklib }
builder:set_compile_cmd( compcmd )
builder:set_link_cmd( linkcmd )
builder:set_exe_extension( exeprefix )
-- Build everything
builder:make_exe_target( output, full_files )
builder:build()