Skip to content

Commit 473ca8a

Browse files
committed
Optionally include scalar when building/testing Git
The Scalar project started out as a separate project. As designated successor of VFS for Git, its goal has been from the start to apply the learnings from the VFS for Git project to allow Git to scale. In contrast to VFS for Git, Scalar very much wants Git to be aware that the checkout is sparse and the clone is partial (as opposed to VFS for Git which tried to pretend that everything is there via a virtual file system driver). The intention has always been to integrate as much as possible of Scalar into Git proper. And this has been the case: the partial clone feature, the sparse checkout (cone mode), the commit graph, multi-pack index files, scheduled maintenance tasks, all of these wonderful things can now be enjoyed by Git users _without_ having to install Scalar. So what remains of Scalar was ported to C, and put into `contrib/scalar/`. And to make it easier for folks to build and install it along with Git, this here patch makes it possible to simply drop `INCLUDE_SCALAR = YesPlease` into the `config.mak` file to make it so. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 1903310 commit 473ca8a

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

Makefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,6 +1942,10 @@ ifndef PAGER_ENV
19421942
PAGER_ENV = LESS=FRX LV=-c
19431943
endif
19441944

1945+
ifneq (,$(INCLUDE_SCALAR))
1946+
EXTRA_PROGRAMS += contrib/scalar/scalar$X
1947+
endif
1948+
19451949
QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
19461950
QUIET_SUBDIR1 =
19471951

@@ -2595,6 +2599,9 @@ contrib/scalar/scalar$X: $(SCALAR_OBJECTS) GIT-LDFLAGS $(GITLIBS)
25952599
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
25962600
$(filter %.o,$^) $(LIBS)
25972601

2602+
bin-wrappers/scalar: contrib/scalar/Makefile
2603+
$(QUIET_SUBDIR0)contrib/scalar $(QUIET_SUBDIR1) ../../bin-wrappers/scalar
2604+
25982605
$(LIB_FILE): $(LIB_OBJS)
25992606
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
26002607

@@ -2614,14 +2621,23 @@ Documentation/GIT-EXCLUDED-PROGRAMS: FORCE
26142621
.PHONY: doc man man-perl html info pdf
26152622
doc: man-perl
26162623
$(MAKE) -C Documentation all
2624+
ifneq (,$(INCLUDE_SCALAR))
2625+
$(QUIET_SUBDIR0)contrib/scalar $(QUIET_SUBDIR1) scalar.html scalar.1
2626+
endif
26172627

26182628
man: man-perl
26192629
$(MAKE) -C Documentation man
2630+
ifneq (,$(INCLUDE_SCALAR))
2631+
$(QUIET_SUBDIR0)contrib/scalar $(QUIET_SUBDIR1) scalar.1
2632+
endif
26202633

26212634
man-perl: perl/build/man/man3/Git.3pm
26222635

26232636
html:
26242637
$(MAKE) -C Documentation html
2638+
ifneq (,$(INCLUDE_SCALAR))
2639+
$(QUIET_SUBDIR0)contrib/scalar $(QUIET_SUBDIR1) scalar.html
2640+
endif
26252641

26262642
info:
26272643
$(MAKE) -C Documentation info
@@ -2852,6 +2868,10 @@ endif
28522868

28532869
test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))
28542870

2871+
ifneq (,$(INCLUDE_SCALAR))
2872+
test_bindir_programs += bin-wrappers/scalar
2873+
endif
2874+
28552875
all:: $(TEST_PROGRAMS) $(test_bindir_programs)
28562876

28572877
bin-wrappers/%: wrap-for-bin.sh
@@ -2872,6 +2892,9 @@ export TEST_NO_MALLOC_CHECK
28722892

28732893
test: all
28742894
$(MAKE) -C t/ all
2895+
ifneq (,$(INCLUDE_SCALAR))
2896+
$(MAKE) -C contrib/scalar/t
2897+
endif
28752898

28762899
perf: all
28772900
$(MAKE) -C t/perf/ all
@@ -2997,6 +3020,9 @@ install: all
29973020
$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
29983021
$(INSTALL) -m 644 $(SCRIPT_LIB) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
29993022
$(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)'
3023+
ifneq (,$(INCLUDE_SCALAR))
3024+
$(INSTALL) contrib/scalar/scalar$X '$(DESTDIR_SQ)$(bindir_SQ)'
3025+
endif
30003026
ifdef MSVC
30013027
# We DO NOT install the individual foo.o.pdb files because they
30023028
# have already been rolled up into the exe's pdb file.
@@ -3090,6 +3116,10 @@ install-doc: install-man-perl
30903116

30913117
install-man: install-man-perl
30923118
$(MAKE) -C Documentation install-man
3119+
ifneq (,$(INCLUDE_SCALAR))
3120+
$(MAKE) -C contrib/scalar scalar.1
3121+
$(INSTALL) contrib/scalar/scalar.1 '$(DESTDIR_SQ)$(mandir_SQ)/man1'
3122+
endif
30933123

30943124
install-man-perl: man-perl
30953125
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(mandir_SQ)/man3'
@@ -3098,6 +3128,10 @@ install-man-perl: man-perl
30983128

30993129
install-html:
31003130
$(MAKE) -C Documentation install-html
3131+
ifneq (,$(INCLUDE_SCALAR))
3132+
$(MAKE) -C contrib/scalar scalar.html
3133+
$(INSTALL) contrib/scalar/scalar.html '$(DESTDIR_SQ)$(htmldir)'
3134+
endif
31013135

31023136
install-info:
31033137
$(MAKE) -C Documentation install-info
@@ -3234,6 +3268,9 @@ endif
32343268
ifndef NO_TCLTK
32353269
$(MAKE) -C gitk-git clean
32363270
$(MAKE) -C git-gui clean
3271+
endif
3272+
ifneq (,$(INCLUDE_SCALAR))
3273+
$(MAKE) -C contrib/scalar clean
32373274
endif
32383275
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS
32393276
$(RM) GIT-USER-AGENT GIT-PREFIX

contrib/buildsystems/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,13 @@ if(CURL_FOUND)
700700
endif()
701701
endif()
702702

703+
if(DEFINED ENV{INCLUDE_SCALAR} AND NOT ENV{INCLUDE_SCALAR} STREQUAL "")
704+
add_executable(scalar ${CMAKE_SOURCE_DIR}/contrib/scalar/scalar.c)
705+
target_link_libraries(scalar common-main)
706+
set_target_properties(scalar PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/contrib/scalar)
707+
set_target_properties(scalar PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/contrib/scalar)
708+
endif()
709+
703710
parse_makefile_for_executables(git_builtin_extra "BUILT_INS")
704711

705712
option(SKIP_DASHED_BUILT_INS "Skip hardlinking the dashed versions of the built-ins")
@@ -924,6 +931,13 @@ string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
924931
string(REPLACE "@@PROG@@" "git-cvsserver" content "${content}")
925932
file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
926933

934+
if(DEFINED ENV{INCLUDE_SCALAR} AND NOT ENV{INCLUDE_SCALAR} STREQUAL "")
935+
file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
936+
string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
937+
string(REPLACE "@@PROG@@" "contrib/scalar/scalar${EXE_EXTENSION}" content "${content}")
938+
file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/scalar ${content})
939+
endif()
940+
927941
#options for configuring test options
928942
option(PERL_TESTS "Perform tests that use perl" ON)
929943
option(PYTHON_TESTS "Perform tests that use python" ON)

0 commit comments

Comments
 (0)