Commit cd553c34 authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'wix-fix-shortcut-ids'

fe7f8c99 CPackWiX: use safe IDs for generated start menu shortcuts
parents d36d5d8f fe7f8c99
This diff is collapsed.
......@@ -18,6 +18,12 @@
#include <string>
#include <map>
struct cmWIXShortcut
{
std::string textLabel;
std::string workingDirectoryId;
};
class cmWIXSourceWriter;
/** \class cmCPackWIXGenerator
......@@ -56,6 +62,7 @@ protected:
private:
typedef std::map<std::string, std::string> id_map_t;
typedef std::map<std::string, size_t> ambiguity_map_t;
typedef std::map<std::string, cmWIXShortcut> shortcut_map_t;
bool InitializeWiXConfiguration();
......@@ -71,6 +78,15 @@ private:
bool CreateWiXSourceFiles();
bool CreateStartMenuShortcuts(
cmWIXSourceWriter& directoryDefinitions,
cmWIXSourceWriter& fileDefinitions,
cmWIXSourceWriter& featureDefinitions);
void CreateUninstallShortcut(
std::string const& packageName,
cmWIXSourceWriter& fileDefinitions);
void AppendUserSuppliedExtraSources();
void AppendUserSuppliedExtraObjects(std::ostream& stream);
......@@ -89,9 +105,7 @@ private:
cmWIXSourceWriter& directoryDefinitions,
cmWIXSourceWriter& fileDefinitions,
cmWIXSourceWriter& featureDefinitions,
const std::vector<std::string>& pkgExecutables,
std::vector<std::string>& dirIdExecutables
);
const std::vector<std::string>& pkgExecutables);
bool RequireOption(const std::string& name, std::string& value) const;
......@@ -118,6 +132,7 @@ private:
std::vector<std::string> wixSources;
id_map_t pathToIdMap;
ambiguity_map_t idAmbiguityCounter;
shortcut_map_t shortcutMap;
};
#endif
......@@ -21,7 +21,8 @@ cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger,
bool isIncludeFile):
Logger(logger),
file(filename.c_str()),
state(DEFAULT)
state(DEFAULT),
sourceFilename(filename)
{
WriteXMLDeclaration();
......@@ -39,10 +40,15 @@ cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger,
cmWIXSourceWriter::~cmWIXSourceWriter()
{
while(elements.size())
if(elements.size() > 1)
{
EndElement();
cmCPackLogger(cmCPackLog::LOG_ERROR,
elements.size() - 1 << " WiX elements were still open when closing '" <<
sourceFilename << "'" << std::endl);
return;
}
EndElement(elements.back());
}
void cmWIXSourceWriter::BeginElement(const std::string& name)
......@@ -60,12 +66,22 @@ void cmWIXSourceWriter::BeginElement(const std::string& name)
state = BEGIN;
}
void cmWIXSourceWriter::EndElement()
void cmWIXSourceWriter::EndElement(std::string const& name)
{
if(elements.empty())
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"can not end WiX element with no open elements" << std::endl);
"can not end WiX element with no open elements in '" <<
sourceFilename << "'" << std::endl);
return;
}
if(elements.back() != name)
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"WiX element <" << elements.back() <<
"> can not be closed by </" << name << "> in '" <<
sourceFilename << "'" << std::endl);
return;
}
......@@ -173,6 +189,9 @@ std::string cmWIXSourceWriter::EscapeAttributeValue(
case '<':
result += "&lt;";
break;
case '>':
result += "&gt;";
break;
case '&':
result +="&amp;";
break;
......
......@@ -32,7 +32,7 @@ public:
void BeginElement(const std::string& name);
void EndElement();
void EndElement(const std::string& name);
void AddProcessingInstruction(
const std::string& target, const std::string& content);
......@@ -62,6 +62,8 @@ private:
State state;
std::vector<std::string> elements;
std::string sourceFilename;
};
#endif
......@@ -4,15 +4,17 @@ project(CPackWiXGenerator)
add_library(mylib mylib.cpp)
add_executable(mylibapp mylibapp.cpp)
target_link_libraries(mylibapp mylib)
add_executable(my-libapp mylibapp.cpp)
target_link_libraries(my-libapp mylib)
add_executable(my-other-app myotherapp.cpp)
install(TARGETS mylib
ARCHIVE
DESTINATION lib
COMPONENT libraries)
install(TARGETS mylibapp
install(TARGETS my-libapp my-other-app
RUNTIME
DESTINATION bin
COMPONENT applications)
......@@ -36,7 +38,11 @@ set(CPACK_PACKAGE_INSTALL_DIRECTORY "CPack Component Example")
set(CPACK_WIX_UPGRADE_GUID "BF20CE5E-7F7C-401D-8F7C-AB45E8D170E6")
set(CPACK_WIX_UNINSTALL "1")
set(CPACK_PACKAGE_EXECUTABLES "mylibapp; CPack Wix Test")
set(CPACK_PACKAGE_EXECUTABLES
"my-libapp" "CPack WiX Test"
"my-other-app" "Second CPack WiX Test"
)
include(CPack)
......
int main() {}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment