stevedonovan / Lake

A Lua-based Build Tool
MIT License
132 stars 16 forks source link

Disable auto definition of luaopen_xxx export entry #6

Closed moteus closed 11 years ago

moteus commented 12 years ago

In luasocket library export function name is luaopen_xxx_core. it would be convenient if we can write this like: export = { "luapoen_mime_core", luapoen_mime = "luapoen_mime_core", }

stevedonovan commented 12 years ago

I've hit this exact problem with MSVC; since it does not export the function explicitly, I resort to an explicit export, and this gets confused with these cases. (It should read a .def file if possible!)

c.shared{'socket/core',src='...',llua='socket.core',needs='lua socket'}

That 'llua' is a new feature in current master which allows you to specify the exported name - it will then use luaopen_socket_core.

moteus commented 12 years ago

This lake file compile just fine. I just disable export luaopen_xxx in lake.

table.append = function(t1,t2) table.foreachi(t2,function(_,v) table.insert(t1,v) end) return t1 end

local J = function(...) local t,r = {...} r = t[1] for i = 2, #t do r = path.join(r,t[i]) end return r end

define_need('sockets2',function() return {libs = {"ws2_32"}} end)

DEFS = {} if WINDOWS then table.append(DEFS, { "WIN32"; "_WIN32"; "_WINDOWS"; "_USRDLL"; }); if MSVC then
table.append(DEFS, { "_CRT_SECURE_NO_WARNINGS"; "_WIN32_WINNT=0x501"; }) end end API = WINDOWS and MSVC and "__declspec(dllexport)" or ''

SOCKET_EXCLUDE = {'mime','inet_ntop'} if not WINDOWS then table.append(SOCKET_EXCLUDE, {'wsocket'}) else table.append(SOCKET_EXCLUDE, {'usocket','unix'}) end

mime = c.shared{'mime', base = 'src'; defines = table.append({ "MIME_EXPORTS"; "MIME_API=" .. API },DEFS); needs={'lua','sockets2'}; }

socket = c.shared{'socket', base='src'; src='*.c'; exclude=SOCKET_EXCLUDE; defines = table.append({ "LUASOCKET_EXPORTS"; "LUASOCKET_API=" .. API },DEFS); needs={'lua','sockets2'}; }

lib = target('lib', {mime,socket} )

PS. Can you add 'lake.lua' just like 'lake.exe'. I run lake.lua ... as lake ... PPS. -j option also work

stevedonovan commented 12 years ago

PS. Can you add 'lake.lua' just like 'lake.exe'. I run lake.lua ... as lake ...

Once it was lake.lua, but to make it work properly with LuaRocks I had to make it without extension and directly executable on Unix.

I tend to type 'lua lake' these days, but you can always make a batch file to do the job. It's also possible to pack Lake as a standalone executable, which will be useful for people who want to use Lake but do not have Lua.

Your solution looks fine, really - I had not noticed LUASOCKET_API (as a side note, GCC on Windows also needs and understands declspec(dllexport))

The define _CRT_SECURE_NO_WARNINGS is probably a good idea for all MSVC builds. What do you think?

moteus commented 12 years ago

Once it was lake.lua, but to make it work properly with LuaRocks I had to make it without extension and directly executable on Unix. I mean change if arg[0] == 'lake' or arg[0]:find '[/]lake$' or arg[0]:find '[/]lake.exe' then to if arg[0] == 'lake' or arg[0]:find '[/]lake$' or arg[0]:find '[/]lake.exe' or arg[0]:find '[/]lake.lua' then I can add extension or create exe file myself while installing

I think that _CRT_SECURE_NO_WARNINGS need if we use /WX option. Also maybe should add NDEBUG to release.

And one more question. How i can add action to clean target? For example i create:

function MD(...) local target = J(...) print("!MD " .. target) if not TESTING then path.mkdir(target) end end

target('make_lib_dir',{ action(MD,'lib','bin','mime'); action(MD,'lib','bin','socket'); action(MD,'lib','lua'); action(MD,'lib','lua','socket'); })

and while cleaning i want remove this directories.

moteus commented 12 years ago

whith this line i have stack overflow file.group{src = path.join('test','')} this line work file.group{src = path.join('test','.*')}, but ignore files without extension file.group{src = path.join('test','README')} - also stack overflow

stevedonovan commented 12 years ago

For file.group, you have to provide 'odir'; otherwise it gets very confused about where to copy the files. I should give a sensible error message if odir is not specified.

moteus commented 12 years ago

No. this works. But do not copy README. file.group{ src = J('test','.'), odir=J(INSTALL_DIR,'test'); };

this causes stack(lua) overflow file.group{ src = J('test','README'), -- or '*' odir=J(INSTALL_DIR,'test'); };

stevedonovan commented 12 years ago

Ah, I bet you it has to do with README not having an extension! I will look at this.

stevedonovan commented 12 years ago

Ah, I bet you it has to do with README not having an extension! I will look at this.

stevedonovan commented 12 years ago

Ah, I bet you it has to do with README not having an extension! I will look at this.

moteus commented 12 years ago

Sorry. My English is not very good.

stevedonovan commented 12 years ago

Sorry, github was playing funny just do - I hit the button and nothing changed! Your English is fine, and you are reporting important issues clearly. I can confirm that it is any file that does not have an extension...