From d812809df1fd0b64cb4434f7f2b1ecbbcd8079ae Mon Sep 17 00:00:00 2001 From: Michael Hillmann Date: Sat, 13 Aug 2022 13:55:44 +0200 Subject: [PATCH] generate CMake source package of HAL on release --- .github/workflows/release.yaml | 29 +++++++ .gitignore | 2 + CMakeLists.txt | 55 +++++++++++++ Drivers/CMakeLists.txt | 137 +++++++++++++++++++++++++++++++++ 4 files changed, 223 insertions(+) create mode 100644 .github/workflows/release.yaml create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 Drivers/CMakeLists.txt diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000000..f96de3ca09 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,29 @@ +name: Release +permissions: + contents: write + +on: + release: + types: [published] + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Create build environment + run: cmake -E make_directory build + - name: Configure + working-directory: build/ + run: cmake $GITHUB_WORKSPACE + - name: Package source code + working-directory: build/ + run: cmake --build . --target stm32f4xx-hal_package + + - name: Add packaged source code to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: build/stm32f4xx-hal-src.zip + tag: ${{ github.ref }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..296faeaf4f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# ignore +/build diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000..3621d11561 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,55 @@ +#****************************************************************************** +# Copyright 2020 Embedded Office GmbH & Co. KG +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#****************************************************************************** + +#--- +# Preamble +# +cmake_minimum_required(VERSION 3.20) # buildPresets is introduced in 3.20 +project(stm32f4xx-hal) + +#--- +# Target exported by this project as 'stm32f4xx-hal' +# +# You must configure the HAL with some cached variables in your project: +# - STM_HAL_CONF_DIR : [path] directory which holds the configuration: stm32f4xx_hal_conf.h +# - STM_HAL_DEVICE : [string] select a supported compiler definition (e.g. 'STM32F429xx') +# - STM_USE_HAL_DRIVER : [boolean] true = set compiler definition 'USE_HAL_DRIVER' +# - STM_USE_FULL_LL_DRIVER : [boolean] true = set compiler definition 'USE_FULL_LL_DRIVER' +# - STM_USE_FULL_ASSERT : [bbolean] true = set compiler definition 'USE_FULL_ASSERT' +add_subdirectory(Drivers) + +#--- +# This is needed only if we are the top level project +# +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + + # Setup target which creates a source package for efficient usage with Cmake CPM/FetchContent + set(package_files + Drivers/CMSIS/Device + Drivers/CMSIS/Include + Drivers/STM32F4xx_HAL_Driver + Drivers/CMakeLists.txt + CMakeLists.txt + LICENSE.md + ) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-src.zip + COMMAND ${CMAKE_COMMAND} -E tar c ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-src.zip --format=zip -- ${package_files} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ${package_files} + ) + add_custom_target(${PROJECT_NAME}_package DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-src.zip) + +endif() diff --git a/Drivers/CMakeLists.txt b/Drivers/CMakeLists.txt new file mode 100644 index 0000000000..9c403a466d --- /dev/null +++ b/Drivers/CMakeLists.txt @@ -0,0 +1,137 @@ +#****************************************************************************** +# Copyright 2020 Embedded Office GmbH & Co. KG +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#****************************************************************************** + +add_library(stm32f4xx-hal) + +target_sources(stm32f4xx-hal + PRIVATE + STM32F4xx_HAL_Driver/src/Legacy/stm32f4xx_hal_can.c + STM32F4xx_HAL_Driver/src/Legacy/stm32f4xx_hal_eth.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_adc.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_adc_ex.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_can.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_cec.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_cortex.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_crc.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_cryp.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_cryp_ex.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_dac.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_dac_ex.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_dcmi.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_dcmi_ex.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_dfsdm.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_dma.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_dma2d.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_dma_ex.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_dsi.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_eth.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_exti.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_flash.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_flash_ex.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_flash_ramfunc.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_fmpi2c.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_fmpi2c_ex.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_fmpsmbus.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_fmpsmbus_ex.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_gpio.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_hash.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_hash_ex.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_hcd.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_i2c.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_i2c_ex.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_i2s.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_i2s_ex.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_irda.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_iwdg.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_lptim.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_ltdc.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_ltdc_ex.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_mmc.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_msp_template.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_nand.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_nor.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_pccard.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_pcd.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_pcd_ex.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_pwr.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_pwr_ex.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_qspi.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_rcc.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_rcc_ex.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_rng.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_rtc.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_rtc_ex.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_sai.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_sai_ex.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_sd.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_sdram.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_smartcard.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_smbus.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_spdifrx.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_spi.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_sram.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_tim.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_timebase_rtc_alarm_template.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_timebase_rtc_wakeup_template.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_timebase_tim_template.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_tim_ex.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_uart.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_usart.c + STM32F4xx_HAL_Driver/src/stm32f4xx_hal_wwdg.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_adc.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_crc.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_dac.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_dma.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_dma2d.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_exti.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_fmc.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_fmpi2c.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_fsmc.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_gpio.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_i2c.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_lptim.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_pwr.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_rcc.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_rng.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_rtc.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_sdmmc.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_spi.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_tim.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_usart.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_usb.c + STM32F4xx_HAL_Driver/src/stm32f4xx_ll_utils.c +) + +target_include_directories(stm32f4xx-hal + PUBLIC + CMSIS/Include + CMSIS/Device/ST/STM32F4xx/Include + STM32F4xx_HAL_Driver/Inc + STM32F4xx_HAL_Driver/Inc/Legacy + ${STM_HAL_CONF_DIR} +) + +if (${STM_USE_HAL_DRIVER}) + target_compile_definitions(stm32f4xx-hal PUBLIC USE_HAL_DRIVER) +endif() +if (${STM_USE_FULL_LL_DRIVER}) + target_compile_definitions(stm32f4xx-hal PUBLIC USE_FULL_LL_DRIVER) +endif() +if (${STM_USE_FULL_ASSERT}) + target_compile_definitions(stm32f4xx-hal PUBLIC USE_FULL_ASSERT) +endif() +target_compile_definitions(stm32f4xx-hal PUBLIC ${STM_HAL_DEVICE})