From 8fe13b971fe3ceff9e1fcbb9089e417dbeb17366 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Fri, 4 May 2018 19:05:02 -0700 Subject: Fix androidmk converting cc libraries The java library rewrites should only happen for java modules, not cc modules. Bug: 79272000 Test: Ran androidmk on a number of Android.mk files Change-Id: Ife2cfb5a69d7db37216671f08317033b99fcd3a1 Merged-In: Ife2cfb5a69d7db37216671f08317033b99fcd3a1 (cherry picked from commit 75dec2291b73995ca4d4ddb1b828dfce7f959043) --- androidmk/cmd/androidmk/androidmk_test.go | 13 +++++++++++++ bpfix/bpfix/bpfix.go | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/androidmk/cmd/androidmk/androidmk_test.go b/androidmk/cmd/androidmk/androidmk_test.go index edf3d42f..37e2427c 100644 --- a/androidmk/cmd/androidmk/androidmk_test.go +++ b/androidmk/cmd/androidmk/androidmk_test.go @@ -576,6 +576,19 @@ include $(call all-makefiles-under,$(LOCAL_PATH)) } `, }, + { + desc: "cc_library shared_libs", + in: ` + include $(CLEAR_VARS) + LOCAL_SHARED_LIBRARIES := libfoo + include $(BUILD_SHARED_LIBRARY) + `, + expected: ` + cc_library_shared { + shared_libs: ["libfoo"], + } + `, + }, } func TestEndToEnd(t *testing.T) { diff --git a/bpfix/bpfix/bpfix.go b/bpfix/bpfix/bpfix.go index e4d4e34e..d5c318c5 100644 --- a/bpfix/bpfix/bpfix.go +++ b/bpfix/bpfix/bpfix.go @@ -22,6 +22,7 @@ import ( "fmt" "io" "path/filepath" + "strings" "github.com/google/blueprint/parser" ) @@ -220,6 +221,10 @@ func (f *Fixer) rewriteIncorrectAndroidmkAndroidLibraries() error { continue } + if !strings.HasPrefix(mod.Type, "java_") && !strings.HasPrefix(mod.Type, "android_") { + continue + } + hasAndroidLibraries := hasNonEmptyLiteralListProperty(mod, "android_libs") hasStaticAndroidLibraries := hasNonEmptyLiteralListProperty(mod, "android_static_libs") hasResourceDirs := hasNonEmptyLiteralListProperty(mod, "resource_dirs") -- cgit v1.2.3