用NDK及scons編譯Platinum
阿新 • • 發佈:2019-01-10
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow
也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!
版本:Platinum-f4d639, android-ndk-r6
拿到Platinum和ndk的原始碼後,需要針對Config.scons,Build.scons, Boot.scons等檔案做一些修改&補充工作,才能開展開發工作。
(1)配置環境變數(ndk路徑)
export ANDROID_NDK_ROOT=/home/bao/dlna/android-ndk-r6b
ANDROID_NDK_ROOT這個環境變數在 Build/Target/arm-android-linux/Config.scons配置檔案中會用到。
(2) 在ndk根目錄下新增一個檔案$ ANDROID_NDK_ROOT/out/config.mk,檔案內容如下:
HOST_TAG := linux-x86
這個檔案是為了對應Config.scons中的內容:
[html] view plain copy
- ### figure out the host config
- try:
- host_config = open(ANRDOID_NDK_OUT+'/host/config.mk')
- HOST_CONFIG={}
- for line in host_config.readlines():
- pair = re.split('\s+:=\s+', line);
- if len(pair) == 2:
- HOST_CONFIG[pair[0]] = pair[1].rstrip()
- host_config.close()
- except:
- platform_map = {'linux2':'linux-x86', 'darwin':'darwin-x86', 'cygwin':'windows'}
- if sys.platform not in platform_map:
- raise Exception('Unrecognized host platform')
- HOST_CONFIG={'HOST_TAG':platform_map[sys.platform]}
(3)apt-get install安裝scons後,Build/Boot.scons 檔案中修改target:
options = Variables()options.AddVariables( EnumVariable('target', 'build target', 'arm-android-linux', allowed_values=['arm-android-linux']), BoolVariable('stop_on_warning', 'Stop the build on warnings', False), ListVariable('build_config', 'build configurations', 'Release', names=['Debug', 'Release']))
然後到Platinum根目錄下執行scons,即可開始編譯工作。(4)檢視生成的庫和檔案
根據上一步的配置編譯之後,生成的庫和檔案在目錄Build/Target/arm-android-linux/Release下。
今後在開發工作中,專案目錄的配置選項都在Build/Build.scons檔案中進行。