@@ -730,7 +730,7 @@ static Strings listWindowsKits()
730730 return kits;
731731}
732732
733- void detectWindowsSdk (DETECT_ARGS)
733+ static void detectWindowsSdk (DETECT_ARGS)
734734{
735735 // ucrt - universal CRT
736736 //
@@ -908,14 +908,14 @@ void detectWindowsSdk(DETECT_ARGS)
908908 }
909909}
910910
911- void detectMsvc (DETECT_ARGS)
911+ static void detectMsvc (DETECT_ARGS)
912912{
913913 detectMsvc15Plus (s);
914914 detectMsvc14AndOlder (s);
915915 detectWindowsSdk (s);
916916}
917917
918- void detectWindowsClang (DETECT_ARGS)
918+ static void detectWindowsClang (DETECT_ARGS)
919919{
920920 // create programs
921921 const path base_llvm_path = path (" c:" ) / " Program Files" / " LLVM" ;
@@ -1024,13 +1024,111 @@ void detectWindowsClang(DETECT_ARGS)
10241024 }
10251025}
10261026
1027- void detectWindowsCompilers (DETECT_ARGS)
1027+ static void detectIntelCompilers (DETECT_ARGS)
1028+ {
1029+ // some info at https://gitlab.com/ita1024/waf/blob/master/waflib/Tools/msvc.py#L521
1030+
1031+ // C, C++
1032+
1033+ // win
1034+ {
1035+ auto add_prog_from_path = [&s](const path &name, const String &ppath)
1036+ {
1037+ auto p = std::make_shared<SimpleProgram>(s);
1038+ p->file = resolveExecutable (name);
1039+ if (fs::exists (p->file ))
1040+ {
1041+ auto v = getVersion (s, p->file );
1042+ addProgram (s, PackageId (ppath, v), p);
1043+
1044+ // icl/xilib/xilink on win wants VC in PATH
1045+ auto &cld = s.getPredefinedTargets ();
1046+ auto i = cld[" com.Microsoft.VisualStudio.VC.cl" ].rbegin_releases ();
1047+ if (i != cld[" com.Microsoft.VisualStudio.VC.cl" ].rend_releases ())
1048+ {
1049+ if (!i->second .empty ())
1050+ {
1051+ if (auto t = (*i->second .begin ())->as <PredefinedProgramTarget *>())
1052+ {
1053+ path x = t->getProgram ().getCommand ()->getProgram ();
1054+ p->getCommand ()->addPathDirectory (x.parent_path ());
1055+ }
1056+ }
1057+ }
1058+ }
1059+ return p;
1060+ };
1061+
1062+ add_prog_from_path (" icl" , " com.intel.compiler.c" );
1063+ add_prog_from_path (" icl" , " com.intel.compiler.cpp" );
1064+ add_prog_from_path (" xilib" , " com.intel.compiler.lib" );
1065+ add_prog_from_path (" xilink" , " com.intel.compiler.link" );
1066+
1067+ // ICPP_COMPILER{VERSION} like ICPP_COMPILER19 etc.
1068+ for (int i = 9 ; i < 23 ; i++)
1069+ {
1070+ auto s = " ICPP_COMPILER" + std::to_string (i);
1071+ auto v = getenv (s.c_str ());
1072+ if (!v)
1073+ continue ;
1074+
1075+ path root = v;
1076+ auto bin = root;
1077+ bin /= " bin" ;
1078+ auto arch = " intel64" ;
1079+ bin /= arch;
1080+
1081+ std::shared_ptr<SimpleProgram> p;
1082+ p = add_prog_from_path (bin / " icl" , " com.intel.compiler.c" );
1083+ p->getCommand ()->push_back (" -I" );
1084+ p->getCommand ()->push_back (root / " compiler" / " include" );
1085+
1086+ p = add_prog_from_path (bin / " icl" , " com.intel.compiler.cpp" );
1087+ p->getCommand ()->push_back (" -I" );
1088+ p->getCommand ()->push_back (root / " compiler" / " include" );
1089+
1090+ add_prog_from_path (bin / " xilib" , " com.intel.compiler.lib" );
1091+
1092+ p = add_prog_from_path (bin / " xilink" , " com.intel.compiler.link" );
1093+ p->getCommand ()->push_back (" -LIBPATH:" + (root / " compiler" / " lib" / arch).u8string ());
1094+ p->getCommand ()->push_back (" libirc.lib" );
1095+ }
1096+
1097+ // also registry paths
1098+ // HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Intel ...
1099+ }
1100+
1101+ // *nix
1102+ {
1103+ {
1104+ auto p = std::make_shared<SimpleProgram>(s); // new object
1105+ p->file = resolveExecutable (" icc" );
1106+ if (fs::exists (p->file ))
1107+ {
1108+ auto v = getVersion (s, p->file );
1109+ addProgram (s, PackageId (" com.intel.compiler.c" , v), p);
1110+ }
1111+ }
1112+
1113+ {
1114+ auto p = std::make_shared<SimpleProgram>(s); // new object
1115+ p->file = resolveExecutable (" icpc" );
1116+ if (fs::exists (p->file ))
1117+ {
1118+ auto v = getVersion (s, p->file );
1119+ addProgram (s, PackageId (" com.intel.compiler.cpp" , v), p);
1120+ }
1121+ }
1122+ }
1123+ }
1124+
1125+ static void detectWindowsCompilers (DETECT_ARGS)
10281126{
10291127 detectMsvc (s);
10301128 detectWindowsClang (s);
10311129}
10321130
1033- void detectNonWindowsCompilers (DETECT_ARGS)
1131+ static void detectNonWindowsCompilers (DETECT_ARGS)
10341132{
10351133 auto resolve_and_add = [&s](const path &prog, const String &ppath)
10361134 {
@@ -1081,6 +1179,7 @@ void detectNativeCompilers(DETECT_ARGS)
10811179 }
10821180 else
10831181 detectNonWindowsCompilers (s);
1182+ detectIntelCompilers (s);
10841183}
10851184
10861185}
0 commit comments