android编译引擎,Android_用于cocos2d-x引擎(ndk)中为android项目生成编译文件列表, 复制代码 代码如下:package - phpStudy...

该博客介绍了一个Java类`GenerateAndroidMakefile`,其主要用于Cocos2d-x引擎中Android项目的编译文件列表生成。类中包含了处理classes目录、过滤编译文件和转换文件路径的方法,以输出符合特定格式的编译文件列表。通过示例代码展示了如何实例化并使用该类来输出classes文件夹下的编译文件列表。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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"));

}

}

}

LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_STATIC_JAVA_LIBRARIES := fmodjar include $(BUILD_PACKAGE) include $(CLEAR_VARS) LOCAL_MODULE := fmod LOCAL_SRC_FILES := $(LOCAL_PATH)/../../../fmod/api/lib/$(TARGET_ARCH_ABI)/libfmod.so LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../fmod/api/inc include $(PREBUILT_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := fmodL LOCAL_SRC_FILES := $(LOCAL_PATH)/../../../fmod/api/lib/$(TARGET_ARCH_ABI)/libfmodL.so LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../fmod/api/inc include $(PREBUILT_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := fmodjar:libs/fmod.jar include $(BUILD_MULTI_PREBUILT) include $(CLEAR_VARS) $(call import-add-path,$(LOCAL_PATH)/../../cocos2d) $(call import-add-path,$(LOCAL_PATH)/../../cocos2d/external) $(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos) LOCAL_MODULE := youme_voice_engine LOCAL_SRC_FILES := $(LOCAL_PATH)/../../../youme_voice_engine/lib/android/$(TARGET_ARCH_ABI)/libyoume_voice_engine.so include $(PREBUILT_SHARED_LIBRARY) cmd-strip = $(TOOLCHAIN_PREFIX)strip --strip-debug -x $1 LOCAL_CFLAGS += -fvisibility=hidden LOCAL_CPPFLAGS += -fvisibility=hidden LOCAL_MODULE := cocos2dcpp_shared LOCAL_MODULE_FILENAME := libcocos2dcpp FILE_LIST := hellocpp/main.cpp \ ../../Classes/AppDelegate.cpp \ ../../Classes/QuickSDKAndroid.cpp \ ../../Classes/YouMeVoiceEngineImp.cpp \ ../../Classes/QuickSDK.cpp FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/*/*.cpp) LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%) LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \ $(LOCAL_PATH)/../../cocos2d/libiconv/include \ $(LOCAL_PATH)/../../cocos2d/libiconv/libcharset \ $(LOCAL_PATH)/../../cocos2d/libiconv/lib \ $(LOCAL_PATH)/../../cocos2d/libiconv/libcharset/include \ $(LOCAL_PATH)/../../cocos2d/libiconv/srclib \ $(LOCAL_PATH)/../../cocos2d/libiconv \ $(LOCAL_PATH)/../../Classes \ $(LOCAL_PATH)/../../youme_voice_engine/include # _COCOS_HEADER_ANDROID_BEGIN # _COCOS_HEADER_ANDROID_END LOCAL_STATIC_LIBRARIES := cc_static LOCAL_STATIC_LIBRARIES += libiconv_static LOCAL_SHARED_LIBRARIES := fmodL LOCAL_SHARED_LIBRARIES += fmod LOCAL_SHARED_LIBRARIES += youme_voice_engine # _COCOS_LIB_ANDROID_BEGIN # _COCOS_LIB_ANDROID_END include $(BUILD_SHARED_LIBRARY) $(call import-module,.) $(call import-module,libiconv) # _COCOS_LIB_IMPORT_ANDROID_BEGIN # _COCOS_LIB_IMPORT_ANDROID_END C:\Users\Administrator\Desktop\client\proj.android\libs\arm64-v8a文件.so文件都在这个文件夹下啊。你看下路径是否正确?
07-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值