]> git.tdb.fi Git - builder.git/commitdiff
Generate GUIDs for Visual C++ project files
authorMikko Rasa <tdb@tdb.fi>
Sun, 18 Dec 2022 15:58:59 +0000 (17:58 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 18 Dec 2022 15:58:59 +0000 (17:58 +0200)
Build
source/vcxprojectfile.cpp
source/vcxprojectfile.h
source/vcxprojectgenerator.cpp

diff --git a/Build b/Build
index 2363ad785cd8a760c4cab3d8ed4d2c58cf4661e1..34f5e400e2794fd1dd93c30ff9796073456d413f 100644 (file)
--- a/Build
+++ b/Build
@@ -5,6 +5,7 @@ package "builder"
 
        require "mspcore";
        require "mspdatafile";
+       require "mspcrypto";
        require "sigc++-2.0";
 
        program "builder"
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]));
+       }
 }
index b5a90d1f0b1b01840d3f6750977348e51544b492..ff3aba13ba316242bbfc06efdd4df09ebc209055 100644 (file)
@@ -5,10 +5,15 @@
 
 class VcxProjectFile: public FileTarget
 {
+private:
+       std::string guid;
+
 public:
        VcxProjectFile(Builder &, const SourcePackage &);
 
        virtual const char *get_type() const { return "VcxProjectFile"; }
+
+       const std::string &get_guid() const { return guid; }
 };
 
 #endif
index 871cde9f9eebfdf4bcc8825c67b5526abf6bfbb5..a173829941da9bb0adc18bb2ac103dea9625d354 100644 (file)
@@ -57,6 +57,7 @@ void VcxProjectGenerator::Worker::main()
        IO::print(out, "\t<PropertyGroup Label=\"Globals\">\n");
        IO::print(out, "\t\t<VCProjectVersion>15.0</VCProjectVersion>\n");
        IO::print(out, "\t\t<Keyword>MakeFileProj</Keyword>\n");
+       IO::print(out, "\t\t<ProjectGuid>{%s}</ProjectGuid>\n", target.get_guid());
        IO::print(out, "\t</PropertyGroup>\n");
 
        IO::print(out, "\t<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n");