اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release بدلاً من aosp-main لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
علامات الإنشاء هي ثوابت وقت الإنشاء ولا يمكن تغييرها أثناء وقت التشغيل. يتم استخدام
هذه العلامات في الحالات التي لا يمكن فيها استخدام علامات aconfig، مثل
لديك قطعة رمز تم تجميعها أو إنشاؤها مسبقًا تريد تضمينها اختياريًا في إصدار.
إذا كنت تريد إجراء تغييرات على نظام الإنشاء نفسه
إذا أردت وضع علامات حول التبعيات لإدارة حجم الرمز
تريد إدارة إطلاق ميزة، ولكن عليك التحقّق من قيمة العلامة قبل أن يُتيح النظام علامات aconfig.
تحديد علامة إنشاء
يتمّ الإعلان عن علامات الإنشاء في ملفات textproto. لتعريف علامة بناء:
الانتقال إلى WORKING_DIRECTORY/build/release/flag_declarations/
أنشئ ملفًا باسم RELEASE_MY_FLAG_NAME.textproto.
عدِّل الملف وأضِف إدخالاً مشابهًا لما يلي:
name: "RELEASE_MY_FLAG_NAME"
namespace: "android_UNKNOWN"
description: "Control if we should read from new storage."
workflow: LAUNCH
containers: "product"
containers: "system"
containers: "system_ext"
containers: "vendor"
المكان:
يحتوي name على اسم البلاغ مسبوقًا بـ RELEASE_. يُسمح فقط باستخدام
الأحرف الكبيرة والشرط السفلي.
يحتوي namespace على مساحة الاسم للمساهمات. عليك العمل مع
المراجع المعيّن من Google لتحديد مساحة الاسم. إذا كنت تستخدِم
علامات إطلاق الميزات للحفاظ على ثبات نسخة AOSP المطابقة الخاصة بك، يمكنك
استخدام مساحة الاسم كيفما تشاء.
value هو النوع والقيمة الأوليان للعلامة. يمكن أن يكون النوع
bool_value أو string_value. إذا كان النوع هو string_value، يجب أن تكون القيمة
بين علامتَي اقتباس. إذا لم يتم تحديد قيمة، تكون القيمة سلسلة فارغة. يتم تمثيل القيم المنطقية
إما بالرمز true أو السلسلة الفارغة للقيمة "خطأ".
workflow هو إما LAUNCH أو PREBUILT. استخدِم LAUNCH للعلامات الحقيقية أو الخاطئة
التي تنتقل من false إلى true، تمامًا مثل علامات إطلاق الميزات.
استخدِم PREBUILT للعلامات التي تحدّد إصدارًا، عادةً لإصدار مُعدّ مسبقًا.
containers نوع الرمز الذي تكتبه، مثل "vendor" لرمز العميل
أو "product" لرمز المنتج إذا لم تكن متأكّدًا من القيمة التي يجب استخدامها،
استخدِم جميع أنواع الحاويات الأربعة كما هو موضّح في العيّنة السابقة.
استخدام علامة إنشاء في ملف Soong
في ملف الإنشاء والوحدة التي تريد طلب البحث عن قيمة العلامة فيها، استخدِم تعبيرًا
شرطيًا لتقسيم المسار بناءً على قيمة العلامة. على سبيل المثال، في المقتطف التالي، تتم معالجة قيمة العلامة RELEASE__READ_FROM_NEW_STORAGE:
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-07-27 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Declare and use a build flag\n\nBuild flags are build-time constants and can't be changed during runtime. These\nflags are used in circumstances where aconfig flags can't be used, such as\n\n- You have a precompiled or prebuilt piece of code that you want include optionally in a build.\n- You want to make changes to build system itself.\n- You want to put flags around dependencies to manage code size.\n- You want to manage the launch of a feature, but you need to check the value of the flag before aconfig flags are made available by the system.\n\nDeclare a build flag\n--------------------\n\nBuild flags are declared in textproto files. To declare a build flag:\n\n1. Navigate to \u003cvar translate=\"no\"\u003eWORKING_DIRECTORY\u003c/var\u003e`/build/release/flag_declarations/`\n2. Create a file called `RELEASE_`\u003cvar translate=\"no\"\u003eMY_FLAG_NAME\u003c/var\u003e`.textproto`.\n3. Edit the file and add an entry similar to the following:\n\n name: \"RELEASE_MY_FLAG_NAME\"\n namespace: \"android_UNKNOWN\"\n description: \"Control if we should read from new storage.\"\n workflow: LAUNCH\n containers: \"product\"\n containers: \"system\"\n containers: \"system_ext\"\n containers: \"vendor\"\n\n Where:\n - `name` contains the name of the flag preceded by `RELEASE_`. Only uppercase letters and underscore are allowed.\n - `namespace` contains the namespace for contributions. You must work with the assigned Google reviewer to determine your namespace. If you are using feature launch flags to maintain stability of your own AOSP mirror, you can use namespace however you like.\n - `value` is the initial type and value for the flag. The type can be `bool_value` or `string_value`. If type is `string_value` then the value must be in quotes. If not specified, the value is an empty string. Boolean values are represented as either `true` or the empty string for false.\n - `workflow` is either `LAUNCH` or `PREBUILT`. Use `LAUNCH` for boolean flags that advance from `false` to `true`, similar to feature launch flags. Use `PREBUILT` for flags that set a version, typically of a prebuilt.\n - `containers` the type of code you are writing, such as \"vendor\" for vendor code or \"product\" for product code. If you are in doubt of the value to use, use all four containers types as shown in the previous sample.\n\nUse a build flag in a Soong file\n--------------------------------\n\nIn the build file and module where you want to query the flag value, use a\nconditional to branch on the flag value. For example, in the following snippet,\nthe `RELEASE__READ_FROM_NEW_STORAGE` flag's value is queried: \n\n cc_defaults {\n name: \"aconfig_lib_cc_shared_link.defaults\",\n shared_libs: select(release_flag(\"RELEASE_READ_FROM_NEW_STORAGE\"), {\n true: [\"libaconfig_storage_read_api_cc],\n default: [],\n }),\n }\n\nIf this flag's value is `true`, the `libaconfig_storage_read_api_cc` module is\ndynamically linked into the `cc_defaults` module.\n\nIf this flag's value is `false`, nothing (`default: [],`) happens.\n\nUse a build flag in a makefile\n------------------------------\n\nIn the make file, a build flag is a read-only make variable. The following\nmakefile sample accesses a build flag called `RELEASED_PACKAGE_NFC_STCK`: \n\n # NFC and Secure Element packages\n PRODUCT_PACKAGES += \\\n $(RELEASE_PACKAGE_NFC_STACK) \\\n Tag \\\n SecureElement \\\n android.hardware.nfc-service.st \\\n android.hardware.secure_element@1.0-service.st \\\n NfcOverlayCoral\n\nThis flag's declaration has a `workflow` field set to `PREBUILT` in\n[`RELEASE_PACKAGE_NFC_STACK.textproto`](https://cs.android.com/android/platform/superproject/+/android-latest-release:build/release/flag_declarations/RELEASE_PACKAGE_NFC_STACK.textproto?q=%22RELEASE_PACKAGE_NFC_STACK%22&ss=android%2Fplatform%2Fsuperproject%2Fmain)\nand a string value of\n`com.android.nfcservices` [`RELEASE_PACKAGE_NFC_STACK.textproto`](https://cs.android.com/android/platform/superproject/+/android-latest-release:build/release/flag_values/ap3a/RELEASE_PACKAGE_NFC_STACK.textproto)\nthe flag values file for the `trunk_staging` development configuration.\n| **Note:** Flags whose `workflow` field is set to `LAUNCH` should always be compared to an empty string, for example if `flag == true` is written `ifneq (,$(RELEASE_MY_FLAG))` and if `flag == false` is written `ifeq (,$(RELEASE_MY_FLAG))`."]]