iis服务器助手广告广告
返回顶部
首页 > 资讯 > 移动开发 >用于cocos2d-x引擎(ndk)中为android项目生成编译文件列表
  • 243
分享到

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

cocos2dcocos列表ndkcocos2d-xAndroid 2022-06-06 10:06:18 243人浏览 薄情痞子
摘要

  代码如下:package com.leeass.generate; import java.io.File;import java.io.FileFilter;i

  代码如下:
package com.leeass.generate;

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


public class GenerateAndroidMakefile {
 
 private static final String LINE_BREAK = System.getProperty("line.separator", "/n");
 
 private File classesDir = null;
 
 private String classesPath = "";
 
 private String classesRelativePath = "";
 
 private BuildFileFilter buildFileFilter = null;
 
 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);
  }
 }
 
 private String translateBuildFilePath(String filepath){
  return filepath.replaceAll("\\\\", "/").replace(classesPath, classesRelativePath);
 }
 
 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();
 }
 
 
 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"));
  }
 }

}

您可能感兴趣的文章:Android NDK开发详细介绍Android NDK 生成以及调用so 文件Android NDK 开发教程Android开发的IDE、ADT、SDK、jdk、NDK等名词解释Android提高之使用NDK把彩图转换灰度图的方法Android NDK中Socket的用法以及注意事项分析Android NDK开发之:配置环境的详解Android NDK开发的环境搭建与简单示例


--结束END--

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

本文链接: https://www.lsjlt.com/news/27118.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作