Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Commit

Permalink
Add GAUZE_ANDROID_START_EMULATOR option
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslo committed Jan 28, 2019
1 parent 9b98cd8 commit 8805c4f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmake/gauze_add_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function(gauze_add_test)
set(TESTING_DIR "${GAUZE_ANDROID_DEVICE_TESTING_ROOT}/${PROJECT_NAME}/${toolchain_suffix}")

option(GAUZE_ANDROID_PUSH_QUIET "adb push quietly" OFF)
option(GAUZE_ANDROID_START_EMULATOR "Start Android emulator" ON)

if(GAUZE_ANDROID_USE_EMULATOR)
gauze_start_android_emulator()
Expand Down
20 changes: 18 additions & 2 deletions cmake/gauze_check_emulator_running.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,29 @@ function(gauze_check_emulator_running device_running_result)

string(REPLACE "\n" ";" output "${output}")
string(REPLACE "\t" " " output "${output}")

if(GAUZE_ANDROID_START_EMULATOR)
# We expect that emulator created by Gauze, with name 'emulator-*'
foreach(x ${output})
string(REGEX MATCH "^emulator-${GAUZE_DEVICE_PORT}[ ]+device$" match "${x}")
if(NOT "${match}" STREQUAL "")
set(${device_running_result} TRUE PARENT_SCOPE)
return()
endif()
endforeach()

set(${device_running_result} FALSE PARENT_SCOPE)
return()
endif()

# Emulator should be started by user
foreach(x ${output})
string(REGEX MATCH "^emulator-${GAUZE_DEVICE_PORT}[ ]+device$" match "${x}")
string(REGEX MATCH "[ ]+device$" match "${x}")
if(NOT "${match}" STREQUAL "")
set(${device_running_result} TRUE PARENT_SCOPE)
return()
endif()
endforeach()

set(${device_running_result} FALSE PARENT_SCOPE)
message(FATAL_ERROR "Device not found, command to verify: ${cmd}")
endfunction()

0 comments on commit 8805c4f

Please sign in to comment.