From b76de4c1fb632724c412a1638af8694fb35e021d Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 8 Dec 2021 23:15:44 +0800 Subject: add linux driver rule stub --- tests/projects/linux/driver/hello/Makefile | 2 +- tests/projects/linux/driver/hello/hello.c | 21 --------------------- tests/projects/linux/driver/hello/src/hello.c | 21 +++++++++++++++++++++ tests/projects/linux/driver/hello/xmake.lua | 9 +++++++++ xmake/rules/platform/linux/driver/xmake.lua | 27 +++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 22 deletions(-) delete mode 100644 tests/projects/linux/driver/hello/hello.c create mode 100644 tests/projects/linux/driver/hello/src/hello.c create mode 100644 tests/projects/linux/driver/hello/xmake.lua create mode 100644 xmake/rules/platform/linux/driver/xmake.lua diff --git a/tests/projects/linux/driver/hello/Makefile b/tests/projects/linux/driver/hello/Makefile index d69924339..0cac0535c 100644 --- a/tests/projects/linux/driver/hello/Makefile +++ b/tests/projects/linux/driver/hello/Makefile @@ -1,5 +1,5 @@ ifneq ($(KERNELRELEASE),) - obj-m := hello.o + obj-m := src/hello.o else KERN_DIR ?= /usr/src/linux-headers-5.11.0-41-generic/ PWD := $(shell pwd) diff --git a/tests/projects/linux/driver/hello/hello.c b/tests/projects/linux/driver/hello/hello.c deleted file mode 100644 index 2614fb2cc..000000000 --- a/tests/projects/linux/driver/hello/hello.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -MODULE_LICENSE("Dual BSD/GPL"); -MODULE_AUTHOR("Ruki"); -MODULE_DESCRIPTION("A simple Hello World Module"); -MODULE_ALIAS("a simplest module"); - -int hello_init(void) -{ - printk(KERN_INFO "Hello World\n"); - return 0; -} - -void hello_exit(void) -{ - printk(KERN_INFO "Goodbye World\n"); -} - -module_init(hello_init); -module_exit(hello_exit); diff --git a/tests/projects/linux/driver/hello/src/hello.c b/tests/projects/linux/driver/hello/src/hello.c new file mode 100644 index 000000000..2614fb2cc --- /dev/null +++ b/tests/projects/linux/driver/hello/src/hello.c @@ -0,0 +1,21 @@ +#include +#include + +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_AUTHOR("Ruki"); +MODULE_DESCRIPTION("A simple Hello World Module"); +MODULE_ALIAS("a simplest module"); + +int hello_init(void) +{ + printk(KERN_INFO "Hello World\n"); + return 0; +} + +void hello_exit(void) +{ + printk(KERN_INFO "Goodbye World\n"); +} + +module_init(hello_init); +module_exit(hello_exit); diff --git a/tests/projects/linux/driver/hello/xmake.lua b/tests/projects/linux/driver/hello/xmake.lua new file mode 100644 index 000000000..079c31754 --- /dev/null +++ b/tests/projects/linux/driver/hello/xmake.lua @@ -0,0 +1,9 @@ +add_rules("mode.release", "mode.debug") + +add_requires("linux-headers", {configs = {driver_modules = true}}) + +target("hello") + add_rules("platform.linux.driver") + add_files("src/*.c") + add_packages("linux-headers") + set_license("GPL-2.0") diff --git a/xmake/rules/platform/linux/driver/xmake.lua b/xmake/rules/platform/linux/driver/xmake.lua new file mode 100644 index 000000000..dcecf4a1b --- /dev/null +++ b/xmake/rules/platform/linux/driver/xmake.lua @@ -0,0 +1,27 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file xmake.lua +-- + +-- build linux driver module +rule("platform.linux.driver") + on_load(function (target) + target:set("kind", "binary") + -- TODO + end) + -- cgit v1.3.1