Android平台使用ninja全编/模块编译提高效率

26 篇文章 1 订阅
本文详细介绍了使用Ninja工具进行增量编译的过程,对比了传统Make编译方式,指出Ninja能显著提高编译速度。通过实例展示了模块编译、目标文件生成及警告信息,强调Ninja在Android项目中的高效应用。
摘要由CSDN通过智能技术生成

全编

prebuilts/build-tools/linux-x86/bin/ninja -f out/combined-full_k80hd_bsp_fwv_512m.ninja 2>&1 | tee ninja_build.log

ps : 在后面加上 2>&1 | tee ninja_build.log 可以在终端上记录编译的中间过程和编译生成的一些文件

模块编译

prebuilts/build-tools/linux-x86/bin/ninja -f out/combined-full_k80hd_bsp_fwv_512m.ninja MtkSettings 2>&1 | tee ninja_build.log

ps : 其中 MtkSettings 为在 Android.bp/Android.mk 文件中定义的模块名称

编译结果如下 :
[1/9] Target Java: out/target/common/obj/APPS/Settings_intermediates/classes-full-debug.jar
[2/9] build out/target/common/obj/APPS/Settings_intermediates/classes-combined.jar
[3/9] Copy: out/target/common/obj/APPS/Settings_intermediates/classes.jar
[4/9] R8: out/target/common/obj/APPS/Settings_intermediates/dex/classes.dex
Warning: Library class vendor.sprd.hardware.radio.V1_0.IAtcRadioResponse implements program class android.hidl.base.V1_0.IBase
Warning: Library class vendor.sprd.hardware.radio.V1_0.IExtRadio implements program class android.hidl.base.V1_0.IBase
Warning: Library class vendor.sprd.hardware.radio.V1_0.IExtRadioIndication implements program class android.hidl.base.V1_0.IBase
Warning: Library class vendor.sprd.hardware.radio.V1_0.IExtRadioResponse implements program class android.hidl.base.V1_0.IBase
Warning: Library class vendor.sprd.hardware.radio.V1_0.IAtcRadioIndication implements program class android.hidl.base.V1_0.IBase
Warning: Library class vendor.sprd.hardware.radio.V1_0.IAtcRadioResponse implements program class android.hidl.base.V1_0.IBase
Warning: Library class vendor.sprd.hardware.radio.V1_0.IExtRadio implements program class android.hidl.base.V1_0.IBase
Warning: Library class vendor.sprd.hardware.radio.V1_0.IExtRadioIndication implements program class android.hidl.base.V1_0.IBase
Warning: Library class vendor.sprd.hardware.radio.V1_0.IExtRadioResponse implements program class android.hidl.base.V1_0.IBase
Warning: Library class vendor.sprd.hardware.radio.V1_0.IAtcRadioIndication implements program class android.hidl.base.V1_0.IBase
[5/9] Copying: out/target/common/obj/APPS/Settings_intermediates/classes.dex
[6/9] build out/target/common/obj/APPS/Settings_intermediates/dex.jar
[7/9] target Package: Settings (out/target/product/sp7731e_1h10/obj/APPS/Settings_intermediates/package.apk)
[8/9] Settings dexpreopt
[9/9] Install: out/target/product/sp7731e_1h10/product/priv-app/Settings/Settings.apk

使用ninja编译比make编译更快,因为使用的是增量编译

Android经典源码全集[简单易懂],共88套代码,完整有效,已全部测试! Android经典源码列表: GestureRecogniseSample GetPostSample GridAndImageSwitcherSample HandlerSample ImageButton Intent_ComponentSample Intent_DataSample Intent_TabHostSample IOStreamSample LauncherActivitySample LauncherSample Layer-listSample LinearLayoutSample ListViewSample ListViewTweenSample LocationManagerSample LockScreen LogicAlertDialogSample Matrix MatrixText MediaProviderSample MediaRecorder MenuItemSample MenuSample MenuXmlSample MockDialogSample MonitorPhone MoveBackgroundSample MusicBox MyLiveWallPaper PathEffectSample PlanGame PopupWindowSample ProgressBarSample ProgressDialogSample ProximityAlertSample RadioAndCheckbox RadioButtonAndCheckBox RatingBarSample RecordSound RegeditTable RegTable RelativeLayoutSample RequestCodeAndResponseCodeSample ScrollViewAndHorizontalViewSample SDCardSample SDFileExplorerSample SeekerBarSample SelecterDrawableSample SelecterSample SendSMSSample SensorSample ServiceSample ShaderSample ShapSample SharePreferencesSample SimpleAdapterSample SMSLisenter SpinnerSample SpinnerSample2 SQLiteOpenHelperSample SQLiteSample StartActivityToSecondActivitySimple StateListDrawableSample StyleSample SufaceVideoTest SundPoolSample SurfaceViewTest SweenedText TabHostSample TelephonyManagerSample TextToSpeechSample TextViewBackground TextViewSample TitleProgressBar ToastSample ToggleButton TouchCircle TweenAnimationSample UseIntentRebackHomeSample VibratorSample VideoViewSample VideoViewSample2 WallpaperManagerSample WindowThemeSample XmlResourceParserSample XmlValuesSample XmlValuesSample2
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值