鸿蒙开发环境搭建
组件
打开build/subsystem_config.json文件,添加内容:
…
"sample": {
"path": "sample",
"name": "sample"
},
…
新建sample/hello/bundle.json文件
{
"name": "@openharmony/hello",
"version": "3.1.0",
"description": "hello",
"publishAs": "code-segment",
"segment": {
"destPath": "sample/hello"
},
"scripts": {},
"author": {},
"repository": "",
"license": "Apache License 2.0",
"component": {
"name": "hello",
"subsystem": "sample",
"adapted_system_type": [
"standard"
],
"syscap": [],
"features": [],
"rom": "967KB",
"ram": "28MB",
"deps": {
"components": [
"libhilog",
"libipc_single",
"libsystem_ability_fwk",
"libsyspara",
"samgr_proxy",
"utils_base"
],
"third_party": [
"utils",
"cjson_static",
"mbedtls_shared"
]
},
"build": {
"sub_component": [
"//sample/hello:hello"
],
"inner_kits": [],
"test": []
}
}
}
新建sample/hello/BUILD.gn文件
mport("//build/ohos.gni")
ohos_executable("hello") {
install_enable = true
sources = [ "hello.c" ]
include_dirs = [ ]
cflags = [
"-Wall",
"-std=c99",
]
deps = []
part_name = "hello"
subsystem_name = "sample"
}
打开productdefine/common/products/rk3568.json文件,在“parts”成员中添加以下内容:
"parts":{
…
"sample:hello":{},
…
新建sample/hello/hello.c文件,添加以下内容
#include <stdio.h>
#include "hilog/log.h"
#undef LOG_DOMAIN
#undef LOG_TAG
#define LOG_DOMAIN 0xD002E12
#define LOG_TAG "SampleHello"
int main()
{
printf("Hello MineHarmony\n");
HILOG_DEBUG(LOG_CORE, ":%{public}s", "HILOG_DEBUG called.");
HILOG_INFO(LOG_CORE, ":%{public}s", "HILOG_INFO called.");
HILOG_WARN(LOG_CORE, ":%{public}s", "HILOG_WARN called.");
HILOG_ERROR(LOG_CORE, ":%{public}s", "HILOG_ERROR called.");
HILOG_FATAL(LOG_CORE, ":%{public}s", "HILOG_FATAL called.");
return 0;
}
- 点赞
- 收藏
- 关注作者
评论(0)