Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
42 changes: 26 additions & 16 deletions examples/simple/CMakeLists.txt → CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,37 @@
# cmake .. -DBUILDROOT_SOURCE_DIR=<path to Buildroot.git>
# make

cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 3.14)

# Set up the module path so Buildroot.cmake and Git.cmake are found.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/)

include("Buildroot")
include("Git")
include("cmake/Buildroot.cmake")
include("cmake/Git.cmake")
include("cmake/GitUtils.cmake")

# Look for the Buildroot source code, by default alongside the checkout of
# Buildroot.cmake.git, but you can pass -DBUILDROOT_SOURCE_DIR=<path> to
# specify a location to look in.
git_add_external_repo(
buildroot
DESCRIPTION "Buildroot"
DEFAULT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../buildroot)
project(examples)

GitUtils_Define(
buildroot
"https://git.buildroot.net/buildroot"
TAG "2020.11.x"
FOLDER "build"
DEPTH 1
FREEZE SINGLE DEPTHONE
)

# Compile a Buildroot toolchain
buildroot_target(
raspberrypi2
OUTPUT images/rootfs.tar.gz
CONFIG raspberrypi2.config
)
raspberrypi2
OUTPUT images/rootfs.tar.gz
CONFIG examples/raspberrypi2_defconfig
)

buildroot_target(
raspberrypi4
OUTPUT images/rootfs.tar.gz
CONFIG examples/raspberrypi4_defconfig
)

add_custom_target(all-buildroot ALL DEPENDS raspberrypi2)
add_custom_target(all-buildroot ALL DEPENDS raspberrypi2 raspberrypi4)
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ For more information, see:

* the inline documentation comments in [Buildroot.cmake].

* the [examples](https://github.com/raumfeld/Buildroot.cmake/tree/master/examples/)
* the [examples](https://github.com/raumfeld/Buildroot.cmake/tree/master/CMakeLists.txt/)

Use
```
mkdir -p build
cd build
cmake -S ../ -B ./
make
```

[Artifactory.cmake]: https://github.com/raumfeld/Artifactory.cmake
[Buildroot.cmake]: https://github.com/raumfeld/Buildroot.cmake/blob/master/Buildroot.cmake
Expand Down
22 changes: 14 additions & 8 deletions Buildroot.cmake → cmake/Buildroot.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
# It provides two commands: buildroot_target and buildroot_toolchain. See below
# for documentation.

include("support/cmake/DefaultValue")
include("support/cmake/EnsureAllArgumentsParsed")
include("support/cmake/FindArtifactFile")
include("${CMAKE_CURRENT_LIST_DIR}/support/DefaultValue.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/support/EnsureAllArgumentsParsed.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/support/FindArtifactFile.cmake")

if(("${BUILDROOT_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") AND
("${CMAKE_GENERATOR}" STREQUAL "Unix Makefiles"))
Expand Down Expand Up @@ -181,7 +181,7 @@ function(buildroot_target name)
cmake_parse_arguments(BR "" "${one_value_keywords}" "${multi_value_keywords}" ${ARGN})
ensure_all_arguments_parsed(buildroot_target "${BR_UNPARSED_ARGUMENTS}")

default_value(BR_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/config)
default_value(BR2_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/config)

if(NOT ${BUILDROOT_OUTPUT})
message(FATAL_ERROR "buildroot_target(${name}): the OUTPUT paramater is required")
Expand Down Expand Up @@ -234,9 +234,8 @@ function(buildroot_target name)

set(build_log ${CMAKE_CURRENT_BINARY_DIR}/${name}-log.txt)
set(extra_depends ${BR_CONFIG} ${toolchain_depends})

if(artifact_prebuilt
AND (device_tree_artifact_prebuilt OR NOT BR_DEVICE_TREE_ARTIFACT_PREBUILT)
if(artifact_prebuilt
AND (device_tree_artifact_prebuilt OR NOT BR_DEVICE_TREE_ARTIFACT_PREBUILT)
AND (host_tools_artifact_prebuilt OR NOT BR_HOST_TOOLS_ARTIFACT_PREBUILT))
if(BR_ARTIFACT_PREBUILT_UNPACK_TO)
_buildroot_use_prebuilt_directory(
Expand Down Expand Up @@ -543,8 +542,15 @@ function(_buildroot_prepare_config source_dir build_dir input)
set(input ${CMAKE_CURRENT_SOURCE_DIR}/${input})
endif()

if(IS_SYMLINK ${input})
message(FATAL_ERROR "The configuration file does not appear to be configured. Please the configuration file path")
endif()

execute_process(COMMAND cmake -E copy ${input} ${source_dir}/configs/custom_defconfig)
execute_process(COMMAND make -C ${source_dir} custom_defconfig)

configure_file(${input} ${build_dir}/.config.stamp)
execute_process(COMMAND cmake -E copy ${input} ${build_dir}/.config)
execute_process(COMMAND cmake -E copy ${source_dir}/.config ${build_dir}/.config)
buildroot_edit_config_file(${build_dir}/.config ${commands})
endfunction()

Expand Down
File renamed without changes.
Loading