Skip to content

Commit

Permalink
change the script generator to run the protobuf compilaton first
Browse files Browse the repository at this point in the history
  • Loading branch information
ggeorgiev committed Jun 7, 2016
1 parent abc0617 commit 72c2fe6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
10 changes: 6 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
if [ ! -e build/ ]; then mkdir build/; fi
if [ ! -e build/release/ ]; then mkdir build/release/; fi
if [ ! -e build/release/src/ ]; then mkdir build/release/src/; fi
if [ ! -e build/release/src/rpc/ ]; then mkdir build/release/src/rpc/; fi
echo Compile src/rpc/rpc.proto
pushd src/ > /dev/null && \
../protobuf/bin/protoc --cpp_out=. rpc/rpc.proto && \
popd > /dev/null &
wait
if [ ! -e build/release/src/const/ ]; then mkdir build/release/src/const/; fi
echo Compile src/const/constants.cpp
clang++ -D NDEBUG -I src/ -O3 -c src/const/constants.cpp -isystem src/system/ \
Expand Down Expand Up @@ -216,16 +222,12 @@ clang++ -D NDEBUG -I src/ -O3 -c src/parser/dbs/dbs_parser.cpp \
-isystem axe/include/ -isystem boost/include/ -isystem fmt/include/ \
-isystem spdlog/include/ -isystem src/system/ \
-o build/release/src/parser/dbs/dbs_parser.cpp.o -std=c++14 &
if [ ! -e build/release/src/rpc/ ]; then mkdir build/release/src/rpc/; fi
if [ ! -e build/release/src/rpc/client/ ]; then mkdir build/release/src/rpc/client/; fi
echo Compile src/rpc/client/client.cpp
clang++ -D NDEBUG -I src/ -O3 -c src/rpc/client/client.cpp \
-isystem protobuf/include/ -isystem src/system/ \
-o build/release/src/rpc/client/client.cpp.o -std=c++14 &
echo Compile src/rpc/rpc.pb.cc
pushd src/ && \
../protobuf/bin/protoc --cpp_out=. rpc/rpc.proto && \
popd && \
clang++ -D NDEBUG -I src/ -O3 -c src/rpc/rpc.pb.cc -isystem protobuf/include/ \
-isystem src/system/ -o build/release/src/rpc/rpc.pb.cc.o -std=c++14 &
if [ ! -e build/release/src/task/ ]; then mkdir build/release/src/task/; fi
Expand Down
4 changes: 2 additions & 2 deletions src/doim/sys/sys_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ string SysCommand::toString(const FsDirectorySPtr& root) const

if (directory() != nullptr)
if (directory() != root)
result += "pushd " + directory()->path(root) + " && \\\n";
result += "pushd " + directory()->path(root) + " > /dev/null && \\\n";

result += executable()->path(directory() == nullptr ? root : directory());
size_t line = result.size();
Expand All @@ -51,7 +51,7 @@ string SysCommand::toString(const FsDirectorySPtr& root) const

if (directory() != nullptr)
if (directory() != root)
result += " && \\\npopd";
result += " && \\\npopd > /dev/null";

return result;
}
Expand Down
39 changes: 24 additions & 15 deletions src/engine/cxx_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,28 +397,37 @@ string CxxEngine::buildScript(EBuildFor buildFor,
string compileOrigin;

auto origin = objectFile->cxxFile()->origin();
if (!apply_visitor(vst::isNullptr, origin))
if (apply_visitor(vst::isNullptr, origin))
continue;

string description;
doim::SysCommandSPtr compileCommand;

if (origin.type() == typeid(doim::ProtobufFileSPtr))
{
if (origin.type() == typeid(doim::ProtobufFileSPtr))
{
const auto& protobufFile = boost::get<doim::ProtobufFileSPtr>(origin);
auto compileProtobufCommand =
mProtobufCompiler->compileCommand(protobufFile->directory(),
protobufFile,
objectFile->cxxFile());

compileOrigin = compileProtobufCommand->toString(directory) + " && \\\n";
}
else
ASSERT(false);
const auto& protobufFile = boost::get<doim::ProtobufFileSPtr>(origin);
description = protobufFile->file()->path(directory);
compileCommand = mProtobufCompiler->compileCommand(protobufFile->directory(),
protobufFile,
objectFile->cxxFile());
}
else
ASSERT(false);

stream << makeDirectory(directory, objectFile->file()->directory(), directories);
stream << "echo Compile " << description << std::endl;
stream << compileCommand->toString(directory) << " &" << std::endl;
}

stream << "wait" << std::endl;

for (const auto& objectFile : objects)
{
stream << makeDirectory(directory, objectFile->file()->directory(), directories);
stream << "echo Compile " << objectFile->cxxFile()->file()->path(directory)
<< std::endl;
auto compileCommand = mCompiler->compileCommand(directory, objectFile);
stream << compileOrigin << compileCommand->toString(directory) << " &"
<< std::endl;
stream << compileCommand->toString(directory) << " &" << std::endl;
}

stream << "wait" << std::endl;
Expand Down

0 comments on commit 72c2fe6

Please sign in to comment.