Skip to content

Commit 5b9d716

Browse files
committed
don't fail miserably, when an unknown vc version is used
1 parent c0b0e1b commit 5b9d716

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

win32/build/confutils.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2610,9 +2610,20 @@ function toolset_setup_compiler()
26102610
ERROR("Unsupported MS C++ Compiler, VC11 (2011) minimum is required");
26112611
}
26122612

2613-
AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
2614-
DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]);
2615-
AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID");
2613+
if (undefined == COMPILER_NAME) {
2614+
var tmp = probe_binary(PHP_CL);
2615+
COMPILER_NAME = "MSVC " + tmp + ", untested";
2616+
2617+
WARNING("Using unknown MSVC version " + tmp);
2618+
2619+
AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
2620+
DEFINE("PHP_COMPILER_SHORT", tmp);
2621+
AC_DEFINE('PHP_COMPILER_ID', tmp, "Compiler compatibility ID");
2622+
} else {
2623+
AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version");
2624+
DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]);
2625+
AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID");
2626+
}
26162627
} else if (CLANG_TOOLSET) {
26172628
CLANGVERS = COMPILER_NUMERIC_VERSION;
26182629

@@ -2732,8 +2743,15 @@ function toolset_get_compiler_name()
27322743
var version;
27332744

27342745
if (VS_TOOLSET) {
2746+
var name = undefined;
2747+
27352748
version = probe_binary(PHP_CL).substr(0, 5).replace('.', '');
2736-
return VC_VERSIONS[version];
2749+
2750+
if (undefined != VC_VERSIONS[version]) {
2751+
name = VC_VERSIONS[version];
2752+
}
2753+
2754+
return name;
27372755
} else if (CLANG_TOOLSET || ICC_TOOLSET) {
27382756
var command = 'cmd /c ""' + PHP_CL + '" -v"';
27392757
var full = execute(command + '" 2>&1"');

0 commit comments

Comments
 (0)