Mercurial > hg > Members > tobaru > CbC_xv6
annotate src/CMakeLists.txt @ 86:765449889623
fix translate interface routine
author | anatofuz |
---|---|
date | Tue, 15 Oct 2019 20:03:48 +0900 |
parents | d33e6b5adb57 |
children | add5e775339c |
rev | line source |
---|---|
42 | 1 cmake_minimum_required(VERSION 3.8) |
43 | 2 project(xv6cbc C ASM) |
62 | 3 set(BUILD_DIR ${PROJECT_BINARY_DIR}) |
59 | 4 add_subdirectory(tools) |
61 | 5 add_subdirectory(usr) |
66 | 6 enable_language(C ASM) |
42 | 7 |
55 | 8 |
42 | 9 set(USE_CUDA,0) |
10 # -DUSE_CUDA | |
11 # add_definitions("-Wall -g -O") | |
12 | |
13 # -DCMAKE_BUILD_TYPE=Debug | |
14 set(CMAKE_C_FLAGS_DEBUG "-O0") | |
58 | 15 add_definitions(${PMAKE_ARGS}) |
16 | |
17 #add_custom_command(OUTPUT tools | |
18 # COMMAND "cd ${CMAKE_CURRENT_SOURCE_DIR}/tools && make run" | |
19 #) | |
20 # #WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tools | |
21 | |
42 | 22 |
23 if (${USE_CUDA}) | |
24 include_directories("/usr/local/cuda/include") | |
86 | 25 #include_directories(${CMAKE_SOURCE_DIR}) |
42 | 26 set(NVCCFLAG "-std=c++11" "-g" "-O0" ) |
27 if (UNIX AND NOT APPLE) # LINUX | |
28 set(CUDA_LINK_FLAGS "-L/usr/local/cuda/lib64 -lcuda -lcudart") | |
29 elseif (APPLE) | |
30 set(CUDA_LINK_FLAGS "-framework CUDA -lc++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names /usr/local/cuda/lib/libcudart_static.a -Wl,-rpath,/usr/local/cuda/lib") | |
31 endif() | |
32 find_package(CUDA REQUIRED) | |
33 SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CUDA_LINK_FLAGS}" ) | |
34 endif() | |
35 | |
70 | 36 set(CMAKE_BEFORE_PROJECT_PATH "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}") |
61 | 37 configure_file("${CMAKE_SOURCE_DIR}/kernel-cmake.ld" "${CMAKE_CURRENT_BINARY_DIR}/kernel-cmake.ld" COPYONLY) |
42 | 38 |
39 macro( GearsCommand ) | |
66 | 40 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXV6KERNEL") |
61 | 41 set(CMAKE_C_COMPILER "${CBC_COM}") |
42 set(CMAKE_LINKER "${X_CMAKE_LINKER}") | |
43 set(CMAKE_C_LINK_EXECUTABLE "${X_CMAKE_C_LINK_EXECUTABLE}") | |
42 | 44 set( _OPTIONS_ARGS ) |
45 set( _ONE_VALUE_ARGS TARGET ) | |
46 set( _MULTI_VALUE_ARGS SOURCES ) | |
47 cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) | |
84
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
83
diff
changeset
|
48 set(CMAKE_KERNEL_DIR "${CMAKE_BINARY_DIR}") |
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
83
diff
changeset
|
49 set(CMAKE_KERNEL_DIR_C "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir") |
42 | 50 |
43 | 51 set (_Gears_CBC_SOURCES) |
42 | 52 set (_Gears_CSOURCES) |
53 foreach(i ${_Gears_SOURCES}) | |
54 if (${i} MATCHES "\\.cbc") | |
55 string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i}) | |
56 add_custom_command ( | |
84
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
83
diff
changeset
|
57 OUTPUT ${CMAKE_KERNEL_DIR_C}/${j} |
42 | 58 DEPENDS ${i} |
84
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
83
diff
changeset
|
59 COMMAND "cd" "${CMAKE_KERNEL_DIR_C}" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_stub.pl" "-o" ${j} ${CMAKE_SOURCE_DIR}/${i} |
42 | 60 ) |
84
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
83
diff
changeset
|
61 list(APPEND _Gears_CBC_SOURCES "${CMAKE_KERNEL_DIR_C}/${j}") |
70 | 62 #list(APPEND _Gears_CBC_SOURCES ${j}) |
42 | 63 elseif (${i} MATCHES "\\.cu") |
64 string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i}) | |
65 add_custom_command ( | |
74
10d09cd9fad3
set variable CMAKE_KERNEL_DIR on src/CMakeLists.txt
anatofuz
parents:
73
diff
changeset
|
66 OUTPUT ${CMAKE_KERNEL_DIR}/${j} |
42 | 67 DEPENDS ${i} |
68 COMMAND nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i} | |
69 ) | |
74
10d09cd9fad3
set variable CMAKE_KERNEL_DIR on src/CMakeLists.txt
anatofuz
parents:
73
diff
changeset
|
70 list(APPEND _Gears_CBC_SOURCES ${CMAKE_KERNEL_DIR}/${j}) |
42 | 71 else() |
72 set(j ${i}) | |
73 | 73 #list(APPEND _Gears_CSOURCES "${CMAKE_BINARY_DIR}/${_Gears_TARGET}.dir/${j}") |
43 | 74 list(APPEND _Gears_CSOURCES ${j}) |
42 | 75 endif() |
76 endforeach(i) | |
77 | |
61 | 78 #target_link_libraries(syslib) |
84
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
83
diff
changeset
|
79 file(COPY "${CMAKE_SOURCE_DIR}/interface/" DESTINATION ${CMAKE_KERNEL_DIR_C}) |
86 | 80 file(COPY "${CMAKE_SOURCE_DIR}/origin-context.h" DESTINATION ${CMAKE_KERNEL_DIR_C}) |
81 file(RENAME "${CMAKE_KERNEL_DIR_C}/origin-context.h" "${CMAKE_KERNEL_DIR_C}/context.h") | |
42 | 82 add_custom_command ( |
86 | 83 OUTPUT ${CMAKE_KERNEL_DIR_C}/c/${_Gears_TARGET}-context.c |
66 | 84 DEPENDS ${_Gears_CBC_SOURCES} fs.img initcode |
73 | 85 COMMAND "cd" "CMakeFiles/kernel.dir" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} ${_Gears_CBC_SOURCES} |
42 | 86 ) |
84
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
83
diff
changeset
|
87 # add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${CMAKE_KERNEL_DIR}/c/${_Gears_TARGET}-context.c ) |
86 | 88 include_directories(${CMAKE_KERNEL_DIR_C}) |
89 file(GLOB XV6_HEADERS "${CMAKE_SOURCE_DIR}/*.h") | |
90 file(COPY ${XV6_HEADERS} DESTINATION ${CMAKE_KERNEL_DIR_C}) | |
91 file(COPY "${CMAKE_SOURCE_DIR}/device" DESTINATION "${CMAKE_KERNEL_DIR_C}") | |
92 add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${CMAKE_KERNEL_DIR_C}/c/${_Gears_TARGET}-context.c ) | |
53 | 93 # target_link_libraries(${_Gears_TARGET} m pthread) |
42 | 94 endmacro() |
95 | |
66 | 96 |
97 set(CMAKE_C_FLAGS "${INITOCDE_CFLAGS}") | |
98 set(CMAKE_ASM_LINK_EXECUTABLE "${INITOCDE_LINK_EXECUTABLE}") | |
70 | 99 add_executable(initcode.o ${CMAKE_SOURCE_DIR}/initcode.S) |
100 set_target_properties(initcode.o PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BEFORE_PROJECT_PATH}/kernel.dir") | |
66 | 101 add_custom_command( |
70 | 102 OUTPUT "initcode" |
66 | 103 DEPENDS initcode.o |
70 | 104 COMMAND "arm-none-eabi-objcopy" "-S" "-O" "binary" "--prefix-symbols=\"_binary_build/initcode\"" "${CMAKE_BEFORE_PROJECT_PATH}/kernel.dir/initcode.o" "initcode" |
66 | 105 ) |
70 | 106 #file(COPY "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/initcode.o.dir/initcode" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) |
107 | |
42 | 108 |
53 | 109 GearsCommand ( |
42 | 110 TARGET |
111 kernel | |
112 SOURCES | |
61 | 113 string.c arm.c asm.S bio.c buddy.c console.cbc exec.c file.cbc fs.c log.c main.c memide.c pipe.cbc proc.cbc spinlock.cbc |
52 | 114 start.c swtch.S syscall.cbc sysfile.cbc sysproc.c trap_asm.S trap.c vm.c device/picirq.c device/timer.c device/uart.c |
80 | 115 SingleLinkedStack.cbc |
61 | 116 entry.S |
42 | 117 ) |