国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > 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"));
  }
 }

}



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 琼结县| 青海省| 金门县| 民丰县| 孟州市| 望江县| 喀喇沁旗| 安仁县| 旌德县| 游戏| 孟津县| 蒙阴县| 巩义市| 榆树市| 木兰县| 焉耆| 民权县| 麻阳| 浦东新区| 隆回县| 丰都县| 河间市| 迁安市| 界首市| 靖宇县| 阳高县| 华容县| 武安市| 栾川县| 陵川县| 隆林| 和平县| 芦山县| 达日县| 武强县| 南丹县| 铅山县| 乾安县| 辽宁省| 孟州市| 梅州市|