12
12
from __future__ import print_function
13
13
14
14
import os
15
+ import sys
15
16
import xml .dom .minidom as DOM
16
17
from utilities import open_for_update , parseInclusionList
17
18
@@ -468,6 +469,7 @@ def parseTemplateNodes(templateNodes):
468
469
469
470
def generateClrallEvents (eventNodes , allTemplates , target_cpp , runtimeFlavor , write_xplatheader , providerName , inclusionList , generatedFileType ):
470
471
clrallEvents = []
472
+ is_linux = sys .platform .startswith ('linux' )
471
473
for eventNode in eventNodes :
472
474
eventName = eventNode .getAttribute ('symbol' )
473
475
@@ -495,7 +497,7 @@ def generateClrallEvents(eventNodes, allTemplates, target_cpp, runtimeFlavor, wr
495
497
496
498
if runtimeFlavor .coreclr or write_xplatheader or runtimeFlavor .nativeaot :
497
499
if os .name == 'posix' :
498
- if runtimeFlavor .coreclr :
500
+ if is_linux and runtimeFlavor .coreclr :
499
501
clrallEvents .append (" || UserEventsEventEnabled" + eventName + "()" )
500
502
# native AOT does not support non-windows eventing other than via event pipe
501
503
if not runtimeFlavor .nativeaot :
@@ -591,7 +593,7 @@ def generateClrallEvents(eventNodes, allTemplates, target_cpp, runtimeFlavor, wr
591
593
592
594
fnbody .append ("ActivityId,RelatedActivityId);\n " )
593
595
594
- if runtimeFlavor . coreclr and os . name == 'posix' :
596
+ if is_linux and runtimeFlavor . coreclr :
595
597
fnbody .append ("status &= UserEventsWriteEvent" + eventName + "(" + '' .join (line ))
596
598
if len (line ) > 0 :
597
599
fnbody .append ("," )
@@ -872,6 +874,7 @@ def getKeywordsMaskCombined(keywords, keywordsToMask):
872
874
873
875
def updateclreventsfile (write_xplatheader , target_cpp , runtimeFlavor , eventpipe_trace_context_typedef , dotnet_trace_context_typedef_windows , tree , clrallevents , inclusion_list , generatedFileType ):
874
876
is_windows = os .name == 'nt'
877
+ is_linux = sys .platform .startswith ('linux' )
875
878
with open_for_update (clrallevents ) as Clrallevents :
876
879
Clrallevents .write (stdprolog )
877
880
if generatedFileType == "header-impl" :
@@ -880,10 +883,8 @@ def updateclreventsfile(write_xplatheader, target_cpp, runtimeFlavor, eventpipe_
880
883
if runtimeFlavor .coreclr or write_xplatheader :
881
884
Clrallevents .write ('#include "clrxplatevents.h"\n ' )
882
885
Clrallevents .write ('#include "clreventpipewriteevents.h"\n ' )
883
- if runtimeFlavor .coreclr :
884
- Clrallevents .write ('#ifdef TARGET_LINUX\n ' )
886
+ if is_linux and runtimeFlavor .coreclr :
885
887
Clrallevents .write ('#include "clrusereventswriteevents.h"\n ' )
886
- Clrallevents .write ('#endif // TARGET_LINUX\n ' )
887
888
elif generatedFileType == "header" :
888
889
Clrallevents .write ('#ifndef CLR_ETW_ALL_MAIN_H\n ' )
889
890
Clrallevents .write ('#define CLR_ETW_ALL_MAIN_H\n \n ' )
@@ -892,10 +893,8 @@ def updateclreventsfile(write_xplatheader, target_cpp, runtimeFlavor, eventpipe_
892
893
Clrallevents .write ('#include <PalRedhawk.h>\n ' )
893
894
Clrallevents .write ('#include "clretwallmain.h"\n ' )
894
895
Clrallevents .write ('#include "clreventpipewriteevents.h"\n ' )
895
- if runtimeFlavor .coreclr :
896
- Clrallevents .write ('#ifdef TARGET_LINUX\n ' )
896
+ if is_linux and runtimeFlavor .coreclr :
897
897
Clrallevents .write ('#include "clrusereventswriteevents.h"\n ' )
898
- Clrallevents .write ('#endif // TARGET_LINUX\n ' )
899
898
Clrallevents .write ('#ifdef FEATURE_ETW\n ' )
900
899
Clrallevents .write ('#include "ClrEtwAll.h"\n ' )
901
900
Clrallevents .write ('#endif\n ' )
@@ -1003,6 +1002,7 @@ def generatePlatformIndependentFiles(sClrEtwAllMan, incDir, etmDummyFile, extern
1003
1002
"""
1004
1003
1005
1004
is_windows = os .name == 'nt'
1005
+ is_linux = sys .platform .startswith ('linux' )
1006
1006
1007
1007
# Write the main source(s) for FireETW* functions
1008
1008
# nativeaot requires header and source file to be separated as well as a noop implementation
@@ -1084,7 +1084,7 @@ def generatePlatformIndependentFiles(sClrEtwAllMan, incDir, etmDummyFile, extern
1084
1084
#eventpipe: create clreventpipewriteevents.h
1085
1085
Clreventpipewriteevents .write (generateClrEventPipeWriteEvents (eventNodes , allTemplates , extern , target_cpp , runtimeFlavor , providerName , inclusion_list ) + "\n " )
1086
1086
1087
- if runtimeFlavor . coreclr and os . name == 'posix' :
1087
+ if is_linux and runtimeFlavor . coreclr :
1088
1088
clrusereventswriteeventsPath = os .path .join (incDir , "clrusereventswriteevents.h" )
1089
1089
with open_for_update (clrusereventswriteeventsPath ) as clrusereventswriteevents :
1090
1090
clrusereventswriteevents .write (stdprolog + "\n " )
0 commit comments