Merge "Sanitize APEX module name properly."
diff --git a/cc/compiler.go b/cc/compiler.go
index f504c38..c268dec 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -573,10 +573,12 @@
 	return compiler.useApexNameMacro()
 }
 
+var invalidDefineCharRegex = regexp.MustCompile("[^a-zA-Z0-9_]")
+
 // makeDefineString transforms a name of an APEX module into a value to be used as value for C define
 // For example, com.android.foo => COM_ANDROID_FOO
 func makeDefineString(name string) string {
-	return strings.ReplaceAll(strings.ToUpper(name), ".", "_")
+	return invalidDefineCharRegex.ReplaceAllString(strings.ToUpper(name), "_")
 }
 
 var gnuToCReplacer = strings.NewReplacer("gnu", "c")