2012-10-03 18:08:49 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2012 Kitware, Inc.
|
|
|
|
|
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
|
|
|
|
|
|
|
#ifndef cmCPackWIXGenerator_h
|
|
|
|
#define cmCPackWIXGenerator_h
|
|
|
|
|
2013-12-17 01:30:11 +04:00
|
|
|
#include "cmWIXPatchParser.h"
|
|
|
|
|
2012-10-03 18:08:49 +04:00
|
|
|
#include <CPack/cmCPackGenerator.h>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
|
|
|
|
2013-10-23 14:14:39 +04:00
|
|
|
struct cmWIXShortcut
|
|
|
|
{
|
|
|
|
std::string textLabel;
|
|
|
|
std::string workingDirectoryId;
|
|
|
|
};
|
|
|
|
|
2012-10-03 18:08:49 +04:00
|
|
|
class cmWIXSourceWriter;
|
|
|
|
|
|
|
|
/** \class cmCPackWIXGenerator
|
|
|
|
* \brief A generator for WIX files
|
|
|
|
*/
|
|
|
|
class cmCPackWIXGenerator : public cmCPackGenerator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmCPackTypeMacro(cmCPackWIXGenerator, cmCPackGenerator);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual int InitializeInternal();
|
|
|
|
|
|
|
|
virtual int PackageFiles();
|
|
|
|
|
|
|
|
virtual const char* GetOutputExtension()
|
|
|
|
{
|
|
|
|
return ".msi";
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual enum CPackSetDestdirSupport SupportsSetDestdir() const
|
|
|
|
{
|
|
|
|
return SETDESTDIR_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool SupportsAbsoluteDestination() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool SupportsComponentInstallation() const
|
|
|
|
{
|
2013-11-20 00:38:09 +04:00
|
|
|
return true;
|
2012-10-03 18:08:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2013-10-11 00:49:33 +04:00
|
|
|
typedef std::map<std::string, std::string> id_map_t;
|
|
|
|
typedef std::map<std::string, size_t> ambiguity_map_t;
|
2013-10-23 14:14:39 +04:00
|
|
|
typedef std::map<std::string, cmWIXShortcut> shortcut_map_t;
|
2013-11-10 22:48:29 +04:00
|
|
|
typedef std::set<std::string> extension_set_t;
|
2013-10-11 00:49:33 +04:00
|
|
|
|
2012-10-03 18:08:49 +04:00
|
|
|
bool InitializeWiXConfiguration();
|
|
|
|
|
|
|
|
bool PackageFilesImpl();
|
|
|
|
|
|
|
|
bool CreateWiXVariablesIncludeFile();
|
|
|
|
|
|
|
|
void CopyDefinition(
|
|
|
|
cmWIXSourceWriter &source, const std::string &name);
|
|
|
|
|
|
|
|
void AddDefinition(cmWIXSourceWriter& source,
|
|
|
|
const std::string& name, const std::string& value);
|
|
|
|
|
|
|
|
bool CreateWiXSourceFiles();
|
|
|
|
|
2014-01-08 04:28:24 +04:00
|
|
|
bool CreateCMakePackageRegistryEntry(
|
|
|
|
cmWIXSourceWriter& featureDefinitions);
|
|
|
|
|
2013-11-20 00:38:09 +04:00
|
|
|
bool CreateFeatureHierarchy(
|
|
|
|
cmWIXSourceWriter& featureDefinitions);
|
|
|
|
|
|
|
|
bool EmitFeatureForComponentGroup(
|
|
|
|
cmWIXSourceWriter& featureDefinitions,
|
|
|
|
cmCPackComponentGroup const& group);
|
|
|
|
|
|
|
|
bool EmitFeatureForComponent(
|
|
|
|
cmWIXSourceWriter& featureDefinitions,
|
|
|
|
cmCPackComponent const& component);
|
|
|
|
|
|
|
|
bool AddComponentsToFeature(
|
|
|
|
std::string const& rootPath,
|
|
|
|
std::string const& featureId,
|
2013-10-23 14:14:39 +04:00
|
|
|
cmWIXSourceWriter& directoryDefinitions,
|
|
|
|
cmWIXSourceWriter& fileDefinitions,
|
2013-11-20 00:38:09 +04:00
|
|
|
cmWIXSourceWriter& featureDefinitions,
|
|
|
|
shortcut_map_t& shortcutMap);
|
|
|
|
|
|
|
|
bool CreateStartMenuShortcuts(
|
|
|
|
std::string const& cpackComponentName,
|
|
|
|
std::string const& featureId,
|
|
|
|
shortcut_map_t& shortcutMap,
|
|
|
|
cmWIXSourceWriter& fileDefinitions,
|
2013-10-23 14:14:39 +04:00
|
|
|
cmWIXSourceWriter& featureDefinitions);
|
|
|
|
|
|
|
|
void CreateUninstallShortcut(
|
|
|
|
std::string const& packageName,
|
|
|
|
cmWIXSourceWriter& fileDefinitions);
|
|
|
|
|
2013-10-13 15:16:54 +04:00
|
|
|
void AppendUserSuppliedExtraSources();
|
|
|
|
|
|
|
|
void AppendUserSuppliedExtraObjects(std::ostream& stream);
|
|
|
|
|
2012-10-03 18:08:49 +04:00
|
|
|
bool CreateLicenseFile();
|
|
|
|
|
|
|
|
bool RunWiXCommand(const std::string& command);
|
|
|
|
|
|
|
|
bool RunCandleCommand(
|
|
|
|
const std::string& sourceFile, const std::string& objectFile);
|
|
|
|
|
|
|
|
bool RunLightCommand(const std::string& objectFiles);
|
|
|
|
|
|
|
|
void AddDirectoryAndFileDefinitons(const std::string& topdir,
|
|
|
|
const std::string& directoryId,
|
|
|
|
cmWIXSourceWriter& directoryDefinitions,
|
|
|
|
cmWIXSourceWriter& fileDefinitions,
|
|
|
|
cmWIXSourceWriter& featureDefinitions,
|
2013-11-20 00:38:09 +04:00
|
|
|
const std::vector<std::string>& pkgExecutables,
|
|
|
|
shortcut_map_t& shortcutMap);
|
2013-03-01 06:09:58 +04:00
|
|
|
|
2012-10-03 18:08:49 +04:00
|
|
|
bool RequireOption(const std::string& name, std::string& value) const;
|
|
|
|
|
|
|
|
std::string GetArchitecture() const;
|
|
|
|
|
|
|
|
static std::string GenerateGUID();
|
|
|
|
|
|
|
|
static std::string QuotePath(const std::string& path);
|
|
|
|
|
|
|
|
static std::string GetRightmostExtension(const std::string& filename);
|
|
|
|
|
2013-10-11 00:49:33 +04:00
|
|
|
std::string PathToId(const std::string& path);
|
|
|
|
|
|
|
|
std::string CreateNewIdForPath(const std::string& path);
|
|
|
|
|
|
|
|
static std::string CreateHashedId(
|
|
|
|
const std::string& path, const std::string& normalizedFilename);
|
|
|
|
|
|
|
|
std::string NormalizeComponentForId(
|
|
|
|
const std::string& component, size_t& replacementCount);
|
|
|
|
|
|
|
|
static bool IsLegalIdCharacter(char c);
|
|
|
|
|
2013-11-10 22:48:29 +04:00
|
|
|
void CollectExtensions(
|
|
|
|
const std::string& variableName, extension_set_t& extensions);
|
|
|
|
|
|
|
|
void AddCustomFlags(
|
|
|
|
const std::string& variableName, std::ostream& stream);
|
|
|
|
|
2013-11-20 00:38:09 +04:00
|
|
|
void CreateStartMenuFolder(cmWIXSourceWriter& directoryDefinitions);
|
|
|
|
|
2013-12-17 01:30:11 +04:00
|
|
|
void LoadPatchFragments(const std::string& patchFilePath);
|
|
|
|
|
|
|
|
void ApplyPatchFragment(const std::string& id, cmWIXSourceWriter& writer);
|
|
|
|
|
|
|
|
void ApplyPatchElement(const cmWIXPatchElement& element,
|
|
|
|
cmWIXSourceWriter& writer);
|
|
|
|
|
2013-12-20 21:12:01 +04:00
|
|
|
std::vector<std::string> WixSources;
|
|
|
|
id_map_t PathToIdMap;
|
|
|
|
ambiguity_map_t IdAmbiguityCounter;
|
2013-11-10 22:48:29 +04:00
|
|
|
|
2013-12-20 21:12:01 +04:00
|
|
|
extension_set_t CandleExtensions;
|
|
|
|
extension_set_t LightExtensions;
|
2013-12-17 01:30:11 +04:00
|
|
|
|
2013-12-20 21:12:01 +04:00
|
|
|
cmWIXPatchParser::fragment_map_t Fragments;
|
2012-10-03 18:08:49 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|