Skip to content

Commit 524c1d3

Browse files
authored
Merge pull request libgit2#4334 from pks-t/pks/reproducible-builds
Reproducible builds
2 parents 212da30 + d630887 commit 524c1d3

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ OPTION( CURL "Use curl for HTTP if available" ON)
5050
OPTION( USE_EXT_HTTP_PARSER "Use system HTTP_Parser if available" ON)
5151
OPTION( DEBUG_POOL "Enable debug pool allocator" OFF )
5252
OPTION( ENABLE_WERROR "Enable compilation with -Werror" OFF )
53+
IF (UNIX AND NOT APPLE)
54+
OPTION( ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF )
55+
ENDIF()
5356

5457
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
5558
SET( USE_ICONV ON )
@@ -222,6 +225,12 @@ IF (MSVC)
222225
SET(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
223226
SET(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL}")
224227
ELSE ()
228+
IF (ENABLE_REPRODUCIBLE_BUILDS)
229+
SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Dqc <TARGET> <LINK_FLAGS> <OBJECTS>")
230+
SET(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> Dq <TARGET> <LINK_FLAGS> <OBJECTS>")
231+
SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -D <TARGET>")
232+
ENDIF()
233+
225234
SET(CMAKE_C_FLAGS "-D_GNU_SOURCE ${CMAKE_C_FLAGS}")
226235

227236
MACRO(ENABLE_WARNINGS flag)

tests/generate.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,18 @@ def write(self):
207207
return False
208208

209209
with open(output, 'w') as data:
210-
for module in self.modules.values():
210+
modules = sorted(self.modules.values(), key=lambda module: module.name)
211+
212+
for module in modules:
211213
t = Module.DeclarationTemplate(module)
212214
data.write(t.render())
213215

214-
for module in self.modules.values():
216+
for module in modules:
215217
t = Module.CallbacksTemplate(module)
216218
data.write(t.render())
217219

218220
suites = "static struct clar_suite _clar_suites[] = {" + ','.join(
219-
Module.InfoTemplate(module).render() for module in sorted(self.modules.values(), key=lambda module: module.name)
221+
Module.InfoTemplate(module).render() for module in modules
220222
) + "\n};\n"
221223

222224
data.write(suites)

0 commit comments

Comments
 (0)