Skip to content

Commit

Permalink
POC of using premake to compile muduo: use base, net, and simple_echo…
Browse files Browse the repository at this point in the history
… as examples
  • Loading branch information
hpcx82 committed Sep 7, 2013
1 parent 391de8d commit 701b835
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 0 deletions.
10 changes: 10 additions & 0 deletions examples/simple/premake4.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
project "simple_echo"
kind "ConsoleApp"
language "C++"
targetdir(bindir)
links{'net', 'base', 'pthread', 'rt'}
files {
'echo/echo.cc',
'echo/main.cc',
}

24 changes: 24 additions & 0 deletions muduo/base/premake4.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
project "base"
kind "StaticLib"
language "C++"
links{'pthread', 'rt'}
targetdir(libdir)
targetname('muduo_base')
headersdir('muduo/base')
headers('*.h')
files {
'AsyncLogging.cc',
'Condition.cc',
'CountDownLatch.cc',
'Date.cc',
'Exception.cc',
'FileUtil.cc',
'LogFile.cc',
'Logging.cc',
'LogStream.cc',
'ProcessInfo.cc',
'Timestamp.cc',
'TimeZone.cc',
'Thread.cc',
'ThreadPool.cc',
}
45 changes: 45 additions & 0 deletions muduo/net/premake4.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
project "net"
kind "StaticLib"
language "C++"
links('base')
targetdir(libdir)
targetname('muduo_net')
includedirs('../..')
headersdir('muduo/net')
headers {
'Buffer.h',
'Callbacks.h',
'Channel.h',
'Endian.h',
'EventLoop.h',
'EventLoopThread.h',
'EventLoopThreadPool.h',
'InetAddress.h',
'TcpClient.h',
'TcpConnection.h',
'TcpServer.h',
'TimerId.h',
}

files {
'Acceptor.cc',
'Buffer.cc',
'Channel.cc',
'Connector.cc',
'EventLoop.cc',
'EventLoopThread.cc',
'EventLoopThreadPool.cc',
'InetAddress.cc',
'Poller.cc',
'poller/DefaultPoller.cc',
'poller/EPollPoller.cc',
'poller/PollPoller.cc',
'Socket.cc',
'SocketsOps.cc',
'TcpClient.cc',
'TcpConnection.cc',
'TcpServer.cc',
'Timer.cc',
'TimerQueue.cc',
}

69 changes: 69 additions & 0 deletions premake4.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
solution "muduo"
projectdir = basedir()
builddir = path.join(projectdir, '../build')
installdir = path.join(projectdir, '../install')
bindir = path.join(installdir, 'bin')
libdir = path.join(installdir, 'lib')
includedir = path.join(installdir, 'include')
curheadersdir = includedir

-- set the sub header dir to install files
function headersdir(dir)
curheadersdir = dir
end

-- install header files
function headers(files)
if type(files) == 'string' then
files = { files }
end
local finalfiles = {}
for _, file in ipairs(files) do
if file:find('*') then
file = os.matchfiles(file)
end
finalfiles = table.join(finalfiles, file)
end
local source = table.concat(finalfiles, ' ')
local target = path.join(includedir, curheadersdir)
assert(os.mkdir(target))
assert(os.execute('cp ' .. source .. ' ' .. target))
end

-- solution level settings
configurations { "Debug", "Release" }
location(builddir)
includedirs(includedir)

defines '_FILE_OFFSET_BITS=64'
flags {"ExtraWarnings", "FatalWarnings"}
buildoptions { '-g',
'-march=native',
'-rdynamic',
'-Wconversion',
'-Wno-unused-parameter',
'-Wold-style-cast',
'-Woverloaded-virtual',
'-Wpointer-arith',
'-Wshadow',
'-Wwrite-strings',
}

configuration "Debug"
buildoptions {'-O0'}
targetsuffix('-g')
configuration "Release"
buildoptions {'-finline-limit=1000'}
defines { "NDEBUG" }
flags { "Optimize" }

-- filter by kind not support in premake4.4 .4 .4 .4 beta
-- configuration {"*App"}
-- targetdir(bindir)
-- configuration { "*Lib" }
-- targetdir(libdir)
-- configuration {}

include 'muduo/base'
include 'muduo/net'
include 'examples/simple'

0 comments on commit 701b835

Please sign in to comment.