Repository: lucy-charmonizer Updated Branches: refs/heads/master 78e998499 -> 0b6b2a3b7
Feature test for shell used by make Project: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/commit/d2545fb4 Tree: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/tree/d2545fb4 Diff: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/diff/d2545fb4 Branch: refs/heads/master Commit: d2545fb4de3e62865d6c450dd7ef38fd395d624a Parents: 78e9984 Author: Nick Wellnhofer <[email protected]> Authored: Sat May 21 01:55:12 2016 +0200 Committer: Nick Wellnhofer <[email protected]> Committed: Sat May 21 01:55:12 2016 +0200 ---------------------------------------------------------------------- src/Charmonizer/Core/Make.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/d2545fb4/src/Charmonizer/Core/Make.c ---------------------------------------------------------------------- diff --git a/src/Charmonizer/Core/Make.c b/src/Charmonizer/Core/Make.c index 75732b0..0ddf60c 100644 --- a/src/Charmonizer/Core/Make.c +++ b/src/Charmonizer/Core/Make.c @@ -81,22 +81,25 @@ S_write_rule(chaz_MakeRule *rule, FILE *out); void chaz_Make_init(const char *make_command) { if (make_command) { - chaz_Make.make_command = chaz_Util_strdup(make_command); + if (!chaz_Make_detect(make_command, NULL)) { + chaz_Util_warn("Make utility '%s' doesn't appear to work"); + } } else { - chaz_Make_detect("make", "gmake", "nmake", "dmake", "mingw32-make", - "mingw64-make", NULL); - } - - if (chaz_Make.make_command) { - if (strcmp(chaz_Make.make_command, "nmake") == 0) { - chaz_Make.shell_type = CHAZ_OS_CMD_EXE; + if (!chaz_Make_detect("make", "gmake", "nmake", "dmake", + "mingw32-make", "mingw64-make", NULL) + ) { + chaz_Util_warn("No working make utility found"); } - else { - /* TODO: Feature test which shell make uses on Windows. */ - chaz_Make.shell_type = CHAZ_OS_POSIX; + else if (chaz_Util_verbosity) { + printf("Detected make utility '%s'\n", chaz_Make.make_command); } } + + if (chaz_Make.shell_type == 0) { + // Assume POSIX. + chaz_Make.shell_type = CHAZ_OS_POSIX; + } } void @@ -119,7 +122,7 @@ chaz_Make_detect(const char *make1, ...) { va_list args; const char *candidate; int found = 0; - const char makefile_content[] = "foo:\n\techo \"foo!\"\n"; + const char makefile_content[] = "foo:\n\t@echo \\^foo!\n"; chaz_Util_write_file("_charm_Makefile", makefile_content); /* Audition candidates. */ @@ -145,7 +148,12 @@ chaz_Make_audition(const char *make) { if (chaz_Util_can_open_file("_charm_foo")) { size_t len; char *content = chaz_Util_slurp_file("_charm_foo", &len); - if (NULL != strstr(content, "foo!")) { + if (strncmp(content, "\\foo!", 5) == 0) { + chaz_Make.shell_type = CHAZ_OS_CMD_EXE; + succeeded = 1; + } + else if (strncmp(content, "^foo!", 5) == 0) { + chaz_Make.shell_type = CHAZ_OS_POSIX; succeeded = 1; } free(content);
