2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
VNDK の有効化
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Vendor Native Development Kit(VNDK)では、ベンダーとシステムを切り離して扱うために、コードベースにいくつかの変更が必要です。ベンダーまたは OEM のコードベースで VNDK を有効にするには、以下のガイドをご覧ください。
ビルドシステム ライブラリ
ビルドシステムには、ライブラリ(共有、静的、ヘッダー)やバイナリなど、数種類のオブジェクトが含まれています。
図 1. ビルドシステム ライブラリ。
core
ライブラリは、システム イメージ上でシステム イメージによって使用されます。このライブラリが vendor
ライブラリ、vendor_available
ライブラリ、vndk
ライブラリ、vndk-sp
ライブラリによって使用されることはありません。cc_library {
name: "libThatIsCore",
...
}
vendor-only
(または proprietary
)ライブラリは、ベンダー イメージ上でベンダー イメージによって使用されます。cc_library {
name: "libThatIsVendorOnly",
proprietary: true,
# or: vendor: true, # (for things in AOSP)
...
}
vendor_available
ライブラリは、ベンダー イメージ上でベンダー イメージによって使用されます(core
の重複が含まれている場合があります)。cc_library {
name: "libThatIsVendorAvailable",
vendor_available: true,
...
}
vndk
ライブラリは、システム イメージ上でベンダー イメージによって使用されます。cc_library {
name: "libThatIsVndk",
vendor_available: true,
vndk: {
enabled: true,
}
...
}
vndk-sp
ライブラリは、ベンダー イメージだけでなく、システム イメージによっても間接的に使用されます。cc_library {
name: "libThatIsVndkSp",
vendor_available: true,
vndk: {
enabled: true,
support_system_process: true,
}
...
}
llndk
ライブラリは、システム イメージとベンダー イメージの両方によって使用されます。cc_library {
name: "libThatIsLlndk",
llndk: {
symbol_file: "libthatisllndk.map.txt"
}
...
}
lib が vendor_available:true
としてマークされている場合は、次のように 2 回ビルドされます。
- プラットフォーム用に 1 回(その後
/system/lib
にインストールされます)
- ベンダー用に 1 回(その後
/vendor/lib
または VNDK APEX にインストールされます)
lib のベンダー バージョンは、-D__ANDROID_VNDK__
とともにビルドされます。Android の今後のバージョンで大幅に変更される可能性のある非公開システム コンポーネントは、このフラグで無効になります。さらに、各ライブラリがそれぞれ異なるセットのヘッダー(liblog
など)をエクスポートします。ターゲットのベンダー バリアントに固有のオプションは、以下にある Android.bp
ファイルで指定できます。
target: { vendor: { … } }
コードベースの VNDK の有効化
コードベースの VNDK を有効化するには:
vendor.img
パーティションと system.img
パーティションの必須サイズを計算して対象となるかどうかを判断します。
BOARD_VNDK_VERSION=current
を有効にします。BoardConfig.mk
に追加することも、コンポーネントとともに直接ビルドすることもできます(例: m -j BOARD_VNDK_VERSION=current MY-LIB
)。
ビルドシステムは、BOARD_VNDK_VERSION=current
を有効にした後、以下の依存関係とヘッダーの要件を適用します。
依存関係を管理する
vndk
に存在しない、または vendor
オブジェクトとして存在しない core
コンポーネントに依存する vendor
オブジェクトは、次のいずれかのオプションを使用して解決する必要があります。
- 依存関係は削除できます。
vendor
が core
コンポーネントを所有する場合は、vendor_available
または vendor
としてマークすることが可能です。
vndk
のコア オブジェクト部分の変更は、Google に送信される可能性があります。
さらに、core
コンポーネントが vendor
コンポーネントに依存している場合、vendor
コンポーネントを core
コンポーネントにするか、または依存関係を別の方法で解消する必要があります(たとえば、依存関係を削除する、または依存関係を vendor
コンポーネントに移動する)。
ヘッダーのビルドに -D__ANDROID_VNDK__
を使用するかしないかをビルドシステムが把握できるようにするには、グローバル ヘッダーの依存関係を解消する必要があります。たとえば、utils/StrongPointer.h
のような libutils ヘッダーは、ヘッダー ライブラリ libutils_headers
を使用して引き続きアクセスできます。
一部のヘッダー(unistd.h
など)は、推移的に含めることはできなくなりましたが、ローカルに含めることができます。
最後に、private/android_filesystem_config.h
の公開部分は cutils/android_filesystem_config.h
に移動しました。これらのヘッダーを管理するには、次のいずれかの操作を行います。
- 可能な場合、すべての
AID_*
マクロを getgrnam
または getpwnam
の呼び出しに置き換えて、private/android_filesystem_config.h
への依存関係を解消します。次に例を示します。
(uid_t)AID_WIFI
を getpwnam("wifi")->pw_uid
に変更します。
(gid_t)AID_SDCARD_R
を getgrnam("sdcard_r")->gr_gid
に変更します。
詳細については private/android_filesystem_config.h
をご覧ください。
- ハードコードされた AIS の場合は、
cutils/android_filesystem_config.h
を含めます。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-03-02 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-03-02 UTC。"],[],[],null,["# Enable VNDK\n\nThe Vendor Native Development Kit (VNDK) requires several changes to a codebase to separate\nconcerns between vendor and system. Use the following guide to enable VNDK in a vendor/OEM\ncodebase.\n\nBuild system libraries\n----------------------\n\nThe build system contains several types of objects including libraries\n(shared, static, or header) and binaries.\n\n**Figure 1.** Build system libraries.\n\n- `core` libraries are used by the system image, on the system image. These libraries can't be used by `vendor`, `vendor_available`, `vndk`, or `vndk-sp` libraries. \n\n ```carbon\n cc_library {\n name: \"libThatIsCore\",\n ...\n }\n ```\n- `vendor-only` (or `proprietary`) libraries are used by the vendor image, on the vendor image. \n\n ```carbon\n cc_library {\n name: \"libThatIsVendorOnly\",\n proprietary: true,\n # or: vendor: true, # (for things in AOSP)\n ...\n }\n ```\n- `vendor_available` libraries are used by the vendor image, on the vendor image (may contain duplicates of `core`). \n\n ```carbon\n cc_library {\n name: \"libThatIsVendorAvailable\",\n vendor_available: true,\n ...\n }\n ```\n- `vndk` libraries are used by the vendor image, on the system image. \n\n ```carbon\n cc_library {\n name: \"libThatIsVndk\",\n vendor_available: true,\n vndk: {\n enabled: true,\n }\n ...\n }\n ```\n- `vndk-sp` libraries are used by the vendor image, and also by the system image indirectly. \n\n ```carbon\n cc_library {\n name: \"libThatIsVndkSp\",\n vendor_available: true,\n vndk: {\n enabled: true,\n support_system_process: true,\n }\n ...\n }\n ```\n- `llndk` libraries are used by both the system and vendor images. \n\n ```carbon\n cc_library {\n name: \"libThatIsLlndk\",\n llndk: {\n symbol_file: \"libthatisllndk.map.txt\"\n }\n ...\n }\n ```\n\nWhen a lib is marked as `vendor_available:true`, it's built\ntwice:\n\n- Once for platform (and thus installed to `/system/lib`)\n- Once for vendor (and thus installed to `/vendor/lib` or VNDK APEX)\n\nThe vendor versions of libs are built with `-D__ANDROID_VNDK__`.\nPrivate system components that may change significantly in future versions of\nAndroid are disabled with this flag. In addition, different libraries export a\ndifferent set of headers (such as `liblog`). Options specific to a\nvendor variant of a target can be specified in an `Android.bp` file\nin: \n\n```text\ntarget: { vendor: { … } }\n```\n\nEnable VNDK for a codebase\n--------------------------\n\nTo enable the VNDK for a codebase:\n\n1. Determine eligibility by calculating the required sizes of `vendor.img` and `system.img` partitions.\n2. Enable `BOARD_VNDK_VERSION=current`. You can add to `BoardConfig.mk` or build components with it directly (for example, `m -j BOARD_VNDK_VERSION=current `\u003cvar translate=\"no\"\u003eMY-LIB\u003c/var\u003e).\n\nAfter enabling `BOARD_VNDK_VERSION=current`, the build system\nenforces the following dependency and header requirements.\n\n### Manage dependencies\n\nA `vendor` object that depends on a `core` component\nthat doesn't exist in `vndk` or as a `vendor` object\nmust be resolved using one of the following options:\n\n- The dependency can be removed.\n- If the `core` component is owned by `vendor`, it can be marked as `vendor_available` or `vendor`.\n- A change making the core object part of the `vndk` may be upstreamed to Google.\n\nIn addition, if a `core` component has dependencies on a\n`vendor` component, the `vendor` component must be made\ninto a `core` component **or** the dependency must be\nremoved in another way (for example, by removing the dependency or by moving the\ndependency into a `vendor` component).\n\n### Manage headers\n\nGlobal header dependencies must be removed to enable the build system to know\nwhether to build the headers with or without `-D__ANDROID_VNDK__`.\nFor example, libutils headers such as `utils/StrongPointer.h` can\nstill be accessed using the header library\n[`libutils_headers`](https://android.googlesource.com/platform/system/core/+/android16-release/libutils/include/utils).\n\nSome headers (such as `unistd.h`) can no longer be included transitively\nbut can be included locally.\n\nFinally, the public part of `private/android_filesystem_config.h`\nhas been moved to `cutils/android_filesystem_config.h`. To manage\nthese headers, do one of the following:\n\n- Remove the dependency to `private/android_filesystem_config.h` by replacing all `AID_*` macros with [getgrnam](http://man7.org/linux/man-pages/man3/getgrnam.3.html)/ [getpwnam](http://man7.org/linux/man-pages/man3/getpwnam.3.html) calls if possible. For example:\n - `(uid_t)AID_WIFI` becomes `getpwnam(\"wifi\")-\u003epw_uid`.\n - `(gid_t)AID_SDCARD_R` becomes `getgrnam(\"sdcard_r\")-\u003egr_gid`.\n\n For details, refer to [private/android_filesystem_config.h](https://android.googlesource.com/platform/system/core/+/android16-release/libcutils/include/private/android_filesystem_config.h).\n- For hard-coded AIS, include `cutils/android_filesystem_config.h`."]]