Skip to content

Commit b6cd128

Browse files
第一轮Compile、LD属性同步上VC。
1 parent 8cffd53 commit b6cd128

File tree

4 files changed

+215
-152
lines changed

4 files changed

+215
-152
lines changed

YY.Build.Cross.Tasks/Cross/Compile.cs

Lines changed: 117 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public Compile()
4949
switchOrderList.Add("SymbolsHiddenByDefault");
5050
switchOrderList.Add("ExceptionHandling");
5151
switchOrderList.Add("RuntimeTypeInfo");
52-
switchOrderList.Add("CLanguageStandard");
53-
switchOrderList.Add("CppLanguageStandard");
52+
switchOrderList.Add("LanguageStandard_C");
53+
switchOrderList.Add("LanguageStandard");
5454
switchOrderList.Add("ForcedIncludeFiles");
5555
switchOrderList.Add("EnableASAN");
5656
switchOrderList.Add("AdditionalOptions");
@@ -227,10 +227,16 @@ public string WarningLevel
227227
toolSwitch.DisplayName = "Warning Level";
228228
toolSwitch.Description = "Select how strict you want the compiler to be about code errors. Other flags should be added directly to Additional Options. (/w, /Weverything).";
229229
toolSwitch.ArgumentRelationList = new ArrayList();
230-
string[][] switchMap = new string[2][]
230+
string[][] switchMap = new string[][]
231231
{
232232
new string[2] { "TurnOffAllWarnings", "-w" },
233-
new string[2] { "EnableAllWarnings", "-Wall" }
233+
new string[2] { "Level1", "-Wall" },
234+
new string[2] { "Level2", "-Wall" },
235+
new string[2] { "Level3", "-Wall" },
236+
new string[2] { "Level4", "-Wall - Wextra" },
237+
238+
// 微软Linux工作集附带,顺道兼容一下。
239+
new string[2] { "EnableAllWarnings", "-Wall" },
234240
};
235241
toolSwitch.SwitchValue = ReadSwitchMap("WarningLevel", switchMap, value);
236242
toolSwitch.Name = "WarningLevel";
@@ -719,8 +725,15 @@ public string ExceptionHandling
719725
toolSwitch.DisplayName = "Enable C++ Exceptions";
720726
toolSwitch.Description = "Specifies the model of exception handling to be used by the compiler.";
721727
toolSwitch.ArgumentRelationList = new ArrayList();
722-
string[][] switchMap = new string[2][]
728+
string[][] switchMap = new string[][]
723729
{
730+
// 特意兼容微软
731+
new string[2] { "false", "-fno-exceptions" },
732+
new string[2] { "Async", "-fexceptions" },
733+
new string[2] { "Sync", "-fexceptions" },
734+
new string[2] { "SyncCThrow", "-fexceptions" },
735+
736+
// 微软Linux工具集附带,顺道也兼容一下。
724737
new string[2] { "Disabled", "-fno-exceptions" },
725738
new string[2] { "Enabled", "-fexceptions" }
726739
};
@@ -759,119 +772,134 @@ public bool RuntimeTypeInfo
759772
}
760773
}
761774

762-
public string CLanguageStandard
775+
public string LanguageStandard_C
763776
{
764777
get
765778
{
766-
if (IsPropertySet("CLanguageStandard"))
779+
if (IsPropertySet("LanguageStandard_C"))
767780
{
768-
return base.ActiveToolSwitches["CLanguageStandard"].Value;
781+
return base.ActiveToolSwitches["LanguageStandard_C"].Value;
769782
}
770783
return null;
771784
}
772785
set
773786
{
774-
base.ActiveToolSwitches.Remove("CLanguageStandard");
787+
base.ActiveToolSwitches.Remove("LanguageStandard_C");
775788
ToolSwitch toolSwitch = new ToolSwitch(ToolSwitchType.String);
776789
toolSwitch.DisplayName = "C Language Standard";
777790
toolSwitch.Description = "Determines the C language standard.";
778791
toolSwitch.ArgumentRelationList = new ArrayList();
779-
string[][] switchMap = new string[8][]
792+
string[][] switchMap = new string[][]
780793
{
781794
new string[2] { "Default", "" },
795+
new string[2] { "stdc11", "-std=c11" },
796+
new string[2] { "stdc17", "-std=c17" },
797+
798+
// Linux工具集兼容
782799
new string[2] { "c89", "-std=c89" },
800+
new string[2] { "gnu90", "-std=gnu90" }, // 附加
783801
new string[2] { "iso9899:199409", "-std=iso9899:199409" },
784802
new string[2] { "c99", "-std=c99" },
785803
new string[2] { "c11", "-std=c11" },
804+
new string[2] { "c2x", "-std=c2x" }, // 附加
786805
new string[2] { "gnu89", "-std=gnu89" },
787806
new string[2] { "gnu99", "-std=gnu99" },
788-
new string[2] { "gnu11", "-std=gnu11" }
807+
new string[2] { "gnu11", "-std=gnu11" },
808+
new string[2] { "gnu17", "-std=gnu17" }, // 附加
789809
};
790-
toolSwitch.SwitchValue = ReadSwitchMap("CLanguageStandard", switchMap, value);
791-
toolSwitch.Name = "CLanguageStandard";
810+
toolSwitch.SwitchValue = ReadSwitchMap("LanguageStandard_C", switchMap, value);
811+
toolSwitch.Name = "LanguageStandard_C";
792812
toolSwitch.Value = value;
793813
toolSwitch.MultipleValues = true;
794-
base.ActiveToolSwitches.Add("CLanguageStandard", toolSwitch);
814+
base.ActiveToolSwitches.Add("LanguageStandard_C", toolSwitch);
795815
AddActiveSwitchToolValue(toolSwitch);
796816
}
797817
}
798818

799-
public string CppLanguageStandard
800-
{
801-
get
802-
{
803-
if (IsPropertySet("CppLanguageStandard"))
804-
{
805-
return base.ActiveToolSwitches["CppLanguageStandard"].Value;
806-
}
807-
return null;
808-
}
809-
set
810-
{
811-
base.ActiveToolSwitches.Remove("CppLanguageStandard");
812-
ToolSwitch toolSwitch = new ToolSwitch(ToolSwitchType.String);
813-
toolSwitch.DisplayName = "C++ Language Standard";
814-
toolSwitch.Description = "Determines the C++ language standard.";
815-
toolSwitch.ArgumentRelationList = new ArrayList();
816-
string[][] switchMap = new string[17][]
817-
{
818-
new string[2] { "Default", "" },
819-
new string[2] { "c++98", "-std=c++98" },
820-
new string[2] { "c++03", "-std=c++03" },
821-
new string[2] { "c++11", "-std=c++11" },
822-
new string[2] { "c++1y", "-std=c++14" },
823-
new string[2] { "c++14", "-std=c++14" },
824-
new string[2] { "c++17", "-std=c++17" },
825-
new string[2] { "c++2a", "-std=c++2a" },
826-
new string[2] { "c++20", "-std=c++20" },
827-
new string[2] { "gnu++98", "-std=gnu++98" },
828-
new string[2] { "gnu++03", "-std=gnu++03" },
829-
new string[2] { "gnu++11", "-std=gnu++11" },
830-
new string[2] { "gnu++1y", "-std=gnu++1y" },
831-
new string[2] { "gnu++14", "-std=gnu++14" },
832-
new string[2] { "gnu++1z", "-std=gnu++1z" },
833-
new string[2] { "gnu++17", "-std=gnu++17" },
834-
new string[2] { "gnu++20", "-std=gnu++20" }
835-
};
836-
toolSwitch.SwitchValue = ReadSwitchMap("CppLanguageStandard", switchMap, value);
837-
toolSwitch.Name = "CppLanguageStandard";
838-
toolSwitch.Value = value;
839-
toolSwitch.MultipleValues = true;
840-
base.ActiveToolSwitches.Add("CppLanguageStandard", toolSwitch);
841-
AddActiveSwitchToolValue(toolSwitch);
842-
}
843-
}
844-
845-
public string CompileAs
819+
public string LanguageStandard
846820
{
847-
get
848-
{
849-
if (IsPropertySet("CompileAs"))
850-
{
851-
return base.ActiveToolSwitches["CompileAs"].Value;
852-
}
853-
return null;
854-
}
855-
set
856-
{
857-
base.ActiveToolSwitches.Remove("CompileAs");
858-
ToolSwitch toolSwitch = new ToolSwitch(ToolSwitchType.String);
859-
toolSwitch.DisplayName = "Compile As";
860-
toolSwitch.Description = "Select compile language option for .c and .cpp files. 'Default' will detect based on .c or .cpp extention. (-x c, -x c++)";
861-
toolSwitch.ArgumentRelationList = new ArrayList();
862-
string[][] switchMap = new string[3][]
863-
{
864-
new string[2] { "Default", "" },
865-
new string[2] { "CompileAsC", "-x c" },
866-
new string[2] { "CompileAsCpp", "-x c++" }
867-
};
868-
toolSwitch.SwitchValue = ReadSwitchMap("CompileAs", switchMap, value);
869-
toolSwitch.Name = "CompileAs";
870-
toolSwitch.Value = value;
871-
toolSwitch.MultipleValues = true;
872-
base.ActiveToolSwitches.Add("CompileAs", toolSwitch);
873-
AddActiveSwitchToolValue(toolSwitch);
874-
}
821+
get
822+
{
823+
if (IsPropertySet("LanguageStandard"))
824+
{
825+
return base.ActiveToolSwitches["LanguageStandard"].Value;
826+
}
827+
return null;
828+
}
829+
set
830+
{
831+
base.ActiveToolSwitches.Remove("LanguageStandard");
832+
ToolSwitch toolSwitch = new ToolSwitch(ToolSwitchType.String);
833+
toolSwitch.DisplayName = "C++ Language Standard";
834+
toolSwitch.Description = "Determines the C++ language standard.";
835+
toolSwitch.ArgumentRelationList = new ArrayList();
836+
string[][] switchMap = new string[][]
837+
{
838+
new string[2] { "Default", "" },
839+
new string[2] { "stdcpp14", "-std=c++14" },
840+
new string[2] { "stdcpp17", "-std=c++17" },
841+
new string[2] { "stdcpp20", "-std=c++20" },
842+
new string[2] { "stdcpplatest", "-std=c++2b" },
843+
844+
// Linux工具集兼容
845+
new string[2] { "c++98", "-std=c++98" },
846+
new string[2] { "c++03", "-std=c++03" },
847+
new string[2] { "c++11", "-std=c++11" },
848+
new string[2] { "c++1y", "-std=c++14" },
849+
new string[2] { "c++14", "-std=c++14" },
850+
new string[2] { "c++17", "-std=c++17" },
851+
new string[2] { "c++2a", "-std=c++2a" },
852+
new string[2] { "c++20", "-std=c++20" },
853+
new string[2] { "c++2b", "-std=c++2b" }, // 附加
854+
new string[2] { "gnu++98", "-std=gnu++98" },
855+
new string[2] { "gnu++03", "-std=gnu++03" },
856+
new string[2] { "gnu++11", "-std=gnu++11" },
857+
new string[2] { "gnu++1y", "-std=gnu++1y" },
858+
new string[2] { "gnu++14", "-std=gnu++14" },
859+
new string[2] { "gnu++1z", "-std=gnu++1z" },
860+
new string[2] { "gnu++17", "-std=gnu++17" },
861+
new string[2] { "gnu++20", "-std=gnu++20" },
862+
new string[2] { "gnu++2b", "-std=gnu++2b" }, // 附加
863+
};
864+
toolSwitch.SwitchValue = ReadSwitchMap("LanguageStandard", switchMap, value);
865+
toolSwitch.Name = "LanguageStandard";
866+
toolSwitch.Value = value;
867+
toolSwitch.MultipleValues = true;
868+
base.ActiveToolSwitches.Add("LanguageStandard", toolSwitch);
869+
AddActiveSwitchToolValue(toolSwitch);
870+
}
871+
}
872+
873+
public virtual string CompileAs
874+
{
875+
get
876+
{
877+
if (IsPropertySet("CompileAs"))
878+
{
879+
return base.ActiveToolSwitches["CompileAs"].Value;
880+
}
881+
return null;
882+
}
883+
set
884+
{
885+
base.ActiveToolSwitches.Remove("CompileAs");
886+
ToolSwitch toolSwitch = new ToolSwitch(ToolSwitchType.String);
887+
toolSwitch.DisplayName = "Compile As";
888+
toolSwitch.Description = "Select compile language option for .c and .cpp files. 'Default' will detect based on .c or .cpp extention. (-x c, -x c++)";
889+
toolSwitch.ArgumentRelationList = new ArrayList();
890+
string[][] switchMap = new string[3][]
891+
{
892+
new string[2] { "Default", "" },
893+
new string[2] { "CompileAsC", "-x c" },
894+
new string[2] { "CompileAsCpp", "-x c++" }
895+
};
896+
toolSwitch.SwitchValue = ReadSwitchMap("CompileAs", switchMap, value);
897+
toolSwitch.Name = "CompileAs";
898+
toolSwitch.Value = value;
899+
toolSwitch.MultipleValues = true;
900+
base.ActiveToolSwitches.Add("CompileAs", toolSwitch);
901+
AddActiveSwitchToolValue(toolSwitch);
902+
}
875903
}
876904

877905
public string[] ForcedIncludeFiles

0 commit comments

Comments
 (0)