Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[buildmgr] Enable CMake to handle AC6 projects with only legacy assembly files #1101

Merged
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
6 changes: 6 additions & 0 deletions tools/buildmgr/cbuildgen/config/AC6.6.18.0.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ set(AS "armasm")
set(CC "armclang")
set(CXX "armclang")
set(CPP "armclang")
set(LD "armlink")
set(AR "armar")
set(OC "fromelf")

if(DEFINED REGISTERED_TOOLCHAIN_ROOT)
Expand All @@ -28,6 +30,8 @@ if(DEFINED TOOLCHAIN_ROOT AND NOT TOOLCHAIN_ROOT STREQUAL "")
set(CC ${TOOLCHAIN_ROOT}/${CC}${EXT})
set(CXX ${TOOLCHAIN_ROOT}/${CXX}${EXT})
set(CPP ${TOOLCHAIN_ROOT}/${CPP}${EXT})
set(LD ${TOOLCHAIN_ROOT}/${LD}${EXT})
set(AR ${TOOLCHAIN_ROOT}/${AR}${EXT})
set(OC ${TOOLCHAIN_ROOT}/${OC}${EXT})
endif()

Expand Down Expand Up @@ -626,6 +630,8 @@ set(CMAKE_AS_ARM_COMPILER "${CC}")
set(CMAKE_AS_GNU_COMPILER "${CC}")
set(CMAKE_C_COMPILER "${CC}")
set(CMAKE_CXX_COMPILER "${CXX}")
set(CMAKE_LINKER "${LD}")
set(CMAKE_AR "${AR}")
set(CMAKE_OBJCOPY "${OC}")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMakeASM")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
set(CMAKE_AS_ARM_COMPILER_ENV_VAR "AS_ARM")
configure_file(${CMAKE_MODULE_PATH}/CMakeAS_ARMCompiler.cmake.in ${CMAKE_PLATFORM_INFO_DIR}/CMakeAS_ARMCompiler.cmake)
configure_file(${CMAKE_MODULE_PATH}/CMakeAS_ARMCompiler.cmake.in ${CMAKE_PLATFORM_INFO_DIR}/CMakeAS_ARMCompiler.cmake)
include(${CMAKE_ROOT}/Modules/Compiler/ARMClang.cmake)
__compiler_armclang(AS_ARM)
11 changes: 11 additions & 0 deletions tools/buildmgr/test/integrationtests/src/CBuildAC6Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ TEST_F(CBuildAC6Tests, Asm) {
CheckCMakeLists (param);
}

// Verify and build project with single legacy assembly file
TEST_F(CBuildAC6Tests, ArmAsm) {
TestParam param = { "AC6/ArmAsm", "Target" };

RunCBuildScriptClean(param);
RunCBuildScript(param);
CheckCMakeLists(param);
const string outputFile = examples_folder + "/" + param.name + "/OutDir/Blinky.axf";
ASSERT_TRUE(fs::exists(outputFile));
}

// Validate project compilation having minimal configurations
TEST_F(CBuildAC6Tests, Minimal) {
TestParam param = { "AC6/Minimal", "MyProject" };
Expand Down
8 changes: 8 additions & 0 deletions tools/buildmgr/test/testinput/Examples/AC6/ArmAsm/ArmSyntax.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

AREA DATA

IF :LNOT::DEF:_RTE_
INFO 1, "_RTE_ is not defined!"
ENDIF

END
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# CMSIS Build CMakeLists generated on 2023-08-29T15:26:15

cmake_minimum_required(VERSION 3.22)

# Target options

set(TARGET Blinky)
set(CPU Cortex-M3)
set(PRJ_DIR "C:/sandbox/devtools/build/TestOutput/TestData/Examples/AC6/ArmAsm")
set(OUT_DIR "C:/sandbox/devtools/build/TestOutput/TestData/Examples/AC6/ArmAsm/OutDir")
set(INT_DIR "C:/sandbox/devtools/build/TestOutput/TestData/Examples/AC6/ArmAsm/IntDir")
set(FPU NO_FPU)
set(DSP NO_DSP)
set(TZ NO_TZ)
set(SECURE Non-secure)
set(MVE NO_MVE)
set(BYTE_ORDER Little-endian)
set(AS_FLAGS_GLOBAL "-masm=auto")
set(LD_SCRIPT "C:/sandbox/devtools/build/TestOutput/TestData/Examples/AC6/ArmAsm/LinkerScript.sct")

set(DEFINES
ARMCM3
_RTE_
)

set(INC_PATHS
"C:/sandbox/devtools/build/TestOutput/TestData/Examples/AC6/ArmAsm/RTE/_Target_1"
"C:/Users/Test/AppData/Local/Arm/Packs/ARM/CMSIS/5.9.0/CMSIS/Core/Include"
"C:/Users/Test/AppData/Local/Arm/Packs/ARM/CMSIS/5.9.0/Device/ARM/ARMCM3/Include"
)

set(AS_ARM_SRC_FILES
"C:/sandbox/devtools/build/TestOutput/TestData/Examples/AC6/ArmAsm/ArmSyntax.s"
)

# Toolchain config map

set(TOOLCHAIN_VERSION_MIN "6.0.0")
set(TOOLCHAIN_VERSION_MAX "6.99.99")
include ("C:/sandbox/cbuild/etc/AC6.6.18.0.cmake")
include ("C:/sandbox/cbuild/etc/CMSIS-Build-Utils.cmake")

# Setup project

project(${TARGET} LANGUAGES AS_ARM)

cbuild_get_running_toolchain(TOOLCHAIN_ROOT TOOLCHAIN_VERSION AS_ARM)

# Global Flags

set(CMAKE_AS_ARM_FLAGS "${AS_ARM_CPU} ${AS_ARM_BYTE_ORDER} ${AS_ARM_DEFINES} ${AS_ARM_FLAGS} ${AS_FLAGS_GLOBAL}")
set(CMAKE_C_LINK_FLAGS "${LD_CPU} ${_LS}\"${LD_SCRIPT}\" ${LD_SECURE} ${LD_FLAGS}")

# Local Flags

foreach(SRC ${AS_ARM_SRC_FILES})
set_source_files_properties(${SRC} PROPERTIES LANGUAGE AS_ARM)
endforeach()

# Compilation Database

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_custom_target(database COMMAND ${CMAKE_COMMAND} -E copy_if_different "${INT_DIR}/compile_commands.json" "${OUT_DIR}")

# Setup Target

add_executable(${TARGET} ${AS_ARM_SRC_FILES})
set_target_properties(${TARGET} PROPERTIES PREFIX "" SUFFIX ".axf" OUTPUT_NAME "Blinky")
set_target_properties(${TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${OUT_DIR} LINK_DEPENDS ${LD_SCRIPT})
target_include_directories(${TARGET} PUBLIC ${INC_PATHS})
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

LR_IROM1 0x08000000 0x00080000 { ; load region size_region
ER_IROM1 0x08000000 0x00080000 { ; load address = execution address
.ANY (+RO)
}
RW_IRAM1 0x20000000 0x00001000 { ; RW data
.ANY (+RW +ZI)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* CBUILDGEN generated file: DO NOT EDIT!
* Generated by: cbuildgen version 2.1.0-dev1
*
* Project: 'Target'
* Target: 'Target 1'
*/

#ifndef RTE_COMPONENTS_H
#define RTE_COMPONENTS_H


/*
* Define the Device Header File:
*/
#define CMSIS_device_header "ARMCM3.h"



#endif /* RTE_COMPONENTS_H */
32 changes: 32 additions & 0 deletions tools/buildmgr/test/testinput/Examples/AC6/ArmAsm/Target.cprj
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<cprj schemaVersion="2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="CPRJ.xsd">

<created timestamp="2020-09-04T10:07:24" tool="uVision V5.31.0.0"/>

<packages>
<package name="CMSIS" vendor="ARM"/>
<package name="ARM_Compiler" vendor="Keil"/>
</packages>

<compilers>
<compiler name="AC6" version="6.0.0:6.99.99"/>
</compilers>

<target Ddsp="NO_DSP" Dendian="Little-endian" Dfpu="NO_FPU" Dmve="NO_MVE" Dname="ARMCM3" Dsecure="Non-secure" Dtz="NO_TZ" Dvendor="ARM:82">
<output elf="Blinky.axf" name="Blinky" type="exe"/>
<ldflags compiler="AC6" file="./LinkerScript.sct"/>
<asflags add="-masm=auto" compiler="AC6"/>
</target>

<components>
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM"/>
</components>

<files>
<group name="Source Files">
<file category="sourceAsm" name="./ArmSyntax.s">
</file>
</group>
</files>

</cprj>
Loading