Android9.0 Android.bp添加宏开关demo

1.test.cpp
#define LOG_TAG "test_demo"
#include <stdlib.h>
#include <stdio.h>
#include <utils/Log.h>

int main(){
#ifdef DEBUG
  ALOGE("Android.mk is define DEBUG");
  printf("Android.mk is define DEBUG.\n");
#else
  ALOGE("Android.mk is not define DEBUG");
  printf("Android.mk is not define DEBUG.\n");
#endif
  return 0;
}

2.Android.bp
cc_binary {
    name: "test",
    srcs: ["test.cpp"],

    shared_libs: [
    "libcutils",
    "liblog",
    ],
    //增加宏开关:DEBUG
    cflags: ["-DDEBUG"],
    //去掉宏开关:DEBUG
    //cflags: ["-DDEBUG"],
}
发布了748 篇原创文章 · 获赞 458 · 访问量 243万+

猜你喜欢

转载自blog.csdn.net/u010164190/article/details/104974618