Skip to content

Commit 3f72bf7

Browse files
authored
Use forward slash as separator after path relativize
1 parent da3c215 commit 3f72bf7

File tree

6 files changed

+30
-4
lines changed

6 files changed

+30
-4
lines changed

pkg/maker/contextlists.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ import (
1515
"golang.org/x/exp/maps"
1616
)
1717

18-
func (m *Maker) CreateContextCMakeLists(index int, cbuild Cbuild) error {
19-
18+
func (m *Maker) CreateContextCMakeLists(index int) error {
19+
cbuild := &m.Cbuilds[index]
2020
outputByProducts, outputFile, outputType, customCommands := OutputFiles(cbuild.BuildDescType.Output)
2121
outputExt := path.Ext(outputFile)
2222
outputName := strings.TrimSuffix(outputFile, outputExt)
2323
cbuild.ContextRoot, _ = filepath.Rel(m.CbuildIndex.BaseDir, cbuild.BaseDir)
24+
cbuild.ContextRoot = filepath.ToSlash(cbuild.ContextRoot)
2425
cbuild.Toolchain = m.RegisteredToolchains[m.SelectedToolchainVersion[index]].Name
2526
outDir := AddRootPrefix(cbuild.ContextRoot, cbuild.BuildDescType.OutputDirs.Outdir)
2627
contextDir := path.Join(m.SolutionIntDir, cbuild.BuildDescType.Context)

pkg/maker/maker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (m *Maker) GenerateCMakeLists() error {
7373

7474
// Create context specific CMake files
7575
for index := range m.Cbuilds {
76-
err = m.CreateContextCMakeLists(index, m.Cbuilds[index])
76+
err = m.CreateContextCMakeLists(index)
7777
if err != nil {
7878
return err
7979
}

pkg/maker/maker_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,24 @@ func init() {
2222

2323
func TestMaker(t *testing.T) {
2424
assert := assert.New(t)
25-
var m maker.Maker
2625

2726
t.Run("test maker", func(t *testing.T) {
27+
var m maker.Maker
2828
m.Params.InputFile = testRoot + "/run/generic/solutionName1.cbuild-idx.yml"
2929
err := m.GenerateCMakeLists()
3030
assert.Nil(err)
3131
})
3232

33+
t.Run("test maker with cbuild in subfolder", func(t *testing.T) {
34+
var m maker.Maker
35+
m.Params.InputFile = testRoot + "/run/generic/solutionName4.cbuild-idx.yml"
36+
err := m.GenerateCMakeLists()
37+
assert.Nil(err)
38+
assert.Equal("project/subfolder", m.Cbuilds[0].ContextRoot)
39+
})
40+
3341
t.Run("test maker with invalid input param", func(t *testing.T) {
42+
var m maker.Maker
3443
m.Params.InputFile = testRoot + "invalid.cbuild-idx.yml"
3544
err := m.GenerateCMakeLists()
3645
assert.Error(err)

pkg/maker/superlists.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func (m *Maker) CreateSuperCMakeLists() error {
3333
}
3434
}
3535
cbuildRelativePath, _ := filepath.Rel(m.CbuildIndex.BaseDir, cbuild.BaseDir)
36+
cbuildRelativePath = filepath.ToSlash(cbuildRelativePath)
3637
output := AddRootPrefix(cbuildRelativePath, path.Join(cbuild.BuildDescType.OutputDirs.Outdir, outputFile))
3738
outputs += " \"" + output + "\"\n"
3839
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
build:
2+
compiler: AC6@>=6.6.6
3+
device: deviceName
4+
output:
5+
- type: lib
6+
file: projectName.lib
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
build-idx:
2+
generated-by: csolution version 2.2.1
3+
csolution: solutionName.csolution.yml
4+
cprojects:
5+
- cproject: projectName.cproject.yml
6+
cbuilds:
7+
- cbuild: project/subfolder/contextName.cbuild.yml
8+
project: projectName
9+
configuration: .BuildType+TargetType

0 commit comments

Comments
 (0)