Skip to content

Commit

Permalink
[cbuild2cmake] Trigger project executes after project build step
Browse files Browse the repository at this point in the history
This adds a new CONTEXT-executes target to CMake that is automatically
run after build that triggers the executes statements of that project.
Fixes #185.
  • Loading branch information
EaselinkBachmann committed Oct 8, 2024
1 parent 2e34f7f commit ded205c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
15 changes: 15 additions & 0 deletions cmd/cbuild2cmake/commands/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,26 @@ add_dependencies(Archive_Artifacts
project.Release+ARMCM0-build
project.Release+ARMCM0-Sign_Artifact
)
add_dependencies(Archive_Artifacts-executes
Archive_Artifacts
)
add_dependencies(Generate_Project_Sources-executes
Generate_Project_Sources
)
add_dependencies(Run_After_Archiving
Archive_Artifacts
)
add_dependencies(Run_After_Archiving-executes
Run_After_Archiving
)
add_dependencies(Run_Always-executes
Run_Always
)
add_dependencies(project.Release+ARMCM0-Sign_Artifact
project.Release+ARMCM0-build
)
add_dependencies(project.Release+ARMCM0-executes
project.Release+ARMCM0-Sign_Artifact
)`)
})
}
3 changes: 3 additions & 0 deletions pkg/maker/buildcontent.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ func (m *Maker) BuildDependencies() string {
}
for _, item := range m.CbuildIndex.BuildIdx.Executes {
content += m.CMakeTargetAddDependencies(item.Execute, item.DependsOn)

var context = strings.Split(item.Execute, "-")[0]
content += m.CMakeTargetAddDependencies(context+"-executes", []string{item.Execute})
}
if len(content) > 0 {
content = "\n\n# Build dependencies" + content
Expand Down
8 changes: 7 additions & 1 deletion pkg/maker/superlists.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ foreach(INDEX RANGE ${CONTEXTS_LENGTH})
BUILD_BYPRODUCTS ${OUTPUTS_${N}}` + logConfigure + `
USES_TERMINAL_BUILD ON
)
ExternalProject_Add_StepTargets(${CONTEXT} build configure)
# Executes command step
ExternalProject_Add_Step(${CONTEXT} executes
DEPENDEES build
)
ExternalProject_Add_StepTargets(${CONTEXT} build configure executes)
# Debug
message(VERBOSE "Configure Context: ${CMAKE_COMMAND} -G Ninja -S ${DIR} -B ${N}")
Expand Down
8 changes: 7 additions & 1 deletion test/data/solutions/blanks/ref/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ foreach(INDEX RANGE ${CONTEXTS_LENGTH})
BUILD_BYPRODUCTS ${OUTPUTS_${N}}
USES_TERMINAL_BUILD ON
)
ExternalProject_Add_StepTargets(${CONTEXT} build configure)

# Executes command step
ExternalProject_Add_Step(${CONTEXT} executes
DEPENDEES build
)

ExternalProject_Add_StepTargets(${CONTEXT} build configure executes)

# Debug
message(VERBOSE "Configure Context: ${CMAKE_COMMAND} -G Ninja -S ${DIR} -B ${N}")
Expand Down
8 changes: 7 additions & 1 deletion test/data/solutions/pre-include-oot/ref/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@ foreach(INDEX RANGE ${CONTEXTS_LENGTH})
BUILD_BYPRODUCTS ${OUTPUTS_${N}}
USES_TERMINAL_BUILD ON
)
ExternalProject_Add_StepTargets(${CONTEXT} build configure)

# Executes command step
ExternalProject_Add_Step(${CONTEXT} executes
DEPENDEES build
)

ExternalProject_Add_StepTargets(${CONTEXT} build configure executes)

# Debug
message(VERBOSE "Configure Context: ${CMAKE_COMMAND} -G Ninja -S ${DIR} -B ${N}")
Expand Down

0 comments on commit ded205c

Please sign in to comment.