Skip to content

Commit b17ad7c

Browse files
Fea, Compile时传入完整路径,方便报错时查看代码路径
1 parent 1faf69d commit b17ad7c

File tree

4 files changed

+40
-6
lines changed

4 files changed

+40
-6
lines changed

Microsoft.Build.CPPTasks/ToolSwitch.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public class ToolSwitch
6060

6161
private ITaskItem[] taskItemArray;
6262

63+
#if __REMOVE
64+
#else
65+
// GCC工具链没有完整路径选择,为了方便出错时查看代码路径,所以添加了完整路径输出能力。
66+
public bool TaskItemFullPath = false;
67+
#endif
6368
private string value = string.Empty;
6469

6570
private string switchValue = string.Empty;

Microsoft.Build.CPPTasks/VCToolTask.cs

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -915,18 +915,37 @@ private static void EmitTaskItemArraySwitch(CommandLineBuilder builder, ToolSwit
915915
ITaskItem[] taskItemArray = toolSwitch.TaskItemArray;
916916
foreach (ITaskItem taskItem in taskItemArray)
917917
{
918+
#if __REMOVE
918919
builder.AppendSwitchIfNotNull(toolSwitch.SwitchValue, Environment.ExpandEnvironmentVariables(taskItem.ItemSpec));
920+
#else
921+
var ExpandItemSpec =Environment.ExpandEnvironmentVariables(toolSwitch.TaskItem.ItemSpec);
922+
if(toolSwitch.TaskItemFullPath)
923+
{
924+
ExpandItemSpec = FileUtilities.NormalizePath(ExpandItemSpec);
925+
}
926+
927+
builder.AppendSwitchIfNotNull(toolSwitch.SwitchValue, ExpandItemSpec);
928+
#endif
919929
}
920930
return;
921931
}
922932
ITaskItem[] array = new ITaskItem[toolSwitch.TaskItemArray.Length];
923933
for (int j = 0; j < toolSwitch.TaskItemArray.Length; j++)
924934
{
935+
#if __REMOVE
925936
array[j] = new TaskItem(Environment.ExpandEnvironmentVariables(toolSwitch.TaskItemArray[j].ItemSpec));
926-
//if (format == CommandLineFormat.ForTracking)
927-
//{
928-
// array[j].ItemSpec = array[j].ItemSpec.ToUpperInvariant();
929-
//}
937+
if (format == CommandLineFormat.ForTracking)
938+
{
939+
array[j].ItemSpec = array[j].ItemSpec.ToUpperInvariant();
940+
}
941+
#else
942+
var ExpandItemSpec = Environment.ExpandEnvironmentVariables(toolSwitch.TaskItemArray[j].ItemSpec);
943+
if (toolSwitch.TaskItemFullPath)
944+
{
945+
ExpandItemSpec = FileUtilities.NormalizePath(ExpandItemSpec);
946+
}
947+
array[j] = new TaskItem(ExpandItemSpec);
948+
#endif
930949
}
931950
builder.AppendSwitchIfNotNull(toolSwitch.SwitchValue, array, toolSwitch.Separator);
932951
}
@@ -935,7 +954,16 @@ private static void EmitTaskItemSwitch(CommandLineBuilder builder, ToolSwitch to
935954
{
936955
if (!string.IsNullOrEmpty(toolSwitch.TaskItem.ItemSpec))
937956
{
957+
#if __REMOVE
938958
builder.AppendFileNameIfNotNull(Environment.ExpandEnvironmentVariables(toolSwitch.TaskItem.ItemSpec + toolSwitch.Separator));
959+
#else
960+
var ExpandItemSpec = Environment.ExpandEnvironmentVariables(toolSwitch.TaskItem.ItemSpec);
961+
if(toolSwitch.TaskItemFullPath)
962+
{
963+
ExpandItemSpec = FileUtilities.NormalizePath(ExpandItemSpec);
964+
}
965+
builder.AppendFileNameIfNotNull(ExpandItemSpec + toolSwitch.Separator);
966+
#endif
939967
}
940968
}
941969

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
> 举个例子:代码完全优化(Full选项),微软编译器时中映射为 `-Ox`,而使用GCC时则映射为`-O3`
1515
16-
未来开发计划
17-
* [ ] 解决增量编译不生效问题
16+
目前开发计划
17+
* [x] [Fea 5](https://github.com/Chuyu-Team/MSBuildCppCrossToolset/issues/5), 添加最小化生成支持
1818
* [ ] 优化并行生成效率。
1919
* [ ] 单元测试。
2020

YY.Build.Linux.Tasks/GCC/Compile.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public ITaskItem[] Sources
122122
toolSwitch.Required = true;
123123
toolSwitch.ArgumentRelationList = new ArrayList();
124124
toolSwitch.TaskItemArray = value;
125+
toolSwitch.TaskItemFullPath = true;
125126
base.ActiveToolSwitches.Add("Sources", toolSwitch);
126127
AddActiveSwitchToolValue(toolSwitch);
127128
}

0 commit comments

Comments
 (0)