Skip to content

Commit e9a9b79

Browse files
authored
CXX-3021 Add SBOM Lite and update release instructions (#1134)
1 parent b3f4d7d commit e9a9b79

File tree

9 files changed

+295
-143
lines changed

9 files changed

+295
-143
lines changed

CMakeLists.txt

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ endif()
2020

2121
project(MONGO_CXX_DRIVER LANGUAGES CXX)
2222

23+
set(CMAKE_MODULE_PATH
24+
${CMAKE_MODULE_PATH}
25+
${PROJECT_SOURCE_DIR}/cmake
26+
${PROJECT_SOURCE_DIR}/cmake/make_dist
27+
)
28+
2329
option(BUILD_TESTING "Include test targets in the \"all\" target")
2430

2531
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
@@ -42,9 +48,11 @@ else()
4248
message(WARNING "Unknown compiler... recklessly proceeding without a version check")
4349
endif()
4450

51+
# Also update etc/purls.txt.
4552
set(LIBBSON_REQUIRED_VERSION 1.25.0)
4653
set(LIBBSON_REQUIRED_ABI_VERSION 1.0)
4754

55+
# Also update etc/purls.txt.
4856
set(LIBMONGOC_REQUIRED_VERSION 1.25.0)
4957
set(LIBMONGOC_DOWNLOAD_VERSION 1.25.0)
5058
set(LIBMONGOC_REQUIRED_ABI_VERSION 1.0)
@@ -67,45 +75,7 @@ endif()
6775

6876
if(NEED_DOWNLOAD_C_DRIVER)
6977
message(STATUS "No Mongo C Driver path provided via CMAKE_PREFIX_PATH, will download C driver version ${LIBMONGOC_DOWNLOAD_VERSION} from the internet.")
70-
message(STATUS "Download and configure C driver version ${LIBMONGOC_DOWNLOAD_VERSION} ... begin")
71-
include(FetchContent)
72-
include(ExternalProject)
73-
74-
# Declare mongo-c-driver as a dependency
75-
FetchContent_Declare(
76-
mongo-c-driver
77-
GIT_REPOSITORY https://github.com/mongodb/mongo-c-driver.git
78-
GIT_TAG ${LIBMONGOC_DOWNLOAD_VERSION}
79-
)
80-
81-
FetchContent_GetProperties(mongo-c-driver)
82-
83-
if(NOT mongo-c-driver_POPULATED)
84-
set(OLD_ENABLE_TESTS ${ENABLE_TESTS})
85-
set(OLD_BUILD_TESTING ${BUILD_TESTING})
86-
set(OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
87-
set(OLD_CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
88-
89-
set(ENABLE_EXTRA_ALIGNMENT OFF)
90-
91-
FetchContent_Populate(mongo-c-driver)
92-
93-
# Set ENABLE_TESTS to OFF to disable the test-libmongoc target in the C driver.
94-
# This prevents the LoadTests.cmake script from attempting to execute test-libmongoc.
95-
# test-libmongoc is not built with the "all" target.
96-
# Attempting to execute test-libmongoc results in an error: "Unable to find executable: NOT_FOUND"
97-
set(ENABLE_TESTS OFF)
98-
set(BUILD_TESTING OFF)
99-
string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
100-
string(REPLACE " -Werror" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
101-
add_subdirectory(${mongo-c-driver_SOURCE_DIR} ${mongo-c-driver_BINARY_DIR})
102-
set(CMAKE_CXX_FLAGS ${OLD_CMAKE_CXX_FLAGS})
103-
set(CMAKE_C_FLAGS ${OLD_CMAKE_C_FLAGS})
104-
set(ENABLE_TESTS ${OLD_ENABLE_TESTS})
105-
set(BUILD_TESTING ${OLD_BUILD_TESTING})
106-
endif()
107-
108-
message(STATUS "Download and configure C driver version ${LIBMONGOC_DOWNLOAD_VERSION} ... end")
78+
include(FetchMongoC)
10979
endif()
11080

11181
# All of our target compilers support the deprecated
@@ -230,12 +200,6 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND MONGOCXX_OVERRIDE_DEFAULT_INS
230200
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "default install path" FORCE)
231201
endif()
232202

233-
set(CMAKE_MODULE_PATH
234-
${CMAKE_MODULE_PATH}
235-
${PROJECT_SOURCE_DIR}/cmake
236-
${PROJECT_SOURCE_DIR}/cmake/make_dist
237-
)
238-
239203
include(GNUInstallDirs)
240204
include(ParseVersion)
241205

cmake/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
add_subdirectory(make_dist)
1616

1717
set(cmake_MODULES
18-
ParseVersion.cmake
19-
MacroGuardTest.cmake
2018
BsoncxxUtil.cmake
19+
FetchMnmlstcCore.cmake
20+
FetchMongoC.cmake
21+
MacroGuardTest.cmake
2122
MongocxxUtil.cmake
23+
ParseVersion.cmake
2224
)
2325

2426
set_local_dist(cmake_DIST_local

cmake/FetchMnmlstcCore.cmake

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Use FetchContent to obtain mnmlstc/core.
2+
3+
include(FetchContent)
4+
5+
set(core-src "${CMAKE_CURRENT_BINARY_DIR}/_deps/core-src")
6+
set(core-subbuild "${CMAKE_CURRENT_BINARY_DIR}/_deps/core-subbuild")
7+
set(core-build "${CMAKE_CURRENT_BINARY_DIR}/_deps/core-build")
8+
set(core-install "${CMAKE_CURRENT_BINARY_DIR}/_deps/core-install")
9+
10+
# Also update etc/purls.txt.
11+
FetchContent_Declare(
12+
EP_mnmlstc_core
13+
14+
SOURCE_DIR "${core-src}"
15+
SUBBUILD_DIR "${core-subbuild}"
16+
BINARY_DIR "${core-build}"
17+
INSTALL_DIR "${core-install}"
18+
19+
GIT_REPOSITORY https://github.com/mnmlstc/core
20+
GIT_TAG v1.1.0
21+
GIT_SHALLOW TRUE
22+
LOG_DOWNLOAD ON
23+
24+
FETCHCONTENT_UPDATES_DISCONNECTED ON
25+
)
26+
FetchContent_GetProperties(EP_mnmlstc_core)
27+
28+
find_package(core NO_DEFAULT_PATH PATHS "${core-install}" QUIET)
29+
30+
if(core_FOUND AND "$CACHE{INTERNAL_MONGOC_MNMLSTC_CORE_FOUND}")
31+
# The mnmlstc/core library is already populated and up-to-date.
32+
else()
33+
if(NOT ep_mnmlstc_core_POPULATED)
34+
message(STATUS "Downloading mnmlstc/core...")
35+
FetchContent_Populate(EP_mnmlstc_core)
36+
message(STATUS "Downloading mnmlstc/core... done.")
37+
endif()
38+
39+
message(STATUS "Configuring mnmlstc/core...")
40+
execute_process(
41+
COMMAND
42+
"${CMAKE_COMMAND}"
43+
"-S" "${core-src}"
44+
"-B" "${core-build}"
45+
"-DCMAKE_INSTALL_PREFIX=${core-install}"
46+
"-DBUILD_TESTING=OFF"
47+
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
48+
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
49+
RESULT_VARIABLE retval
50+
)
51+
52+
if(NOT "${retval}" STREQUAL "0")
53+
message(FATAL_ERROR "execute_process() fatal error: ${retval}")
54+
endif()
55+
56+
message(STATUS "Configuring mnmlstc/core... done.")
57+
58+
message(STATUS "Building mnmlstc/core...")
59+
execute_process(
60+
COMMAND
61+
"${CMAKE_COMMAND}"
62+
--build "${core-build}"
63+
--config "${CMAKE_BUILD_TYPE}"
64+
RESULT_VARIABLE retval
65+
)
66+
67+
if(NOT "${retval}" STREQUAL "0")
68+
message(FATAL_ERROR "execute_process() fatal error: ${retval}")
69+
endif()
70+
71+
message(STATUS "Building mnmlstc/core... done.")
72+
73+
message(STATUS "Installing mnmlstc/core...")
74+
execute_process(
75+
COMMAND
76+
"${CMAKE_COMMAND}"
77+
--install "${core-build}"
78+
--config "${CMAKE_BUILD_TYPE}"
79+
RESULT_VARIABLE retval
80+
)
81+
82+
if(NOT "${retval}" STREQUAL "0")
83+
message(FATAL_ERROR "execute_process() fatal error: ${retval}")
84+
endif()
85+
86+
message(STATUS "Installing mnmlstc/core... done.")
87+
88+
find_package(core REQUIRED NO_DEFAULT_PATH PATHS "${core-install}")
89+
90+
# Ensure the mnmlstc/core CMake configuration is also (re)configured if the cache is fresh.
91+
set(INTERNAL_MONGOC_MNMLSTC_CORE_FOUND TRUE CACHE INTERNAL "")
92+
endif()
93+
94+
set(CORE_INCLUDE_DIR "${CORE_INCLUDE_DIR}" PARENT_SCOPE)
95+
96+
install(
97+
DIRECTORY "${core-install}/include/"
98+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc"
99+
)

cmake/FetchMongoC.cmake

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Use FetchContent to obtain libbson and libmongoc.
2+
3+
include(FetchContent)
4+
5+
message(STATUS "Download and configure C driver version ${LIBMONGOC_DOWNLOAD_VERSION} ... begin")
6+
7+
# Declare mongo-c-driver as a dependency
8+
FetchContent_Declare(
9+
mongo-c-driver
10+
GIT_REPOSITORY https://github.com/mongodb/mongo-c-driver.git
11+
GIT_TAG ${LIBMONGOC_DOWNLOAD_VERSION}
12+
)
13+
14+
FetchContent_GetProperties(mongo-c-driver)
15+
16+
if(NOT mongo-c-driver_POPULATED)
17+
set(OLD_ENABLE_TESTS ${ENABLE_TESTS})
18+
set(OLD_BUILD_TESTING ${BUILD_TESTING})
19+
set(OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
20+
set(OLD_CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
21+
22+
set(ENABLE_EXTRA_ALIGNMENT OFF)
23+
24+
FetchContent_Populate(mongo-c-driver)
25+
26+
# Set ENABLE_TESTS to OFF to disable the test-libmongoc target in the C driver.
27+
# This prevents the LoadTests.cmake script from attempting to execute test-libmongoc.
28+
# test-libmongoc is not built with the "all" target.
29+
# Attempting to execute test-libmongoc results in an error: "Unable to find executable: NOT_FOUND"
30+
set(ENABLE_TESTS OFF)
31+
set(BUILD_TESTING OFF)
32+
string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
33+
string(REPLACE " -Werror" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
34+
add_subdirectory(${mongo-c-driver_SOURCE_DIR} ${mongo-c-driver_BINARY_DIR})
35+
set(CMAKE_CXX_FLAGS ${OLD_CMAKE_CXX_FLAGS})
36+
set(CMAKE_C_FLAGS ${OLD_CMAKE_C_FLAGS})
37+
set(ENABLE_TESTS ${OLD_ENABLE_TESTS})
38+
set(BUILD_TESTING ${OLD_BUILD_TESTING})
39+
endif()
40+
41+
message(STATUS "Download and configure C driver version ${LIBMONGOC_DOWNLOAD_VERSION} ... end")

etc/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
file (GLOB etc_DIST_cmds RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cmd)
1616
file (GLOB etc_DIST_csss RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.css)
17+
file (GLOB etc_DIST_jsons RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.json)
1718
file (GLOB etc_DIST_mds RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.md)
1819
file (GLOB etc_DIST_pls RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.pl)
1920
file (GLOB etc_DIST_pys RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.py)
@@ -24,6 +25,7 @@ set_dist_list (etc_DIST
2425
CMakeLists.txt
2526
${etc_DIST_cmds}
2627
${etc_DIST_csss}
28+
${etc_DIST_jsons}
2729
${etc_DIST_mds}
2830
${etc_DIST_pls}
2931
${etc_DIST_pys}

etc/cyclonedx.sbom.json

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{
2+
"components": [
3+
{
4+
"bom-ref": "pkg:github/mnmlstc/[email protected]",
5+
"copyright": "Copyright \u00a9 2013 - 2014 MNMLSTC",
6+
"externalReferences": [
7+
{
8+
"type": "distribution",
9+
"url": "https://github.com/mnmlstc/core/archive/refs/tags/v1.1.0.tar.gz"
10+
},
11+
{
12+
"type": "website",
13+
"url": "https://github.com/mnmlstc/core/tree/v1.1.0"
14+
}
15+
],
16+
"group": "mnmlstc",
17+
"licenses": [
18+
{
19+
"license": {
20+
"id": "Apache-2.0"
21+
}
22+
}
23+
],
24+
"name": "core",
25+
"purl": "pkg:github/mnmlstc/[email protected]",
26+
"type": "library",
27+
"version": "v1.1.0"
28+
},
29+
{
30+
"bom-ref": "pkg:github/mongodb/[email protected]",
31+
"copyright": "Copyright 2009-present MongoDB, Inc.",
32+
"externalReferences": [
33+
{
34+
"type": "distribution",
35+
"url": "https://github.com/mongodb/mongo-c-driver/archive/refs/tags/v1.25.0.tar.gz"
36+
},
37+
{
38+
"type": "website",
39+
"url": "https://github.com/mongodb/mongo-c-driver/tree/v1.25.0"
40+
}
41+
],
42+
"group": "mongodb",
43+
"licenses": [
44+
{
45+
"license": {
46+
"id": "Apache-2.0"
47+
}
48+
}
49+
],
50+
"name": "mongo-c-driver",
51+
"purl": "pkg:github/mongodb/[email protected]",
52+
"type": "library",
53+
"version": "v1.25.0"
54+
}
55+
],
56+
"dependencies": [
57+
{
58+
"ref": "pkg:github/mnmlstc/[email protected]"
59+
},
60+
{
61+
"ref": "pkg:github/mongodb/[email protected]"
62+
}
63+
],
64+
"metadata": {
65+
"timestamp": "2024-05-09T15:50:40.695420+00:00",
66+
"tools": [
67+
{
68+
"externalReferences": [
69+
{
70+
"type": "build-system",
71+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/actions"
72+
},
73+
{
74+
"type": "distribution",
75+
"url": "https://pypi.org/project/cyclonedx-python-lib/"
76+
},
77+
{
78+
"type": "documentation",
79+
"url": "https://cyclonedx-python-library.readthedocs.io/"
80+
},
81+
{
82+
"type": "issue-tracker",
83+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/issues"
84+
},
85+
{
86+
"type": "license",
87+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/LICENSE"
88+
},
89+
{
90+
"type": "release-notes",
91+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/blob/main/CHANGELOG.md"
92+
},
93+
{
94+
"type": "vcs",
95+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib"
96+
},
97+
{
98+
"type": "website",
99+
"url": "https://github.com/CycloneDX/cyclonedx-python-lib/#readme"
100+
}
101+
],
102+
"name": "cyclonedx-python-lib",
103+
"vendor": "CycloneDX",
104+
"version": "6.4.4"
105+
}
106+
]
107+
},
108+
"serialNumber": "urn:uuid:dd68fbb0-f77c-4bb9-90cd-606dd854f301",
109+
"version": 1,
110+
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
111+
"bomFormat": "CycloneDX",
112+
"specVersion": "1.5"
113+
}

etc/purls.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These package URLs (purls) point to the versions (tags) of external dependencies
2+
# that are committed to the project. Refer: https://github.com/package-url/purl-spec
3+
4+
# This file is fed to silkbomb to generate the cyclonedx.sbom.json file. Edit this file
5+
# instead of modifying the SBOM JSON directly. After modifying this file, be sure to
6+
# re-generate the SBOM JSON file!
7+
8+
# libbson and libmongoc are obtained via cmake/FetchMongoC.cmake.
9+
pkg:github/mongodb/[email protected]
10+
11+
# mnmlstc/core is obtained via cmake/FetchMnmlstcCore.cmake.
12+
pkg:github/mnmlstc/[email protected]

0 commit comments

Comments
 (0)