Skip to content

Commit 7b5c93c

Browse files
vdyegitster
authored andcommitted
scalar: include in standard Git build & installation
Move 'scalar' out of 'contrib/' and into the root of the Git tree. The goal of this change is to build 'scalar' as part of the standard Git build & install processes. This patch includes both the physical move of Scalar's files out of 'contrib/' ('scalar.c', 'scalar.txt', and 't9xxx-scalar.sh'), and the changes to the build definitions in 'Makefile' and 'CMakelists.txt' to accommodate the new program. At a high level, Scalar is built so that: - there is a 'scalar-objs' target (similar to those created in 029bac0 (Makefile: add {program,xdiff,test,git,fuzz}-objs & objects targets, 2021-02-23)) for debugging purposes. - it appears in the root of the install directory (rather than the gitexecdir). - it is included in the 'bin-wrappers/' directory for use in tests. - it receives a platform-specific executable suffix (e.g., '.exe'), if applicable. - 'scalar.txt' is installed as 'man1' documentation. - the 'clean' target removes the 'scalar' executable. Additionally, update the root level '.gitignore' file to ignore the Scalar executable. Signed-off-by: Victoria Dye <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b6faef3 commit 7b5c93c

File tree

10 files changed

+28
-142
lines changed

10 files changed

+28
-142
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@
185185
/git-whatchanged
186186
/git-worktree
187187
/git-write-tree
188+
/scalar
188189
/git-core-*/?*
189190
/git.res
190191
/gitweb/GITWEB-BUILD-OPTIONS

Documentation/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ MAN1_TXT += $(filter-out \
2121
MAN1_TXT += git.txt
2222
MAN1_TXT += gitk.txt
2323
MAN1_TXT += gitweb.txt
24+
MAN1_TXT += scalar.txt
2425

2526
# man5 / man7 guides (note: new guides should also be added to command-list.txt)
2627
MAN5_TXT += gitattributes.txt
File renamed without changes.

Makefile

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,9 @@ FUZZ_OBJS =
608608
FUZZ_PROGRAMS =
609609
GIT_OBJS =
610610
LIB_OBJS =
611+
SCALAR_OBJS =
611612
OBJECTS =
613+
OTHER_PROGRAMS =
612614
PROGRAM_OBJS =
613615
PROGRAMS =
614616
EXCLUDED_PROGRAMS =
@@ -821,10 +823,12 @@ BUILT_INS += git-switch$X
821823
BUILT_INS += git-whatchanged$X
822824

823825
# what 'all' will build but not install in gitexecdir
824-
OTHER_PROGRAMS = git$X
826+
OTHER_PROGRAMS += git$X
827+
OTHER_PROGRAMS += scalar$X
825828

826829
# what test wrappers are needed and 'install' will install, in bindir
827830
BINDIR_PROGRAMS_NEED_X += git
831+
BINDIR_PROGRAMS_NEED_X += scalar
828832
BINDIR_PROGRAMS_NEED_X += git-receive-pack
829833
BINDIR_PROGRAMS_NEED_X += git-shell
830834
BINDIR_PROGRAMS_NEED_X += git-upload-archive
@@ -2222,7 +2226,7 @@ profile-fast: profile-clean
22222226

22232227
all:: $(ALL_COMMANDS_TO_INSTALL) $(SCRIPT_LIB) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
22242228
ifneq (,$X)
2225-
$(QUIET_BUILT_IN)$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_COMMANDS_TO_INSTALL) git$X)), test -d '$p' -o '$p' -ef '$p$X' || $(RM) '$p';)
2229+
$(QUIET_BUILT_IN)$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_COMMANDS_TO_INSTALL) $(OTHER_PROGRAMS))), test -d '$p' -o '$p' -ef '$p$X' || $(RM) '$p';)
22262230
endif
22272231

22282232
all::
@@ -2545,7 +2549,12 @@ GIT_OBJS += git.o
25452549
.PHONY: git-objs
25462550
git-objs: $(GIT_OBJS)
25472551

2552+
SCALAR_OBJS += scalar.o
2553+
.PHONY: scalar-objs
2554+
scalar-objs: $(SCALAR_OBJS)
2555+
25482556
OBJECTS += $(GIT_OBJS)
2557+
OBJECTS += $(SCALAR_OBJS)
25492558
OBJECTS += $(PROGRAM_OBJS)
25502559
OBJECTS += $(TEST_OBJS)
25512560
OBJECTS += $(XDIFF_OBJS)
@@ -2556,10 +2565,6 @@ ifndef NO_CURL
25562565
OBJECTS += http.o http-walker.o remote-curl.o
25572566
endif
25582567

2559-
SCALAR_SOURCES := contrib/scalar/scalar.c
2560-
SCALAR_OBJECTS := $(SCALAR_SOURCES:c=o)
2561-
OBJECTS += $(SCALAR_OBJECTS)
2562-
25632568
.PHONY: objects
25642569
objects: $(OBJECTS)
25652570

@@ -2691,7 +2696,7 @@ $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS
26912696
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
26922697
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
26932698

2694-
contrib/scalar/scalar$X: $(SCALAR_OBJECTS) GIT-LDFLAGS $(GITLIBS)
2699+
scalar$X: scalar.o GIT-LDFLAGS $(GITLIBS)
26952700
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
26962701
$(filter %.o,$^) $(LIBS)
26972702

@@ -2747,8 +2752,7 @@ XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell \
27472752
XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --language=Perl \
27482753
--keyword=__ --keyword=N__ --keyword="__n:1,2"
27492754
MSGMERGE_FLAGS = --add-location --backup=off --update
2750-
LOCALIZED_C = $(sort $(FOUND_C_SOURCES) $(FOUND_H_SOURCES) $(SCALAR_SOURCES) \
2751-
$(GENERATED_H))
2755+
LOCALIZED_C = $(sort $(FOUND_C_SOURCES) $(FOUND_H_SOURCES) $(GENERATED_H))
27522756
LOCALIZED_SH = $(sort $(SCRIPT_SH) git-sh-setup.sh)
27532757
LOCALIZED_PERL = $(sort $(SCRIPT_PERL))
27542758

@@ -3062,7 +3066,7 @@ bin-wrappers/%: wrap-for-bin.sh
30623066
$(call mkdir_p_parent_template)
30633067
$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
30643068
-e 's|@@BUILD_DIR@@|$(shell pwd)|' \
3065-
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%$(X),$(@F))$(patsubst git%,$(X),$(filter $(@F),$(BINDIR_PROGRAMS_NEED_X)))|' < $< > $@ && \
3069+
-e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%,$(@F))$(if $(filter-out $(BINDIR_PROGRAMS_NO_X),$(@F)),$(X),)|' < $< > $@ && \
30663070
chmod +x $@
30673071

30683072
# GNU make supports exporting all variables by "export" without parameters.
@@ -3276,14 +3280,14 @@ ifndef NO_TCLTK
32763280
$(MAKE) -C git-gui gitexecdir='$(gitexec_instdir_SQ)' install
32773281
endif
32783282
ifneq (,$X)
3279-
$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_COMMANDS_TO_INSTALL) git$X)), test '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p' -ef '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p$X' || $(RM) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p';)
3283+
$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_COMMANDS_TO_INSTALL) $(OTHER_PROGRAMS))), test '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p' -ef '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p$X' || $(RM) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p';)
32803284
endif
32813285

32823286
bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \
32833287
execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \
32843288
destdir_from_execdir_SQ=$$(echo '$(gitexecdir_relative_SQ)' | sed -e 's|[^/][^/]*|..|g') && \
32853289
{ test "$$bindir/" = "$$execdir/" || \
3286-
for p in git$X $(filter $(install_bindir_programs),$(ALL_PROGRAMS)); do \
3290+
for p in $(OTHER_PROGRAMS) $(filter $(install_bindir_programs),$(ALL_PROGRAMS)); do \
32873291
$(RM) "$$execdir/$$p" && \
32883292
test -n "$(INSTALL_SYMLINKS)" && \
32893293
ln -s "$$destdir_from_execdir_SQ/$(bindir_relative_SQ)/$$p" "$$execdir/$$p" || \
@@ -3458,7 +3462,7 @@ clean: profile-clean coverage-clean cocciclean
34583462
$(RM) git.res
34593463
$(RM) $(OBJECTS)
34603464
$(RM) $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(REFTABLE_TEST_LIB)
3461-
$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X
3465+
$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS)
34623466
$(RM) $(TEST_PROGRAMS)
34633467
$(RM) $(FUZZ_PROGRAMS)
34643468
$(RM) $(SP_OBJ)
@@ -3509,6 +3513,7 @@ ALL_COMMANDS += git-citool
35093513
ALL_COMMANDS += git-gui
35103514
ALL_COMMANDS += gitk
35113515
ALL_COMMANDS += gitweb
3516+
ALL_COMMANDS += scalar
35123517

35133518
.PHONY: check-docs
35143519
check-docs::

contrib/buildsystems/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ unset(CMAKE_REQUIRED_INCLUDES)
610610
#programs
611611
set(PROGRAMS_BUILT
612612
git git-daemon git-http-backend git-sh-i18n--envsubst
613-
git-shell)
613+
git-shell scalar)
614614

615615
if(NOT CURL_FOUND)
616616
list(APPEND excluded_progs git-http-fetch git-http-push)
@@ -757,6 +757,9 @@ target_link_libraries(git-sh-i18n--envsubst common-main)
757757
add_executable(git-shell ${CMAKE_SOURCE_DIR}/shell.c)
758758
target_link_libraries(git-shell common-main)
759759

760+
add_executable(scalar ${CMAKE_SOURCE_DIR}/scalar.c)
761+
target_link_libraries(scalar common-main)
762+
760763
if(CURL_FOUND)
761764
add_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c)
762765

@@ -903,7 +906,7 @@ list(TRANSFORM git_perl_scripts PREPEND "${CMAKE_BINARY_DIR}/")
903906

904907
#install
905908
foreach(program ${PROGRAMS_BUILT})
906-
if(program STREQUAL "git" OR program STREQUAL "git-shell")
909+
if(program MATCHES "^(git|git-shell|scalar)$")
907910
install(TARGETS ${program}
908911
RUNTIME DESTINATION bin)
909912
else()
@@ -977,7 +980,7 @@ endif()
977980

978981
#wrapper scripts
979982
set(wrapper_scripts
980-
git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)
983+
git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext scalar)
981984

982985
set(wrapper_test_scripts
983986
test-fake-ssh test-tool)

contrib/scalar/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

contrib/scalar/Makefile

Lines changed: 0 additions & 35 deletions
This file was deleted.

contrib/scalar/t/Makefile

Lines changed: 0 additions & 81 deletions
This file was deleted.
File renamed without changes.

contrib/scalar/t/t9099-scalar.sh renamed to t/t9210-scalar.sh

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,9 @@
22

33
test_description='test the `scalar` command'
44

5-
TEST_DIRECTORY=$PWD/../../../t
6-
export TEST_DIRECTORY
5+
. ./test-lib.sh
76

8-
# Make it work with --no-bin-wrappers
9-
PATH=$PWD/..:$PATH
10-
11-
. ../../../t/test-lib.sh
12-
13-
GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab ../cron.txt,launchctl:true,schtasks:true"
7+
GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt,launchctl:true,schtasks:true"
148
export GIT_TEST_MAINT_SCHEDULER
159

1610
test_expect_success 'scalar shows a usage' '

0 commit comments

Comments
 (0)