Skip to content

Commit 3d94383

Browse files
authored
Add MSCCLPP_GIT_COMMIT micro (#640)
- Add MSCCLPP_GIT_COMMIT micro - Update docs
1 parent da84c6e commit 3d94383

File tree

8 files changed

+48
-27
lines changed

8 files changed

+48
-27
lines changed

.github/workflows/update-version.yml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,13 @@ jobs:
2727
- name: Update Version in Files
2828
run: |
2929
VERSION=${{ env.VERSION }}
30-
sed -i "s/^version: .*/version: ${VERSION}/" CITATION.cff
3130
sed -i "s/^release = \".*\"/release = \"v${VERSION}\"/" docs/conf.py
32-
sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" pyproject.toml
33-
34-
IFS='.' read -ra VER <<< "$VERSION"
35-
MAJOR=${VER[0]}
36-
MINOR=${VER[1]}
37-
PATCH=${VER[2]}
38-
39-
# Update CMakeLists.txt
40-
sed -i "s/set(MSCCLPP_MAJOR \".*\")/set(MSCCLPP_MAJOR \"${MAJOR}\")/" CMakeLists.txt
41-
sed -i "s/set(MSCCLPP_MINOR \".*\")/set(MSCCLPP_MINOR \"${MINOR}\")/" CMakeLists.txt
42-
sed -i "s/set(MSCCLPP_PATCH \".*\")/set(MSCCLPP_PATCH \"${PATCH}\")/" CMakeLists.txt
43-
44-
# Update header files
45-
sed -i "s/#define MSCCLPP_MAJOR .*/#define MSCCLPP_MAJOR ${MAJOR}/" include/mscclpp/core.hpp
46-
sed -i "s/#define MSCCLPP_MINOR .*/#define MSCCLPP_MINOR ${MINOR}/" include/mscclpp/core.hpp
47-
sed -i "s/#define MSCCLPP_PATCH .*/#define MSCCLPP_PATCH ${PATCH}/" include/mscclpp/core.hpp
4831
4932
- name: Commit and Push Changes
5033
run: |
5134
git config user.name "github-actions"
5235
git config user.email "github-actions@github.com"
53-
git add CITATION.cff docs/conf.py include/mscclpp/core.hpp pyproject.toml || true
36+
git add CITATION.cff docs/conf.py || true
5437
if git diff --cached --exit-code; then
5538
echo "No changes to commit."
5639
else

CMakeLists.txt

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT license.
33

4+
cmake_minimum_required(VERSION 3.25)
5+
project(mscclpp LANGUAGES CXX)
6+
47
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" MSCCLPP_VERSION_CONTENT)
58
if(MSCCLPP_VERSION_CONTENT MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)")
69
set(MSCCLPP_MAJOR "${CMAKE_MATCH_1}")
@@ -13,8 +16,27 @@ endif()
1316
set(MSCCLPP_SOVERSION ${MSCCLPP_MAJOR})
1417
set(MSCCLPP_VERSION "${MSCCLPP_MAJOR}.${MSCCLPP_MINOR}.${MSCCLPP_PATCH}")
1518

16-
cmake_minimum_required(VERSION 3.25)
17-
project(mscclpp LANGUAGES CXX)
19+
find_package(Git)
20+
set(GIT_HASH "UNKNOWN")
21+
if(Git_FOUND)
22+
execute_process(
23+
COMMAND "${GIT_EXECUTABLE}" rev-parse --short=12 HEAD
24+
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
25+
OUTPUT_VARIABLE _git_out
26+
OUTPUT_STRIP_TRAILING_WHITESPACE
27+
)
28+
if(NOT _git_out STREQUAL "")
29+
set(GIT_HASH "${_git_out}")
30+
endif()
31+
else()
32+
message(WARNING "Git not found, setting GIT_HASH to 'UNKNOWN'")
33+
endif()
34+
35+
configure_file(
36+
"${CMAKE_CURRENT_SOURCE_DIR}/include/mscclpp/version.hpp.in"
37+
"${CMAKE_CURRENT_BINARY_DIR}/include/mscclpp/version.hpp"
38+
@ONLY
39+
)
1840

1941
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
2042

File renamed without changes.

docs/programming_guide.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ This section provides advanced topics and best practices for using MSCCL++. It i
1212
guide/advanced-connections
1313
guide/cpp-examples
1414
guide/mscclpp-dsl
15+
guide/customized-algorithm-with-nccl-api

include/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT license.
33

4-
file(GLOB_RECURSE HEADERS CONFIGURE_DEPENDS *.hpp)
5-
target_sources(mscclpp_obj PUBLIC FILE_SET HEADERS FILES ${HEADERS})
4+
file(GLOB_RECURSE HEADERS CONFIGURE_DEPENDS *.hpp ${CMAKE_CURRENT_BINARY_DIR}/*.hpp)
5+
target_sources(
6+
mscclpp_obj PUBLIC FILE_SET HEADERS
7+
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
8+
FILES ${HEADERS}
9+
)

include/mscclpp/core.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@
44
#ifndef MSCCLPP_CORE_HPP_
55
#define MSCCLPP_CORE_HPP_
66

7-
#define MSCCLPP_MAJOR 0
8-
#define MSCCLPP_MINOR 7
9-
#define MSCCLPP_PATCH 0
10-
#define MSCCLPP_VERSION (MSCCLPP_MAJOR * 10000 + MSCCLPP_MINOR * 100 + MSCCLPP_PATCH)
11-
127
#include <array>
138
#include <bitset>
149
#include <future>
1510
#include <memory>
1611
#include <mscclpp/errors.hpp>
12+
#include <mscclpp/version.hpp>
1713
#include <string>
1814
#include <vector>
1915

include/mscclpp/version.hpp.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
#ifndef MSCCLPP_VERSION_HPP_
5+
#define MSCCLPP_VERSION_HPP_
6+
7+
#define MSCCLPP_MAJOR @MSCCLPP_MAJOR@
8+
#define MSCCLPP_MINOR @MSCCLPP_MINOR@
9+
#define MSCCLPP_PATCH @MSCCLPP_PATCH@
10+
#define MSCCLPP_VERSION (MSCCLPP_MAJOR * 10000 + MSCCLPP_MINOR * 100 + MSCCLPP_PATCH)
11+
#define MSCCLPP_GIT_COMMIT "@GIT_HASH@"
12+
13+
#endif // MSCCLPP_VERSION_HPP_

python/mscclpp/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
_version.py
2+
PKG-INFO

0 commit comments

Comments
 (0)