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 },
}

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

相关内容

热门资讯

透视了解!aapoker辅助器... 透视了解!aapoker辅助器怎么用(透视)hhpoker必备开挂-切实真的有挂(哔哩哔哩)一、aa...
透视了解!aapoker ai... 透视了解!aapoker ai插件(透视)德州hhpoker是真的吗-好像真的有挂(哔哩哔哩)1、超...
目前来看!wpk俱乐部怎么透视... 目前来看!wpk俱乐部怎么透视(透视)wpk模拟器多开-果然真的是有挂(哔哩哔哩)1、wpk俱乐部怎...
透视数据!德扑圈有透视吗(透视... 透视数据!德扑圈有透视吗(透视)德普之星透视辅助-都是是真的挂(哔哩哔哩)1、玩家可以在德普之星透视...
代打辅助挂!we poker辅... 代打辅助挂!we poker辅助器(透视)wepoker有辅助功能吗-总是真的有挂(哔哩哔哩)1、下...
据统计!hhpoker真能买到... 据统计!hhpoker真能买到挂吗(透视)hhpoker辅助软件下载-总是有挂(哔哩哔哩)1、hhp...
2026版总结!wepoker... 2026版总结!wepoker免费辅助器(透视)wepoker有机器人吗-一贯是真的挂(哔哩哔哩)1...
有了最新消息!德普之星有透视辅... 有了最新消息!德普之星有透视辅助吗(透视)如何下载德普之星辅助软件-果然存在有挂(哔哩哔哩)1、完成...
据通报!智星德州插件怎么下载(... 据通报!智星德州插件怎么下载(透视)智星菠萝可以辅助吗-好像有挂(哔哩哔哩)1、首先打开智星德州插件...
现场直击!德普之星辅助工具如何... 现场直击!德普之星辅助工具如何设置(透视)德扑之心免费透视-都是真的是有挂(哔哩哔哩)1、在德普之星...