From 4062b2c93922ff9f4cfa031391cfcdf8013ad417 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 20 Apr 2006 04:04:47 +0000 Subject: [PATCH] ppremake 1.20, introducing #output --- ppremake/config_msvc.h | 2 +- ppremake/configure.in | 2 +- ppremake/ppCommandFile.cxx | 53 ++++++++++++++++++++++++++++++++++++++ ppremake/ppCommandFile.h | 1 + ppremake/ppDirectory.cxx | 7 +++-- ppremake/ppremake.sln | 10 +++---- ppremake/ppremake.vcproj | 50 ++++++++++++++++++++++------------- 7 files changed, 98 insertions(+), 27 deletions(-) diff --git a/ppremake/config_msvc.h b/ppremake/config_msvc.h index efc5797685..2ebb05fe47 100644 --- a/ppremake/config_msvc.h +++ b/ppremake/config_msvc.h @@ -86,5 +86,5 @@ ** Also be sure to change the version number ** ** at the beginning of configure.in. ** **************** ****************/ -#define VERSION "1.19" +#define VERSION "1.20" /**************** UPDATE VERSION NUMBER HERE ****************/ diff --git a/ppremake/configure.in b/ppremake/configure.in index 18c9d076c8..f58e2c717c 100644 --- a/ppremake/configure.in +++ b/ppremake/configure.in @@ -5,7 +5,7 @@ dnl **************** UPDATE VERSION NUMBER HERE **************** dnl ** Also be sure to change the version number ** dnl ** at the end of config_msvc.h. ** dnl **************** **************** -AM_INIT_AUTOMAKE(ppremake, 1.19) +AM_INIT_AUTOMAKE(ppremake, 1.20) dnl **************** UPDATE VERSION NUMBER HERE **************** AM_CONFIG_HEADER(config.h) diff --git a/ppremake/ppCommandFile.cxx b/ppremake/ppCommandFile.cxx index 1e12dba794..810c6485c2 100644 --- a/ppremake/ppCommandFile.cxx +++ b/ppremake/ppCommandFile.cxx @@ -665,6 +665,9 @@ handle_command(const string &line) { } else if (_command == "sinclude") { return handle_sinclude_command(); + } else if (_command == "copy") { + return handle_copy_command(); + } else if (_command == "call") { return handle_call_command(); @@ -1404,6 +1407,56 @@ handle_sinclude_command() { return include_file(filename); } +//////////////////////////////////////////////////////////////////// +// Function: PPCommandFile::handle_copy_command +// Access: Protected +// Description: Handles the #copy command: the indicated file is +// read and output at this point. This is useful for +// inserting within an #output sequence, to copy the +// contents of some file into the target file. +//////////////////////////////////////////////////////////////////// +bool PPCommandFile:: +handle_copy_command() { + string filename = trim_blanks(_scope->expand_string(_params)); + + // We allow optional quotation marks around the filename. + if (filename.length() >= 2 && + filename[0] == '"' && + filename[filename.length() - 1] == '"') { + filename = filename.substr(1, filename.length() - 2); + } + + Filename fn(filename); + fn.set_text(); + + ifstream in; + if (!fn.open_read(in)) { + cerr << "Unable to open copy file " << fn << ".\n"; + errors_occurred = true; + return false; + } + if (verbose) { + cerr << "Reading (copy) \"" << fn << "\"\n"; + } + + string line; + getline(in, line); + while (!in.fail() && !in.eof()) { + if (!_write_state->write_line(line)) { + return false; + } + getline(in, line); + } + + if (!in.eof()) { + cerr << "Error reading " << fn << ".\n"; + errors_occurred = true; + return false; + } + + return true; +} + //////////////////////////////////////////////////////////////////// // Function: PPCommandFile::handle_call_command // Access: Protected diff --git a/ppremake/ppCommandFile.h b/ppremake/ppCommandFile.h index 0d78f4f633..9496d2340a 100644 --- a/ppremake/ppCommandFile.h +++ b/ppremake/ppCommandFile.h @@ -59,6 +59,7 @@ protected: bool handle_printvar_command(); bool handle_include_command(); bool handle_sinclude_command(); + bool handle_copy_command(); bool handle_call_command(); bool handle_error_command(); bool handle_mkdir_command(); diff --git a/ppremake/ppDirectory.cxx b/ppremake/ppDirectory.cxx index c3f273f78f..06f821509e 100644 --- a/ppremake/ppDirectory.cxx +++ b/ppremake/ppDirectory.cxx @@ -10,6 +10,7 @@ #include "ppCommandFile.h" #include "ppDependableFile.h" #include "tokenize.h" +#include "ppremake.h" #ifdef HAVE_DIRENT_H #include @@ -365,9 +366,10 @@ get_dependable_file(const string &filename, bool is_header) { if (_tree != main_tree && other->get_directory()->get_tree() != main_tree) { // Both files are in external dependable trees. - cerr << "Warning: header file " << dependable->get_fullpath() + cerr << "Error: header file " << dependable->get_fullpath() << " may be confused with " << other->get_fullpath() << ".\n"; + errors_occurred = true; } else if (other->get_directory()->get_tree() != _tree) { // This file is a source file in this tree, while the other @@ -377,9 +379,10 @@ get_dependable_file(const string &filename, bool is_header) { } else { // Both files are within the same source tree. - cerr << "Warning: source file " << dependable->get_pathname() + cerr << "Error: source file " << dependable->get_pathname() << " may be confused with " << other->get_pathname() << ".\n"; + errors_occurred = true; } } } diff --git a/ppremake/ppremake.sln b/ppremake/ppremake.sln index cb210b8386..18746235a5 100644 --- a/ppremake/ppremake.sln +++ b/ppremake/ppremake.sln @@ -1,12 +1,12 @@ -Microsoft Visual Studio Solution File, Format Version 7.00 +Microsoft Visual Studio Solution File, Format Version 8.00 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ppremake", "ppremake.vcproj", "{B2B6A5F5-4403-4386-9294-B10EE8B0B3E8}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution - ConfigName.0 = Debug - ConfigName.1 = Release - EndGlobalSection - GlobalSection(ProjectDependencies) = postSolution + Debug = Debug + Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {B2B6A5F5-4403-4386-9294-B10EE8B0B3E8}.Debug.ActiveCfg = Debug|Win32 diff --git a/ppremake/ppremake.vcproj b/ppremake/ppremake.vcproj index 0b10076f7c..1e339d6aef 100644 --- a/ppremake/ppremake.vcproj +++ b/ppremake/ppremake.vcproj @@ -1,7 +1,7 @@ - + @@ -32,8 +32,14 @@ Name="VCResourceCompilerTool"/> + + + + + + + + - - @@ -102,6 +113,9 @@ + + @@ -112,24 +126,21 @@ - - + + - - @@ -137,7 +148,7 @@ RelativePath="filename.h"> + RelativePath="filename.I"> @@ -145,6 +156,9 @@ + + @@ -205,6 +219,12 @@ + + + + @@ -217,12 +237,6 @@ - - - -