diff options
Diffstat (limited to 'rust/androidmk.go')
-rw-r--r-- | rust/androidmk.go | 31 |
1 files changed, 1 insertions, 30 deletions
diff --git a/rust/androidmk.go b/rust/androidmk.go index c9056e1b4..107959f84 100644 --- a/rust/androidmk.go +++ b/rust/androidmk.go @@ -18,7 +18,6 @@ import ( "fmt" "io" "path/filepath" - "regexp" "strings" "android/soong/android" @@ -119,37 +118,9 @@ func (compiler *baseCompiler) AndroidMk(ctx AndroidMkContext, ret *android.Andro ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { path := compiler.path.RelPathString() dir, file := filepath.Split(path) - stem, suffix, _ := splitFileExt(file) + stem, suffix, _ := android.SplitFileExt(file) fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+suffix) fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir)) fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) }) } - -//TODO: splitFileExt copied from cc/util.go; move this to android/util.go and refactor usages. - -// splitFileExt splits a file name into root, suffix and ext. root stands for the file name without -// the file extension and the version number (e.g. "libexample"). suffix stands for the -// concatenation of the file extension and the version number (e.g. ".so.1.0"). ext stands for the -// file extension after the version numbers are trimmed (e.g. ".so"). -var shlibVersionPattern = regexp.MustCompile("(?:\\.\\d+(?:svn)?)+") - -func splitFileExt(name string) (string, string, string) { - // Extract and trim the shared lib version number if the file name ends with dot digits. - suffix := "" - matches := shlibVersionPattern.FindAllStringIndex(name, -1) - if len(matches) > 0 { - lastMatch := matches[len(matches)-1] - if lastMatch[1] == len(name) { - suffix = name[lastMatch[0]:lastMatch[1]] - name = name[0:lastMatch[0]] - } - } - - // Extract the file name root and the file extension. - ext := filepath.Ext(name) - root := strings.TrimSuffix(name, ext) - suffix = ext + suffix - - return root, suffix, ext -} |