From d90a33b850d825c3047fd570478fc8a66f22414f Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 11 Feb 2018 01:48:53 +0100 Subject: [PATCH] Some reviews for Android compilation --- src/Makefile | 14 ++++++++++---- src/core.c | 4 ++-- templates/advance_game/Makefile.Android | 22 ++++------------------ 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/Makefile b/src/Makefile index e41a88a3a..6752d9e7b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -262,15 +262,20 @@ endif # -Wno-missing-braces ignore invalid warning (GCC bug 53119) # -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec # -Werror=pointer-arith catch unportable code that does direct arithmetic on void pointers -# -Werror=implicit-function-declaration catch function calls without prior declaration -CFLAGS += -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -Werror=pointer-arith -Werror=implicit-function-declaration +CFLAGS += -O1 -Wall -std=c99 -D_DEFAULT_SOURCE -fgnu89-inline -Wno-missing-braces -Werror=pointer-arith ifeq ($(RAYLIB_BUILD_MODE), DEBUG) CFLAGS += -g endif # Additional flags for compiler (if desired) -#CFLAGS += -Wextra -Wmissing-prototypes -Wstrict-prototypes +# -Wextra enables some extra warning flags that are not enabled by -Wall +# -Wmissing-prototypes warn if a global function is defined without a previous prototype declaration +# -Wstrict-prototypes warn if a function is declared or defined without specifying the argument types +# -Werror=implicit-function-declaration catch function calls without prior declaration +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + CFLAGS += -Werror=implicit-function-declaration +endif ifeq ($(PLATFORM),PLATFORM_WEB) # -O2 # if used, also set --memory-init-file 0 # --memory-init-file 0 # to avoid an external memory initialization code file (.mem) @@ -285,7 +290,8 @@ ifeq ($(PLATFORM),PLATFORM_ANDROID) # Compilation functions attributes options CFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC # Compiler options for the linker - CFLAGS += -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes + # -Werror=format-security + CFLAGS += -Wa,--noexecstack -Wformat -no-canonical-prefixes # Preprocessor macro definitions CFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=16 endif diff --git a/src/core.c b/src/core.c index d6a109431..ce017af2a 100644 --- a/src/core.c +++ b/src/core.c @@ -294,11 +294,11 @@ static int renderOffsetX = 0; // Offset X from render area (must b static int renderOffsetY = 0; // Offset Y from render area (must be divided by 2) static bool fullscreen = false; // Fullscreen mode (useful only for PLATFORM_DESKTOP) static Matrix downscaleView; // Matrix to downscale view (in case screen size bigger than display size) +static bool cursorHidden = false; // Track if cursor is hidden +static bool cursorOnScreen = false; // Tracks if cursor is inside client area #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB) || defined(PLATFORM_UWP) static const char *windowTitle = NULL; // Window text title... -static bool cursorHidden = false; // Track if cursor is hidden -static bool cursorOnScreen = false; // Tracks if cursor is inside client area static int screenshotCounter = 0; // Screenshots counter // Register mouse states diff --git a/templates/advance_game/Makefile.Android b/templates/advance_game/Makefile.Android index 2fda53721..f082ab230 100644 --- a/templates/advance_game/Makefile.Android +++ b/templates/advance_game/Makefile.Android @@ -53,26 +53,21 @@ APP_COMPANY_NAME ?= raylib APP_PRODUCT_NAME ?= rgame APP_VERSION_CODE ?= 1 APP_VERSION_NAME ?= 1.0 -APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\logo36x36.png -APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\logo48x48.png -APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\logo72x72.png +APP_ICON_LDPI ?= $(RAYLIB_PATH)\logo\raylib_36x36.png +APP_ICON_MDPI ?= $(RAYLIB_PATH)\logo\raylib_48x48.png +APP_ICON_HDPI ?= $(RAYLIB_PATH)\logo\raylib_72x72.png APP_SCREEN_ORIENTATION ?= landscape APP_KEYSTORE_PASS ?= raylib -# Library type used for raylib and OpenAL Soft: STATIC (.a) or SHARED (.so/.dll) +# Library type used for raylib: STATIC (.a) or SHARED (.so/.dll) RAYLIB_LIBTYPE ?= STATIC -OPENAL_LIBTYPE ?= STATIC RAYLIB_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a -OPENAL_LIB_PATH = $(RAYLIB_PATH)\release\libs\android\armeabi-v7a # Shared libs must be added to APK if required # NOTE: Generated NativeLoader.java automatically load those libraries ifeq ($(RAYLIB_LIBTYPE),SHARED) PROJECT_SHARED_LIBS = lib/armeabi-v7a/libraylib.so endif -ifeq ($(OPENAL_LIBTYPE),SHARED) - PROJECT_SHARED_LIBS += lib/armeabi-v7a/libopenal.so -endif # Compiler and archiver # NOTE: GCC is being deprectated in Android NDK r16 @@ -154,15 +149,9 @@ copy_project_required_libs: ifeq ($(RAYLIB_LIBTYPE),SHARED) copy /Y $(RAYLIB_LIB_PATH)\libraylib.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.so endif -ifeq ($(OPENAL_LIBTYPE),SHARED) - copy /Y $(OPENAL_LIB_PATH)\libopenal.so $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libopenal.so -endif ifeq ($(RAYLIB_LIBTYPE),STATIC) copy /Y $(RAYLIB_LIB_PATH)\libraylib.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libraylib.a endif -ifeq ($(OPENAL_LIBTYPE),STATIC) - copy /Y $(OPENAL_LIB_PATH)\libopenal.a $(PROJECT_BUILD_PATH)\lib\armeabi-v7a\libopenal.a -endif # Copy project required resources: strings.xml, icon.png, assets # NOTE: Required strings.xml is generated and game resources are copied to assets folder @@ -182,9 +171,6 @@ generate_loader_script: @echo. >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java @echo public class NativeLoader extends android.app.NativeActivity { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java @echo static { >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java -ifeq ($(OPENAL_LIBTYPE),SHARED) - @echo System.loadLibrary("openal"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java -endif ifeq ($(RAYLIB_LIBTYPE),SHARED) @echo System.loadLibrary("raylib"); >> $(PROJECT_BUILD_PATH)/src/com/$(APP_COMPANY_NAME)/$(APP_PRODUCT_NAME)/NativeLoader.java endif