如何一步步将Android.mk 转变成Cmkelist.txt

前言:研究别人代码,发现google现在推荐并在Android Studio 支持cmkelist 放弃mk方式。比较蛋疼,但是也是学习的一个方式。一步步积累如何使用Cmakelist

对比

  • LOCAL_MODULE,LOCAL_SRC_FILES
    mk 写法,整个mk文件我拆分两部分,主要是为了学习写法
    前部分
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := KRoom
LOCAL_SRC_FILES := KRoom.cpp \
                   ./manager/JniManager.cpp \
                   ./manager/AVMediaPlayer.cpp \
                   ./manager/AudioManager.cpp \
                   ./manager/VideoManager.cpp \
                   ./opengl/NativeRender.cpp \
                   ./common/Buffer.cpp \
                   ./common/Mutex.cpp \
                   ./common/Frame.cpp \
                   ./common/FrameMap.cpp \
                   ./common/FrameList.cpp \
                   ./common/FrameSub.cpp \
                   ./common/FrameSubMap.cpp \
                   ./common/util.cpp \
                   ./stream/StreamDecoder.cpp \
                   ./stream/StreamPlayer.cpp    \
                   ./vedio/VideoDecoder.cpp   \
                   ./shellmp4/FileControl.cpp   \
                   ./shellmp4/HttpShellInterface.cpp    \
                   ./shellmp4/MakeAACHead.cpp   \
                   ./shellmp4/MP4Control.cpp    \
                   ./shellmp4/MP4Handler.cpp    \
                   ./shellmp4/ShellMain.cpp \
                   ./shellmp4/ShellMp4.cpp  \
                   ./shellmp4/GetData.cpp   \
                   check.c \
                   md5.c

后部分

LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog 
# for native audio
LOCAL_LDLIBS    += -lOpenSLES
# for native bitmap
LOCAL_LDLIBS    += -ljnigraphics
# for native opengl es v2
LOCAL_LDLIBS    += -lGLESv2
# for native opengl es v1
LOCAL_LDLIBS    += -lGLESv1_CM
# for native asset manager
LOCAL_LDLIBS    += -landroid
LOCAL_CFLAGS += -g
LOCAL_STATIC_LIBRARIES  := avcodec avutil x264 macdecoder reverb 
#LOCAL_STATIC_LIBRARIES     := faad2 faac avcodec avutil x264 macdecoder reverb 
LOCAL_SHARED_LIBRARIES := decoding

LOCAL_C_INCLUDES := \
        $(LOCAL_PATH)/ffmpeg/   \
        $(LOCAL_PATH)/shellmp4/
        
include $(BUILD_SHARED_LIBRARY)

转换成cmakelist写法超级简单

add_library( # Sets the name of the library.
             KRoom

             # Sets the library as a shared library.
             SHARED

             # Provides a relative path to your source file(s).
             ./main/cpp/kroom/KRoom.cpp
             ./main/cpp/kroom/manager/JniManager.cpp
             ./main/cpp/kroom/manager/AVMediaPlayer.cpp
             ./main/cpp/kroom/manager/AudioManager.cpp
             ./main/cpp/kroom/manager/VideoManager.cpp
             ./main/cpp/kroom/opengl/NativeRender.cpp
             ./main/cpp/kroom/common/Buffer.cpp
             ./main/cpp/kroom/common/Mutex.cpp
             ./main/cpp/kroom/common/Frame.cpp
             ./main/cpp/kroom/common/FrameMap.cpp
             ./main/cpp/kroom/common/FrameList.cpp
             ./main/cpp/kroom/common/FrameSub.cpp
             ./main/cpp/kroom/common/FrameSubMap.cpp
             ./main/cpp/kroom/common/util.cpp
             ./main/cpp/kroom/stream/StreamDecoder.cpp
             ./main/cpp/kroom/stream/StreamPlayer.cpp
             ./main/cpp/kroom/vedio/VideoDecoder.cpp
             ./main/cpp/kroom/shellmp4/FileControl.cpp
             ./main/cpp/kroom/shellmp4/HttpShellInterface.cpp
             ./main/cpp/kroom/shellmp4/MakeAACHead.cpp
             ./main/cpp/kroom/shellmp4/MP4Control.cpp
             ./main/cpp/kroom/shellmp4/MP4Handler.cpp
             ./main/cpp/kroom/shellmp4/ShellMain.cpp
             ./main/cpp/kroom/shellmp4/ShellMp4.cpp
             ./main/cpp/kroom/shellmp4/GetData.cpp
             ./main/cpp/kroom/check.c
             ./main/cpp/kroom/md5.c )

你可能感兴趣的:(如何一步步将Android.mk 转变成Cmkelist.txt)