Android makefiles: How to “early return”?

只谈情不闲聊 提交于 2019-12-25 08:12:33

问题


I'm building a bucnh of libraries using ndk-build. At some point, a mk file could be included twice, as it imports 3rd party libraries, I protected double-import using a global variable:

# Importing nlopt!
# Prevent warnings reporting module was imported twice:
ifneq ($(imported_nlopt_$(TARGET_ARCH_ABI)),true)
    imported_nlopt_$(TARGET_ARCH_ABI) := true
    ifeq ($(APP_OPTIM),debug)
        # Importing static library nlopt_debug:
            include $(CLEAR_VARS)
            LOCAL_MODULE    := nlopt_debug
            LOCAL_SRC_FILES := nlopt/nlopt-2.4.2/lib/$(PLATFORM)/$(COMPILER)/Debug/$(LIB_PREFIX)nlopt$(DEBUG_INFIX)$(DYNAMIC_LINK_EXT)
            include $(PREBUILT_SHARED_LIBRARY)
    else
        # Importing static library nlopt_release:
            include $(CLEAR_VARS)
            LOCAL_MODULE    := nlopt_release
            LOCAL_SRC_FILES := nlopt/nlopt-2.4.2/lib/$(PLATFORM)/$(COMPILER)/Release/$(LIB_PREFIX)nlopt$(DYNAMIC_LINK_EXT)
            include $(PREBUILT_SHARED_LIBRARY)
    endif
else
    $(info "NLOPT already imported!")
endif

I need to do this in many place and it starts anoying me to have the whole file being in an if statement.

Are "early returns" supported in makefiles? Could I do something like:

ifeq ($(imported_nlopt_$(TARGET_ARCH_ABI)),true)
    return
endif

imported_nlopt_$(TARGET_ARCH_ABI) := true
...

return is not recognized when I execute this.


回答1:


Luckily in Android.mk it is enough to protect only the statement include $(BUILD_SHARED_LIBRARY), etc



来源:https://stackoverflow.com/questions/40173692/android-makefiles-how-to-early-return

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!