http://hi.baidu.com/kenny_wju/item/042603c7f4f66d78ced4f83b
最近移植tslib庫到android系統,發現編譯好的庫和測試載入器竟然沒有輸入到out/target/product/Ok6410/system/lib 和 out/target/product/Ok6410/system/bin下面,感覺很奇怪,於是下定決心看一下,到底輸入到了哪裡。
過程如下:
tslib的原始碼放到了android2.3 原始碼下 vendor 目錄 (android2.3中自己添加,如何設定自己的vendor 我的部落格中有說明)forlinx/OK6410/的下面. tslib目錄下面的 Android.mk寫好以後,重新make clean 整個android源碼,再次make 編譯通過,奇怪的是輸出目錄 out/target/product/Ok6410/system/bin 下面竟然沒有tslib相關的工具,而是放在了out/target/product/OK6410/symbols/system/bin 下面,在做打包檔案時,由於沒有把symbols檔案夾放到檔案系統裡面,所以校準功能不能實現。(事實上提取檔案系統過程中也不應該把symbols檔案夾考慮在內)。
最後尋找原因 ,是因為tslib檔案下的Android.mk檔案裡面,LOCAL_MODULE_TAGS變數設定的有問題。
LOCAL_MODULE_TAGS :=optional
把這項改為
LOCAL_MODULE_TAGS :=eng即可
原因是LOCAL_MODULE_TAGS 變數跟TARGET_BUILD_VARIANT 變數息息相關。 android系統編譯時間如果不指定
TARGET_BUILD_VARIANT 變數的值,預設 TARGET_BUILD_VARIANT=eng ,這一項指定 編譯android時形成的版本風格,一般發布時使用這個值,當然還有user,debuguser等風格值,具體看一下這個連結,如果打不開,翻個牆就可以。
這樣設定好以後,重新編譯,輸出目錄out/target/product/Ok6410/system/bin ,out/target/product/Ok6410/system/lib裡面就有tslib 相關的庫和測試程式了。
所以,如果自己需要加額外的模組,或者應用程式,一定要注意Android.mk裡面的這個變數,當然了,如果你指定了LOCAL_MODULE_TAGS :=optional,也能編譯出來,但是存放的輸入路徑就不是一般的
out/target/product/Ok6410/system/目錄了,而是out/target/product/OK6410/symbols/system/目錄。
後來自己在android原始碼的 external目錄下面放了一個模組,指定該模組的編譯風格為LOCAL_MODULE_TAGS :=optional,重新編譯,通過以後,竟然直接輸出到了out/target/product/Ok6410/system/ 目錄,很是驚訝,個人認為還跟模組存放的目錄有關.所以無論模組在哪個檔案夾下面,最好指定的值跟TARGET_BUILD_VARIANT 相關,如果沒指定TARGET_BUILD_VARIANT ,系統會預設設定TARGET_BUILD_VARIANT =eng,你也就指定LOCAL_MODULE_TAGS :=eng
目前自己遇到的 vendor目錄,hardware目錄下面的模組輸出路徑跟LOCAL_MODULE_TAGS 有很大的關係
LOCAL_MODULE_TAGS :=optional >> out/target/product/OK6410/symbols/system/
LOCAL_MODULE_TAGS :=eng >> out/target/product/Ok6410/system/
當然前提是TARGET_BUILD_VARIANT=eng .
下面是網友遇到的類似問題:
"Set LOCAL_MODULE_TAGS to any number of whitespace-separated tags.
This variable controls what build flavors the package gets included
in. For example:
* user: include this in user/userdebug builds
* eng: include this in eng builds
* tests: the target is a testing target and makes it available for tests
* optional: don't include this"
Are these the same as "variants" and if so, which name would affect
the build and how? I've noticed that everything mentioned in a
product's makefile will always get built. But what gets in the final
system.img not always the same as what gets built.
http://groups.google.com.tw/group/android-platform/browse_thread/thread/a4f70254a2ceb622