用于cocos2d-x引擎(ndk)中為android項(xiàng)目生成編譯文件列表
package com.leeass.generate;
import java.io.File;
import java.io.FileFilter;
import java.io.FileNotFoundException;
/**
* 用于cocos2d-x引擎中android項(xiàng)目編譯文件列表生成
* @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文件夾相對(duì)路徑 */
private String classesRelativePath = "";
/** 編譯文件過(guò)濾器 */
private BuildFileFilter buildFileFilter = null;
/**
* 創(chuàng)建GenerateAndroidMakefile
* @param classesAbsolutePath classes文件夾絕對(duì)路徑
* @param classesRelativePath classes文件夾在編譯文件中的相對(duì)路徑
* @throws Exception
*/
public GenerateAndroidMakefile(String classesAbsolutePath,String classesRelativePath) throws Exception{
if(classesRelativePath == null){
throw new Exception("classes文件夾相對(duì)路徑錯(cuò)誤,不能為NULL!");
}
if(classesAbsolutePath == null || "".equals(classesAbsolutePath)){
throw new Exception("classes文件夾路徑輸入錯(cuò)誤,不能為空!");
}
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();
}
/**
* 編譯文件過(guò)濾器
* @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)文章
Android自定義指示器時(shí)間軸效果實(shí)例代碼詳解
指示器時(shí)間軸在外賣(mài)、購(gòu)物類(lèi)的APP里會(huì)經(jīng)常用到,效果大家都知道的差不多吧,下面小編通過(guò)實(shí)例代碼給大家分享Android自定義指示器時(shí)間軸效果,需要的朋友參考下吧2017-12-12Android RippleDrawable 水波紋/漣漪效果的實(shí)現(xiàn)
這篇文章主要介紹了Android RippleDrawable 水波紋/漣漪效果的實(shí)現(xiàn),小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-08-08Android使用ftp方式實(shí)現(xiàn)文件上傳和下載功能
這篇文章主要介紹了Android使用ftp方式實(shí)現(xiàn)文件上傳和下載功能,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-06-068種android 對(duì)話框(Dialog)使用方法詳解
這篇文章主要介紹了8種android 對(duì)話框(Dialog)使用方法。感興趣的朋友可以參考一下2016-03-03Android 狀態(tài)欄虛擬導(dǎo)航鍵透明效果的實(shí)現(xiàn)方法
這篇文章主要介紹了Android 狀態(tài)欄虛擬導(dǎo)航鍵透明效果的實(shí)現(xiàn)方法,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-03-03OpenHarmony實(shí)現(xiàn)屏幕亮度動(dòng)態(tài)調(diào)節(jié)方法詳解
大家在拿到dayu之后,都吐槽說(shuō),會(huì)經(jīng)常熄屏,不利于調(diào)試,那么有沒(méi)有一種辦法,可以讓app不熄屏呢,答案是有的,今天我們就來(lái)揭秘一下,如何控制屏幕亮度2022-11-11android studio集成unity導(dǎo)出工程的實(shí)現(xiàn)
本文主要介紹了android studio集成unity導(dǎo)出工程的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-05-05Android開(kāi)發(fā)中畫(huà)廊視圖Gallery的兩種使用方法分析
這篇文章主要介紹了Android開(kāi)發(fā)中畫(huà)廊視圖Gallery的兩種使用方法,結(jié)合實(shí)例形式分析了Android畫(huà)廊視圖Gallery的簡(jiǎn)單布局與功能實(shí)現(xiàn)相關(guān)操作技巧,需要的朋友可以參考下2018-01-01Android實(shí)現(xiàn)注冊(cè)頁(yè)面(攜帶數(shù)據(jù)包跳轉(zhuǎn))
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)注冊(cè)頁(yè)面,點(diǎn)擊注冊(cè)按鈕跳轉(zhuǎn)到另一個(gè)頁(yè)面并顯示輸入信息,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-04-04