!45 bsp 下新增 xr806 openharmony

* 修改requesrment.txt 的内容,目前没有XR806 的Package
* bsp 下增加 XR806 openharmony 下的 pikascript 示例,目前只是一个简单的 hello world 工程
This commit is contained in:
sjy 2022-07-10 15:18:26 +00:00 committed by 李昂
parent e7f6cd3431
commit 9a734b227e
5 changed files with 117 additions and 0 deletions

View File

@ -0,0 +1,69 @@
import os
# 函数功能:提取指定目录下的所有.c 文件
# dir:str : 字符串类型,指定的路径
# gn_fd:os : BUILD.gn 文件的文件描述符
# 返回值none
def extract_c_files_name(dir:str, gn_fd:os)->None:
file_list = os.listdir(dir)
for files in file_list:
if ('.c' == os.path.splitext(files)[1]):
print(files)
gn_fd.write(""" \"""" + dir + files + "\",\r\n")
# 指定当前BULID.gn 文件的路径
gn_file_path = "/home/wait/project/xr806/xr806_openharmony/device/xradio/xr806/ohosdemo/pikascript_test_prj/"
# make sure the current path is prj dir
if( os.getcwd() != gn_file_path):
os.chdir(gn_file_path)
print("gn_file_path: ",gn_file_path)
# 前面只是给定了文件路径,这里要把字符串 "BUILD.gn" 也加进来
gn_file_path += "BUILD.gn"
# gn_file_path = gn_file_path + "/BUILD.gn"
#通过写方式打开,且每次会覆盖,这样每次运行脚本写进去的开头部分不会重复
gn_file = open(gn_file_path, 'w+')
#这里面 main.c 的位置根据需要调整
gn_content = """\
import("//device/xradio/xr806/liteos_m/config.gni")\r\n
static_library(\"app_pikascript\") { \r\n
configs = []\r\n
sources = [
"main.c",
"""
gn_file.write(gn_content)
src_dir = ["pikascript/pikascript-api/", "pikascript/pikascript-core/", "pikascript/pikascript-lib/PikaStdLib/"]
for dir in src_dir:
print("**********" + dir + "**********")
extract_c_files_name(dir,gn_file)
gn_file.write(""" ]\r\n\r\ncflags = board_cflags
include_dirs = board_include_dirs
include_dirs += [
"//kernel/liteos_m/kernel/arch/include",
"pikascript/pikascript-api/",
"pikascript/pikascript-core/",
"pikascript/pikascript-lib/PikaStdLib/"
]
}""")
gn_file.close()
# file_list = []
# source_file_f = os.listdir("pikascript-api/")
# print("pikascript-api .c files")
# i = 0
# #source_file_fd = open(source_file_path,"r") #only read
# for files in source_file_f:
# if (".c" == os.path.splitext(files)[1]):
# file_list.append(files)
# print(file_list[i])
# gn_file.write(""" \"""" + "pikascript-api/" + file_list[i] + "\",\r\n")
# i += 1
# file_list.clear()

View File

@ -0,0 +1,29 @@
#include "ohos_init.h"
#include "kernel/os/os.h"
#include "pikascript/pikascript-api/pikaScript.h"
static OS_Thread_t g_main_thread;
/* support pikaScript Shell */
static void MainThread(void *arg)
{
PikaObj* pikamain = pikaScriptInit();
while (1) {
}
}
void HelloTestMain(void)
{
printf("pikascript Test Start\n");
if (OS_ThreadCreate(&g_main_thread, "MainThread", MainThread, NULL,
OS_THREAD_PRIO_APP, 4 * 1024) != OS_OK) {
printf("[ERR] Create MainThread Failed\n");
}
}
SYS_RUN(HelloTestMain);

View File

@ -0,0 +1,14 @@
这仅仅是一个简单的在 XR806 上运行openharmony系统时跑 pikascript 的工程
openharmony 配置脚本可以参考以下链接:
1. 大佬一键配置脚本: https://aijishu.com/a/1060000000291606#item-1-4
2. 官方说明文档: https://xr806.docs.aw-ol.com/
3. 相关问题以及解决方法: https://blog.csdn.net/weixin_43094346/article/details/123089595
gen_gnfiles.py 是一个生成BUILD.gn 的 py 脚本,如有错误或者更好的写法可以修改,同时希望留下注释,以便大家互相学习一波

View File

@ -0,0 +1,3 @@
import PikaStdLib
print('hello openharmony! hello PikaScript!')

View File

@ -0,0 +1,2 @@
pikascript-core==v1.9.0
PikaStdLib==v1.9.0