a亚洲精品_精品国产91乱码一区二区三区_亚洲精品在线免费观看视频_欧美日韩亚洲国产综合_久久久久久久久久久成人_在线区

首頁 > 系統 > Android > 正文

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

2020-04-11 11:50:30
字體:
來源:轉載
供稿:網友

 

復制代碼 代碼如下:

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;

 /**
  * 創建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("http:////", "/");
  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);
  }
 }
 /**
  * 轉換編譯文件路徑
  * @param filepath
  * @return
  */
 private String translateBuildFilePath(String filepath){
  return filepath.replaceAll("http:////", "/").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"));
  }
 }

}



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 久久精品国产99 | 国产免费久久 | hd国产人妖ts另类视频 | 中文精品久久久 | 国产黄色视| 漂亮少妇videoshd忠贞 | 美女诱惑av | 国产精品亚洲欧美日韩一区在线 | 久久久精品久久 | 欧州一区二区 | 欧美日韩国产一区 | 91精品久久| 国产乱精品一区二区三区视频了 | 国产韩国精品一区二区三区 | 狠狠操狠狠操 | 中文成人在线 | 亚洲国产精品18久久 | 男人天堂视频网 | 一级黄色爱爱视频 | 麻豆色呦呦 | 麻豆沈芯语在线观看 | 在线污污 | 特级黄一级播放 | 特级黄一级播放 | 99re视频在线观看 | 在线免费观看激情视频 | 欧美成人精品一区二区 | 国产一级免费在线观看 | 中文字幕在线观看2021 | 99精品电影 | 久久亚洲一区 | 黄色片在线免费观看 | 久久天堂 | 欧美在线网站 | 一区二区三区久久 | 精品欧美乱码久久久久久 | 美女天天操 | 国产日韩av在线 | 久久成人国产精品 | 欧美国产日本 | 欧美精品在线观看一区二区 |