From c3177e0ffc9ab16e637300df30595b9ae1534ccc Mon Sep 17 00:00:00 2001 From: Tomasz Wasilczyk Date: Mon, 10 Jun 2024 14:38:45 -0700 Subject: [PATCH] Enable cmake testing Bug: 302718225 Test: atest binder_sdk_test Change-Id: Id841d73d11f3b0c75f7bcd523be8ff69300a503e --- cc/cmake_main.txt | 1 + cc/cmake_module_cc.txt | 15 ++++++++++++--- cc/cmake_snapshot.go | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/cc/cmake_main.txt b/cc/cmake_main.txt index deb1de1f8..e9177d6e2 100644 --- a/cc/cmake_main.txt +++ b/cc/cmake_main.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.18) project(<<.M.Name>> CXX) set(CMAKE_CXX_STANDARD 20) +enable_testing() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(AddAidlLibrary) diff --git a/cc/cmake_module_cc.txt b/cc/cmake_module_cc.txt index 488e5e102..693406d52 100644 --- a/cc/cmake_module_cc.txt +++ b/cc/cmake_module_cc.txt @@ -8,15 +8,24 @@ (getLinkerProperties .M).Header_libs (getExtraLibs .M) ) .Pprop.LibraryMapping>> +<<$moduleType := getModuleType .M>> +<<$moduleTypeCmake := "executable">> +<> +<<$moduleTypeCmake = "library">> +<> # <<.M.Name>> <> <> -add_<>(<<.M.Name>> ${<<.M.Name>>_SRCS}) +add_<<$moduleTypeCmake>>(<<.M.Name>> ${<<.M.Name>>_SRCS}) <<- else>> -add_<>(<<.M.Name>> INTERFACE) +add_<<$moduleTypeCmake>>(<<.M.Name>> INTERFACE) +<<- end>> +<<- if eq $moduleType "library">> +add_library(android::<<.M.Name>> ALIAS <<.M.Name>>) +<<- else if eq $moduleType "test">> +add_test(NAME <<.M.Name>> COMMAND <<.M.Name>>) <<- end>> -add_<>(android::<<.M.Name>> ALIAS <<.M.Name>>) <> <<- if $includeDirs>> diff --git a/cc/cmake_snapshot.go b/cc/cmake_snapshot.go index 9ac63504c..ad7beedab 100644 --- a/cc/cmake_snapshot.go +++ b/cc/cmake_snapshot.go @@ -488,9 +488,9 @@ func getModuleType(m *Module) string { case *libraryDecorator: return "library" case *testBinary: - return "executable" + return "test" case *benchmarkDecorator: - return "executable" + return "test" } panic(fmt.Sprintf("Unexpected module type: %T", m.linker)) }