Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
c418edb2
Mace
项目概览
Xiaomi
/
Mace
通知
106
Star
40
Fork
27
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Mace
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c418edb2
编写于
8月 28, 2017
作者:
L
Liangliang He
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add logging/selective build support
上级
31dc70cc
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
138 addition
and
7 deletion
+138
-7
mace/BUILD
mace/BUILD
+25
-0
mace/core/BUILD
mace/core/BUILD
+10
-0
mace/core/logging.h
mace/core/logging.h
+60
-0
mace/examples/BUILD
mace/examples/BUILD
+8
-3
mace/examples/README.md
mace/examples/README.md
+7
-2
mace/examples/helloworld.cc
mace/examples/helloworld.cc
+3
-2
mace/mace.bzl
mace/mace.bzl
+25
-0
mace/utils/BUILD
mace/utils/BUILD
+0
-0
未找到文件。
mace/BUILD
0 → 100644
浏览文件 @
c418edb2
config_setting
(
name
=
"android"
,
values
=
{
"crosstool_top"
:
"//external:android/crosstool"
,
},
visibility
=
[
"//visibility:public"
],
)
config_setting
(
name
=
"android_armv7"
,
values
=
{
"crosstool_top"
:
"//external:android/crosstool"
,
"android_cpu"
:
"armeabi-v7a"
,
},
visibility
=
[
"//visibility:public"
],
)
config_setting
(
name
=
"android_arm64"
,
values
=
{
"crosstool_top"
:
"//external:android/crosstool"
,
"android_cpu"
:
"arm64-v8a"
,
},
visibility
=
[
"//visibility:public"
],
)
mace/core/BUILD
浏览文件 @
c418edb2
package
(
default_visibility
=
[
"//visibility:public"
])
cc_library
(
name
=
"lib_core"
,
hdrs
=
[
"logging.h"
],
srcs
=
[
],
)
mace/core/logging.h
0 → 100644
浏览文件 @
c418edb2
#ifndef MACE_COMMON_LOGGING_H_
#define MACE_COMMON_LOGGING_H_
#ifdef __ANDROID__
#include <android/log.h>
#else
#include <cstdio>
#endif
namespace
mace
{
const
int
FATAL
=
0
;
const
int
ERROR
=
1
;
const
int
WARN
=
2
;
const
int
INFO
=
3
;
const
int
DEBUG
=
4
;
const
int
VERBOSE
=
5
;
namespace
internal
{
const
char
*
kTag
=
"MACE"
;
#ifdef __ANDROID__
#define _MACE_LOG_FATAL \
do { \
__android_log_print(ANDROID_LOG_FATAL, mace::internal::kTag, __VA_ARGS__); \
abort(); \
} while (0)
#define _MACE_LOG_ERROR(...) \
__android_log_print(ANDROID_LOG_ERROR, mace::internal::kTag, __VA_ARGS__)
#define _MACE_LOG_WARN(...) \
__android_log_print(ANDROID_LOG_WARN, mace::internal::kTag, __VA_ARGS__)
#define _MACE_LOG_INFO(...) \
__android_log_print(ANDROID_LOG_INFO, mace::internal::kTag, __VA_ARGS__)
#define _MACE_LOG_DEBUG(...) \
__android_log_print(ANDROID_LOG_DEBUG, mace::internal::kTag, __VA_ARGS__)
#define _MACE_LOG_VERBOSE(...) \
__android_log_print(ANDROID_LOG_VERBOSE, mace::internal::kTag, __VA_ARGS__)
#define LOG(severity, ...) _MACE_LOG_##severity(__VA_ARGS__)
#else // Non Android, just for tests
// TODO(heliangliang): Fix newline
#define LOG(severity, ...) \
do { \
printf(__VA_ARGS__); \
printf("\n"); \
} while (0)
#endif // __ANDROID__
}
// namespace internal
}
// namespace mace
#endif // MACE_COMMON_LOGGING_H_
mace/examples/BUILD
浏览文件 @
c418edb2
# Examples
load
(
"//mace:mace.bzl"
,
"if_android"
,
)
cc_binary
(
name
=
"helloworld"
,
srcs
=
[
"helloworld.cc"
,
],
linkopts
=
[
"-pie"
,
]
deps
=
[
"//mace/core:lib_core"
,
],
linkopts
=
if_android
([
"-pie"
,
"-llog"
])
)
mace/examples/README.md
浏览文件 @
c418edb2
Examples
=======
*
Build the example
*
Build the example
(e.g., with armeabi-v7a target)
```
bazel build mace/examples:helloworld \
--crosstool_top=//external:android/crosstool \
...
...
@@ -9,7 +9,7 @@ bazel build mace/examples:helloworld \
--cpu=armeabi-v7a
```
*
To run adb inside docker, the
network should use 'host':
*
To run adb inside docker, the
container network should use 'host'
```
docker run -it --net=host mace-dev /bin/bash
```
...
...
@@ -20,3 +20,8 @@ adb shell "mkdir /data/local/tmp/helloword"
adb shell push bazel-bin/mace/examples/helloworld /data/local/tmp/helloword
adb shell /data/local/tmp/helloword/helloworld
```
*
Check the logs
```
adb logcat | grep MACE
```
mace/examples/helloworld.cc
浏览文件 @
c418edb2
#include
<cstdio>
#include
"mace/core/logging.h"
int
main
()
{
printf
(
"Hello world
\n
"
);
LOG
(
INFO
,
"Hello World"
);
return
0
;
}
mace/mace.bzl
0 → 100644
浏览文件 @
c418edb2
# -*- Python -*-
def
if_android
(
a
):
return
select
({
"//mace:android"
:
a
,
"//conditions:default"
:
[],
})
def
if_not_android
(
a
):
return
select
({
"//mace:android"
:
[],
"//conditions:default"
:
a
,
})
def
if_android_armv7
(
a
):
return
select
({
"//mace:android_armv7"
:
a
,
"//conditions:default"
:
[],
})
def
if_android_arm64
(
a
):
return
select
({
"//mace:android_arm64"
:
a
,
"//conditions:default"
:
[],
})
mace/utils/BUILD
已删除
100644 → 0
浏览文件 @
31dc70cc
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录