aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/command_line_interface.cc
diff options
context:
space:
mode:
authorGravatar kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2010-01-04 19:47:18 +0000
committerGravatar kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2010-01-04 19:47:18 +0000
commitd2fcbba230d222d6419c89a20e9f7bf711e10b6b (patch)
tree58325af198b458f4daee8ef3c8d3f22a996d70e1 /src/google/protobuf/compiler/command_line_interface.cc
parent5066322074b975fac2436cb137d3b169d75c96d6 (diff)
Improve zip/jar support:
- Don't support par or war since par is not a standard format and outputting to war doesn't make sense. - Add boilerplate manifest when outputting to Jar. - Remove "XXX check conversion" comments because I don't care. - Add a test.
Diffstat (limited to 'src/google/protobuf/compiler/command_line_interface.cc')
-rw-r--r--src/google/protobuf/compiler/command_line_interface.cc20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc
index c266766c..1bc4ce89 100644
--- a/src/google/protobuf/compiler/command_line_interface.cc
+++ b/src/google/protobuf/compiler/command_line_interface.cc
@@ -227,6 +227,7 @@ class CommandLineInterface::MemoryOutputDirectory : public OutputDirectory {
bool WriteAllToDisk(const string& prefix);
bool WriteAllToZip(const string& filename);
+ void AddJarManifest();
// implements OutputDirectory --------------------------------------
io::ZeroCopyOutputStream* Open(const string& filename);
@@ -393,6 +394,16 @@ bool CommandLineInterface::MemoryOutputDirectory::WriteAllToZip(
return true;
}
+void CommandLineInterface::MemoryOutputDirectory::AddJarManifest() {
+ string** map_slot = &files_["META-INF/MANIFEST.MF"];
+ if (*map_slot == NULL) {
+ *map_slot = new string(
+ "Manifest-Version: 1.0\n"
+ "Created-By: 1.6.0 (protoc)\n"
+ "\n");
+ }
+}
+
io::ZeroCopyOutputStream* CommandLineInterface::MemoryOutputDirectory::Open(
const string& filename) {
return new MemoryOutputStream(this, filename);
@@ -594,11 +605,8 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
if (mode_ == MODE_COMPILE) {
for (int i = 0; i < output_directives_.size(); i++) {
string output_location = output_directives_[i].output_location;
- cout << "location: " << output_location << endl;
if (!HasSuffixString(output_location, ".zip") &&
- !HasSuffixString(output_location, ".jar") &&
- !HasSuffixString(output_location, ".war") &&
- !HasSuffixString(output_location, ".par")) {
+ !HasSuffixString(output_location, ".jar")) {
AddTrailingSlash(&output_location);
}
MemoryOutputDirectory** map_slot = &output_directories_[output_location];
@@ -624,6 +632,10 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
return 1;
}
} else {
+ if (HasSuffixString(location, ".jar")) {
+ directory->AddJarManifest();
+ }
+
if (!directory->WriteAllToZip(location)) {
return 1;
}