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辅助软件教程)辅助神器app还具备辅助透视行为开挂功能,通过对客...
解密关于!wepoker软件安... 解密关于!wepoker软件安装包,epoker底牌透视,详细教程(有挂透明)关于wepoker软件...
玩家必看科普!哈糖大菠萝怎么挂... 《玩家必看科普!哈糖大菠萝怎么挂,hardrock透视工具,新2025版(有挂技巧)》 哈糖大菠萝怎...
六分钟了解!WePoKer辅助... 六分钟了解!WePoKer辅助器,wepoker透视脚本免费下载pc,教你攻略(有挂透视)准备好在w...
总算明白!wepoker怎么下... 总算明白!wepoker怎么下载游戏,pokemmo手机版透视脚本,爆料教程(有挂神器);《WPK辅...
一分钟了解!竞技联盟透视,we... 一分钟了解!竞技联盟透视,wepoker怎么看牌型,可靠教程(有挂教程);支持多人共享记分板与复盘,...
重要通知!werplan外挂,... 1、重要通知!werplan外挂,wepoker可以免费玩吗,可靠教程(有挂攻略);详细教程。2、w...
分享一款!wepoker怎么挂... 分享一款!wepoker怎么挂飞机,有没有人wepoker,必备教程(有挂技巧);支持多人共享记分板...
技巧知识分享!菠萝辅助器免费版... 技巧知识分享!菠萝辅助器免费版的功能介绍,wepoker有辅助工具吗,详细教程(有挂技巧)是由北京得...
玩家必备攻略!we-poker... 玩家必备攻略!we-poker辅助软件教程,破解辅助插件wepoker,2025新版教程(有挂技巧)...