deprecate non-`native` platform being used by default in Windows builds (#4734)
* deprecate non-`native` platform being used by default in Windows builds * test-helloworld.py: avoid deprecation warnings
This commit is contained in:
parent
ea617553a6
commit
f16ffd88e9
|
@ -128,10 +128,18 @@ void CmdLineParser::printError(const std::string &message)
|
|||
printMessage("error: " + message);
|
||||
}
|
||||
|
||||
#if defined(_WIN64) || defined(_WIN32)
|
||||
bool CmdLineParser::SHOW_DEF_PLATFORM_MSG = true;
|
||||
#endif
|
||||
|
||||
// TODO: normalize/simplify/native all path parameters
|
||||
// TODO: error out on all missing given files/paths
|
||||
bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
||||
{
|
||||
#if defined(_WIN64) || defined(_WIN32)
|
||||
bool default_platform = true;
|
||||
#endif
|
||||
|
||||
bool def = false;
|
||||
bool maxconfigs = false;
|
||||
|
||||
|
@ -617,6 +625,10 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
return false;
|
||||
}
|
||||
|
||||
#if defined(_WIN64) || defined(_WIN32)
|
||||
default_platform = false;
|
||||
#endif
|
||||
|
||||
// TODO: remove
|
||||
// these are loaded via external files and thus have Settings::PlatformFile set instead.
|
||||
// override the type so they behave like the regular platforms.
|
||||
|
@ -1039,6 +1051,14 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
return true;
|
||||
}
|
||||
|
||||
#if defined(_WIN64)
|
||||
if (SHOW_DEF_PLATFORM_MSG && default_platform)
|
||||
printMessage("Windows 64-bit binaries currently default to the 'win64' platform. Starting with Cppcheck 2.13 they will default to 'native' instead. Please specify '--platform=win64' explicitly if you rely on this.");
|
||||
#elif defined(_WIN32)
|
||||
if (SHOW_DEF_PLATFORM_MSG && default_platform)
|
||||
printMessage("Windows 32-bit binaries currently default to the 'win32A' platform. Starting with Cppcheck 2.13 they will default to 'native' instead. Please specify '--platform=win32A' explicitly if you rely on this.");
|
||||
#endif
|
||||
|
||||
// Print error only if we have "real" command and expect files
|
||||
if (!mExitAfterPrint && mPathNames.empty() && mSettings->project.fileSettings.empty()) {
|
||||
printError("no C or C++ source files found.");
|
||||
|
|
|
@ -93,6 +93,11 @@ public:
|
|||
return mIgnoredPaths;
|
||||
}
|
||||
|
||||
#if defined(_WIN64) || defined(_WIN32)
|
||||
// temporary variable to "un-break" tests
|
||||
static bool SHOW_DEF_PLATFORM_MSG;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,3 +4,4 @@ release notes for cppcheck-2.10
|
|||
- if the file provided via "--file-list" cannot be opened it will now error out
|
||||
- add command-line option "--disable=<id>" to individually disable checks
|
||||
- added CMake option BUILD_CORE_DLL to build lib as cppcheck-core.dll with Visual Studio
|
||||
- Windows binaries currently default to the "win32A" and "win64" platform respectively. Starting with Cppcheck 2.13 they will default to 'native' instead. Please specify '--platform=win32A' or '--platform=win64' explicitly if you rely on this.
|
||||
|
|
|
@ -72,7 +72,7 @@ def test_addon_absolute_path():
|
|||
|
||||
def test_addon_relative_path():
|
||||
prjpath = getRelativeProjectPath()
|
||||
ret, stdout, stderr = cppcheck(['--addon=misra', '--template=cppcheck1', prjpath])
|
||||
ret, stdout, stderr = cppcheck(['--platform=native', '--addon=misra', '--template=cppcheck1', prjpath])
|
||||
filename = os.path.join(prjpath, 'main.c')
|
||||
assert ret == 0, stdout
|
||||
assert stdout == ('Checking %s ...\n'
|
||||
|
@ -83,7 +83,7 @@ def test_addon_relative_path():
|
|||
def test_addon_with_gui_project():
|
||||
project_file = 'helloworld/test.cppcheck'
|
||||
create_gui_project_file(project_file, paths=['.'], addon='misra')
|
||||
ret, stdout, stderr = cppcheck(['--template=cppcheck1', '--project=' + project_file])
|
||||
ret, stdout, stderr = cppcheck(['--platform=native', '--template=cppcheck1', '--project=' + project_file])
|
||||
filename = os.path.join('helloworld', 'main.c')
|
||||
assert ret == 0, stdout
|
||||
assert stdout == 'Checking %s ...\n' % filename
|
||||
|
|
|
@ -37,7 +37,17 @@ class TestCmdlineParser : public TestFixture {
|
|||
public:
|
||||
TestCmdlineParser()
|
||||
: TestFixture("TestCmdlineParser")
|
||||
, defParser(&settings) {}
|
||||
, defParser(&settings) {
|
||||
#if defined(_WIN64) || defined(_WIN32)
|
||||
CmdLineParser::SHOW_DEF_PLATFORM_MSG = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
~TestCmdlineParser() override {
|
||||
#if defined(_WIN64) || defined(_WIN32)
|
||||
CmdLineParser::SHOW_DEF_PLATFORM_MSG = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
Settings settings; // TODO: reset after each test
|
||||
|
@ -131,6 +141,10 @@ private:
|
|||
TEST_CASE(platformUnspecified);
|
||||
TEST_CASE(platformPlatformFile);
|
||||
TEST_CASE(platformUnknown);
|
||||
#if defined(_WIN64) || defined(_WIN32)
|
||||
TEST_CASE(platformDefault);
|
||||
TEST_CASE(platformDefault2);
|
||||
#endif
|
||||
TEST_CASE(plistEmpty);
|
||||
TEST_CASE(plistDoesNotExist);
|
||||
TEST_CASE(suppressionsOld);
|
||||
|
@ -1065,6 +1079,41 @@ private:
|
|||
ASSERT_EQUALS("cppcheck: error: unrecognized platform: \"win128\".\n", GET_REDIRECT_OUTPUT);
|
||||
}
|
||||
|
||||
#if defined(_WIN64) || defined(_WIN32)
|
||||
void platformDefault() {
|
||||
REDIRECT;
|
||||
|
||||
CmdLineParser::SHOW_DEF_PLATFORM_MSG = true;
|
||||
|
||||
const char * const argv[] = {"cppcheck", "file.cpp"};
|
||||
settings = Settings();
|
||||
ASSERT(defParser.parseFromArgs(2, argv));
|
||||
#if defined(_WIN64)
|
||||
ASSERT_EQUALS(Settings::Win64, settings.platformType);
|
||||
ASSERT_EQUALS("cppcheck: Windows 64-bit binaries currently default to the 'win64' platform. Starting with Cppcheck 2.13 they will default to 'native' instead. Please specify '--platform=win64' explicitly if you rely on this.\n", GET_REDIRECT_OUTPUT);
|
||||
#elif defined(_WIN32)
|
||||
ASSERT_EQUALS(Settings::Win32A, settings.platformType);
|
||||
ASSERT_EQUALS("cppcheck: Windows 32-bit binaries currently default to the 'win32A' platform. Starting with Cppcheck 2.13 they will default to 'native' instead. Please specify '--platform=win32A' explicitly if you rely on this.\n", GET_REDIRECT_OUTPUT);
|
||||
#endif
|
||||
|
||||
CmdLineParser::SHOW_DEF_PLATFORM_MSG = false;
|
||||
}
|
||||
|
||||
void platformDefault2() {
|
||||
REDIRECT;
|
||||
|
||||
CmdLineParser::SHOW_DEF_PLATFORM_MSG = true;
|
||||
|
||||
const char * const argv[] = {"cppcheck", "--platform=unix64", "file.cpp"};
|
||||
settings = Settings();
|
||||
ASSERT(defParser.parseFromArgs(3, argv));
|
||||
ASSERT_EQUALS(Settings::Unix64, settings.platformType);
|
||||
ASSERT_EQUALS("", GET_REDIRECT_OUTPUT);
|
||||
|
||||
CmdLineParser::SHOW_DEF_PLATFORM_MSG = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
void plistEmpty() {
|
||||
REDIRECT;
|
||||
const char * const argv[] = {"cppcheck", "--plist-output=", "file.cpp"};
|
||||
|
|
|
@ -37,6 +37,7 @@ private:
|
|||
TEST_CASE(valid_config_file_4);
|
||||
TEST_CASE(invalid_config_file_1);
|
||||
TEST_CASE(empty_elements);
|
||||
TEST_CASE(default_platform);
|
||||
}
|
||||
|
||||
static bool readPlatform(cppcheck::Platform& platform, const char* xmldata) {
|
||||
|
@ -313,6 +314,17 @@ private:
|
|||
ASSERT_EQUALS(platform.PlatformFile, platform.platformType);
|
||||
ASSERT(!platform.isWindowsPlatform());
|
||||
}
|
||||
|
||||
void default_platform() {
|
||||
cppcheck::Platform platform;
|
||||
#if defined(_WIN64)
|
||||
ASSERT_EQUALS(cppcheck::Platform::Win64, platform.platformType);
|
||||
#elif defined(_WIN32)
|
||||
ASSERT_EQUALS(cppcheck::Platform::Win32A, platform.platformType);
|
||||
#else
|
||||
ASSERT_EQUALS(cppcheck::Platform::Native, platform.platformType);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestPlatform)
|
||||
|
|
Loading…
Reference in New Issue