changeset 58:f1b965f53d3b

add tools userlists
author tobaru
date Fri, 05 Jul 2019 16:39:01 +0900
parents 450ee0f18709
children 8f435de13b91
files src/CMakeLists.txt src/tools/CMakeLists.txt src/usr/CMakeLists.txt
diffstat 3 files changed, 78 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/src/CMakeLists.txt	Thu Jun 06 19:50:24 2019 +0900
+++ b/src/CMakeLists.txt	Fri Jul 05 16:39:01 2019 +0900
@@ -1,51 +1,23 @@
 cmake_minimum_required(VERSION 3.8)
 project(xv6cbc C ASM)
 
-# https://github.com/llvm-mirror/libcxx/blob/master/cmake/Modules/HandleCompilerRT.cmake
-function(find_compiler_rt_library dest)
-  set(dest "" PARENT_SCOPE)
-  set(CLANG_COMMAND ${CMAKE_C_COMPILER} 
-      "--print-libgcc-file-name")
-  if (CMAKE_C_COMPILER_ID MATCHES Clang AND CMAKE_C_COMPILER_TARGET)
-    list(APPEND CLANG_COMMAND "--target=${CMAKE_C_COMPILER_TARGET}")
-  endif()
-  string(REPLACE " " ";" LIBC_C_FLAGS "${LIBC_C_FLAGS}")
-  list(APPEND CLANG_COMMAND ${LIBC_C_FLAGS})
-  execute_process(
-      COMMAND ${CLANG_COMMAND}
-      RESULT_VARIABLE HAD_ERROR
-      OUTPUT_VARIABLE LIBRARY_FILE
-  )
-  string(STRIP "${LIBRARY_FILE}" LIBRARY_FILE)
-  set(${dest} "${LIBRARY_FILE}" PARENT_SCOPE)
-endfunction()
-
-
 
 set(USE_CUDA,0)
 # -DUSE_CUDA
 #  add_definitions("-Wall -g -O")
 
-if (APPLE)
-    set(CMAKE_C_COMPILER $ENV{CBC_LANG_COMPILER})
-    add_definitions("-Wall -g -arch arm -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -Werror -I. -g -O0 
-             -Wno-macro-redefined -Wno-gnu-designator -Wno-sometimes-uninitialized -Wno-tautological-compare 
-             -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include
-             -Wno-nullability-completeness -Wno-expansion-to-defined")
-    set(CMAKE_EXE_LINKER_FLAGS "-L. -arch armv7 -T  kernel-cmake.ld -o  kernel.elf ")
-else (APPLE)
-    set(CMAKE_C_COMPILER /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-gcc)
-    set(CMAKE_ASM_COMPILER /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-gcc)
-    add_definitions("-B/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-  
-             -DCBCXV6=1 -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -g -O0")
-    find_compiler_rt_library("LIBRARY_FILE")
-#cmake -DCMAKE_LINKER=/path/to/linker -DCMAKE_CXX_LINK_EXECUTABLE="<CMAKE_LINKER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>"
-    set(CMAKE_C_LINK_EXECUTABLE "/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-ld -L. -T kernel-cmake.ld -o kernel.elf -b binary  -nostdlib <OBJECTS>   ${LIBRARY_FILE}")
-    
-endif (APPLE)
-
 # -DCMAKE_BUILD_TYPE=Debug
 set(CMAKE_C_FLAGS_DEBUG "-O0")
+add_definitions(${PMAKE_ARGS})
+set(CMAKE_C_COMPILER "${CBC_COM}")
+
+#add_custom_command(OUTPUT  tools
+#                   COMMAND "cd ${CMAKE_CURRENT_SOURCE_DIR}/tools && make run"
+#)
+#                   #WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tools
+add_subdirectory(tools)
+add_subdirectory(usr)
+
 
 if (${USE_CUDA})
     include_directories("/usr/local/cuda/include")
@@ -111,4 +83,3 @@
      lib/string.c    entry.S 
 )
 
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/tools/CMakeLists.txt	Fri Jul 05 16:39:01 2019 +0900
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.8)
+project(tools C)
+
+set(CMAKE_C_FLAGS "-Wall  -iquote ../")
+add_executable(TARGET mkfs SOURCE mkfs.c)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/usr/CMakeLists.txt	Fri Jul 05 16:39:01 2019 +0900
@@ -0,0 +1,63 @@
+cmake_minimum_required(VERSION 3.8)
+project(usr C ASM)
+
+
+set(CMAKE_C_FLAGS_DEBUG "-O0")
+add_definitions(${PMAKE_ARGS})
+set(CMAKE_C_COMPILER "${CBC_COM}")
+
+include_directories("..")
+
+macro( GearsCommand )
+    set( _OPTIONS_ARGS )
+    set( _ONE_VALUE_ARGS TARGET )
+    set( _MULTI_VALUE_ARGS SOURCES )
+    cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
+
+    set (_Gears_CBC_SOURCES)
+    set (_Gears_CSOURCES)
+    foreach(i ${_Gears_SOURCES})
+        if (${i} MATCHES "\\.cbc")
+            string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i})
+            add_custom_command (
+                OUTPUT    ${j}
+                DEPENDS   ${i}
+                COMMAND  "perl" "gearsTools/generate_stub.pl" "-o" ${j} ${i}
+            )
+            list(APPEND _Gears_CBC_SOURCES ${j})
+        elseif (${i} MATCHES "\\.cu")
+            string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i})
+            add_custom_command (
+                OUTPUT    ${j}
+                DEPENDS   ${i}
+                COMMAND  nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i}
+            )
+            list(APPEND _Gears_CBC_SOURCES ${j})
+        else()
+            set(j ${i})
+            list(APPEND _Gears_CSOURCES ${j})
+        endif()
+    endforeach(i)
+
+    add_custom_command (
+          OUTPUT    c/${_Gears_TARGET}-context.c
+          DEPENDS   ${_Gears_CBC_SOURCES}
+          COMMAND  "perl" "gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} ${_Gears_CBC_SOURCES}
+    )
+    add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} c/${_Gears_TARGET}-context.c )
+    target_link_libraries(${_Gears_TARGET} ulib)
+endmacro()
+
+add_library(ulib STATIC  ulib.c usys.c printf.c umalloc.c)
+
+set(USR_COMMANDS _cat _echo _grep _init _kill _ln _ls _mkdir _rm _sh _stressfs _usertests _wc _zombie _hello)
+
+foreach(cmd ${USR_COMMANDS) 
+    GearsCommand (TARGET ${cmd} SOURCES ${cmd}.c) 
+end foreach(cmd)
+
+add_custom_command(OUTPUT fs.img
+  COMMAND ./mkfs fs.img ${USR_COMMAND} UNIX
+  DEPENDS ${USR_COMMANDS}
+)
+