Skip to content

Commit

Permalink
Update #include to compatible with Bazel.
Browse files Browse the repository at this point in the history
Fixed with this Python3 script:

import io, re, os

P = re.compile('^#include [<"](.*)[">]')
def fix_header(filename):
    new = io.StringIO()

    with open(filename) as f:
        for line in f:
            m = P.search(line)
            if m:
                header = m.group(1)
                if header.startswith('muduo/') or header.startswith('examples/'):
                    new.write('#include "%s"\n' % header)
                    continue
                else:
                    h = os.path.join(os.path.split(filename)[0], header);
                    if os.path.exists(h):
                        new.write('#include "%s"\n' % os.path.relpath(h))
                        continue
            new.write(line)

    open(filename, 'w').write(new.getvalue())

for root, dirs, files in os.walk('.'):
    dirs[:] = [d for d in dirs if not d.startswith('.')]
    for f in files:
        if f.endswith('.cc') or f.endswith('.h'):
            fullpath = os.path.join(root, f)
            # print(fullpath)
            fix_header(fullpath)
  • Loading branch information
chenshuo committed Mar 8, 2019
1 parent dfdfca9 commit d980315
Show file tree
Hide file tree
Showing 297 changed files with 959 additions and 964 deletions.
10 changes: 5 additions & 5 deletions contrib/hiredis/Hiredis.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "Hiredis.h"
#include "contrib/hiredis/Hiredis.h"

#include <muduo/base/Logging.h>
#include <muduo/net/Channel.h>
#include <muduo/net/EventLoop.h>
#include <muduo/net/SocketsOps.h>
#include "muduo/base/Logging.h"
#include "muduo/net/Channel.h"
#include "muduo/net/EventLoop.h"
#include "muduo/net/SocketsOps.h"

#include <hiredis/async.h>

Expand Down
10 changes: 5 additions & 5 deletions contrib/hiredis/Hiredis.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef MUDUO_CONTRIB_HIREDIS_HIREDIS_H
#define MUDUO_CONTRIB_HIREDIS_HIREDIS_H

#include <muduo/base/noncopyable.h>
#include <muduo/base/StringPiece.h>
#include <muduo/base/Types.h>
#include <muduo/net/Callbacks.h>
#include <muduo/net/InetAddress.h>
#include "muduo/base/noncopyable.h"
#include "muduo/base/StringPiece.h"
#include "muduo/base/Types.h"
#include "muduo/net/Callbacks.h"
#include "muduo/net/InetAddress.h"

#include <hiredis/hiredis.h>

Expand Down
6 changes: 3 additions & 3 deletions contrib/hiredis/mrediscli.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "Hiredis.h"
#include "contrib/hiredis/Hiredis.h"

#include <muduo/base/Logging.h>
#include <muduo/net/EventLoop.h>
#include "muduo/base/Logging.h"
#include "muduo/net/EventLoop.h"

#include <string>

Expand Down
6 changes: 3 additions & 3 deletions contrib/thrift/ThriftConnection.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "ThriftConnection.h"
#include "contrib/thrift/ThriftConnection.h"

#include <boost/bind.hpp>

#include <muduo/base/Logging.h>
#include "muduo/base/Logging.h"

#include <thrift/transport/TTransportException.h>

#include "ThriftServer.h"
#include "contrib/thrift/ThriftServer.h"

using namespace muduo;
using namespace muduo::net;
Expand Down
2 changes: 1 addition & 1 deletion contrib/thrift/ThriftConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <boost/enable_shared_from_this.hpp>
#include <boost/noncopyable.hpp>

#include <muduo/net/TcpConnection.h>
#include "muduo/net/TcpConnection.h"

#include <thrift/protocol/TProtocol.h>
#include <thrift/transport/TBufferTransports.h>
Expand Down
4 changes: 2 additions & 2 deletions contrib/thrift/ThriftServer.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "ThriftServer.h"
#include "contrib/thrift/ThriftServer.h"

#include <boost/bind.hpp>

#include <muduo/net/EventLoop.h>
#include "muduo/net/EventLoop.h"

using namespace muduo;
using namespace muduo::net;
Expand Down
6 changes: 3 additions & 3 deletions contrib/thrift/ThriftServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#include <boost/bind.hpp>
#include <boost/noncopyable.hpp>

#include <muduo/base/ThreadPool.h>
#include <muduo/net/TcpServer.h>
#include "muduo/base/ThreadPool.h"
#include "muduo/net/TcpServer.h"

#include <thrift/server/TServer.h>

#include "ThriftConnection.h"
#include "contrib/thrift/ThriftConnection.h"

using apache::thrift::TProcessor;
using apache::thrift::TProcessorFactory;
Expand Down
4 changes: 2 additions & 2 deletions contrib/thrift/tests/echo/EchoServer.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <unistd.h>

#include <muduo/base/Logging.h>
#include <muduo/net/EventLoop.h>
#include "muduo/base/Logging.h"
#include "muduo/net/EventLoop.h"

#include "ThriftServer.h"

Expand Down
4 changes: 2 additions & 2 deletions contrib/thrift/tests/ping/PingServer.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <muduo/base/Logging.h>
#include <muduo/net/EventLoop.h>
#include "muduo/base/Logging.h"
#include "muduo/net/EventLoop.h"

#include <thrift/protocol/TCompactProtocol.h>

Expand Down
18 changes: 9 additions & 9 deletions examples/ace/logging/client.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include <examples/ace/logging/logrecord.pb.h>

#include <muduo/base/Mutex.h>
#include <muduo/base/Logging.h>
#include <muduo/base/ProcessInfo.h>
#include <muduo/net/EventLoop.h>
#include <muduo/net/EventLoopThread.h>
#include <muduo/net/TcpClient.h>
#include <muduo/net/protobuf/ProtobufCodecLite.h>
#include "examples/ace/logging/logrecord.pb.h"

#include "muduo/base/Mutex.h"
#include "muduo/base/Logging.h"
#include "muduo/base/ProcessInfo.h"
#include "muduo/net/EventLoop.h"
#include "muduo/net/EventLoopThread.h"
#include "muduo/net/TcpClient.h"
#include "muduo/net/protobuf/ProtobufCodecLite.h"

#include <iostream>
#include <stdio.h>
Expand Down
16 changes: 8 additions & 8 deletions examples/ace/logging/server.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <examples/ace/logging/logrecord.pb.h>

#include <muduo/base/Atomic.h>
#include <muduo/base/FileUtil.h>
#include <muduo/base/Logging.h>
#include <muduo/net/EventLoop.h>
#include <muduo/net/TcpServer.h>
#include <muduo/net/protobuf/ProtobufCodecLite.h>
#include "examples/ace/logging/logrecord.pb.h"

#include "muduo/base/Atomic.h"
#include "muduo/base/FileUtil.h"
#include "muduo/base/Logging.h"
#include "muduo/net/EventLoop.h"
#include "muduo/net/TcpServer.h"
#include "muduo/net/protobuf/ProtobufCodecLite.h"

#include <stdio.h>

Expand Down
4 changes: 2 additions & 2 deletions examples/ace/ttcp/common.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <examples/ace/ttcp/common.h>
#include <muduo/base/Types.h>
#include "examples/ace/ttcp/common.h"
#include "muduo/base/Types.h"

#include <boost/program_options.hpp>

Expand Down
2 changes: 1 addition & 1 deletion examples/ace/ttcp/main.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <examples/ace/ttcp/common.h>
#include "examples/ace/ttcp/common.h"

#include <assert.h>

Expand Down
10 changes: 5 additions & 5 deletions examples/ace/ttcp/ttcp.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <examples/ace/ttcp/common.h>
#include "examples/ace/ttcp/common.h"

#include <muduo/base/Logging.h>
#include <muduo/net/EventLoop.h>
#include <muduo/net/TcpClient.h>
#include <muduo/net/TcpServer.h>
#include "muduo/base/Logging.h"
#include "muduo/net/EventLoop.h"
#include "muduo/net/TcpClient.h"
#include "muduo/net/TcpServer.h"

#include <stdio.h>

Expand Down
4 changes: 2 additions & 2 deletions examples/ace/ttcp/ttcp_asio_async.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <examples/ace/ttcp/common.h>
#include "examples/ace/ttcp/common.h"

#include <muduo/base/Logging.h>
#include "muduo/base/Logging.h"
#include <boost/asio.hpp>
#include <stdio.h>

Expand Down
4 changes: 2 additions & 2 deletions examples/ace/ttcp/ttcp_asio_sync.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <examples/ace/ttcp/common.h>
#include "examples/ace/ttcp/common.h"

#include <muduo/base/Logging.h>
#include "muduo/base/Logging.h"
#include <boost/asio.hpp>
#include <stdio.h>

Expand Down
6 changes: 3 additions & 3 deletions examples/ace/ttcp/ttcp_blocking.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <examples/ace/ttcp/common.h>
#include <muduo/base/Timestamp.h>
#include <muduo/base/Types.h>
#include "examples/ace/ttcp/common.h"
#include "muduo/base/Timestamp.h"
#include "muduo/base/Types.h"

#undef NDEBUG

Expand Down
10 changes: 5 additions & 5 deletions examples/asio/chat/client.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "codec.h"
#include "examples/asio/chat/codec.h"

#include <muduo/base/Logging.h>
#include <muduo/base/Mutex.h>
#include <muduo/net/EventLoopThread.h>
#include <muduo/net/TcpClient.h>
#include "muduo/base/Logging.h"
#include "muduo/base/Mutex.h"
#include "muduo/net/EventLoopThread.h"
#include "muduo/net/TcpClient.h"

#include <iostream>
#include <stdio.h>
Expand Down
8 changes: 4 additions & 4 deletions examples/asio/chat/codec.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef MUDUO_EXAMPLES_ASIO_CHAT_CODEC_H
#define MUDUO_EXAMPLES_ASIO_CHAT_CODEC_H

#include <muduo/base/Logging.h>
#include <muduo/net/Buffer.h>
#include <muduo/net/Endian.h>
#include <muduo/net/TcpConnection.h>
#include "muduo/base/Logging.h"
#include "muduo/net/Buffer.h"
#include "muduo/net/Endian.h"
#include "muduo/net/TcpConnection.h"

class LengthHeaderCodec : muduo::noncopyable
{
Expand Down
16 changes: 8 additions & 8 deletions examples/asio/chat/loadtest.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "codec.h"

#include <muduo/base/Atomic.h>
#include <muduo/base/Logging.h>
#include <muduo/base/Mutex.h>
#include <muduo/net/EventLoop.h>
#include <muduo/net/EventLoopThreadPool.h>
#include <muduo/net/TcpClient.h>
#include "examples/asio/chat/codec.h"

#include "muduo/base/Atomic.h"
#include "muduo/base/Logging.h"
#include "muduo/base/Mutex.h"
#include "muduo/net/EventLoop.h"
#include "muduo/net/EventLoopThreadPool.h"
#include "muduo/net/TcpClient.h"

#include <stdio.h>
#include <unistd.h>
Expand Down
10 changes: 5 additions & 5 deletions examples/asio/chat/server.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "codec.h"
#include "examples/asio/chat/codec.h"

#include <muduo/base/Logging.h>
#include <muduo/base/Mutex.h>
#include <muduo/net/EventLoop.h>
#include <muduo/net/TcpServer.h>
#include "muduo/base/Logging.h"
#include "muduo/base/Mutex.h"
#include "muduo/net/EventLoop.h"
#include "muduo/net/TcpServer.h"

#include <set>
#include <stdio.h>
Expand Down
10 changes: 5 additions & 5 deletions examples/asio/chat/server_threaded.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "codec.h"
#include "examples/asio/chat/codec.h"

#include <muduo/base/Logging.h>
#include <muduo/base/Mutex.h>
#include <muduo/net/EventLoop.h>
#include <muduo/net/TcpServer.h>
#include "muduo/base/Logging.h"
#include "muduo/base/Mutex.h"
#include "muduo/net/EventLoop.h"
#include "muduo/net/TcpServer.h"

#include <set>
#include <stdio.h>
Expand Down
10 changes: 5 additions & 5 deletions examples/asio/chat/server_threaded_efficient.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "codec.h"
#include "examples/asio/chat/codec.h"

#include <muduo/base/Logging.h>
#include <muduo/base/Mutex.h>
#include <muduo/net/EventLoop.h>
#include <muduo/net/TcpServer.h>
#include "muduo/base/Logging.h"
#include "muduo/base/Mutex.h"
#include "muduo/net/EventLoop.h"
#include "muduo/net/TcpServer.h"

#include <set>
#include <stdio.h>
Expand Down
12 changes: 6 additions & 6 deletions examples/asio/chat/server_threaded_highperformance.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "codec.h"
#include "examples/asio/chat/codec.h"

#include <muduo/base/Logging.h>
#include <muduo/base/Mutex.h>
#include <muduo/base/ThreadLocalSingleton.h>
#include <muduo/net/EventLoop.h>
#include <muduo/net/TcpServer.h>
#include "muduo/base/Logging.h"
#include "muduo/base/Mutex.h"
#include "muduo/base/ThreadLocalSingleton.h"
#include "muduo/net/EventLoop.h"
#include "muduo/net/TcpServer.h"

#include <set>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion examples/asio/tutorial/timer2/timer.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <muduo/net/EventLoop.h>
#include "muduo/net/EventLoop.h"

#include <iostream>

Expand Down
2 changes: 1 addition & 1 deletion examples/asio/tutorial/timer3/timer.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <muduo/net/EventLoop.h>
#include "muduo/net/EventLoop.h"

#include <iostream>

Expand Down
2 changes: 1 addition & 1 deletion examples/asio/tutorial/timer4/timer.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <muduo/net/EventLoop.h>
#include "muduo/net/EventLoop.h"

#include <iostream>

Expand Down
6 changes: 3 additions & 3 deletions examples/asio/tutorial/timer5/timer.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <muduo/base/Mutex.h>
#include <muduo/net/EventLoop.h>
#include <muduo/net/EventLoopThread.h>
#include "muduo/base/Mutex.h"
#include "muduo/net/EventLoop.h"
#include "muduo/net/EventLoopThread.h"

#include <iostream>

Expand Down
6 changes: 3 additions & 3 deletions examples/asio/tutorial/timer6/timer.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <muduo/base/Mutex.h>
#include <muduo/net/EventLoop.h>
#include <muduo/net/EventLoopThread.h>
#include "muduo/base/Mutex.h"
#include "muduo/net/EventLoop.h"
#include "muduo/net/EventLoopThread.h"

#include <stdio.h>

Expand Down
8 changes: 4 additions & 4 deletions examples/cdns/Resolver.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <examples/cdns/Resolver.h>
#include "examples/cdns/Resolver.h"

#include <muduo/base/Logging.h>
#include <muduo/net/Channel.h>
#include <muduo/net/EventLoop.h>
#include "muduo/base/Logging.h"
#include "muduo/net/Channel.h"
#include "muduo/net/EventLoop.h"

#include <ares.h>
#include <netdb.h>
Expand Down
8 changes: 4 additions & 4 deletions examples/cdns/Resolver.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef MUDUO_EXAMPLES_CDNS_RESOLVER_H
#define MUDUO_EXAMPLES_CDNS_RESOLVER_H

#include <muduo/base/noncopyable.h>
#include <muduo/base/StringPiece.h>
#include <muduo/base/Timestamp.h>
#include <muduo/net/InetAddress.h>
#include "muduo/base/noncopyable.h"
#include "muduo/base/StringPiece.h"
#include "muduo/base/Timestamp.h"
#include "muduo/net/InetAddress.h"

#include <functional>
#include <map>
Expand Down
4 changes: 2 additions & 2 deletions examples/cdns/dns.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <examples/cdns/Resolver.h>
#include <muduo/net/EventLoop.h>
#include "examples/cdns/Resolver.h"
#include "muduo/net/EventLoop.h"
#include <stdio.h>

using namespace muduo;
Expand Down
Loading

0 comments on commit d980315

Please sign in to comment.