Fix PDK dupbuild issues

The PDK uses pattern rules in order to install files from the PDK. When
those files already have build rules, the explicit rules override the
pattern rules, and everything works. But because Make (and Kati) doesn't
attempt to clean the file paths, if one of the rules has a redundant /,
we'll export two ninja rules, and ninja will error out with a dupbuild
error.

The PDK pattern rules are clean, but the explicit notice file creation
was not, it was always adding a double // in between NOTICE_FILES/src
and the module path.

Some modules were also setting a LOCAL_MODULE_PATH with a trailing /,
which is redundant, and also hits the above problem. Instead of fixing
all of the modules, just strip a trailing / from my_module_path.

Bug: 33451638
Test: Build with a PDK
Change-Id: Iff3e98fd191ea90626b9b89f179537e8a75f5ef2
diff --git a/core/base_rules.mk b/core/base_rules.mk
index e9d9c33..e89917e 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -161,6 +161,7 @@
 else
 my_module_path := $(strip $(LOCAL_MODULE_PATH))
 endif
+my_module_path := $(patsubst %/,%,$(my_module_path))
 my_module_relative_path := $(strip $(LOCAL_MODULE_RELATIVE_PATH))
 ifeq ($(my_module_path),)
   ifdef LOCAL_IS_HOST_MODULE
diff --git a/core/notice_files.mk b/core/notice_files.mk
index f0013c2..8a0ae6f 100644
--- a/core/notice_files.mk
+++ b/core/notice_files.mk
@@ -33,7 +33,7 @@
 # compliance.
 # Includes the leading slash
 ifdef LOCAL_INSTALLED_MODULE
-  module_installed_filename := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
+  module_installed_filename := $(patsubst $(PRODUCT_OUT)/%,%,$(LOCAL_INSTALLED_MODULE))
 else
   # This module isn't installable
   ifeq ($(LOCAL_MODULE_CLASS),STATIC_LIBRARIES)
@@ -41,7 +41,7 @@
     # We can't use xxx_OUT_STATIC_LIBRARIES because it points into
     # device-obj or host-obj.
     module_installed_filename := \
-        $(patsubst $(PRODUCT_OUT)%,%,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE))
+        $(patsubst $(PRODUCT_OUT)/%,%,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE))
   else
     ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
       # Stick the static java libraries with the regular java libraries.
@@ -53,7 +53,7 @@
         module_leaf := $(LOCAL_MODULE).jar
       endif
       module_installed_filename := \
-          $(patsubst $(PRODUCT_OUT)%,%,$($(my_prefix)OUT_JAVA_LIBRARIES))/$(module_leaf)
+          $(patsubst $(PRODUCT_OUT)/%,%,$($(my_prefix)OUT_JAVA_LIBRARIES))/$(module_leaf)
     else
       $(error Cannot determine where to install NOTICE file for $(LOCAL_MODULE))
     endif # JAVA_LIBRARIES
@@ -61,8 +61,8 @@
 endif
 
 # In case it's actually a host file
-module_installed_filename := $(patsubst $(HOST_OUT)%,%,$(module_installed_filename))
-module_installed_filename := $(patsubst $(HOST_CROSS_OUT)%,%,$(module_installed_filename))
+module_installed_filename := $(patsubst $(HOST_OUT)/%,%,$(module_installed_filename))
+module_installed_filename := $(patsubst $(HOST_CROSS_OUT)/%,%,$(module_installed_filename))
 
 installed_notice_file := $($(my_prefix)OUT_NOTICE_FILES)/src/$(module_installed_filename).txt