mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-06 02:10:28 +00:00
DEVTOOLS: Make create_engine run from scummvm root as well
This commit is contained in:
parent
8cc936fcf0
commit
3b3817823c
@ -25,6 +25,7 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// Specified engine name with different cases
|
||||
#define MAX_LINE_LENGTH 256
|
||||
@ -85,15 +86,15 @@ void process_file(FILE *in, FILE *out) {
|
||||
}
|
||||
|
||||
// Copies and processes the specified file
|
||||
void process_file(const char *filename) {
|
||||
void process_file(const char *filename, const char *prefix, const char *prefix2) {
|
||||
char srcFilename[128], destFilename[128];
|
||||
sprintf(srcFilename, "files/%s", filename);
|
||||
sprintf(srcFilename, "%s/files/%s", prefix2, filename);
|
||||
if (!strncmp(filename, "xyzzy.", 6))
|
||||
sprintf(destFilename, "../../engines/%s/%s.%s",
|
||||
engineLowercase, engineLowercase, filename + 6);
|
||||
sprintf(destFilename, "%s/engines/%s/%s.%s",
|
||||
prefix, engineLowercase, engineLowercase, filename + 6);
|
||||
else
|
||||
sprintf(destFilename, "../../engines/%s/%s",
|
||||
engineLowercase, filename);
|
||||
sprintf(destFilename, "%s/engines/%s/%s",
|
||||
prefix, engineLowercase, filename);
|
||||
|
||||
printf("Creating file %s...", destFilename);
|
||||
fflush(stdout);
|
||||
@ -120,17 +121,22 @@ void process_file(const char *filename) {
|
||||
// For Visual Studio convenience, creates a copy of the
|
||||
// create_msvc.bat to <engine>.bat that allows creating
|
||||
// the ScummVM solution with just that engine enabled
|
||||
void create_batch_file() {
|
||||
void create_batch_file(const char *prefix) {
|
||||
FILE *in, *out;
|
||||
char line[MAX_LINE_LENGTH];
|
||||
char destFilename[MAX_LINE_LENGTH];
|
||||
|
||||
if (!(in = fopen("../../dists/msvc/create_msvc.bat", "r"))) {
|
||||
sprintf(destFilename, "%s/dists/msvc/create_msvc.bat", prefix);
|
||||
if (!(in = fopen(destFilename, "r"))) {
|
||||
printf("Could not open create_msvc.bat\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
char destFilename[MAX_LINE_LENGTH];
|
||||
sprintf(destFilename, "../../dists/msvc/%s.bat", engineLowercase);
|
||||
sprintf(destFilename, "%s/dists/msvc/%s.bat", prefix, engineLowercase);
|
||||
|
||||
printf("Creating file %s...", destFilename);
|
||||
fflush(stdout);
|
||||
|
||||
if (!(out = fopen(destFilename, "w"))) {
|
||||
printf("Could not create %s.bat\n", engineLowercase);
|
||||
exit(0);
|
||||
@ -148,6 +154,8 @@ void create_batch_file() {
|
||||
fputs(line, out);
|
||||
}
|
||||
|
||||
printf("done\n");
|
||||
|
||||
fclose(in);
|
||||
fclose(out);
|
||||
}
|
||||
@ -166,11 +174,25 @@ int main(int argc, char *argv[]) {
|
||||
engineUppercase[i] : engineLowercase[i];
|
||||
}
|
||||
|
||||
char prefix[100];
|
||||
char prefix2[100];
|
||||
if (!access("../../engines", F_OK)) {
|
||||
strcpy(prefix, "../..");
|
||||
strcpy(prefix2, ".");
|
||||
} else if (!access("engines", F_OK)) {
|
||||
strcpy(prefix, ".");
|
||||
strcpy(prefix2, "devtools/create_engine");
|
||||
} else {
|
||||
printf("Cound not locate engines directory. Run from the scummvm source root directory\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Create a directory for the new engine
|
||||
char folder[MAX_LINE_LENGTH];
|
||||
sprintf(folder, "../../engines/%s", engineLowercase);
|
||||
sprintf(folder, "%s/engines/%s", prefix, engineLowercase);
|
||||
|
||||
printf("Creating directory ../../engines/%s...", engineLowercase);
|
||||
printf("Creating directory %s...", folder);
|
||||
fflush(stdout);
|
||||
|
||||
if (mkdir(folder, 0755)) {
|
||||
@ -181,9 +203,9 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// Process the files
|
||||
for (const char *const *filename = FILENAMES; *filename; ++filename)
|
||||
process_file(*filename);
|
||||
process_file(*filename, prefix, prefix2);
|
||||
|
||||
create_batch_file();
|
||||
create_batch_file(prefix);
|
||||
|
||||
printf("Engine generation complete.\n");
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user