modified the way --preprocess works.

the source folder doesn't need to be in data/ folder and all result
files will be placed in the target directory.
This commit is contained in:
Timotei Dolean 2010-05-15 19:27:04 +00:00
parent 3db682f822
commit 19b1f0a6a5
3 changed files with 12 additions and 14 deletions

View file

@ -145,8 +145,12 @@ runs the game without sounds and music.
prints the name of the game data directory and exits. prints the name of the game data directory and exits.
.TP .TP
.B --preprocess, -p[=<define1>,<define2>,...] <file/folder> <target directory> .B --preprocess, -p[=<define1>,<define2>,...] <file/folder> <target directory>
preprocesses a specified file/folder relative to the data/ directory. The file(s) will be written in the data/preproc folder: a plain cfg file and a processed cfg file. The needed folder tree will be created automatically if it doesn't exist. preprocesses a specified file/folder. The file(s) will be written in specified target
define1,define2,... - the extra defines will be added before processing the files. directory: a plain cfg file and a processed cfg file. If a folder is specified, it will
be preprocessed recursively based on the known preprocessor rules. The common macroses
from the data/core/macros will be preprocessed before the specified resources.
.B define1,define2,...
- the extra defines will be added before processing the files.
.TP .TP
.BI -r\ X x Y ,\ --resolution\ X x Y .BI -r\ X x Y ,\ --resolution\ X x Y
sets the screen resolution. Example: sets the screen resolution. Example:

View file

@ -1829,11 +1829,9 @@ static int process_command_args(int argc, char** argv) {
<< " errors unless every player uses it)\n" << " errors unless every player uses it)\n"
<< " --path prints the path to the data directory and exits.\n" << " --path prints the path to the data directory and exits.\n"
<< " --preprocess, -p[=<define1>,<define2>,...] <file/folder> <target directory>\n" << " --preprocess, -p[=<define1>,<define2>,...] <file/folder> <target directory>\n"
<< " preprocesses a specified file/folder relative to\n" << " preprocesses a specified file/folder. The preprocessed\n"
<< " the data/ directory. The file(s) will be written in\n" << " file(s) will be written in the specified target\n"
<< " the specified target directory: a plain cfg file and a\n" << " directory: a plain cfg file and a processed cfg file.\n"
<< " processed cfg file. The needed folder tree will be\n"
<< " created automatically if it doesn't exist\n"
<< " define1,define2,... - the extra defines will\n" << " define1,define2,... - the extra defines will\n"
<< " be added before processing the files.\n" << " be added before processing the files.\n"
<< " -r, --resolution XxY sets the screen resolution. Example: -r 800x600\n" << " -r, --resolution XxY sets the screen resolution. Example: -r 800x600\n"
@ -1989,11 +1987,10 @@ static int process_command_args(int argc, char** argv) {
preprocess_resource(game_config::path + "/data/core/macros/",&defines_map); preprocess_resource(game_config::path + "/data/core/macros/",&defines_map);
LOG_PREPROC<<"processing target resource...\n"; LOG_PREPROC<<"processing target resource...\n";
preprocess_resource(game_config::path +"/data/"+ resourceToProcess, &defines_map, preprocess_resource(resourceToProcess, &defines_map, true,true, targetDir);
true,true, targetDir);
} }
else{ else{
std::cerr<<"Please specify a source file/folder relative to the data/ directory and a target folder\n"; std::cerr<<"Please specify a source file/folder and a target folder\n";
} }
return 1; return 1;
} }

View file

@ -1038,10 +1038,7 @@ void preprocess_resource(const std::string res_name, preproc_map *defines_map,
if (write_cfg == true || write_plain_cfg == true) if (write_cfg == true || write_plain_cfg == true)
{ {
std::string preproc_res_name = res_name; const std::string preproc_res_name = target_directory + "/" + file_name(res_name);
// we replace <path>/data/<resource> with <target_directory>/<resource>
preproc_res_name.erase(0,preproc_res_name.find("/data")+5);
preproc_res_name.insert(0,target_directory);
// write the processed cfg file // write the processed cfg file
if (write_cfg == true) if (write_cfg == true)