Skip to content

feat(taskfiles): Add tasks to install boost; Add test for boost install tasks. #42

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

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b26c793
Add tasks to install boost libraries
sitaowang1998 Apr 25, 2025
a7ce193
Add boost install test
sitaowang1998 Apr 25, 2025
c2d72f1
Reformat files
sitaowang1998 Apr 25, 2025
01a18ab
Reformat cmake files
sitaowang1998 Apr 25, 2025
0b70373
Fix clang-tidy
sitaowang1998 Apr 25, 2025
1ba12d3
Fix if comparison to follow style guideline.
sitaowang1998 Apr 25, 2025
8aca005
Fix cmake for wrong reference
sitaowang1998 Apr 25, 2025
238d1de
Merge branch 'boost-install-task' of github.com:sitaowang1998/yscope-…
sitaowang1998 Apr 25, 2025
b0b9c9c
Remove unnecessary check for library not found.
sitaowang1998 Apr 28, 2025
744d42c
Use target_compile_feature to set c++ version
sitaowang1998 Apr 28, 2025
186204f
Remove unused code in .clang-format
sitaowang1998 Apr 28, 2025
3655a0a
Use tasks from cmake to configure and build boost test project
sitaowang1998 Apr 28, 2025
0968a4a
Restructure the tests folder
sitaowang1998 Apr 28, 2025
d34daaf
Merge branch 'boost-install-task' of github.com:sitaowang1998/yscope-…
sitaowang1998 Apr 28, 2025
75d0aed
Bump boost min requirement for potential url library
sitaowang1998 Apr 28, 2025
8ca176d
Add more boost libraries
sitaowang1998 Apr 28, 2025
0ab8ca5
Use absolute include path for taskfiles.
sitaowang1998 Apr 29, 2025
6158dc7
Revert "Use absolute include path for taskfiles."
sitaowang1998 Apr 29, 2025
6ee995d
Add all boost libraries linkage in cmake
sitaowang1998 Apr 29, 2025
0f4fc49
Rename boost tasks to remove prefix
sitaowang1998 Apr 29, 2025
dabe6b2
Add simple tests for each library
sitaowang1998 Apr 30, 2025
92f1d44
Fix clang tidy
sitaowang1998 Apr 30, 2025
9ae2231
Fix clang tidy
sitaowang1998 Apr 30, 2025
7742814
Fix file name change
sitaowang1998 Apr 30, 2025
c8e0162
Do not clean up after tests.
sitaowang1998 May 2, 2025
863b9c3
Make including depdencies install cmake optional
sitaowang1998 May 2, 2025
66670cf
Use InitCap for boost cmake package name.
sitaowang1998 May 2, 2025
55317ce
Merge branch 'boost-install-task' of github.com:sitaowang1998/yscope-…
sitaowang1998 May 2, 2025
a5ea408
Use top level build directory for boost tests.
sitaowang1998 May 2, 2025
7163bc8
Fix the directory in taskfiles and cmake
sitaowang1998 May 2, 2025
99f5616
Add requried and default arguments for boost
sitaowang1998 May 5, 2025
8e9b7a0
Fix cmake comment about including optional files
sitaowang1998 May 5, 2025
d804217
Use heredoc to write to cmake file.
sitaowang1998 May 5, 2025
b7302f7
Fix heredoc
sitaowang1998 May 5, 2025
3174964
Replace ROOT_DIR with TASK_DIR and mark TARGET optional in docstring
sitaowang1998 May 5, 2025
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
184 changes: 184 additions & 0 deletions exports/taskfiles/utils/boost.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
version: "3"

includes:
remote: "remote.yaml"

set: ["u", "pipefail"]
shopt: ["globstar"]

tasks:
# Runs the bootstrap.sh generate step in the given source directory. Boost only supports
# in-source generation and building.
#
# @param {string} SOURCE_DIR Project source directory.
# @param {string} INSTALL_PREFIX Path prefix of where the project should be installed.
# @param {string[]} TARGETS Target libraries to build.
# @param {string[]} [EXTRA_ARGS] Any additional arguments to pass to the generate command.
generate:
internal: true
dir: "{{.SOURCE_DIR}}"
vars:
EXTRA_ARGS:
ref: "default (list) .EXTRA_ARGS"
requires:
vars: ["SOURCE_DIR", "INSTALL_PREFIX", "TARGETS"]
cmds:
- >-
./bootstrap.sh
--prefix="{{.INSTALL_PREFIX}}"
--exec-prefix="{{.INSTALL_PREFIX}}"
--with-libraries={{(join "," .TARGETS)}}
{{- range .EXTRA_ARGS}}
"{{.}}"
{{- end}}
# Runs the b2 build step for boost. The caller must have previously called `generate` on
# `SOURCE_DIR` for this task to succeed.
#
# @param {string} SOURCE_DIR Directory containing the boost source.
# @param {string[]} [EXTRA_ARGS] Any additional arguments to pass to the build command.
# @param {int} [JOBS] The maximum number of concurrent processes to use when building. If
# omitted, the b2 default number is used. Before 1.76.0, the number was 1. Since 1.76.0, the
# default is the number of cores.
build:
internal: true
dir: "{{.SOURCE_DIR}}"
vars:
EXTRA_ARGS:
ref: "default (list) .EXTRA_ARGS"
JOBS: >-
{{default "" .JOBS}}
requires:
vars: ["SOURCE_DIR"]
cmds:
- >-
./b2
{{- range .EXTRA_ARGS}}
"{{.}}"
{{- end}}
{{- if .JOBS}}
"-j{{.JOBS}}"
{{- end}}
# Runs the b2 install step for boost. The caller must have previously called `build` on
# `SOURCE_DIR` for this task to succeed. If `CMAKE_SETTINGS_DIR` is set, a settings file will be
# created in that directory, containing a `boost_ROOT` CMake variable that points to
# `INSTALL_PREFIX`.
#
# @param {string} SOURCE_DIR Directory containing the boost source.
# @param {string} INSTALL_PREFIX Path prefix of where the project should be installed.
# @param {string} [CMAKE_SETTINGS_DIR] If set, the directory where the project's CMake settings
# file should be stored.
# @param {string[]} [EXTRA_ARGS] Any additional arguments to pass to the install command.
install:
internal: true
dir: "{{.SOURCE_DIR}}"
vars:
EXTRA_ARGS:
ref: "default (list) .EXTRA_ARGS"
INSTALL_PREFIX: >-
{{default "" .INSTALL_PREFIX}}
CMAKE_SETTINGS_DIR: >-
{{default "" .CMAKE_SETTINGS_DIR}}
requires:
vars: ["SOURCE_DIR", "INSTALL_PREFIX"]
cmds:
- >-
./b2
install
{{- range .EXTRA_ARGS}}
"{{.}}"
{{- end}}
- |
{{- if .CMAKE_SETTINGS_DIR}}
cat <<EOF >> "{{.CMAKE_SETTINGS_DIR}}/boost.cmake"
set(Boost_ROOT "{{.INSTALL_PREFIX}}" CACHE PATH "Package root for boost.")
EOF
{{- end}}
# Downloads boost from `URL` and installs boost.
#
# General parameters
# @param {string} [WORK_DIR={{.TASK_DIR}}] Base directory to store the install and src
# directories inside.
# @param {string} [SOURCE_DIR={{.WORK_DIR}}/boost-src] Directory in which to extract the tar
# file.
#
# Download parameters
# @param {string} FILE_SHA256 Content hash to verify the downloaded tar file against.
# @param {string} URL
#
# Boost generate parameters
# @param {string} [INSTALL_PREFIX={{.WORK_DIR}}/boost-install] Path prefix of where the project
# should be installed.
# @param {string[]} [TARGETS] Target libraries to build.
# @param {string[]} [GEN_ARGS] Any additional arguments to pass to the generate command.
#
# Boost build parameters
# @param {int} [JOBS] The maximum number of concurrent processes to use when building. If
# omitted, the b2 default number is used. Before 1.76.0, the number was 1. Since 1.76.0, the
# default is the number of cores.
# @param {string[]} [BUILD_ARGS] Any additional arguments to pass to the build command.
#
# Boost install parameters
# @param {string[]} [INSTALL_ARGS] Any additional arguments to pass to the install command.
# @param {string} [CMAKE_SETTINGS_DIR] If set, the directory where the project's CMake settings
# file should be stored.
download-and-install:
internal: true
label: "{{.TASK}}:{{.URL}}-{{.INSTALL_PREFIX}}"
vars:
# General parameters
WORK_DIR: >-
{{default .TASK_DIR .WORK_DIR}}
SOURCE_DIR: >-
{{default (printf "%s/boost-src" .WORK_DIR) .SOURCE_DIR}}
# Boost generate parameters
INSTALL_PREFIX: >-
{{default (printf "%s/boost-install" .WORK_DIR) .INSTALL_PREFIX}}
TARGETS:
ref: "default (list) .TARGETS"
GEN_ARGS:
ref: "default (list) .GEN_ARGS"

# Boost build parameters
BUILD_ARGS:
ref: "default (list) .BUILD_ARGS"
JOBS: >-
{{default "" .JOBS}}
# Boost install parameters
INSTALL_ARGS:
ref: "default (list) .INSTALL_ARGS"
CMAKE_SETTINGS_DIR: >-
{{default "" .CMAKE_SETTINGS_DIR}}
requires:
vars: ["FILE_SHA256", "URL"]
deps:
- task: "remote:download-and-extract-tar"
vars:
FILE_SHA256: "{{.FILE_SHA256}}"
OUTPUT_DIR: "{{.SOURCE_DIR}}"
URL: "{{.URL}}"
cmds:
- task: "generate"
vars:
SOURCE_DIR: "{{.SOURCE_DIR}}"
INSTALL_PREFIX: "{{.INSTALL_PREFIX}}"
TARGETS:
ref: ".TARGETS"
EXTRA_ARGS:
ref: ".GEN_ARGS"
- task: "build"
vars:
SOURCE_DIR: "{{.SOURCE_DIR}}"
JOBS: "{{.JOBS}}"
EXTRA_ARGS:
ref: ".BUILD_ARGS"
- task: "install"
vars:
SOURCE_DIR: "{{.SOURCE_DIR}}"
INSTALL_PREFIX: "{{.INSTALL_PREFIX}}"
CMAKE_SETTINGS_DIR: "{{.CMAKE_SETTINGS_DIR}}"
EXTRA_ARGS:
ref: ".INSTALL_ARGS"
1 change: 1 addition & 0 deletions exports/taskfiles/utils/utils.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
version: "3"

includes:
boost: boost.yaml
checksum: checksum.yaml
cmake: cmake.yaml
cpp-lint: cpp-lint.yaml
Expand Down
2 changes: 1 addition & 1 deletion taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ tasks:

test:
cmds:
- task: "tests:download-and-extract-zip-basic"
- task: "tests:all"
17 changes: 17 additions & 0 deletions taskfiles/boost/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
BasedOnStyle: "InheritParentConfig"

IncludeCategories:
# NOTE: A header is grouped by first matching regex
# Library headers. Update when adding new libraries.
# NOTE: clang-format retains leading white-space on a line in violation of the YAML spec.
# Ex:
# - Regex: "<(fmt|spdlog)"
# Priority: 3
- Regex: "^<(boost)"
Priority: 3
# C system headers
- Regex: "^<.+\\.h>"
Priority: 1
# C++ standard libraries
- Regex: "^<.+>"
Priority: 2
54 changes: 54 additions & 0 deletions taskfiles/boost/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
cmake_minimum_required(VERSION 3.22.1)

project(boost-test LANGUAGES CXX VERSION 0.1.0)

set(CMAKE_EXPORT_COMPILE_COMMANDS
ON
CACHE BOOL
"Enable/Disable output of compile commands during generation."
FORCE
)

if(PROJECT_IS_TOP_LEVEL)
# Include dependency settings if the project isn't being included as a subproject.
# NOTE: We mark the file optional because if the user happens to have the dependencies
# installed, this file is not necessary.
include(
"${CMAKE_CURRENT_SOURCE_DIR}/../../build/deps/cmake-settings/all.cmake"
OPTIONAL
)
endif()

find_package(
Boost
1.83
REQUIRED
COMPONENTS
filesystem
headers
iostreams
process
program_options
regex
system
url
)
if(Boost_FOUND)
message(STATUS "Found Boost ${Boost_VERSION}.")
endif()

add_executable(boost-test)
target_compile_features(boost-test PRIVATE cxx_std_20)
target_sources(boost-test PRIVATE test_boost.cpp)
target_link_libraries(
boost-test
PRIVATE
Boost::filesystem
Boost::headers
Boost::iostreams
Boost::process
Boost::program_options
Boost::regex
Boost::system
Boost::url
)
Loading