Skip to content

Commit 7e5eefa

Browse files
authored
feat(core): Support __eq__ and __ne__ for List/Dict (#10)
1 parent 02affe5 commit 7e5eefa

20 files changed

+1102
-921
lines changed

CMakeLists.txt

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
cmake_minimum_required(VERSION 3.15)
22

3+
include(${CMAKE_CURRENT_LIST_DIR}/cmake/Utils/GitVersion.cmake)
4+
5+
message(STATUS "MLC VERSION: ${MLC_VERSION_GIT}")
6+
37
project(
4-
mlc
5-
VERSION 0.1.1
8+
MLC
9+
VERSION ${MLC_VERSION_MAJOR}.${MLC_VERSION_MINOR}.${MLC_VERSION_PATCH}
610
DESCRIPTION "MLC-Python"
711
LANGUAGES C CXX
812
)
@@ -11,7 +15,7 @@ option(MLC_BUILD_TESTS "Build tests. This option will enable a test target `mlc_
1115
option(MLC_BUILD_PY "Build Python bindings." OFF)
1216
option(MLC_BUILD_REGISTRY
1317
"Support for objects with non-static type indices. When turned on, \
14-
targets linked against `mlc` will allow objects that comes with non-pre-defined type indices, \
18+
targets linked against `MLC` will allow objects that comes with non-pre-defined type indices, \
1519
so that the object hierarchy could expand without limitation. \
1620
This will require the downstream targets to link against target `mlc_registry` to be effective."
1721
OFF
@@ -40,9 +44,7 @@ target_include_directories(mlc INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
4044
if (MLC_BUILD_REGISTRY)
4145
add_library(mlc_registry_objs OBJECT
4246
"${CMAKE_CURRENT_SOURCE_DIR}/cpp/c_api.cc"
43-
"${CMAKE_CURRENT_SOURCE_DIR}/cpp/c_api_tests.cc"
4447
"${CMAKE_CURRENT_SOURCE_DIR}/cpp/printer.cc"
45-
"${CMAKE_CURRENT_SOURCE_DIR}/cpp/json.cc"
4648
"${CMAKE_CURRENT_SOURCE_DIR}/cpp/structure.cc"
4749
"${CMAKE_CURRENT_SOURCE_DIR}/cpp/traceback.cc"
4850
"${CMAKE_CURRENT_SOURCE_DIR}/cpp/traceback_win.cc"
@@ -57,6 +59,21 @@ if (MLC_BUILD_REGISTRY)
5759
VISIBILITY_INLINES_HIDDEN ON
5860
PREFIX "lib"
5961
)
62+
63+
string(TIMESTAMP MLC_BUILD_TIME "%Y-%m-%dT%H:%M:%S")
64+
set_property(
65+
SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/cpp/c_api.cc"
66+
APPEND
67+
PROPERTY COMPILE_DEFINITIONS
68+
MLC_VERSION_GIT="${MLC_VERSION_GIT}"
69+
MLC_VERSION_MAJOR="${MLC_VERSION_MAJOR}"
70+
MLC_VERSION_MINOR="${MLC_VERSION_MINOR}"
71+
MLC_VERSION_PATCH="${MLC_VERSION_PATCH}"
72+
MLC_VERSION_COMMIT_NUM="${MLC_VERSION_COMMIT_NUM}"
73+
MLC_VERSION_COMMIT_SHA="${MLC_VERSION_COMMIT_SHA}"
74+
MLC_BUILD_TIME="${MLC_BUILD_TIME}"
75+
)
76+
6077
add_cxx_warning(mlc_registry_objs)
6178
target_link_libraries(mlc_registry_objs PRIVATE dlpack_header)
6279
target_include_directories(mlc_registry_objs PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")

cmake/Utils/GitVersion.cmake

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
find_package(Git)
2+
3+
if (GIT_EXECUTABLE)
4+
execute_process(
5+
COMMAND ${GIT_EXECUTABLE} describe --tags --dirty --match "v*"
6+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
7+
OUTPUT_VARIABLE _GIT_OUTPUT
8+
RESULT_VARIABLE _GIT_ERROR
9+
OUTPUT_STRIP_TRAILING_WHITESPACE
10+
)
11+
if (NOT _GIT_ERROR)
12+
string(REGEX REPLACE "^v" "" MLC_VERSION_RAW "${_GIT_OUTPUT}")
13+
endif()
14+
else()
15+
message(ERROR "Git not found, cannot determine version. Falling back to 0.0.0-0-unknown.")
16+
endif()
17+
18+
if(NOT DEFINED MLC_VERSION_RAW)
19+
set(MLC_VERSION_RAW 0.0.0-0-unknown)
20+
message(WARNING "Failed to determine MLC_VERSION_RAW from Git tags. Using default version \"${MLC_VERSION_RAW}\".")
21+
endif()
22+
23+
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)(-([0-9]+)-([a-z0-9]+))?" MLC_VERSION_MATCH ${MLC_VERSION_RAW})
24+
set(MLC_VERSION_MAJOR ${CMAKE_MATCH_1})
25+
set(MLC_VERSION_MINOR ${CMAKE_MATCH_2})
26+
set(MLC_VERSION_PATCH ${CMAKE_MATCH_3})
27+
set(MLC_VERSION_COMMIT_NUM ${CMAKE_MATCH_5})
28+
set(MLC_VERSION_COMMIT_SHA ${CMAKE_MATCH_6})
29+
30+
if (NOT MLC_VERSION_COMMIT_NUM)
31+
set(MLC_VERSION_GIT ${MLC_VERSION_MAJOR}.${MLC_VERSION_MINOR}.${MLC_VERSION_PATCH})
32+
else()
33+
# Increment `MLC_VERSION_PATCH` by 1
34+
math(EXPR MLC_VERSION_PATCH "${MLC_VERSION_PATCH}+1")
35+
set(MLC_VERSION_GIT ${MLC_VERSION_MAJOR}.${MLC_VERSION_MINOR}.${MLC_VERSION_PATCH}.dev${MLC_VERSION_COMMIT_NUM}+${MLC_VERSION_COMMIT_SHA})
36+
endif()

0 commit comments

Comments
 (0)