1. 程式人生 > >用NDK及scons編譯Platinum

用NDK及scons編譯Platinum

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!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
  1. ### figure out the host config  
  2. try:  
  3.     host_config = open(ANRDOID_NDK_OUT+'/host/config.mk')  
  4.     HOST_CONFIG={}  
  5.     for line in host_config.readlines():  
  6.         pair = re.split('\s+:=\s+', line);  
  7.         if len(pair) == 2:  
  8.             HOST_CONFIG[pair[0]] = pair[1].rstrip()  
  9.               
  10.     host_config.close()  
  11. except:  
  12.     platform_map = {'linux2':'linux-x86', 'darwin':'darwin-x86', 'cygwin':'windows'}  
  13.     if sys.platform not in platform_map:  
  14.         raise Exception('Unrecognized host platform')  
  15.     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檔案中進行。

           

給我老師的人工智慧教程打call!http://blog.csdn.net/jiangjunshow

這裡寫圖片描述