Add JOM support and clean up some of the tar -E stuff

This commit is contained in:
Bill Hoffman 2009-11-05 15:00:15 -05:00
parent a01badcc7a
commit dd09d88065
6 changed files with 147 additions and 18 deletions

View File

@ -281,6 +281,8 @@ IF (WIN32)
cmGlobalMinGWMakefileGenerator.cxx cmGlobalMinGWMakefileGenerator.cxx
cmGlobalNMakeMakefileGenerator.cxx cmGlobalNMakeMakefileGenerator.cxx
cmGlobalNMakeMakefileGenerator.h cmGlobalNMakeMakefileGenerator.h
cmGlobalJOMMakefileGenerator.cxx
cmGlobalJOMMakefileGenerator.h
cmGlobalVisualStudio6Generator.cxx cmGlobalVisualStudio6Generator.cxx
cmGlobalVisualStudio6Generator.h cmGlobalVisualStudio6Generator.h
cmGlobalVisualStudio71Generator.cxx cmGlobalVisualStudio71Generator.cxx

View File

@ -0,0 +1,69 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
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.
============================================================================*/
#include "cmGlobalJOMMakefileGenerator.h"
#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
cmGlobalJOMMakefileGenerator::cmGlobalJOMMakefileGenerator()
{
this->FindMakeProgramFile = "CMakeJOMFindMake.cmake";
this->ForceUnixPaths = false;
this->ToolSupportsColor = true;
this->UseLinkScript = false;
}
void cmGlobalJOMMakefileGenerator
::EnableLanguage(std::vector<std::string>const& l,
cmMakefile *mf,
bool optional)
{
// pick a default
mf->AddDefinition("CMAKE_GENERATOR_CC", "cl");
mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl");
if(!(cmSystemTools::GetEnv("INCLUDE") &&
cmSystemTools::GetEnv("LIB"))
)
{
std::string message = "To use the JOM generator, cmake must be run "
"from a shell that can use the compiler cl from the command line. "
"This environment does not contain INCLUDE, LIB, or LIBPATH, and "
"these must be set for the cl compiler to work. ";
mf->IssueMessage(cmake::WARNING,
message);
}
this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
}
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *cmGlobalJOMMakefileGenerator::CreateLocalGenerator()
{
cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3;
lg->SetDefineWindowsNULL(true);
lg->SetWindowsShell(true);
lg->SetMakeSilentFlag("/nologo");
lg->SetGlobalGenerator(this);
lg->SetIgnoreLibPrefix(true);
lg->SetPassMakeflags(true);
lg->SetNMake(true);
lg->SetUnixCD(false);
return lg;
}
//----------------------------------------------------------------------------
void cmGlobalJOMMakefileGenerator
::GetDocumentation(cmDocumentationEntry& entry) const
{
entry.Name = this->GetName();
entry.Brief = "Generates JOM makefiles.";
entry.Full = "";
}

View File

@ -0,0 +1,47 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
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 cmGlobalJOMMakefileGenerator_h
#define cmGlobalJOMMakefileGenerator_h
#include "cmGlobalUnixMakefileGenerator3.h"
/** \class cmGlobalJOMMakefileGenerator
* \brief Write a JOM makefiles.
*
* cmGlobalJOMMakefileGenerator manages nmake build process for a tree
*/
class cmGlobalJOMMakefileGenerator : public cmGlobalUnixMakefileGenerator3
{
public:
cmGlobalJOMMakefileGenerator();
static cmGlobalGenerator* New() {
return new cmGlobalJOMMakefileGenerator; }
///! Get the name for the generator.
virtual const char* GetName() const {
return cmGlobalJOMMakefileGenerator::GetActualName();}
static const char* GetActualName() {return "JOM Makefiles";}
/** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry) const;
///! Create a local generator appropriate to this Global Generator
virtual cmLocalGenerator *CreateLocalGenerator();
/**
* Try to determine system infomation such as shared library
* extension, pthreads, byte order etc.
*/
virtual void EnableLanguage(std::vector<std::string>const& languages,
cmMakefile *, bool optional);
};
#endif

View File

@ -1704,7 +1704,7 @@ bool cmSystemTools::IsPathToFramework(const char* path)
bool cmSystemTools::CreateTar(const char* outFileName, bool cmSystemTools::CreateTar(const char* outFileName,
const std::vector<cmStdString>& files, const std::vector<cmStdString>& files,
bool gzip, bool verbose) bool gzip, bool bzip2, bool verbose)
{ {
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
@ -1755,6 +1755,14 @@ bool cmSystemTools::CreateTar(const char* outFileName,
cmSystemTools::Error("Unable to use gzip in libarchive"); cmSystemTools::Error("Unable to use gzip in libarchive");
} }
} }
if(bzip2)
{
res = archive_write_set_compression_bzip2(a);
if(res != ARCHIVE_OK)
{
cmSystemTools::Error("Unable to use bzip2 in libarchive");
}
}
res = archive_write_set_format_ustar(a); res = archive_write_set_format_ustar(a);
if(res != ARCHIVE_OK) if(res != ARCHIVE_OK)
{ {
@ -1822,7 +1830,7 @@ namespace{
#define BSDTAR_FILESIZE_PRINTF "%lu" #define BSDTAR_FILESIZE_PRINTF "%lu"
#define BSDTAR_FILESIZE_TYPE unsigned long #define BSDTAR_FILESIZE_TYPE unsigned long
void void
list_item_verbose(FILE *out, struct archive_entry *entry) list_item_verbose(FILE *out, struct archive_entry *entry)
{ {
char tmp[100]; char tmp[100];
size_t w; size_t w;
@ -1862,7 +1870,6 @@ list_item_verbose(FILE *out, struct archive_entry *entry)
u_width = w; u_width = w;
} }
fprintf(out, "%-*s ", (int)u_width, p); fprintf(out, "%-*s ", (int)u_width, p);
/* Use gname if it's present, else gid. */ /* Use gname if it's present, else gid. */
p = archive_entry_gname(entry); p = archive_entry_gname(entry);
if (p != NULL && p[0] != '\0') if (p != NULL && p[0] != '\0')
@ -1967,7 +1974,8 @@ int copy_data(struct archive *ar, struct archive *aw)
} }
} }
bool extract_tar(const char* outFileName, bool verbose, bool extract) bool extract_tar(const char* outFileName, bool verbose,
bool extract)
{ {
struct archive* a = archive_read_new(); struct archive* a = archive_read_new();
struct archive *ext = archive_write_disk_new(); struct archive *ext = archive_write_disk_new();
@ -2038,10 +2046,8 @@ bool extract_tar(const char* outFileName, bool verbose, bool extract)
#endif #endif
bool cmSystemTools::ExtractTar(const char* outFileName, bool cmSystemTools::ExtractTar(const char* outFileName,
const std::vector<cmStdString>& files,
bool , bool verbose) bool , bool verbose)
{ {
(void)files;
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)
return extract_tar(outFileName, verbose, true); return extract_tar(outFileName, verbose, true);
#else #else
@ -2052,11 +2058,10 @@ bool cmSystemTools::ExtractTar(const char* outFileName,
} }
bool cmSystemTools::ListTar(const char* outFileName, bool cmSystemTools::ListTar(const char* outFileName,
std::vector<cmStdString>& files, bool , bool ,
bool verbose) bool verbose)
{ {
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)
(void)files;
return extract_tar(outFileName, verbose, false); return extract_tar(outFileName, verbose, false);
#else #else
(void)outFileName; (void)outFileName;

View File

@ -354,13 +354,11 @@ public:
/** Create tar */ /** Create tar */
static bool ListTar(const char* outFileName, static bool ListTar(const char* outFileName,
std::vector<cmStdString>& files,
bool gzip, bool verbose); bool gzip, bool verbose);
static bool CreateTar(const char* outFileName, static bool CreateTar(const char* outFileName,
const std::vector<cmStdString>& files, bool gzip, const std::vector<cmStdString>& files, bool gzip,
bool verbose); bool bzip2, bool verbose);
static bool ExtractTar(const char* inFileName, static bool ExtractTar(const char* inFileName, bool gzip,
const std::vector<cmStdString>& files, bool gzip,
bool verbose); bool verbose);
// This should be called first thing in main // This should be called first thing in main
// it will keep child processes from inheriting the // it will keep child processes from inheriting the

View File

@ -67,6 +67,7 @@
# include "cmGlobalVisualStudio8Win64Generator.h" # include "cmGlobalVisualStudio8Win64Generator.h"
# include "cmGlobalBorlandMakefileGenerator.h" # include "cmGlobalBorlandMakefileGenerator.h"
# include "cmGlobalNMakeMakefileGenerator.h" # include "cmGlobalNMakeMakefileGenerator.h"
# include "cmGlobalJOMMakefileGenerator.h"
# include "cmGlobalWatcomWMakeGenerator.h" # include "cmGlobalWatcomWMakeGenerator.h"
# define CMAKE_HAVE_VS_GENERATORS # define CMAKE_HAVE_VS_GENERATORS
# endif # endif
@ -969,7 +970,7 @@ void CMakeCommandUsage(const char* program)
<< " remove_directory dir - remove a directory and its contents\n" << " remove_directory dir - remove a directory and its contents\n"
<< " remove [-f] file1 file2 ... - remove the file(s), use -f to force " << " remove [-f] file1 file2 ... - remove the file(s), use -f to force "
"it\n" "it\n"
<< " tar [cxt][vfz] file.tar file/dir1 file/dir2 ... - create a tar " << " tar [cxt][vfz][cvfj] file.tar file/dir1 file/dir2 ... - create a tar "
"archive\n" "archive\n"
<< " time command [args] ... - run command and return elapsed time\n" << " time command [args] ... - run command and return elapsed time\n"
<< " touch file - touch a file.\n" << " touch file - touch a file.\n"
@ -1540,7 +1541,12 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
files.push_back(args[cc]); files.push_back(args[cc]);
} }
bool gzip = false; bool gzip = false;
bool bzip2 = false;
bool verbose = false; bool verbose = false;
if ( flags.find_first_of('j') != flags.npos )
{
bzip2 = true;
}
if ( flags.find_first_of('z') != flags.npos ) if ( flags.find_first_of('z') != flags.npos )
{ {
gzip = true; gzip = true;
@ -1552,7 +1558,7 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
if ( flags.find_first_of('t') != flags.npos ) if ( flags.find_first_of('t') != flags.npos )
{ {
if ( !cmSystemTools::ListTar(outFile.c_str(), files, gzip, verbose) ) if ( !cmSystemTools::ListTar(outFile.c_str(), gzip, verbose) )
{ {
cmSystemTools::Error("Problem creating tar: ", outFile.c_str()); cmSystemTools::Error("Problem creating tar: ", outFile.c_str());
return 1; return 1;
@ -1561,7 +1567,7 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
else if ( flags.find_first_of('c') != flags.npos ) else if ( flags.find_first_of('c') != flags.npos )
{ {
if ( !cmSystemTools::CreateTar( if ( !cmSystemTools::CreateTar(
outFile.c_str(), files, gzip, verbose) ) outFile.c_str(), files, gzip, bzip2, verbose) )
{ {
cmSystemTools::Error("Problem creating tar: ", outFile.c_str()); cmSystemTools::Error("Problem creating tar: ", outFile.c_str());
return 1; return 1;
@ -1570,7 +1576,7 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
else if ( flags.find_first_of('x') != flags.npos ) else if ( flags.find_first_of('x') != flags.npos )
{ {
if ( !cmSystemTools::ExtractTar( if ( !cmSystemTools::ExtractTar(
outFile.c_str(), files, gzip, verbose) ) outFile.c_str(), gzip, verbose) )
{ {
cmSystemTools::Error("Problem extracting tar: ", outFile.c_str()); cmSystemTools::Error("Problem extracting tar: ", outFile.c_str());
return 1; return 1;
@ -2381,6 +2387,8 @@ void cmake::AddDefaultGenerators()
&cmGlobalBorlandMakefileGenerator::New; &cmGlobalBorlandMakefileGenerator::New;
this->Generators[cmGlobalNMakeMakefileGenerator::GetActualName()] = this->Generators[cmGlobalNMakeMakefileGenerator::GetActualName()] =
&cmGlobalNMakeMakefileGenerator::New; &cmGlobalNMakeMakefileGenerator::New;
this->Generators[cmGlobalJOMMakefileGenerator::GetActualName()] =
&cmGlobalJOMMakefileGenerator::New;
this->Generators[cmGlobalWatcomWMakeGenerator::GetActualName()] = this->Generators[cmGlobalWatcomWMakeGenerator::GetActualName()] =
&cmGlobalWatcomWMakeGenerator::New; &cmGlobalWatcomWMakeGenerator::New;
# endif # endif