samples: demonstrate the use of KBUILD_ZEPHYR_APP
Jira: ZEP-2280 Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
c2a2cfc8c8
commit
4ad2746088
9 changed files with 97 additions and 0 deletions
18
samples/application_development/external_lib/Makefile
Normal file
18
samples/application_development/external_lib/Makefile
Normal file
|
@ -0,0 +1,18 @@
|
|||
#
|
||||
# Copyright (c) 2017 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
BOARD = qemu_x86
|
||||
CONF_FILE = prj.conf
|
||||
|
||||
KBUILD_ZEPHYR_APP = libmylib.a
|
||||
SOURCE_DIR = $(CURDIR)
|
||||
subdir-ccflags-y += -I$(SOURCE_DIR)/mylib/include
|
||||
obj-y += src/
|
||||
|
||||
export obj-y subdir-ccflags-y
|
||||
export KBUILD_ZEPHYR_APP
|
||||
|
||||
include ${ZEPHYR_BASE}/Makefile.inc
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
libmylib.a:
|
||||
@echo $(CFLAGS)
|
||||
@rm -f $(O)/libmylib.a
|
||||
$(Q)@+$(MAKE) -C $(SOURCE_DIR)/mylib CFLAGS="$(KBUILD_CFLAGS) $(ZEPHYRINCLUDE)"
|
||||
@cp $(SOURCE_DIR)/mylib/lib/libmylib.a $(O)/libmylib.a
|
||||
|
14
samples/application_development/external_lib/mylib/Makefile
Normal file
14
samples/application_development/external_lib/mylib/Makefile
Normal file
|
@ -0,0 +1,14 @@
|
|||
#
|
||||
# Copyright (c) 2017 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
all:
|
||||
mkdir -p obj lib
|
||||
$(CC) -c $(CFLAGS) -Iinclude src/mylib.c -o obj/mylib.o
|
||||
$(AR) -rcs lib/libmylib.a obj/mylib.o
|
||||
|
||||
clean:
|
||||
rm -rf obj lib
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _MYLIB_H_
|
||||
#define _MYLIB_H_
|
||||
|
||||
int mylib_hello_world(void);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "mylib.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int mylib_hello_world(void)
|
||||
{
|
||||
printf("mylib says: Hello World!\n");
|
||||
return 0;
|
||||
}
|
1
samples/application_development/external_lib/prj.conf
Normal file
1
samples/application_development/external_lib/prj.conf
Normal file
|
@ -0,0 +1 @@
|
|||
CONFIG_STDOUT_CONSOLE=y
|
|
@ -0,0 +1,7 @@
|
|||
#
|
||||
# Copyright (c) 2017 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
#
|
||||
obj-y += main.o
|
20
samples/application_development/external_lib/src/main.c
Normal file
20
samples/application_development/external_lib/src/main.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* hello world example: calling functions from a static library */
|
||||
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <mylib.h>
|
||||
|
||||
void main(void)
|
||||
{
|
||||
printf("Hello World!\n");
|
||||
mylib_hello_world();
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
[test]
|
||||
tags = appdev
|
||||
build_only = true
|
||||
platform_whitelist = qemu_x86
|
Loading…
Add table
Add a link
Reference in a new issue