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 2022/03/17 15:34:46 UTC

[mynewt-newt] branch master updated (0fddb7c -> 4d5eccd)

This is an automated email from the ASF dual-hosted git repository.

andk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git.


    from 0fddb7c  Create a shallow copy by default
     new 8655235  cmake: Fix trimming project path on Windows
     new 4d5eccd  cmake: Minor reformat

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 newt/builder/cmake.go | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

[mynewt-newt] 02/02: cmake: Minor reformat

Posted by an...@apache.org.
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

commit 4d5eccd759ffd1bd3d5fca2d60dfb9470657b362
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Thu Mar 17 14:55:54 2022 +0100

    cmake: Minor reformat
    
    GoLand keeps reformatting this over and over again.
---
 newt/builder/cmake.go | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/newt/builder/cmake.go b/newt/builder/cmake.go
index 61f7767..bb98010 100644
--- a/newt/builder/cmake.go
+++ b/newt/builder/cmake.go
@@ -141,7 +141,7 @@ func CmakeSourceObjectWrite(w io.Writer, cj toolchain.CompilerJob,
 	otherFlags = util.SortFields(otherFlags...)
 
 	fmt.Fprintf(w,
-`set_property(SOURCE %s APPEND_STRING
+		`set_property(SOURCE %s APPEND_STRING
              PROPERTY COMPILE_FLAGS
              "%s")`,
 		cj.Filename,
@@ -261,7 +261,7 @@ func (b *Builder) CMakeTargetWrite(w io.Writer, targetCompiler *toolchain.Compil
 	compileFlags = util.SortFields(compileFlags...)
 
 	fmt.Fprintf(w,
-`set_property(TARGET %s APPEND_STRING
+		`set_property(TARGET %s APPEND_STRING
              PROPERTY
              COMPILE_FLAGS
              "%s")`,
@@ -290,7 +290,7 @@ func (b *Builder) CMakeTargetWrite(w io.Writer, targetCompiler *toolchain.Compil
 	lFlags = append(lFlags, cxxFlags...)
 
 	fmt.Fprintf(w,
-`set_target_properties(%s
+		`set_target_properties(%s
                       PROPERTIES
                       ARCHIVE_OUTPUT_DIRECTORY %s
                       LIBRARY_OUTPUT_DIRECTORY %s
@@ -341,7 +341,7 @@ func CmakeCompilerInfoWrite(w io.Writer, archiveFile string, bpkg *BuildPackage,
 	replaceBackslashesSlice(includes)
 
 	fmt.Fprintf(w,
-`set_target_properties(%s
+		`set_target_properties(%s
                       PROPERTIES
                       ARCHIVE_OUTPUT_DIRECTORY %s
                       LIBRARY_OUTPUT_DIRECTORY %s

[mynewt-newt] 01/02: cmake: Fix trimming project path on Windows

Posted by an...@apache.org.
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

commit 8655235ef89cd4349f444eff1ed2d1a701b1f71c
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Thu Mar 17 13:59:06 2022 +0100

    cmake: Fix trimming project path on Windows
    
    strings.TrimPrefix does not work properly if path already uses
    backshasles as path separator, filepath.Rel will take care of that
    automatically.
    
    Also trimProjectPath should now replace backslashes internally to keep
    returned value consistent.
---
 newt/builder/cmake.go | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/newt/builder/cmake.go b/newt/builder/cmake.go
index 6e5767c..61f7767 100644
--- a/newt/builder/cmake.go
+++ b/newt/builder/cmake.go
@@ -88,8 +88,8 @@ func escapeFlagsSlice(flags []string) []string {
 
 func trimProjectPath(path string) string {
 	proj := interfaces.GetProject()
-	path = strings.TrimPrefix(path, proj.Path()+"/")
-	return path
+	path, _ = filepath.Rel(proj.Path(), path)
+	return replaceBackslashes(path)
 }
 
 func trimProjectPathSlice(elements []string) {
@@ -198,7 +198,7 @@ func (b *Builder) CMakeBuildPackageWrite(w io.Writer, bpkg *BuildPackage,
 	fmt.Fprintf(w, "add_library(%s %s)\n",
 		EscapePkgName(pkgName),
 		strings.Join(files, " "))
-	archivePath := replaceBackslashes(trimProjectPath(filepath.Dir(b.ArchivePath(bpkg))))
+	archivePath := trimProjectPath(filepath.Dir(b.ArchivePath(bpkg)))
 	CmakeCompilerInfoWrite(w, archivePath, bpkg, entries[0], otherIncludes)
 
 	return bpkg, nil
@@ -241,7 +241,7 @@ func (b *Builder) CMakeTargetWrite(w io.Writer, targetCompiler *toolchain.Compil
 			ExtractLibraryName(filename)))
 	}
 
-	elfOutputDir := replaceBackslashes(trimProjectPath(filepath.Dir(b.AppElfPath())))
+	elfOutputDir := trimProjectPath(filepath.Dir(b.AppElfPath()))
 	fmt.Fprintf(w, "file(WRITE %s \"\")\n", replaceBackslashes(filepath.Join(elfOutputDir, "null.c")))
 	fmt.Fprintf(w, "add_executable(%s %s)\n\n", elfName,
 		replaceBackslashes(filepath.Join(elfOutputDir, "null.c")))