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