赞
踩
//引入go脚本 bootstrap_go_package { name: "soong-xxxparser", pkgPath: "android/soong/xxxparser", deps: [ "blueprint", "blueprint-pathtools", "soong", "soong-android", "soong-cc", "soong-genrule", ], srcs: [ "xxxparser.go", ], pluginFor: ["soong_build"], } xxxparser { name: "xxxparser_defaults", } cc_binary { defaults: ["xxxparser_defaults"], name: "AndroidBp", srcs: ["main.c"], cflags: ["-Wno-error=implicit-function-declaration"], shared_libs: [ "libcutils", "liblog", "libutils", ], }
#include<stdio.h>
int main()
{
#ifdef PRINT //宏控制
printf("Hello world\n");
#endif
#ifdef XXX //宏控制
printf("XXOOX\n");
#endif
printf("This is AndroidBp Test\n");
return 0;
}
package xxxparser import ( "android/soong/android" "android/soong/cc" ) func init() { // resister a module "xxxparser_defaults" android.RegisterModuleType("xxxparser", xxxdroidDefaultsFactory) } func xxxdroidDefaultsFactory() (android.Module) { module := cc.DefaultsFactory() android.AddLoadHook(module, xxxdroidDefaults) return module } func xxxdroidDefaults(ctx android.LoadHookContext) { type props struct { Cflags []string } p := &props{} p.Cflags = globalDefaults(ctx) ctx.AppendProperties(p) } func globalDefaults(ctx android.BaseContext) ([]string) { var cppflags []string if ctx.AConfig().Getenv("TARGET_PRODUCT") == "dockdroid_arm64" { cppflags = append(cppflags,"-DXXX") } return cppflags }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。