最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

用于cocos2d-x引擎(ndk)中為android項目生成編譯文件列表

 更新時間:2014年05月05日 09:26:36   作者:  
在android的ndk項目中,添加很多源文件之后總要手動編寫makefile來添加所有的源文件, 很麻煩,所以寫了一個自動生成編譯源文件列表的小工具

 

復(fù)制代碼 代碼如下:

package com.leeass.generate;

import java.io.File;
import java.io.FileFilter;
import java.io.FileNotFoundException;

/**
 * 用于cocos2d-x引擎中android項目編譯文件列表生成
 * @author leeassamite
 *
 */
public class GenerateAndroidMakefile {
 /** 分隔符 */
 private static final String LINE_BREAK = System.getProperty("line.separator", "/n");
 /** classes文件夾 */
 private File classesDir = null;
 /** classes文件夾路徑 */
 private String classesPath = "";
 /** classes文件夾相對路徑 */
 private String classesRelativePath = "";
 /** 編譯文件過濾器 */
 private BuildFileFilter buildFileFilter = null;

 /**
  * 創(chuàng)建GenerateAndroidMakefile
  * @param classesAbsolutePath classes文件夾絕對路徑
  * @param classesRelativePath classes文件夾在編譯文件中的相對路徑
  * @throws Exception
  */
 public GenerateAndroidMakefile(String classesAbsolutePath,String classesRelativePath) throws Exception{
  if(classesRelativePath == null){
   throw new Exception("classes文件夾相對路徑錯誤,不能為NULL!");
  }
  if(classesAbsolutePath == null || "".equals(classesAbsolutePath)){
   throw new Exception("classes文件夾路徑輸入錯誤,不能為空!");
  }
  classesDir = new File(classesAbsolutePath);
  if((!classesDir.exists()) || (!classesDir.canRead()) || (!classesDir.isDirectory())){
   throw new FileNotFoundException("classes文件夾不可讀:"+classesDir.getAbsolutePath());
  }
  this.classesPath = classesAbsolutePath;
  this.classesPath = classesAbsolutePath.replaceAll("\\\\", "/");
  this.classesRelativePath = classesRelativePath;
  buildFileFilter = new BuildFileFilter();
 }

 /**
  * 輸出編譯文件列表
  */
 public void outputBuildFilesList(){
  StringBuilder buildFilesSb = new StringBuilder();
  outputBuildFileList(classesDir,buildFilesSb);
  System.out.println(buildFilesSb.toString());
 }
 private void outputBuildFileList(File buildfile,StringBuilder buildFilesSb){
  if(buildfile.isDirectory()){
   File[] files =buildfile.listFiles(buildFileFilter);
   for (File file : files) {
    outputBuildFileList(file,buildFilesSb);
   }
  }else{
   String buildfileStr = translateBuildFilePath(buildfile.getAbsolutePath()) + " \\";
   buildFilesSb.append(buildfileStr).append(LINE_BREAK);
  }
 }
 /**
  * 轉(zhuǎn)換編譯文件路徑
  * @param filepath
  * @return
  */
 private String translateBuildFilePath(String filepath){
  return filepath.replaceAll("\\\\", "/").replace(classesPath, classesRelativePath);
 }

 /**
  * @param args
  * @throws FileNotFoundException
  */
 public static void main(String[] args) throws Exception {
  String classesPath = "D:\\developer\\cocos2d-x-2.1.4\\projects\\hszg_ol\\Classes";
  String relativePath = "                   ../../Classes";
  GenerateAndroidMakefile gam = new GenerateAndroidMakefile(classesPath,relativePath);
  gam.outputBuildFilesList();
 }

 
 /**
  * 編譯文件過濾器
  * @author leeass
  *
  */
 class BuildFileFilter implements FileFilter{
  @Override
  public boolean accept(File pathname) {
   String name = pathname.getName().toLowerCase();
   return (!pathname.isHidden()) && (pathname.isDirectory() || name.endsWith(".c") || name.endsWith(".cpp"));
  }
 }

}



相關(guān)文章

最新評論

漳平市| 桑日县| 彰化县| 高州市| 南靖县| 佛学| 西藏| 安新县| 木里| 洛川县| 云龙县| 兴文县| 开封市| 洪泽县| 孟村| 遂平县| 沁水县| 仲巴县| 内乡县| 藁城市| 长沙县| 台南市| 夏津县| 永德县| 隆化县| 中方县| 云南省| 调兵山市| 洪湖市| 祁连县| 汉沽区| 沭阳县| 陆河县| 洪雅县| 庄浪县| 哈密市| 凉山| 高雄县| 普兰店市| 田东县| 上林县|