summaryrefslogtreecommitdiff
path: root/src/CMakeLists.txt
blob: 4c999b184dd2804223c7803285663db6a97cf6fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
include_directories("inc")
include_directories("strongname/inc")
include_directories("inc/winrt")
include_directories("debug/inc")
include_directories("debug/inc/${ARCH_SOURCES_DIR}")
include_directories("debug/inc/dump")
include_directories("md/inc")
include_directories("classlibnative/bcltype")
include_directories("classlibnative/cryptography")
include_directories("classlibnative/inc")
include_directories("${GENERATED_INCLUDE_DIR}")

# The Following Logic is used to wire up Build dependencies for Generated files in Event Logging 
# ClrEtwAll.man                  - Event Schema
# ClrEtwAllMeta.lst              - MetaData list [provided to ensure Windows Desktop is not broken]
# genXplatEventing.py            - has the core logic for parsing Event Schema
# genWinEtw.py                   - Uses genXplatEventing to generate Windows Specific ETW Files
# clretwallmain.h and etmdummy.h - Provides the Event Logging Functionality to the VM
# clrxplatevents.h               - Used by clretwallmain.h on Non Windows platform
# ClrEtwAll.h                    - Used by clretwallmain.h on  Windows 
# ClrEtwAll.rc                   - Used by src/dlls/clretwrc/clretrw.rc on Windows

set (ScriptGeneratedEventFiles
      ${GENERATED_INCLUDE_DIR}/clretwallmain.h
      ${GENERATED_INCLUDE_DIR}/etmdummy.h
)
set (GeneratedEventFiles)

if(WIN32)
    set (GenEventFilesScript "${CLR_DIR}/src/scripts/genWinEtw.py")
    set (GenEventArgs --eventheader "${GENERATED_INCLUDE_DIR}/ClrEtwAll.h" --macroheader "${GENERATED_INCLUDE_DIR}/clretwallmain.h")

    list (APPEND ScriptGeneratedEventFiles
          ${GENERATED_INCLUDE_DIR}/ClrEtwAll.h
    )

    list (APPEND GeneratedEventFiles
         ${GENERATED_INCLUDE_DIR}/ClrEtwAll.rc
    )

    add_custom_command(
      COMMENT "Generating ETW resource Files"
      COMMAND ${MC} -h ${GENERATED_INCLUDE_DIR} -r ${GENERATED_INCLUDE_DIR} -b -co -um -p FireEtw "${VM_DIR}/ClrEtwAll.man"
      OUTPUT ${GENERATED_INCLUDE_DIR}/ClrEtwAll.h
      DEPENDS "${VM_DIR}/ClrEtwAll.man"
    )
else()
    set (GenEventFilesScript "${CLR_DIR}/src/scripts/genXplatEventing.py")
    set (GenEventArgs   --inc  "${GENERATED_INCLUDE_DIR}")

    list (APPEND ScriptGeneratedEventFiles
          ${GENERATED_INCLUDE_DIR}/clrxplatevents.h
    )
endif(WIN32)

if(CLR_CMAKE_WARNINGS_ARE_ERRORS)
    set(PYTHON_WARNING_FLAGS -Wall -Werror)
else()
    set(PYTHON_WARNING_FLAGS -Wall)
endif(CLR_CMAKE_WARNINGS_ARE_ERRORS)

add_custom_command(
  COMMENT "Generating Eventing Files"
  COMMAND ${PYTHON} -B ${PYTHON_WARNING_FLAGS} ${GenEventFilesScript} ${GenEventArgs} --man "${VM_DIR}/ClrEtwAll.man" --exc "${VM_DIR}/ClrEtwAllMeta.lst" --dummy "${GENERATED_INCLUDE_DIR}/etmdummy.h"
  OUTPUT ${ScriptGeneratedEventFiles}
  DEPENDS ${GenEventFilesScript} "${VM_DIR}/ClrEtwAll.man" "${VM_DIR}/ClrEtwAllMeta.lst" "${CLR_DIR}/src/scripts/genXplatEventing.py"
)

list (APPEND GeneratedEventFiles
      ${ScriptGeneratedEventFiles}
)

add_custom_target(
  GeneratedEventingFiles
  DEPENDS ${GeneratedEventFiles}
)

if(CLR_CMAKE_PLATFORM_UNIX)
  if(CLR_CMAKE_PLATFORM_LINUX)
    if(CLR_CMAKE_PLATFORM_UNIX_AMD64 OR CLR_CMAKE_PLATFORM_UNIX_ARM)
      add_subdirectory(debug/createdump)
    endif()
  endif(CLR_CMAKE_PLATFORM_LINUX)

  add_subdirectory(ToolBox/SOS/Strike)

  # Include the dummy c++ include files
  include_directories("pal/inc/rt/cpp")

  # This prevents inclusion of standard C compiler headers
  add_compile_options(-nostdinc)

  set (NATIVE_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/nativeresources)
  include_directories(${NATIVE_RESOURCE_DIR})
  set (RC_TO_CPP ${NATIVE_RESOURCE_DIR}/rctocpp.awk)
  set (PROCESS_RC ${NATIVE_RESOURCE_DIR}/processrc.awk)
  set (RESOURCE_STRING_HEADER_DIR ${NATIVE_RESOURCE_DIR})

  # Create a command to create a C++ source file containing an array of
  # NativeStringResource structs which represent the information from a
  # given Windows .rc file. The target C++ file path is returned in the
  # variable specified by the TARGET_FILE parameter.
  function(build_resources SOURCE TARGET_NAME TARGET_FILE)

    get_compile_definitions(PREPROCESS_DEFINITIONS)
    get_include_directories(INCLUDE_DIRECTORIES)

    set(PREPROCESSED_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.rc.i)
    set(RESOURCE_ENTRY_ARRAY_CPP ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.cpp)

    add_custom_command(
      OUTPUT ${RESOURCE_ENTRY_ARRAY_CPP}
      # Preprocess the windows .rc file
      COMMAND ${CMAKE_CXX_COMPILER} -E -P ${PREPROCESS_DEFINITIONS} ${INCLUDE_DIRECTORIES} -o ${PREPROCESSED_SOURCE} -x c ${SOURCE}
      # Convert the preprocessed .rc file to a C++ file which will be used to make a static lib.
      COMMAND ${AWK} -v name=${TARGET_NAME} -f ${RC_TO_CPP} -f ${PROCESS_RC} ${PREPROCESSED_SOURCE} >${RESOURCE_ENTRY_ARRAY_CPP}
            DEPENDS ${SOURCE} ${RC_TO_CPP} ${PROCESS_RC}
    )

    include_directories(${RESOURCE_STRING_HEADER_DIR})
    set(${TARGET_FILE} ${RESOURCE_ENTRY_ARRAY_CPP} PARENT_SCOPE)

  endfunction()

  add_subdirectory(nativeresources)
endif(CLR_CMAKE_PLATFORM_UNIX)

add_subdirectory(utilcode)
add_subdirectory(gcinfo)
add_subdirectory(coreclr)
add_subdirectory(jit)
add_subdirectory(vm)
add_subdirectory(md)
add_subdirectory(debug)
add_subdirectory(inc)
add_subdirectory(strongname)
add_subdirectory(binder)
add_subdirectory(classlibnative)
add_subdirectory(dlls)
add_subdirectory(ToolBox)
add_subdirectory(tools)
add_subdirectory(unwinder)
add_subdirectory(ildasm)
add_subdirectory(ilasm)

if(WIN32)
  add_subdirectory(ipcman)
endif(WIN32)

if(CLR_CMAKE_PLATFORM_UNIX)
    add_subdirectory(palrt)
endif(CLR_CMAKE_PLATFORM_UNIX)