first steps toward VC-compilable ppremake

This commit is contained in:
David Rose 2002-05-21 23:38:04 +00:00
parent 7cbfc0c2ce
commit deaa090dd9
22 changed files with 564 additions and 33 deletions

View File

@ -23,8 +23,8 @@
/* Define if we're compiling for a Windows platform. */
#undef PLATFORM_WIN32
/* The current version number. */
#define VERSION 0.0
/* Define if we're compiling using Windows Microsoft Visual C++. */
#undef WIN32_VC
/* The platform ppremake is compiled for. This primarily controls the
initial setting of the $[PLATFORM] variable. */

83
ppremake/config_msvc.h Normal file
View File

@ -0,0 +1,83 @@
/* config_msvc.h.
This file was generated by hand for use on Win32 environments when
building with Microsoft Visual Studio. It will have to be kept
up-to-date by hand with the automatically-generated config.h on
other platforms.
*/
/* Define if the C++ compiler uses namespaces. */
#define HAVE_NAMESPACE 1
/* Define if the C++ iostream library supports ios::binary. */
/* #undef HAVE_IOS_BINARY */
/* Define if we're compiling for a Windows platform. */
#define PLATFORM_WIN32 1
/* Define if we're compiling using Windows Microsoft Visual C++. */
#define WIN32_VC 1
/* The platform ppremake is compiled for. This primarily controls the
initial setting of the $[PLATFORM] variable. */
#define PLATFORM "Win32"
/* Define if you have the <alloca.h> header file. */
/* #undef HAVE_ALLOCA_H */
/* Define if you have the `getopt' function. */
/* #undef HAVE_GETOPT */
/* Define if you have the <iostream> header file. */
#define HAVE_IOSTREAM 1
/* Define if you have the <io.h> header file. */
#define HAVE_IO_H 1
/* Define if you have the <malloc.h> header file. */
#define HAVE_MALLOC_H 1
/* Define if you have the <minmax.h> header file. */
/* #undef HAVE_MINMAX_H */
/* Define if you have the <glob.h> header file. */
/* #undef HAVE_GLOB_H */
/* Define if you have the <dirent.h> header file. */
/* #undef HAVE_DIRENT_H */
/* Define if you have the <regex.h> header file. */
/* #undef HAVE_REGEX_H */
/* Define if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define if you have the <strstream.h> header file. */
#define HAVE_STRSTREAM_H 1
/* Define if you have the <sys/types.h> header file. */
/* #undef HAVE_SYS_TYPES_H 1 */
/* Define if you have the <sys/time.h> header file. */
/* #undef HAVE_SYS_TIME_H 1 */
/* Define if you have the <sys/utime.h> header file. */
#define HAVE_SYS_UTIME_H 1
/* Define if you have the <sys/wait.h> header file. */
/* #undef HAVE_SYS_WAIT_H 1 */
/* Define if you have the <unistd.h> header file. */
/* #undef HAVE_UNISTD_H 1 */
/* Define if you have the <utime.h> header file. */
/* #undef HAVE_UTIME_H 1 */
/* Name of package */
#define PACKAGE "ppremake"
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "1.03"

View File

@ -35,7 +35,7 @@ AC_SUBST(libm)
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(malloc.h alloca.h unistd.h io.h minmax.h sys/types.h string.h regex.h)
AC_CHECK_HEADERS(malloc.h alloca.h unistd.h utime.h io.h minmax.h glob.h dirent.h sys/types.h sys/time.h sys/utime.h sys/wait.h string.h strstream.h regex.h)
dnl Checks for typedefs, structures, and compiler characteristics.

View File

@ -4,8 +4,11 @@
////////////////////////////////////////////////////////////////////
#include "find_searchpath.h"
#include "include_access.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
string
find_searchpath(const vector<string> &directories, const string &filename) {

View File

@ -17,7 +17,7 @@
GNU General Public License for more details. */
#include <ppremake.h>
#include "ppremake.h"
#if !defined(HAVE_GETOPT)

View File

@ -35,7 +35,7 @@ extern "C" {
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char EXPCL_DTOOL *optarg;
extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
@ -49,7 +49,7 @@ extern char EXPCL_DTOOL *optarg;
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
extern int EXPCL_DTOOL optind;
extern int optind;
/* Callers store zero here to inhibit the error message `getopt' prints
for unrecognized options. */
@ -101,12 +101,12 @@ struct option
#define required_argument 1
#define optional_argument 2
extern EXPCL_DTOOL int
extern int
getopt (int argc, char *const *argv, const char *shortopts);
extern EXPCL_DTOOL int
extern int
getopt_long (int argc, char *const *argv, const char *shortopts,
const struct option *long_options, int *opt_index);
extern EXPCL_DTOOL int
extern int
getopt_long_only (int argc, char *const *argv,
const char *shortopts,
const struct option *long_options,

View File

@ -24,7 +24,7 @@
#pragma alloca
#endif
#include <ppremake.h>
#include "ppremake.h"
#if !defined(HAVE_REGEX_H)
@ -2835,7 +2835,7 @@ re_set_registers (bufp, regs, num_regs, starts, ends)
{
bufp->regs_allocated = REGS_UNALLOCATED;
regs->num_regs = 0;
regs->start = regs->end = (regoff_t) 0;
regs->start = regs->end = (regoff_t *) 0;
}
}

View File

@ -393,7 +393,7 @@ typedef struct
unfortunately clutters up the declarations a bit, but I think it's
worth it. */
#if __STDC__
#if defined(__STDC__) || defined(_MSC_VER)
#define _RE_ARGS(args) args

25
ppremake/include_access.h Normal file
View File

@ -0,0 +1,25 @@
// Filename: include_access.cxx
// Created by: drose (21May02)
//
////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_ACCESS_H
#define INCLUDE_ACCESS_H
// This file includes whatever is necessary to define the access()
// function.
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef WIN32_VC
#include <io.h> // Windows requires this for access()
#define access _access
#define F_OK 00
#define W_OK 02
#define R_OK 04
#endif // WIN32_VC
#endif // INCLUDE_ACCESS_H

View File

@ -8,14 +8,24 @@
#include "ppNamedScopes.h"
#include "ppSubroutine.h"
#include "tokenize.h"
#include "include_access.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_UTIME_H
#include <utime.h>
#endif
#ifdef HAVE_SYS_UTIME_H
#include <sys/utime.h>
#endif
#include <ctype.h>
#include <stdio.h> // for tempnam()
#include <unistd.h>
#include <sys/types.h>
#include <utime.h>
#include <assert.h>
#include <strstream.h>
static const string begin_comment(BEGIN_COMMENT);
@ -1664,7 +1674,11 @@ compare_output(const string &new_contents, const string &filename,
}
}
#ifdef WIN32_VC
ofstream out_b(filename.c_str(), ios::out);
#else // WIN32_VC
ofstream out_b(filename.c_str(), ios::out, 0666);
#endif // WIN32_VC
if (!out_b) {
cerr << "Unable to open file " << filename << " for writing.\n";
return false;

View File

@ -8,8 +8,11 @@
#include "ppDirectoryTree.h"
#include "check_include.h"
#include <assert.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <assert.h>
#include <sys/stat.h>
#include <algorithm>
@ -443,11 +446,13 @@ stat_file() {
return;
}
#ifdef S_ISREG
if (!S_ISREG(st.st_mode)) {
// The file exists, but it's not a regular file--we consider that
// not existing.
return;
}
#endif // S_ISREG
_flags |= F_exists;
_mtime = st.st_mtime;

View File

@ -7,10 +7,13 @@
#define PPDEPENDABLEFILE_H
#include "ppremake.h"
#include <sys/time.h>
#include <set>
#include <vector>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
class PPDirectory;
///////////////////////////////////////////////////////////////////

View File

@ -10,11 +10,27 @@
#include "ppCommandFile.h"
#include "ppDependableFile.h"
#include "tokenize.h"
#include "include_access.h"
#include <sys/types.h>
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <algorithm>
#include <assert.h>
#ifdef WIN32_VC
#include <direct.h>
#include <windows.h>
#endif
PPDirectory *current_output_directory = (PPDirectory *)NULL;
@ -390,17 +406,48 @@ r_scan(const string &prefix) {
if (!prefix.empty()) {
root_name = prefix.substr(0, prefix.length() - 1);
}
// Collect all the filenames in the directory in this vector first,
// so we can sort them.
vector<string> filenames;
#ifdef WIN32_VC
// Use FindFirstFile()/FindNextFile() to walk through the list of
// files in a directory.
string match;
if (root_name.empty()) {
match = "*.*";
} else {
match = root_name + "\\*.*";
}
WIN32_FIND_DATA find_data;
HANDLE handle = FindFirstFile(match.c_str(), &find_data);
if (handle == INVALID_HANDLE_VALUE) {
if (GetLastError() == ERROR_NO_MORE_FILES) {
// No matching files is not an error.
return true;
}
return false;
}
do {
string filename = find_data.cFileName;
if (filename != "." && filename != "..") {
filenames.push_back(filename);
}
} while (FindNextFile(handle, &find_data));
bool scan_ok = (GetLastError() == ERROR_NO_MORE_FILES);
FindClose(handle);
#else // WIN32_VC
DIR *root = opendir(root_name.c_str());
if (root == (DIR *)NULL) {
cerr << "Unable to scan directory " << root_name << "\n";
return false;
}
// Collect all the filenames in the directory in this vector first,
// so we can sort them.
vector<string> filenames;
struct dirent *d;
d = readdir(root);
while (d != (struct dirent *)NULL) {
@ -408,6 +455,7 @@ r_scan(const string &prefix) {
d = readdir(root);
}
closedir(root);
#endif // WIN32_VC
sort(filenames.begin(), filenames.end());
@ -675,7 +723,11 @@ update_file_dependencies(const string &cache_filename) {
if (!_dependables.empty()) {
bool wrote_anything = false;
#ifdef WIN32_VC
ofstream out(cache_pathname.c_str(), ios::out);
#else
ofstream out(cache_pathname.c_str(), ios::out, 0666);
#endif
if (!out) {
cerr << "Cannot update cache dependency file " << cache_pathname << "\n";
return;

View File

@ -8,12 +8,21 @@
#include "ppCommandFile.h"
#include "ppDirectory.h"
#include "tokenize.h"
#include "include_access.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <assert.h>
#include <errno.h>
#include <stdio.h> // for perror
#ifdef WIN32_VC
#include <direct.h> // Windows requires this for getcwd()
#define getcwd _getcwd
#endif // WIN32_VC
string PPMain::_root;
////////////////////////////////////////////////////////////////////

View File

@ -14,20 +14,37 @@
#include "tokenize.h"
#include "find_searchpath.h"
#include "filename.h"
#include "include_access.h"
#ifdef HAVE_GLOB_H
#include <glob.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#include <stdlib.h>
#include <algorithm>
#include <ctype.h>
#include <glob.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h> // for perror() and sprintf().
#include <errno.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <assert.h>
#ifdef WIN32_VC
#include <windows.h> // for GetFileAttributes()
#endif // WIN32_VC
static const string variable_patsubst(VARIABLE_PATSUBST);
PPScope::MapVariableDefinition PPScope::_null_map_def;
@ -1280,14 +1297,24 @@ expand_isdir(const string &params) {
}
const string &filename = results[0];
struct stat stbuf;
string result;
#ifdef WIN32_VC
DWORD dresults = GetFileAttributes(filename.c_str());
if (dresults != -1) {
if ((dresults & FILE_ATTRIBUTE_DIRECTORY) != 0) {
result = filename;
}
}
#else // WIN32_VC
struct stat stbuf;
if (stat(filename.c_str(), &stbuf) == 0) {
if (S_ISDIR(stbuf.st_mode)) {
result = filename;
}
}
#endif // WIN32_VC
return result;
}
@ -1313,14 +1340,25 @@ expand_isfile(const string &params) {
}
const string &filename = results[0];
struct stat stbuf;
string result;
#ifdef WIN32_VC
DWORD dresults = GetFileAttributes(filename.c_str());
if (dresults != -1) {
if (dresults == FILE_ATTRIBUTE_NORMAL) {
result = filename;
}
}
#else // WIN32_VC
struct stat stbuf;
if (stat(filename.c_str(), &stbuf) == 0) {
if (S_ISREG(stbuf.st_mode)) {
result = filename;
}
}
#endif // WIN32_VC
return result;
}
@ -1495,6 +1533,11 @@ expand_bintest(const string &params) {
////////////////////////////////////////////////////////////////////
string PPScope::
expand_shell(const string &params) {
#ifdef WIN32_VC
cerr << "$[shell] is not presently supported on Win32 without Cygwin.\n";
string output;
#else // WIN32_VC
// We run $[shell] commands within the directory indicated by
// $[THISDIRPREFIX]. This way, local filenames will be expanded the
// way we expect.
@ -1572,6 +1615,7 @@ expand_shell(const string &params) {
}
}
close(pd[0]);
#endif // WIN32_VC
// Now get the output. We split it into words and then reconnect
// it, to simulate the shell's backpop operator.
@ -3086,6 +3130,10 @@ p_find_map_variable(const string &varname) {
////////////////////////////////////////////////////////////////////
void PPScope::
glob_string(const string &str, vector<string> &results) {
#ifdef WIN32_VC
cerr << "glob temporarily unsupported in Win32 without Cygwin.\n";
#else // WIN32_VC
// We run glob_string() within the directory indicated by
// $[THISDIRPREFIX]. This way, local filenames will be expanded the
// way we expect.
@ -3126,4 +3174,5 @@ glob_string(const string &str, vector<string> &results) {
// Now restore the current directory back to where it should be.
PPMain::chdir_root();
}
#endif // WIN32_VC
}

View File

@ -13,14 +13,18 @@
#ifdef HAVE_GETOPT
#include <getopt.h>
#else
#include <gnu_getopt.h>
#include "gnu_getopt.h"
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <set>
#include <vector>
#include <algorithm>
#include <sys/stat.h>
#include <unistd.h>
#include <assert.h>
bool unix_platform = false;
bool windows_platform = false;

View File

@ -8,7 +8,13 @@
#ifndef PPREMAKE_H
#define PPREMAKE_H
#include "config.h"
#ifdef _MSC_VER
/* For Visual C, include the special config.h file. */
#include "config_msvc.h"
#else
/* Otherwise, include the normal automatically-generated file. */
#include "config.h"
#endif
#ifdef __cplusplus
#ifdef HAVE_IOSTREAM
@ -28,6 +34,11 @@ using namespace std;
#endif
#endif /* __cplusplus */
#ifndef HAVE_ALLOCA_H
/* If we don't have alloca.h, use malloc() to implement gnu_regex. */
#define REGEX_MALLOC 1
#endif
#define PACKAGE_FILENAME "Package.pp"
#define SOURCE_FILENAME "Sources.pp"

21
ppremake/ppremake.sln Normal file
View File

@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 7.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ppremake", "ppremake.vcproj", "{B2B6A5F5-4403-4386-9294-B10EE8B0B3E8}"
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
ConfigName.0 = Debug
ConfigName.1 = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{B2B6A5F5-4403-4386-9294-B10EE8B0B3E8}.Debug.ActiveCfg = Debug|Win32
{B2B6A5F5-4403-4386-9294-B10EE8B0B3E8}.Debug.Build.0 = Debug|Win32
{B2B6A5F5-4403-4386-9294-B10EE8B0B3E8}.Release.ActiveCfg = Release|Win32
{B2B6A5F5-4403-4386-9294-B10EE8B0B3E8}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

241
ppremake/ppremake.vcproj Normal file
View File

@ -0,0 +1,241 @@
<?xml version="1.0" encoding = "Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="ppremake"
ProjectGUID="{B2B6A5F5-4403-4386-9294-B10EE8B0B3E8}"
Keyword="CustomAppWizProj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
IntermediateDirectory="Debug"
ConfigurationType="1">
<Tool
Name="VCCLCompilerTool"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
IntermediateDirectory="Release"
ConfigurationType="1">
<Tool
Name="VCCLCompilerTool"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
</Configurations>
<Files>
<Filter
Name="Template Files"
Filter="txt">
<File
RelativePath="Templates\1033\ReadMe.txt">
</File>
</Filter>
<Filter
Name="HTML Files"
Filter="htm">
</Filter>
<Filter
Name="Image Files"
Filter="bmp">
</Filter>
<Filter
Name="Script Files"
Filter="js">
<File
RelativePath="Scripts\1033\default.js">
</File>
</Filter>
<Filter
Name="Miscellaneous Files"
Filter="vsz;vsdir;ico;vcproj;csproj;css;inf">
<File
RelativePath="Templates\1033\Templates.inf">
</File>
<File
RelativePath="default.vcproj">
</File>
<File
RelativePath="ppremake.ico">
</File>
<File
RelativePath="ppremake.vsdir">
</File>
<File
RelativePath="ppremake.vsz">
</File>
</Filter>
<File
RelativePath="check_include.cxx">
</File>
<File
RelativePath="check_include.h">
</File>
<File
RelativePath="config_msvc.h">
</File>
<File
RelativePath="filename.cxx">
</File>
<File
RelativePath="filename.h">
</File>
<File
RelativePath="find_searchpath.cxx">
</File>
<File
RelativePath="find_searchpath.h">
</File>
<File
RelativePath="gnu_getopt.c">
</File>
<File
RelativePath="gnu_getopt.h">
</File>
<File
RelativePath="gnu_regex.c">
</File>
<File
RelativePath="gnu_regex.h">
</File>
<File
RelativePath="include_access.h">
</File>
<File
RelativePath="ppCommandFile.cxx">
</File>
<File
RelativePath="ppCommandFile.h">
</File>
<File
RelativePath="ppDependableFile.cxx">
</File>
<File
RelativePath="ppDependableFile.h">
</File>
<File
RelativePath="ppDirectory.cxx">
</File>
<File
RelativePath="ppDirectory.h">
</File>
<File
RelativePath="ppDirectoryTree.cxx">
</File>
<File
RelativePath="ppDirectoryTree.h">
</File>
<File
RelativePath="ppFilenamePattern.cxx">
</File>
<File
RelativePath="ppFilenamePattern.h">
</File>
<File
RelativePath="ppMain.cxx">
</File>
<File
RelativePath="ppMain.h">
</File>
<File
RelativePath="ppNamedScopes.cxx">
</File>
<File
RelativePath="ppNamedScopes.h">
</File>
<File
RelativePath="ppScope.cxx">
</File>
<File
RelativePath="ppScope.h">
</File>
<File
RelativePath="ppSubroutine.cxx">
</File>
<File
RelativePath="ppSubroutine.h">
</File>
<File
RelativePath="ppremake.cxx">
</File>
<File
RelativePath="ppremake.h">
</File>
<File
RelativePath="sedAddress.cxx">
</File>
<File
RelativePath="sedAddress.h">
</File>
<File
RelativePath="sedCommand.cxx">
</File>
<File
RelativePath="sedCommand.h">
</File>
<File
RelativePath="sedContext.cxx">
</File>
<File
RelativePath="sedContext.h">
</File>
<File
RelativePath="sedProcess.cxx">
</File>
<File
RelativePath="sedProcess.h">
</File>
<File
RelativePath="sedScript.cxx">
</File>
<File
RelativePath="sedScript.h">
</File>
<File
RelativePath="tokenize.cxx">
</File>
<File
RelativePath="tokenize.h">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

1
ppremake/ppremake.vsdir Normal file
View File

@ -0,0 +1 @@
ppremake.vsz| |ppremake|1|TODO: Wizard Description.| |6777| |ppremake

8
ppremake/ppremake.vsz Normal file
View File

@ -0,0 +1,8 @@
VSWIZARD 7.0
Wizard=VsWizard.VsWizardEngine
Param="WIZARD_NAME = ppremake"
Param="ABSOLUTE_PATH = C:\Cygwin\home\drose\player\ppremake"
Param="FALLBACK_LCID = 1033"
Param="WIZARD_UI = FALSE"
Param="SOURCE_FILTER = txt"

View File

@ -279,7 +279,7 @@ do_command(SedScript &script, SedContext &context) {
void SedCommand::
do_s_command(SedContext &context) {
size_t nmatch = _re.re_nsub + 1;
regmatch_t pmatch[nmatch];
regmatch_t *pmatch = new regmatch_t[nmatch];
string result;
const char *str = context._pattern_space.c_str();
@ -327,6 +327,7 @@ do_s_command(SedContext &context) {
// If we don't have the global flag set, stop after the first iteration.
result += str;
context._pattern_space = result;
delete[] pmatch;
return;
}
@ -336,4 +337,5 @@ do_s_command(SedContext &context) {
// All done.
result += str;
context._pattern_space = result;
delete[] pmatch;
}