android开发分享用于cocos2d-x引擎(ndk)中为android项目生成编译文件列表

 复制代码 代码如下:package com.leeass.generate; import java.io.file;import java.io.filef

 

复制代码 代码如下:
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(“\\”, “/”);
  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(“\\”, “/”).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”));
  }
 }

}

用于cocos2d-x引擎(ndk)中为android项目生成编译文件列表

上述就是android开发分享用于cocos2d-x引擎(ndk)中为android项目生成编译文件列表的全部内容,如果对大家有所用处且需要了解更多关于Android学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/addevelopment/940198.html

(0)
上一篇 2021年11月13日
下一篇 2021年11月13日

精彩推荐