Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions pkg/maker/buildcontent.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Arm Limited. All rights reserved.
* Copyright (c) 2024-2025 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -764,10 +764,19 @@ func (c *Cbuild) CMakeSetFileProperties(file Files, abstractions CompilerAbstrac
if hasAbstractions {
content += c.CompilerAbstractions(abstractions, language)
}
// file is generated by executes
filename := c.AddRootPrefix(c.ContextRoot, file.File)
isGenerated := slices.Contains(c.GeneratedFiles, filename)
// set file properties
if hasMisc || hasAbstractions {
content += "\nset_source_files_properties(\"" + c.AddRootPrefix(c.ContextRoot, file.File) +
"\" PROPERTIES\n COMPILE_OPTIONS \"" + GetFileOptions(file, hasAbstractions, ";") + "\"\n)"
if hasMisc || hasAbstractions || isGenerated {
content += "\nset_source_files_properties(\"" + filename + "\" PROPERTIES"
if hasMisc || hasAbstractions {
content += "\n COMPILE_OPTIONS \"" + GetFileOptions(file, hasAbstractions, ";") + "\""
}
if isGenerated {
content += "\n GENERATED TRUE"
}
content += "\n)"
}
return content
}
Expand Down Expand Up @@ -879,6 +888,13 @@ func (m *Maker) ListExecutesIOs(io string, list []string, run string) string {
return content
}

func (m *Maker) GetGeneratedFiles(list []string) {
for _, input := range list {
file := AddRootPrefix("", input, m.SolutionRoot)
m.GeneratedFiles = utils.AppendUniquely(m.GeneratedFiles, file)
}
}

func (m *Maker) ExecutesCommands(executes []Executes) string {
var content string
for _, item := range executes {
Expand All @@ -905,6 +921,7 @@ func (m *Maker) ExecutesCommands(executes []Executes) string {
}
if len(item.Output) > 0 {
content += m.ListExecutesIOs("OUTPUT", item.Output, item.Run)
m.GetGeneratedFiles(item.Output)
}
content += customTarget
if !runAlways {
Expand Down
12 changes: 11 additions & 1 deletion pkg/maker/buildcontent_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Arm Limited. All rights reserved.
* Copyright (c) 2024-2025 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -519,4 +519,14 @@ add_dependencies(project.debug+target-executes
assert.Equal(files, cbuild.GetAPIFiles("CORE:API"))
})

t.Run("get executes generated files", func(t *testing.T) {
var m maker.Maker
var files = []string{"./source0.c", "./source1.c"}
m.GetGeneratedFiles(files)
assert.Equal(
[]string{"${SOLUTION_ROOT}/source0.c", "${SOLUTION_ROOT}/source1.c"},
m.GeneratedFiles,
)
})

}
3 changes: 2 additions & 1 deletion pkg/maker/contextlists.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Arm Limited. All rights reserved.
* Copyright (c) 2024-2025 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -27,6 +27,7 @@ func (m *Maker) CreateContextCMakeLists(index int) error {
contextDir := path.Join(m.SolutionTmpDir, cbuild.BuildDescType.Context)
cbuild.IncludeGlobal = make(LanguageMap)
cbuild.UserIncGlobal = make(LanguageMap)
cbuild.GeneratedFiles = m.GeneratedFiles

var cmakeTargetType, outputDirType, linkerVars, linkerOptions string
if outputType == "elf" {
Expand Down
3 changes: 2 additions & 1 deletion pkg/maker/maker.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Arm Limited. All rights reserved.
* Copyright (c) 2024-2025 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -34,6 +34,7 @@ type Vars struct {
Cbuilds []Cbuild
Contexts []string
EnvVars utils.EnvVars
GeneratedFiles []string
ToolchainConfigs map[*semver.Version]Toolchain
RegisteredToolchains map[*semver.Version]Toolchain
SelectedToolchainVersion []*semver.Version
Expand Down
3 changes: 2 additions & 1 deletion pkg/maker/parser.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Arm Limited. All rights reserved.
* Copyright (c) 2024-2025 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -82,6 +82,7 @@ type Cbuild struct {
UserIncGlobal LanguageMap
BuildGroups []string
Toolchain string
GeneratedFiles []string
}

type Cbuilds struct {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
cmake_minimum_required(VERSION 3.27)

# Roots
include("../roots.cmake")

set(CONTEXT project.Release+ARMCM0)
set(TARGET ${CONTEXT})
set(OUT_DIR "${SOLUTION_ROOT}/out/project/ARMCM0/Release")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(LD_SCRIPT "${SOLUTION_ROOT}/project/RTE/Device/ARMCM0/ARMCM0_ac6.sct")
set(LD_SCRIPT_PP ${LD_SCRIPT})

# Processor Options
set(CPU Cortex-M0)
set(FPU NO_FPU)

# Toolchain config map
include("toolchain.cmake")

# Setup project
project(${CONTEXT} LANGUAGES C)

# Compilation database
add_custom_target(database
COMMAND ${CMAKE_COMMAND} -E make_directory "${OUT_DIR}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json" "${OUT_DIR}"
)
set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES})

# Setup context
add_executable(${CONTEXT})
set_target_properties(${CONTEXT} PROPERTIES PREFIX "" SUFFIX ".axf" OUTPUT_NAME "project")
set_target_properties(${CONTEXT} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${OUT_DIR})
add_library(${CONTEXT}_GLOBAL INTERFACE)

# Includes
target_include_directories(${CONTEXT} PUBLIC
${SOLUTION_ROOT}/project/RTE/_Release_ARMCM0
${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Include
${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.1.0/Device/ARMCM0/Include
)

# Defines
target_compile_definitions(${CONTEXT} PUBLIC
$<$<COMPILE_LANGUAGE:C,CXX>:
ARMCM0
_RTE_
>
)

# Compile options
target_compile_options(${CONTEXT} PUBLIC
$<$<COMPILE_LANGUAGE:C>:
"SHELL:${CC_CPU}"
"SHELL:${CC_FLAGS}"
"SHELL:-std=gnu11"
"SHELL:-Wno-macro-redefined"
"SHELL:-Wno-pragma-pack"
"SHELL:-Wno-parentheses-equality"
"SHELL:-Wno-license-management"
>
)

# Add groups and components
include("groups.cmake")
include("components.cmake")

target_link_libraries(${CONTEXT} PUBLIC
Group_Source
ARM_CMSIS_CORE_6_1_0
ARM_Device_Startup_C_Startup_2_2_0
)

# Linker options
target_link_options(${CONTEXT} PUBLIC
"SHELL:${LD_CPU}"
"SHELL:${_LS}\"${LD_SCRIPT_PP}\""
"SHELL:--entry=Reset_Handler"
"SHELL:--map"
"SHELL:--info summarysizes"
"SHELL:--summary_stderr"
"SHELL:--diag_suppress=L6314W"
)
set_target_properties(${CONTEXT} PROPERTIES LINK_DEPENDS ${LD_SCRIPT})
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# components.cmake

# component ARM::CMSIS:CORE@6.1.0
add_library(ARM_CMSIS_CORE_6_1_0 INTERFACE)
target_include_directories(ARM_CMSIS_CORE_6_1_0 INTERFACE
$<TARGET_PROPERTY:${CONTEXT},INTERFACE_INCLUDE_DIRECTORIES>
${CMSIS_PACK_ROOT}/ARM/CMSIS/6.1.0/CMSIS/Core/Include
)
target_compile_definitions(ARM_CMSIS_CORE_6_1_0 INTERFACE
$<TARGET_PROPERTY:${CONTEXT},INTERFACE_COMPILE_DEFINITIONS>
)

# component ARM::Device:Startup&C Startup@2.2.0
add_library(ARM_Device_Startup_C_Startup_2_2_0 OBJECT
"${SOLUTION_ROOT}/project/RTE/Device/ARMCM0/startup_ARMCM0.c"
"${SOLUTION_ROOT}/project/RTE/Device/ARMCM0/system_ARMCM0.c"
)
target_include_directories(ARM_Device_Startup_C_Startup_2_2_0 PUBLIC
$<TARGET_PROPERTY:${CONTEXT},INTERFACE_INCLUDE_DIRECTORIES>
${CMSIS_PACK_ROOT}/ARM/Cortex_DFP/1.1.0/Device/ARMCM0/Include
)
target_compile_definitions(ARM_Device_Startup_C_Startup_2_2_0 PUBLIC
$<TARGET_PROPERTY:${CONTEXT},INTERFACE_COMPILE_DEFINITIONS>
)
target_compile_options(ARM_Device_Startup_C_Startup_2_2_0 PUBLIC
$<TARGET_PROPERTY:${CONTEXT},INTERFACE_COMPILE_OPTIONS>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# groups.cmake

# group Source
add_library(Group_Source OBJECT
"${SOLUTION_ROOT}/project/source0.c"
"${SOLUTION_ROOT}/project/source1.c"
)
target_include_directories(Group_Source PUBLIC
$<TARGET_PROPERTY:${CONTEXT},INTERFACE_INCLUDE_DIRECTORIES>
)
target_compile_definitions(Group_Source PUBLIC
$<TARGET_PROPERTY:${CONTEXT},INTERFACE_COMPILE_DEFINITIONS>
)
target_compile_options(Group_Source PUBLIC
$<TARGET_PROPERTY:${CONTEXT},INTERFACE_COMPILE_OPTIONS>
)
set_source_files_properties("${SOLUTION_ROOT}/project/source0.c" PROPERTIES
GENERATED TRUE
)
set_source_files_properties("${SOLUTION_ROOT}/project/source1.c" PROPERTIES
GENERATED TRUE
)
Loading