diff --git a/ppremake/config_msvc.h b/ppremake/config_msvc.h index 87e22adad8..2126481bcc 100644 --- a/ppremake/config_msvc.h +++ b/ppremake/config_msvc.h @@ -80,5 +80,5 @@ ** Also be sure to change the version number ** ** at the beginning of configure.in. ** **************** ****************/ -#define VERSION "1.1" +#define VERSION "1.11" /**************** UPDATE VERSION NUMBER HERE ****************/ diff --git a/ppremake/configure.in b/ppremake/configure.in index a9d2a4cdd8..11f6ae877a 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.1) +AM_INIT_AUTOMAKE(ppremake, 1.11) dnl **************** UPDATE VERSION NUMBER HERE **************** AM_CONFIG_HEADER(config.h) diff --git a/ppremake/ppCommandFile.cxx b/ppremake/ppCommandFile.cxx index 6402fd3172..a621a4a9a6 100644 --- a/ppremake/ppCommandFile.cxx +++ b/ppremake/ppCommandFile.cxx @@ -801,7 +801,11 @@ handle_endif_command() { nest->pop(this); if (nest->_block != _block_nesting) { - cerr << "If block not closed within scoping block.\n"; + if (nest->_block != (BlockNesting *)NULL) { + cerr << "If block not closed within scoping block " << nest->_block->_name << ".\n"; + } else { + cerr << "If block not closed within scoping block " << _block_nesting->_name << ".\n"; + } return false; } @@ -1106,15 +1110,15 @@ handle_output_command() { nest->push(this); if (!_in_for) { - string filename = trim_blanks(_scope->expand_string(nest->_name)); + Filename filename = trim_blanks(_scope->expand_string(nest->_name)); if (filename.empty()) { cerr << "Attempt to output to empty filename\n"; return false; } - if (filename[0] != '/') { + if (filename.is_local()) { string prefix = _scope->expand_variable("DIRPREFIX"); - filename = prefix + filename; + filename = Filename(prefix, filename); } nest->_params = filename; @@ -1157,7 +1161,7 @@ handle_end_command() { nest->pop(this); if (nest->_if != _if_nesting) { - cerr << "If block not closed within scoping block.\n"; + cerr << "If block not closed within scoping block " << name << ".\n"; return false; } @@ -1436,7 +1440,13 @@ handle_mkdir_command() { vector::const_iterator wi; for (wi = words.begin(); wi != words.end(); ++wi) { Filename dirname(*wi); - Filename filename(*wi, "file"); + + if (dirname.is_local()) { + string prefix = _scope->expand_variable("DIRPREFIX"); + dirname = Filename(prefix, dirname); + } + + Filename filename(dirname, "file"); if (!filename.make_dir()) { if (!dirname.is_directory()) { cerr << "Unable to create directory " << dirname << "\n"; diff --git a/ppremake/ppDirectory.cxx b/ppremake/ppDirectory.cxx index c442fcc9ce..c112fdb828 100644 --- a/ppremake/ppDirectory.cxx +++ b/ppremake/ppDirectory.cxx @@ -498,6 +498,7 @@ read_depends_file(PPNamedScopes *named_scopes) { } named_scopes->set_current(_dirname); + current_output_directory = this; PPCommandFile depends(_scope); if (!depends.read_file(depends_filename)) { cerr << "Error reading dependency definition file " diff --git a/ppremake/ppFilenamePattern.cxx b/ppremake/ppFilenamePattern.cxx index 7d125537e1..4743d49472 100644 --- a/ppremake/ppFilenamePattern.cxx +++ b/ppremake/ppFilenamePattern.cxx @@ -167,7 +167,21 @@ transform(const string &filename, return _prefix; } else { string body = transform_from.extract_body(filename); - return _prefix + body + _suffix; + string result = _prefix + body; + + // Now the suffix might contain more % characters. Replace all + // of them. + size_t p = 0; + size_t pct = _suffix.find(PATTERN_WILDCARD, p); + while (pct != string::npos) { + result += _suffix.substr(p, pct - p); + result += body; + p = pct + 1; + pct = _suffix.find(PATTERN_WILDCARD, p); + } + result += _suffix.substr(p); + + return result; } } diff --git a/ppremake/ppMain.cxx b/ppremake/ppMain.cxx index ee5b6d24e2..6f6554831a 100644 --- a/ppremake/ppMain.cxx +++ b/ppremake/ppMain.cxx @@ -104,7 +104,12 @@ read_source(const string &root) { } // Now cd to the source root and get the actual path. - string osdir = trydir.to_os_specific(); + string osdir; +#ifdef HAVE_CYGWIN + osdir = trydir; +#else + osdir = trydir.to_os_specific(); +#endif if (chdir(osdir.c_str()) < 0) { perror("chdir"); return false; diff --git a/ppremake/ppScope.cxx b/ppremake/ppScope.cxx index f087429bf9..e60b2fd652 100644 --- a/ppremake/ppScope.cxx +++ b/ppremake/ppScope.cxx @@ -2023,7 +2023,7 @@ string PPScope:: expand_patsubst(const string ¶ms, bool separate_words) { // Split the string up into tokens based on the commas. vector tokens; - tokenize_params(params, tokens, true); + tokenize_params(params, tokens, false); if (tokens.size() < 3) { cerr << "patsubst requires at least three parameters.\n"; @@ -2039,9 +2039,9 @@ expand_patsubst(const string ¶ms, bool separate_words) { // only if separate_words is true. vector words; if (separate_words) { - tokenize_whitespace(tokens.back(), words); + tokenize_whitespace(expand_string(tokens.back()), words); } else { - words.push_back(tokens.back()); + words.push_back(expand_string(tokens.back())); } // Build up a vector of from/to patterns. @@ -2053,10 +2053,10 @@ expand_patsubst(const string ¶ms, bool separate_words) { size_t i; for (i = 0; i < tokens.size() - 1; i += 2) { // Each "from" pattern might be a collection of patterns separated - // by spaces. + // by spaces, and it is expanded immediately. from.push_back(Patterns()); vector froms; - tokenize_whitespace(tokens[i], froms); + tokenize_whitespace(expand_string(tokens[i]), froms); vector::const_iterator fi; for (fi = froms.begin(); fi != froms.end(); ++fi) { PPFilenamePattern pattern(*fi); @@ -2068,8 +2068,14 @@ expand_patsubst(const string ¶ms, bool separate_words) { from.back().push_back(pattern); } - // However, the corresponding "to" pattern is just one pattern. - to.push_back(PPFilenamePattern(tokens[i + 1])); + // However, the corresponding "to" pattern is just one pattern, + // and it is expanded immediately only if it does not contain a + // wildcard character. + PPFilenamePattern to_pattern(tokens[i + 1]); + if (!to_pattern.has_wildcard()) { + to_pattern = PPFilenamePattern(expand_string(tokens[i + 1])); + } + to.push_back(to_pattern); } size_t num_patterns = from.size(); assert(num_patterns == to.size()); @@ -2082,7 +2088,8 @@ expand_patsubst(const string ¶ms, bool separate_words) { for (pi = from[i].begin(); pi != from[i].end() && !matched; ++pi) { if ((*pi).matches(*wi)) { matched = true; - (*wi) = to[i].transform(*wi, (*pi)); + string transformed = to[i].transform(*wi, (*pi)); + (*wi) = expand_string(transformed); } } }