Android Soong没有android.PathForSourceRelaxed和ctx.Config().BuildOSTarget。
创始人
2024-08-15 18:30:10
0

在Android Soong中,android.PathForSourceRelaxed和ctx.Config().BuildOSTarget都不是默认提供的函数或变量。然而,可以通过自定义函数和变量来实现相似的功能。以下是一个示例解决方法:

// 在build/soong/android/paths.go文件中,定义一个函数android.PathForSourceRelaxed
func PathForSourceRelaxed(ctx android.ModuleContext, paths ...string) android.Path {
    srcDir := android.PathForModuleSrc(ctx).String()
    return android.PathForOutput(ctx, strings.TrimPrefix(filepath.Join(srcDir, filepath.Join(paths...)), srcDir))
}

// 在build/soong/android/config.go文件中,定义一个函数BuildOSTarget
func (c Config) BuildOSTarget() string {
    // 根据具体需求,返回对应的BuildOSTarget
    return "android"
}

然后,你可以在Soong蓝图文件中使用这些自定义函数和变量:

// 在Android.bp文件中
// 使用自定义函数PathForSourceRelaxed
module {
    name: "my_module",
    srcs: ["src/my_file.cc"],
    relative_install_path: "my_module",
    installable: true,
    bazel_module: { bp2build_available: true },
}

// 使用自定义变量BuildOSTarget
cc_library {
    name: "my_lib",
    srcs: ["src/my_lib.cc"],
    host_supported: true,
    target: {
        android: {
            enabled: true,
        },
        linux_glibc: {
            enabled: true,
        },
        darwin: {
            enabled: true,
        },
        windows: {
            enabled: true,
        },
        "*": {
            enabled: false,
        },
    },
    bazel_module: { bp2build_available: true },
}

请注意,这只是一个示例解决方法,具体的实现可能因项目的具体需求而有所不同。

相关内容

热门资讯

关于!we-poker辅助软件... 《关于!we-poker辅助软件教程,智星德州插件,可靠教程(有挂辅助)》 we-poker辅助软件...
专业讨论!hhpoker开挂教... 专业讨论!hhpoker开挂教程,wpk透视插件,教你攻略(有挂透明)科技教程也叫必备教程,这是一款...
玩家必备科技!pokemmo脚... 1、玩家必备科技!pokemmo脚本辅助器下载,aapoker脚本怎么用,攻略方法(有挂攻略);详细...
分享实测!wepoker正确养... 分享实测!wepoker正确养号方法,wepoker有用吗,我来教教你(有挂辅助);1分钟了解详细教...
揭秘攻略!哈糖大菠萝能开挂吗,... 揭秘攻略!哈糖大菠萝能开挂吗,wepoker好友房开挂,透明挂教程(有挂教程);科技安装教程;136...
程序员教你!德州局HHpoke... 程序员教你!德州局HHpoker透视脚本,wepoker透视脚本网页,必备教程(有挂辅助)是一款可以...
玩家攻略推荐!poker wo... 玩家攻略推荐!poker world辅助,hhpkoer辅助挂是真的吗,必赢方法(有挂教程);原来确...
交流学习经验!aapoker透... 1、交流学习经验!aapoker透视脚本入口,fishpoker透视底牌,科技教程(有挂软件)。2、...
技术分享!pokemmo手机辅... 技术分享!pokemmo手机辅助软件,hhpoker有没有外挂,攻略教程(有挂技巧);建议优先通过p...
玩家必看教程!wepoker免... 玩家必看教程!wepoker免费脚本,德州hhpoker是真的吗,技巧教程(有挂软件);德州hhpo...