Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve vstudio #1904

Merged
merged 10 commits into from
Dec 12, 2021
Merged

Improve vstudio #1904

merged 10 commits into from
Dec 12, 2021

Conversation

SirLynix
Copy link
Member

@SirLynix SirLynix commented Dec 11, 2021

Improve vstudio projects:

  • setup multi-core compilation by default (no longer require add_cxflags("/MP"), which is VS default behavior) - can be disabled with flag /MP1
  • fixes external include dirs, which were not translated like regular include dirs are.
  • add support for rundir
  • add support for /W4 ("allextra" warning level)

Also during my tests I noticed that some flags may appear multiple times, and that the common flag check (which is also done in makefile project) failed because some flags appeared multiple times (like -experimental:external and such, which I suppose are added after xmake remove duplicates flags).

Edit: I checked the reason why some duplicate flags are still there and it's because they were added as a parameter table, thus handled as a whole by _preprocess_flags

@waruqi
Copy link
Member

waruqi commented Dec 12, 2021

Edit: I checked the reason why some duplicate flags are still there and it's because they were added as a parameter table, thus handled as a whole by _preprocess_flags

it will remove duplicate flags.

if flag and not unique[flagkey] then

@SirLynix
Copy link
Member Author

Edit: I checked the reason why some duplicate flags are still there and it's because they were added as a parameter table, thus handled as a whole by _preprocess_flags

it will remove duplicate flags.

if flag and not unique[flagkey] then

It doesn't because external headers are passed as a table, and thus concat. So it doesn't see "-external:W0" but "-external:W0-external:I..."

@waruqi
Copy link
Member

waruqi commented Dec 12, 2021

Edit: I checked the reason why some duplicate flags are still there and it's because they were added as a parameter table, thus handled as a whole by _preprocess_flags

it will remove duplicate flags.

if flag and not unique[flagkey] then

It doesn't because external headers are passed as a table, and thus concat. So it doesn't see "-external:W0" but "-external:W0-external:I..."

The table is used to avoid internal deduplication, for example: avoid -I xx -I yy -> -I xx yy, there is no problem, unless "-external:W0" and "-external:-I" are not put in a table.

@SirLynix
Copy link
Member Author

Edit: I checked the reason why some duplicate flags are still there and it's because they were added as a parameter table, thus handled as a whole by _preprocess_flags

it will remove duplicate flags.

if flag and not unique[flagkey] then

It doesn't because external headers are passed as a table, and thus concat. So it doesn't see "-external:W0" but "-external:W0-external:I..."

The table is used to avoid internal deduplication, for example: avoid -I xx -I yy -> -I xx yy, there is no problem, unless "-external:W0" and "-external:-I" are not put in a table.

I understand what purpose it serves, but it will duplicate -external:W0, see this:

[ 32%]: compiling.debug src\Nazara\Utility\Formats\FreeTypeLoader.cpp
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.30.30705\\bin\\HostX64\\x64\\cl.exe" -c /EHsc -nologo -Zi -FS -Fdbin\windows_x64_debug\compile.NazaraUtility-d.pdb -W4 -Od -std:c++17 -MDd -Iinclude -Isrc -D_CRT_SECURE_NO_WARNINGS -DNAZARA_BUILD -DNAZARA_UTILITY_BUILD -DNAZARA_DEBUG -DNAZARA_UTILITY_DEBUG -DBZ_STATIC -external:W0 -external:Ithirdparty\include -external:W0 -external:IC:\Users\Lynix\AppData\Local\.xmake\packages\e\entt\v3.8.1\b21698e7653b48c49e073d6614de13b4\include -external:W0 -external:IC:\Users\Lynix\AppData\Local\.xmake\packages\f\freetype\2.11.0\ee2054a878394e47ba6e975a91854c2b\include\freetype2 -external:W0 -external:IC:\Users\Lynix\AppData\Local\.xmake\packages\b\brotli\1.0.9\b496cb273fdb41089073359cc81ebb58\include -external:W0 -external:IC:\Users\Lynix\AppData\Local\.xmake\packages\l\libpng\v1.6.37\d3e3dccbfcec47738b9bb4a32a0a1f44\include -external:W0 -external:IC:\Users\Lynix\AppData\Local\.xmake\packages\z\zlib\1.2.11\d6b178abc5d04bdc936c37166df8fe84\include -external:W0 -external:IC:\Users\Lynix\AppData\Local\.xmake\packages\b\bzip2\1.0.8\cc4412cb62de4ce68f2fe59e6d7f8704\include -external:W0 -external:IC:\Users\Lynix\AppData\Local\.xmake\packages\s\stb\0.0\86911977ee9f47b7ac1685c567fd7b8b\include /bigobj /permissive- /Zc:__cplusplus /Zc:externConstexpr /Zc:inline /Zc:lambda /Zc:preprocessor /Zc:referenceBinding /Zc:strictStrings /Zc:throwingNew /w44062 /wd4251 -Fobuild\.objs\NazaraUtility\windows\x64\debug\src\Nazara\Utility\Formats\FreeTypeLoader.cpp.obj src\Nazara\Utility\Formats\FreeTypeLoader.cpp

-external:W0 is put before every -external:I because they're in a table and thus not deduplicated.

@waruqi
Copy link
Member

waruqi commented Dec 12, 2021

Edit: I checked the reason why some duplicate flags are still there and it's because they were added as a parameter table, thus handled as a whole by _preprocess_flags

it will remove duplicate flags.

if flag and not unique[flagkey] then

It doesn't because external headers are passed as a table, and thus concat. So it doesn't see "-external:W0" but "-external:W0-external:I..."

The table is used to avoid internal deduplication, for example: avoid -I xx -I yy -> -I xx yy, there is no problem, unless "-external:W0" and "-external:-I" are not put in a table.

I understand what purpose it serves, but it will duplicate -external:W0, see this:

[ 32%]: compiling.debug src\Nazara\Utility\Formats\FreeTypeLoader.cpp
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.30.30705\\bin\\HostX64\\x64\\cl.exe" -c /EHsc -nologo -Zi -FS -Fdbin\windows_x64_debug\compile.NazaraUtility-d.pdb -W4 -Od -std:c++17 -MDd -Iinclude -Isrc -D_CRT_SECURE_NO_WARNINGS -DNAZARA_BUILD -DNAZARA_UTILITY_BUILD -DNAZARA_DEBUG -DNAZARA_UTILITY_DEBUG -DBZ_STATIC -external:W0 -external:Ithirdparty\include -external:W0 -external:IC:\Users\Lynix\AppData\Local\.xmake\packages\e\entt\v3.8.1\b21698e7653b48c49e073d6614de13b4\include -external:W0 -external:IC:\Users\Lynix\AppData\Local\.xmake\packages\f\freetype\2.11.0\ee2054a878394e47ba6e975a91854c2b\include\freetype2 -external:W0 -external:IC:\Users\Lynix\AppData\Local\.xmake\packages\b\brotli\1.0.9\b496cb273fdb41089073359cc81ebb58\include -external:W0 -external:IC:\Users\Lynix\AppData\Local\.xmake\packages\l\libpng\v1.6.37\d3e3dccbfcec47738b9bb4a32a0a1f44\include -external:W0 -external:IC:\Users\Lynix\AppData\Local\.xmake\packages\z\zlib\1.2.11\d6b178abc5d04bdc936c37166df8fe84\include -external:W0 -external:IC:\Users\Lynix\AppData\Local\.xmake\packages\b\bzip2\1.0.8\cc4412cb62de4ce68f2fe59e6d7f8704\include -external:W0 -external:IC:\Users\Lynix\AppData\Local\.xmake\packages\s\stb\0.0\86911977ee9f47b7ac1685c567fd7b8b\include /bigobj /permissive- /Zc:__cplusplus /Zc:externConstexpr /Zc:inline /Zc:lambda /Zc:preprocessor /Zc:referenceBinding /Zc:strictStrings /Zc:throwingNew /w44062 /wd4251 -Fobuild\.objs\NazaraUtility\windows\x64\debug\src\Nazara\Utility\Formats\FreeTypeLoader.cpp.obj src\Nazara\Utility\Formats\FreeTypeLoader.cpp

-external:W0 is put before every -external:I because they're in a table and thus not deduplicated.

I know it will be repeated, but there is no better way, they can only be placed in a table.

return {"-experimental:external", "-external:W0", "-external:I" .. path.translate(dir)}

@SirLynix
Copy link
Member Author

I know it will be repeated, but there is no better way, they can only be placed in a table.

return {"-experimental:external", "-external:W0", "-external:I" .. path.translate(dir)}

Yes, but then it will break makefile and vstudio common flags search, because they will have a flag more than they have files, this is why I fixed it using a >= instead of ==

@waruqi
Copy link
Member

waruqi commented Dec 12, 2021

Yes, but then it will break makefile and vstudio common flags search, because they will have a flag more than they have files, this is why I fixed it using a >= instead of ==

You can use this workaround solution to be compatible with it first

@waruqi waruqi merged commit 20f9cb8 into xmake-io:dev Dec 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants