]> git.tdb.fi Git - builder.git/blobdiff - source/vcxprojectfile.cpp
Generate GUIDs for Visual C++ project files
[builder.git] / source / vcxprojectfile.cpp
index 7b09db05bbf46380894373bb7807d5cbba8fccff..c591524135e3804283a54f8d9cf33b095de827fb 100644 (file)
@@ -1,9 +1,24 @@
+#include <msp/crypto/md5.h>
+#include <msp/strings/format.h>
 #include "builder.h"
 #include "sourcepackage.h"
 #include "vcxprojectfile.h"
 
+using namespace Msp;
+
 VcxProjectFile::VcxProjectFile(Builder &b, const SourcePackage &p):
        FileTarget(b, p, p.get_source_directory()/(p.get_name()+".vcxproj"))
 {
        tool = &builder.get_toolchain().get_tool("VCXG");
+
+       char digest[16];
+       Crypto::MD5(package->get_name()).get_digest(digest, sizeof(digest));
+       digest[6] = 3;
+       digest[8] = (digest[6]&0x3F)|0x80;
+       for(unsigned j=0; j<sizeof(digest); ++j)
+       {
+               if(j==4 || j==6 || j==8 || j==10)
+                       guid += '-';
+               guid += format("%02x", static_cast<unsigned char>(digest[j]));
+       }
 }