HarmonyOS 多个static library当主工程建有多个target类型时,子的static library的不会随选择的编译类型变化

我们在最外层的build-profile.json5中创建了两种products,并绑定到对应的library_share_utils这个子static library中,当选择编译的变体为dev和debug时,有时候它打出来的BuildProfile中targetName还是default,不会随变体切换变化

最外层build-profile.json5如下:

"products": [
      {
        "name": "default",
        "signingConfig": "default",
        "compatibleSdkVersion": "5.0.0(12)",
        "runtimeOS": "HarmonyOS",
        "bundleName": "xxxxxxxx",
        "icon": "$media:app_icon",
        "label": "$string:app_dev_name"
      },
      {
        "name": "dev",
        "signingConfig": "dev",
        "compatibleSdkVersion": "5.0.0(12)",
        "runtimeOS": "HarmonyOS",
        "bundleName": "xxxxxxxx",
        "icon": "$media:app_icon",
        "label": "$string:app_dev_name"
      }
    ],
    "buildModeSet": [
      {
        "name": "debug",
      },
      {
        "name": "release"
      }
    ]
  },
  "modules": [
    {
      "name": "phone",
      "srcPath": "./products/phone",
      "targets": [
        {
          "name": "default",
          "applyToProducts": [
            "default"
          ]
        },
        {
          "name": "dev",
          "applyToProducts": [
            "dev"
          ]
        }
      ]
    },
    {
      "name": "library_share_utils",
      "srcPath": "./common/library_share_utils",
      "targets": [
        {
          "name": "default",
          "applyToProducts": [
            "default"
          ]
        },
        {
          "name": "dev",
          "applyToProducts": [
            "dev"
          ]
        }
      ]
    }
  ]
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.

library_share_utils的build-profile.json5如下配置:

{
  "apiType": "stageMode",
  "buildOption": {
    "arkOptions": {
      // "apPath": "./modules.ap"  /* Profile used for profile-guided optimization (PGO), a compiler optimization technique to improve app runtime performance. */
    }
  },
  "buildOptionSet": [
    {
      "name": "release",
      "arkOptions": {
        "obfuscation": {
          "ruleOptions": {
            "enable": true,
            "files": [
              "./obfuscation-rules.txt"
            ]
          }
        }
      }
    },
  ],
  "targets": [
    {
      "name": "default"
    },
    {
      "name": "dev"
    }
  ]
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
HarmonyOS
2024-12-28 08:17:41
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Excelsior_abit

单独编译某一个har 按照官网资料描述是用命令单独编译的

非单独编译某一个har,target取决于父级

product选择为free时 :

当har2中不存在target:free时,直接编译entry时 har 编译时使用的资源为 resource的;

当har2中存在target:free时,直接编译entry时 har 编译时使用的资源为 resource——free的;

当前现状(基于DevEco Studio 5.0.3.400):也就是说源码依赖har的多目标依赖是跟踪上一级走的,har的多目标跟随har2,entry不能直接决定(不能隐式传递)。

分享
微博
QQ
微信
回复
2024-12-28 11:11:42
相关问题
无法从static上下文引用非static方法
10941浏览 • 1回复 待解决
HarmonyOS 关于library代码混淆问题
699浏览 • 1回复 待解决
static 方法支持mock吗?
1621浏览 • 1回复 待解决
LIKE后跟查询多个问题?
4226浏览 • 1回复 待解决
HarmonyOS interface中如何定义static方法
638浏览 • 1回复 待解决
HarmonyOS 多个@Prop变化顺序问题
1087浏览 • 1回复 待解决
HarmonyOS 类型选择
438浏览 • 1回复 待解决
如何设置父组件组件宽度变化
3038浏览 • 1回复 待解决
c++侧可以直接调用tsstatic方法吗?
3174浏览 • 1回复 待解决