You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2021/08/27 08:46:58 UTC
[mynewt-newt] branch master updated: cmake: Fix handling of
packages in multiple repos
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git
The following commit(s) were added to refs/heads/master by this push:
new 9306bee cmake: Fix handling of packages in multiple repos
9306bee is described below
commit 9306bee8450f29f5472f546bf39337afe76583aa
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Wed May 19 13:47:26 2021 +0200
cmake: Fix handling of packages in multiple repos
We should better use package name with repo when creating library names
to avoid duplicates when the same package exists in multiple repos.
---
newt/builder/cmake.go | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/newt/builder/cmake.go b/newt/builder/cmake.go
index 7b4e0b3..6e5767c 100644
--- a/newt/builder/cmake.go
+++ b/newt/builder/cmake.go
@@ -44,8 +44,12 @@ func CmakeListsPath() string {
return project.GetProject().BasePath + "/" + CMAKELISTS_FILENAME
}
-func EscapeName(name string) string {
- return strings.Replace(name, "/", "_", -1)
+func EscapePkgName(name string) string {
+ name = strings.Replace(name, "/", "_", -1)
+ if strings.HasPrefix(name, "@") {
+ name = strings.Replace(name, "@", "repos_", 1)
+ }
+ return name
}
func ExtractLibraryName(filepath string) string {
@@ -187,12 +191,12 @@ func (b *Builder) CMakeBuildPackageWrite(w io.Writer, bpkg *BuildPackage,
return nil, nil
}
- pkgName := bpkg.rpkg.Lpkg.Name()
+ pkgName := bpkg.rpkg.Lpkg.NameWithRepo()
util.StatusMessage(util.VERBOSITY_DEFAULT, "Generating CMakeLists.txt for %s\n", pkgName)
fmt.Fprintf(w, "\n# Generating CMakeLists.txt for %s\n", pkgName)
fmt.Fprintf(w, "add_library(%s %s)\n",
- EscapeName(pkgName),
+ EscapePkgName(pkgName),
strings.Join(files, " "))
archivePath := replaceBackslashes(trimProjectPath(filepath.Dir(b.ArchivePath(bpkg))))
CmakeCompilerInfoWrite(w, archivePath, bpkg, entries[0], otherIncludes)
@@ -229,7 +233,7 @@ func (b *Builder) CMakeTargetWrite(w io.Writer, targetCompiler *toolchain.Compil
for _, bpkg := range builtPackages {
targetObjectsBuffer.WriteString(fmt.Sprintf("%s ",
- EscapeName(bpkg.rpkg.Lpkg.Name())))
+ EscapePkgName(bpkg.rpkg.Lpkg.NameWithRepo())))
}
for _, filename := range libraries {
@@ -342,14 +346,14 @@ func CmakeCompilerInfoWrite(w io.Writer, archiveFile string, bpkg *BuildPackage,
ARCHIVE_OUTPUT_DIRECTORY %s
LIBRARY_OUTPUT_DIRECTORY %s
RUNTIME_OUTPUT_DIRECTORY %s)`,
- EscapeName(bpkg.rpkg.Lpkg.Name()),
+ EscapePkgName(bpkg.rpkg.Lpkg.NameWithRepo()),
archiveFile,
archiveFile,
archiveFile,
)
fmt.Fprintln(w)
fmt.Fprintf(w, "target_include_directories(%s PUBLIC %s)\n\n",
- EscapeName(bpkg.rpkg.Lpkg.Name()),
+ EscapePkgName(bpkg.rpkg.Lpkg.NameWithRepo()),
strings.Join(includes, " "))
}