50-win-hybridcrt.conf 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. ## -*- mode: perl; -*-
  2. # Windows HybridCRT targets.
  3. #
  4. # https://github.com/microsoft/WindowsAppSDK/blob/77761e244289fda6b3d5f14c7bded189fed4fb89/docs/Coding-Guidelines/HybridCRT.md
  5. # Link statically against the runtime and STL, but link dynamically against the CRT by ignoring the static CRT
  6. # lib and instead linking against the Universal CRT DLL import library. This "Hybrid" linking mechanism is
  7. # supported according to the CRT maintainer. Dynamic linking against the CRT makes the binaries a bit smaller
  8. # than they would otherwise be if the CRT, runtime, and STL were all statically linked in.
  9. sub remove_from_flags {
  10. my ($toRemove, $flags) = @_;
  11. $flags =~ s/$toRemove//;
  12. return $flags;
  13. }
  14. my %targets = (
  15. "VC-WIN32-HYBRIDCRT" => {
  16. inherit_from => [ "VC-WIN32" ],
  17. cflags => sub {
  18. remove_from_flags(qr/\/MDd?\s/, add(picker(debug => "/MTd",
  19. release => "/MT"))->(@_))
  20. },
  21. lflags => add(picker(debug => "/NODEFAULTLIB:libucrtd.lib /DEFAULTLIB:ucrtd.lib",
  22. release => "/NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")),
  23. },
  24. "VC-WIN64A-HYBRIDCRT" => {
  25. inherit_from => [ "VC-WIN64A" ],
  26. cflags => sub {
  27. remove_from_flags(qr/\/MDd?\s/, add(picker(debug => "/MTd",
  28. release => "/MT"))->(@_))
  29. },
  30. lflags => add(picker(debug => "/NODEFAULTLIB:libucrtd.lib /DEFAULTLIB:ucrtd.lib",
  31. release => "/NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")),
  32. },
  33. );