# HG changeset patch # User Louis Opter # Date 1325967073 -3600 # Node ID b4ca25b8869059b23ad9e0235c50773fb24ce1d1 # Parent 1b7399e39afd10374dd23dca08c63d88a8fa35db Finish patches on the CMake library and on #includes diff -r 1b7399e39afd -r b4ca25b88690 include_in_template_chunks.patch --- a/include_in_template_chunks.patch Sat Jan 07 20:53:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -# HG changeset patch -# Parent 33bf887e240c8c5aa843193ac5ec24663dc7eb8b -Add #include in template chunks - -diff --git a/rathaxes/compiler/rtxParse/rtx.cwp b/rathaxes/compiler/rtxParse/rtx.cwp ---- a/rathaxes/compiler/rtxParse/rtx.cwp -+++ b/rathaxes/compiler/rtxParse/rtx.cwp -@@ -1,11 +1,22 @@ - #include "cnorm.cwp" - -+#ignore["rathaxes"] ::= -+[ -+ ["//" ->[['\r']? '\n']] -+ | ["/*" ->"*/"] -+ | ' ' -+ | '\t' -+ | '\n' -+ | '\r' -+ | '\f' // form feed, sometimes Windows kernel headers have this character. -+]+:skip -+; - /* root of grammar */ - #overload - translation_unit ::= - => traceLine("PARSE!"); - #try -- #ignore -+ #ignore("rathaxes") - #check(cnormNodeRoot(this)) - [ - rtx_declaration(this) -diff --git a/rathaxes/compiler/rtxParse/rtxBack.cwp b/rathaxes/compiler/rtxParse/rtxBack.cwp ---- a/rathaxes/compiler/rtxParse/rtxBack.cwp -+++ b/rathaxes/compiler/rtxParse/rtxBack.cwp -@@ -189,7 +189,32 @@ - /* The two following lines prevent artefacts (by failing previous alternative) */ - =>clearVariable(theBody); - #check(cnormNodeBlock(theBody)) -- compound_statement(theBody) -+ rtx_chunk_compound_statement(theBody) -+; -+ -+rtx_chunk_compound_statement(theBlock : node) ::= -+'{' -+/**/ #check(cnormNodeBlock(theBlock, true)) -+ rtx_chunk_block_item_list(theBlock) -+'}' -+; -+ -+rtx_chunk_block_item_list(theBlock : node) ::= -+[ -+ line_of_code(theBlock) -+ | '#' -+ [// TODO: Add Define with chunks variables detections/substitutions -+ "include" -+ [ -+ ['"' -> '"' | '<' -> '>' ]:sFile -+ ] -+/**/ #pushItem(theBlock.block) -+/**/ => local lastNode; -+/**/ #check(cnormNodeBlock_GetLastNode(theBlock, lastNode)) -+/**/ => local sData = "\n#include " + sFile + " \n"; -+/**/ => cnormNode_Raw(lastNode, sData); -+ ] -+]* - ; - - rtx_stmt<"chunk">(theBlock : node) ::= -diff --git a/rathaxes/compiler/rtxTpl/rtxIntrospect.inc.cws b/rathaxes/compiler/rtxTpl/rtxIntrospect.inc.cws ---- a/rathaxes/compiler/rtxTpl/rtxIntrospect.inc.cws -+++ b/rathaxes/compiler/rtxTpl/rtxIntrospect.inc.cws -@@ -469,6 +469,10 @@ - * Expression type code introspection function - * - */ -+function rtxIntrospect_expr<"__raw__">(local_node : node, theChunk : node, blockIds : node) -+{/*nothing to do*/ -+} -+ - function rtxIntrospect_expr<"__terminal__">(local_node : node, theChunk : node, - blockIds : node) - { -diff --git a/rathaxes/samples/helloworld/main.blt b/rathaxes/samples/helloworld/main.blt ---- a/rathaxes/samples/helloworld/main.blt -+++ b/rathaxes/samples/helloworld/main.blt -@@ -44,7 +44,6 @@ - { - chunk Main::include_headers - { -- /* Won't be printed because # is not supported yet */ - #include - typedef int stdlib_include_stamp; - } diff -r 1b7399e39afd -r b4ca25b88690 maintainers_add_add_rathaxes_lkm_in_use_rathaxes_cmake_file.patch --- a/maintainers_add_add_rathaxes_lkm_in_use_rathaxes_cmake_file.patch Sat Jan 07 20:53:40 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -# HG changeset patch -# Parent dd92091de0edd583c8dd1ff884b5ca5fcd080c3d -maintainers: add the equivalent of ADD_RATHAXES_EXECUTABLE for kernel modules, only support Linux for now - -diff --git a/maintainers/CMakeScripts/Templates/MakefileLKM.in b/maintainers/CMakeScripts/Templates/MakefileLKM.in -new file mode 100644 ---- /dev/null -+++ b/maintainers/CMakeScripts/Templates/MakefileLKM.in -@@ -0,0 +1,12 @@ -+KDIR = /lib/modules/$(shell uname -r)/build -+obj-m := @LKM_OBJECTS@ -+ -+all: -+ $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) modules -+ -+install: -+ $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) modules_install -+ depmod -a -+clean: -+ rm -rf *~ -+ $(MAKE) -C $(KDIR) M=$(PWD) clean -diff --git a/maintainers/CMakeScripts/UseRathaxes.cmake b/maintainers/CMakeScripts/UseRathaxes.cmake ---- a/maintainers/CMakeScripts/UseRathaxes.cmake -+++ b/maintainers/CMakeScripts/UseRathaxes.cmake -@@ -114,6 +114,8 @@ - "${RATHAXES_SOURCE_DIR}/rathaxes/compiler/rtx*.cw[sp]" - "${RATHAXES_SOURCE_DIR}/rathaxes/compiler/rathaxes.cws") - -+ # ADD_CUSTOM_COMMAND + ADD_CUSTOM_TARGET is a CMake idiom to add a target -+ # that should be rebuilt automatically when its sources change. - STRING(REPLACE ";" ", " SYSTEMS "${SYSTEMS}") - ADD_CUSTOM_COMMAND(OUTPUT ${OUTPUTS} - COMMAND ${_RTX_CODEWORKER_COMMAND} "cache" "clear" -@@ -160,3 +162,51 @@ - ADD_EXECUTABLE(${NAME} "${RATHAXES_SOURCE}_${SYSTEM}.c") - ADD_DEPENDENCIES(${NAME} ${RATHAXES_SOURCE}) - ENDFUNCTION(ADD_RATHAXES_EXECUTABLE NAME RATHAXES_SOURCE) -+ -+# This function build a native kernel module from a previously generated -+# Rathaxes sources. It works by setting up a build directory and calling the -+# native build tools from there. -+# -+# Usage: ADD_RATHAXES_LKM(NAME RATHAXES_SOURCE [SYSTEM]) -+# -+# RATHAXES_SOURCE must corresponds to the first argument of a call to -+# ADD_RATHAXES_SOURCES. -+# -+# The third argument SYSTEM may be used if the target system doesn't correspond -+# to CMAKE_SYSTEM_NAME. -+FUNCTION(ADD_RATHAXES_LKM NAME RATHAXES_SOURCE) -+ IF (${ARGC} EQUAL 2) -+ SET(SYSTEM ${CMAKE_SYSTEM_NAME}) -+ ELSE (${ARGC} EQUAL 2) -+ SET(SYSTEM ${ARGV2}) -+ ENDIF (${ARGC} EQUAL 2) -+ -+ IF (${SYSTEM} MATCHES "Linux") -+ # Create a little build space for the native Linux build-chain. -+ SET(MODULE_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${NAME}.dir/${SYSTEM}Build/") -+ -+ # Generate the Linux Makefile to build a Linux kernel module -+ SET(MODULE_MAKEFILE "${MODULE_BUILD_DIR}/Makefile") -+ SET(LKM_OBJECTS "${RATHAXES_SOURCE}_${SYSTEM}.o") -+ CONFIGURE_FILE("${RATHAXES_SOURCE_DIR}/maintainers/CMakeScripts/Templates/MakefileLKM.in" -+ "${MODULE_MAKEFILE}") -+ -+ SET(KERNEL_OBJECT_NAME "${RATHAXES_SOURCE}_${SYSTEM}.ko") -+ ADD_CUSTOM_COMMAND(OUTPUT "${KERNEL_OBJECT_NAME}" -+ # The linux Makefile to build kernel module is quite -+ # picky about file location and its own name. Let's -+ # copy our source side by side with the Makefile: -+ COMMAND "${CMAKE_COMMAND}" "-E" "copy" "${RATHAXES_SOURCE}_${SYSTEM}.c" "${MODULE_BUILD_DIR}" -+ # Then call make in the little build space we created -+ COMMAND "${CMAKE_COMMAND}" "-E" "chdir" "${MODULE_BUILD_DIR}" "${CMAKE_BUILD_TOOL}" -+ # Finally copy the generated .ko back into the current binary dir -+ COMMAND "${CMAKE_COMMAND}" "-E" "copy" "${MODULE_BUILD_DIR}/${KERNEL_OBJECT_NAME}" "${CMAKE_CURRENT_BINARY_DIR}" -+ COMMENT "Building Rathaxes Linux LKM for ${NAME}" -+ VERBATIM -+ DEPENDS "${RATHAXES_SOURCE}_${SYSTEM}.c") -+ -+ ADD_CUSTOM_TARGET("${NAME}" ALL DEPENDS "${KERNEL_OBJECT_NAME}") -+ ELSE (${SYSTEM} MATCHES "Linux") -+ MESSAGE(STATUS "Don't know how to build kernel modules for ${SYSTEM} (yet)") -+ ENDIF (${SYSTEM} MATCHES "Linux") -+ENDFUNCTION(ADD_RATHAXES_LKM NAME RATHAXES_SOURCE) diff -r 1b7399e39afd -r b4ca25b88690 series --- a/series Sat Jan 07 20:53:40 2012 +0100 +++ b/series Sat Jan 07 21:11:13 2012 +0100 @@ -1,6 +1,4 @@ -maintainers_add_add_rathaxes_lkm_in_use_rathaxes_cmake_file.patch rathaxes_add_a_linux_lkm.patch rathaxes_start_to_implement_pci_stuff_in_the_lkm.patch rathaxes_start_to_implement_the_ethernet_subsystem_in_the_lkm.patch rathaxes_start_to_implement_sk_buff_in_the_lkm.patch -include_in_template_chunks.patch