git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] CMake build system for git
@ 2020-04-24  4:01 Sibi Siddharthan via GitGitGadget
  2020-04-24  4:01 ` [PATCH 1/8] Introduce CMake support for configuring Git on Linux Sibi Siddharthan via GitGitGadget
                   ` (9 more replies)
  0 siblings, 10 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-04-24  4:01 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan

This is an attempt to build Git using CMake. CMake is cross-platform build
generator which works well on a variety of platforms(primarily Linux and
Windows). Using CMake we can check whether certain headers exist, certain
functions exist, the required libraries are present and configure the build
accordingly. Using CMake we can also build and test Git out of source,
resulting in a clean source tree.

Tested platforms

Ubuntu 18.04 GCC 7.4 Clang 8.0.1

Windows MinGW GCC 9.2 Clang 9 Visual Studio 2015,2017,2019

Sibi Siddharthan (8):
  Introduce CMake support for configuring Git on Linux
  cmake: generate the shell/perl/python scripts and templates,
    translations
  cmake: installation support for git
  cmake: support for testing git with ctest
  cmake: support for testing git when building out of the source tree
  cmake: support for building git on windows with mingw
  cmake: support for building git on windows with msvc and clang.
  ci: modification of main.yml to use cmake for vs-build job

 .github/workflows/main.yml |  43 +-
 CMakeLists.txt             | 952 +++++++++++++++++++++++++++++++++++++
 2 files changed, 977 insertions(+), 18 deletions(-)
 create mode 100644 CMakeLists.txt


base-commit: 744177e7f7fd407c26e9e4aa3b19696859010c48
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-614%2FSibiSiddharthan%2Fgit-og-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-614/SibiSiddharthan/git-og-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/614
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 179+ messages in thread

* [PATCH 1/8] Introduce CMake support for configuring Git on Linux
  2020-04-24  4:01 [PATCH 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
@ 2020-04-24  4:01 ` Sibi Siddharthan via GitGitGadget
  2020-04-24 17:05   ` Danh Doan
  2020-04-25 17:07   ` brian m. carlson
  2020-04-24  4:01 ` [PATCH 2/8] cmake: generate the shell/perl/python scripts and templates, translations Sibi Siddharthan via GitGitGadget
                   ` (8 subsequent siblings)
  9 siblings, 2 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-04-24  4:01 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

At the moment, the recommended way to configure Git's builds is to
simply run `make`. If that does not work, the recommended strategy is to
look at the top of the `Makefile` to see whether any "Makefile knob" has
to be turned on/off, e.g. `make NO_OPENSSL=YesPlease`.

Alternatively, Git also has an `autoconf` setup which allows configuring
builds via `./configure [<option>...]`.

Both of these options are fine if the developer works on Unix or Linux.
But on Windows, we have to jump through hoops to configure a build
(read: we force the user to install a full Git for Windows SDK, which
occupies around two gigabytes (!) on disk and downloads about three
quarters of a gigabyte worth of Git objects).

To make this a little less awkward, the Git for Windows project offers
the `vs/master` branch which has a full Visual Studio solution generated
and committed. This branch can therefore be used to tinker with Git in
Visual Studio _without_ having to download the full Git for Windows SDK.
Unfortunatly, that branch is auto-generated from Git for Windows'
`master`. If a developer wants to tinker, say, with `pu`, they are out
of luck.

CMake was invented to make this sort of problem go away, by providing a
more standardized, cross-platform way to configure builds.

With a working support CMake, developers on Windows need only install
CMake, configure their build, load the generated Visual Studio solution
and immediately start modifying the code and build their own version of
Git. Likewise, developers on other platforms can use the convenient GUI
tools provided by CMake to configure their build.

So let's start building CMake support for Git.

This is only the first step, and to make it easier to review, it only
allows for configuring builds on the platform that is easiest to
configure for: Linux.

The CMake script checks whether the headers are present(eg. libgen.h),
whether the functions are present(eg. memmem), whether the funtions work
properly (eg. snprintf) and generate the required compile definitions
for the platform. The script also searches for the required libraries,
if it fails to find the required libraries the respective executables
won't be built.(eg. If libcurl is not found then git-remote-http won't
be built). This will help building Git easier.

With a CMake script an out of source build of git is possible resulting
in a clean source tree.

Note: earlier endeavors on the Git mailing list to introduce CMake ended
up in dead water. The primary reason for that was that reviewers
_expected_ CMake support to fall out of maintenance, unless the
contributor would promise to keep an eye on keeping CMake support up to
date. However, in the meantime, support for automated testing has been
introduced in Git's source code, and a later patch will modify the
(still experimental) GitHub workflow to continually verify that CMake
support is still complete. That will make maintenance reasonably easy.

Note: this patch asks for the minimum version v3.14 of CMake (which is
not all that old as of time of writing) because that is the first
version to offer a platform-independent way to generate hardlinks as
part of the build. This is needed to generate all those hardlinks for
the built-in commands of Git.

Instructions to run CMake:

cmake `relative-path-to-srcdir` -DCMAKE_BUILD_TYPE=Release

Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
compiler flags
Debug : -g
Release: -O3
RelWithDebInfo : -O2 -g
MinSizeRel : -Os
empty(default) :

NOTE: -DCMAKE_BUILD_TYPE is optional

This process generates a Makefile.
Then run `make` to build Git.

NOTE: By default CMake uses Makefile as the build tool on Linux, to use
another tool say `ninja` add this to the command line when configuring.
`-G Ninja`

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 CMakeLists.txt | 528 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 528 insertions(+)
 create mode 100644 CMakeLists.txt

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 00000000000..73703bd321f
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,528 @@
+#
+#	Copyright (c) 2020 Sibi Siddharthan
+#
+
+cmake_minimum_required(VERSION 3.14)
+
+#Parse GIT-VERSION-GEN to get the version
+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
+string(REPLACE "DEF_VER=v" "" git_version ${git_version})
+string(REPLACE ".GIT" ".0" git_version ${git_version})#for building from a snapshot
+
+project(git
+	VERSION ${git_version}
+	LANGUAGES C)
+
+
+include(CheckTypeSize)
+include(CheckCSourceRuns)
+include(CheckCSourceCompiles)
+include(CheckIncludeFile)
+include(CheckFunctionExists)
+include(CheckSymbolExists)
+include(CheckStructHasMember)
+
+find_package(ZLIB REQUIRED)
+find_package(CURL)
+find_package(EXPAT)
+find_package(Iconv)
+find_package(Intl)
+
+if(NOT Intl_FOUND)
+	add_compile_definitions(NO_GETTEXT)
+	if(NOT Iconv_FOUND)
+		add_compile_definitions(NO_ICONV)
+	endif()
+endif()
+
+include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
+if(CURL_FOUND)
+	include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
+endif()
+if(EXPAT_FOUND)
+	include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
+endif()
+if(Iconv_FOUND)
+	include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
+endif()
+if(Intl_FOUND)
+	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
+endif()
+
+find_program(SH_EXE sh)
+
+#default behaviour
+include_directories(${CMAKE_SOURCE_DIR})
+add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
+add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)
+add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES
+			SHA1DC_INIT_SAFE_HASH_DEFAULT=0
+			SHA1DC_CUSTOM_INCLUDE_SHA1_C="cache.h"
+			SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="git-compat-util.h" )
+list(APPEND compat_SOURCES sha1dc_git.c sha1dc/sha1.c sha1dc/ubc_check.c block-sha1/sha1.c sha256/block/sha256.c compat/qsort_s.c)
+
+
+add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
+			ETC_GITATTRIBUTES="etc/gitattributes"
+			ETC_GITCONFIG="etc/gitconfig"
+			GIT_EXEC_PATH="libexec/git-core"
+			GIT_LOCALE_PATH="share/locale"
+			GIT_MAN_PATH="share/man"
+			GIT_INFO_PATH="share/info"
+			GIT_HTML_PATH="share/doc/git-doc"
+			DEFAULT_HELP_FORMAT="html"
+			DEFAULT_GIT_TEMPLATE_DIR="share/git-core/templates"
+			GIT_VERSION="${PROJECT_VERSION}.GIT"
+			GIT_USER_AGENT="git/${PROJECT_VERSION}.GIT"
+			BINDIR="bin"
+			GIT_BUILT_FROM_COMMIT="")
+
+set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+
+add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
+list(APPEND compat_SOURCES unix-socket.c)
+
+#header checks
+check_include_file(libgen.h HAVE_LIBGEN_H)
+if(NOT HAVE_LIBGEN_H)
+	add_compile_definitions(NO_LIBGEN_H)
+	list(APPEND compat_SOURCES compat/basename.c)
+endif()
+
+check_include_file(sys/sysinfo.h HAVE_SYSINFO)
+if(HAVE_SYSINFO)
+	add_compile_definitions(HAVE_SYSINFO)
+endif()
+
+check_c_source_compiles("
+#include <alloca.h>
+int
+main ()
+{
+char *p = (char *) alloca (2 * sizeof (int));
+	if (p) return 0;
+	return 0;
+}"
+HAVE_ALLOCA_H)
+if(HAVE_ALLOCA_H)
+	add_compile_definitions(HAVE_ALLOCA_H)
+endif()
+
+check_include_file(strings.h HAVE_STRINGS_H)
+if(HAVE_STRINGS_H)
+	add_compile_definitions(HAVE_STRINGS_H)
+endif()
+
+check_include_file(sys/select.h HAVE_SYS_SELECT_H)
+if(NOT HAVE_SYS_SELECT_H)
+	add_compile_definitions(NO_SYS_SELECT_H)
+endif()
+
+check_include_file(sys/poll.h HAVE_SYS_POLL_H)
+if(NOT HAVE_SYS_POLL_H)
+	add_compile_definitions(NO_SYS_POLL_H)
+endif()
+
+check_include_file(poll.h HAVE_POLL_H)
+if(NOT HAVE_POLL_H)
+	add_compile_definitions(NO_POLL_H)
+endif()
+
+check_include_file(inttypes.h HAVE_INTTYPES_H)
+if(NOT HAVE_INTTYPES_H)
+	add_compile_definitions(NO_INTTYPES_H)
+endif()
+
+check_include_file(paths.h HAVE_PATHS_H)
+if(HAVE_PATHS_H)
+	add_compile_definitions(HAVE_PATHS_H)
+endif()
+
+#function checks
+set(function_checks
+	strcasestr memmem strlcpy strtoimax strtoumax strtoull
+	setenv  mkdtemp poll pread  memmem unsetenv hstrerror)
+
+foreach(f ${function_checks})
+	string(TOUPPER ${f} uf)
+	check_function_exists(${f} HAVE_${uf})
+	if(NOT HAVE_${uf})
+		add_compile_definitions(NO_${uf})
+	endif()
+endforeach()
+
+if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)
+	include_directories(compat/poll)
+	add_compile_definitions(NO_POLL)
+	list(APPEND compat_SOURCES compat/poll/poll.c)
+endif()
+
+if(NOT HAVE_STRCASESTR)
+	list(APPEND compat_SOURCES compat/strcasestr.c)
+endif()
+
+if(NOT HAVE_STRLCPY)
+	list(APPEND compat_SOURCES compat/strlcpy.c)
+endif()
+
+if(NOT HAVE_STRTOUMAX)
+	list(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c)
+endif()
+
+if(NOT HAVE_SETENV)
+	list(APPEND compat_SOURCES compat/setenv.c)
+endif()
+
+if(NOT HAVE_MKDTEMP)
+	list(APPEND compat_SOURCES compat/mkdtemp.c)
+endif()
+
+if(NOT HAVE_PREAD)
+	list(APPEND compat_SOURCES compat/pread.c)
+endif()
+
+if(NOT HAVE_MEMMEM)
+	list(APPEND compat_SOURCES compat/memmem.c)
+endif()
+
+if(NOT WIN32)
+	if(NOT HAVE_UNSETENV)
+		list(APPEND compat_SOURCES compat/unsetenv.c)
+	endif()
+
+	if(NOT HAVE_HSTRERROR)
+		list(APPEND compat_SOURCES compat/hstrerror.c)
+	endif()
+endif()
+
+check_function_exists(getdelim HAVE_GETDELIM)
+if(HAVE_GETDELIM)
+	add_compile_definitions(HAVE_GETDELIM)
+endif()
+
+check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
+check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC)
+if(HAVE_CLOCK_GETTIME)
+	add_compile_definitions(HAVE_CLOCK_GETTIME)
+endif()
+if(HAVE_CLOCK_MONOTONIC)
+	add_compile_definitions(HAVE_CLOCK_MONOTONIC)
+endif()
+
+
+#compile checks
+check_c_source_runs("
+#include<stdio.h>
+#include<stdarg.h>
+#include<string.h>
+#include<stdlib.h>
+int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
+{
+	int ret;
+	va_list ap;
+
+	va_start(ap, format);
+	ret = vsnprintf(str, maxsize, format, ap);
+	va_end(ap);
+	return ret;
+}
+
+int
+main ()
+{
+	char buf[6];
+	if (test_vsnprintf(buf, 3, \"%s\", \"12345\") != 5
+		|| strcmp(buf, \"12\")) return 1;
+	if (snprintf(buf, 3, \"%s\", \"12345\") != 5
+		|| strcmp(buf, \"12\")) return 1;
+
+	return 0;
+}"
+SNPRINTF_OK)
+if(NOT SNPRINTF_OK)
+	add_compile_definitions(SNPRINTF_RETURNS_BOGUS)
+	list(APPEND compat_SOURCES compat/snprintf.c)
+endif()
+
+check_c_source_runs("
+#include<stdio.h>
+int
+main ()
+{
+	FILE *f = fopen(\".\", \"r\");
+	return f != NULL;
+
+	return 0;
+}"
+FREAD_READS_DIRECTORIES_NO)
+if(NOT FREAD_READS_DIRECTORIES_NO)
+	add_compile_definitions(FREAD_READS_DIRECTORIES)
+	list(APPEND compat_SOURCES compat/fopen.c)
+endif()
+
+check_c_source_compiles("
+#include <regex.h>
+#ifndef REG_STARTEND
+#error oops we dont have it
+#endif
+int main(){return 0;}"
+HAVE_REGEX)
+if(NOT HAVE_REGEX)
+	include_directories(compat/regex )
+	list(APPEND compat_SOURCES compat/regex/regex.c )
+	add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
+endif()
+
+
+check_c_source_compiles("
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+int
+main ()
+{
+	int val, mib[2];
+	size_t len;
+
+	mib[0] = CTL_HW;
+	mib[1] = 1;
+	len = sizeof(val);
+	return sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;
+
+	return 0;
+}"
+HAVE_BSD_SYSCTL)
+if(HAVE_BSD_SYSCTL)
+	add_compile_definitions(HAVE_BSD_SYSCTL)
+endif()
+
+#programs
+set(PROGRAMS_BUILT
+	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
+	git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
+
+if(NOT CURL_FOUND)
+	list(APPEND excluded_progs git-http-fetch git-http-push)
+	add_compile_definitions(NO_CURL)
+	message(WARNING "git-http-push and git-http-fetch will not be built")
+else()
+	list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
+	if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
+		add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
+	endif()
+endif()
+
+if(NOT EXPAT_FOUND)
+	list(APPEND excluded_progs git-http-push)
+	add_compile_definitions(NO_EXPAT)
+else()
+	list(APPEND PROGRAMS_BUILT git-http-push)
+	if(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2)
+		add_compile_definitions(EXPAT_NEEDS_XMLPARSE_H)
+	endif()
+endif()
+
+list(REMOVE_DUPLICATES excluded_progs)
+list(REMOVE_DUPLICATES PROGRAMS_BUILT)
+
+
+foreach(p ${excluded_progs})
+	list(APPEND EXCLUSION_PROGS --exclude-program ${p} )
+endforeach()
+
+#for comparing null values
+list(APPEND EXCLUSION_PROGS empty)
+set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" FORCE)
+
+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
+	list(REMOVE_ITEM EXCLUSION_PROGS empty)
+	message("Generating command-list.h")
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/command-list.h)
+endif()
+
+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/config-list.h)
+	message("Generating config-list.h")
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/config-list.h)
+endif()
+
+
+#build
+set(libgit_SOURCES
+	abspath.c add-interactive.c add-patch.c advice.c alias.c
+	alloc.c apply.c archive.c archive-tar.c archive-zip.c argv-array.c
+	attr.c base85.c bisect.c blame.c blob.c bloom.c branch.c bulk-checkin.c
+	bundle.c cache-tree.c chdir-notify.c checkout.c color.c column.c
+	combine-diff.c commit.c commit-graph.c commit-reach.c compat/obstack.c
+	compat/terminal.c config.c connect.c connected.c convert.c copy.c credential.c
+	csum-file.c ctype.c date.c decorate.c delta-islands.c diffcore-break.c
+	diffcore-delta.c diffcore-order.c diffcore-pickaxe.c diffcore-rename.c
+	diff-delta.c diff-lib.c diff-no-index.c diff.c dir.c dir-iterator.c editor.c
+	entry.c environment.c ewah/bitmap.c ewah/ewah_bitmap.c ewah/ewah_io.c
+	ewah/ewah_rlw.c exec-cmd.c fetch-negotiator.c fetch-pack.c fmt-merge-msg.c fsck.c fsmonitor.c
+	gettext.c gpg-interface.c graph.c grep.c hashmap.c linear-assignment.c help.c hex.c
+	ident.c interdiff.c json-writer.c kwset.c levenshtein.c line-log.c line-range.c list-objects.c
+	list-objects-filter.c list-objects-filter-options.c ll-merge.c lockfile.c
+	log-tree.c ls-refs.c mailinfo.c mailmap.c match-trees.c mem-pool.c merge.c merge-blobs.c
+	merge-recursive.c mergesort.c midx.c name-hash.c negotiator/default.c
+	negotiator/skipping.c notes.c notes-cache.c notes-merge.c notes-utils.c object.c oidmap.c
+	oidset.c oid-array.c packfile.c pack-bitmap.c pack-bitmap-write.c pack-check.c pack-objects.c
+	pack-revindex.c pack-write.c pager.c parse-options.c parse-options-cb.c patch-delta.c
+	patch-ids.c path.c pathspec.c pkt-line.c preload-index.c pretty.c prio-queue.c progress.c
+	promisor-remote.c prompt.c protocol.c prune-packed.c quote.c range-diff.c reachable.c read-cache.c rebase.c
+	rebase-interactive.c reflog-walk.c refs.c refs/files-backend.c refs/iterator.c
+	refs/packed-backend.c refs/ref-cache.c refspec.c ref-filter.c remote.c replace-object.c
+	repo-settings.c repository.c rerere.c reset.c resolve-undo.c revision.c run-command.c
+	send-pack.c sequencer.c serve.c server-info.c setup.c sha1-lookup.c
+	sha1-file.c sha1-name.c shallow.c sideband.c sigchain.c split-index.c
+	stable-qsort.c strbuf.c streaming.c string-list.c submodule.c submodule-config.c
+	sub-process.c symlinks.c tag.c tempfile.c thread-utils.c tmp-objdir.c
+	trace.c trace2.c trace2/tr2_cfg.c trace2/tr2_cmd_name.c trace2/tr2_dst.c
+	trace2/tr2_sid.c trace2/tr2_sysenv.c trace2/tr2_tbuf.c trace2/tr2_tgt_event.c
+	trace2/tr2_tgt_normal.c trace2/tr2_tgt_perf.c trace2/tr2_tls.c trailer.c transport.c
+	transport-helper.c tree-diff.c tree.c tree-walk.c unpack-trees.c upload-pack.c url.c
+	urlmatch.c usage.c userdiff.c utf8.c varint.c version.c versioncmp.c walker.c wildmatch.c
+	worktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c
+	zlib.c)
+
+add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
+
+set(libxdiff_SOURCES
+	xdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c
+	xdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)
+add_library(xdiff STATIC ${libxdiff_SOURCES})
+
+set(libvcs-svn_SOURCES
+	vcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c
+	vcs-svn/svndiff.c vcs-svn/svndump.c)
+add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
+
+#link all required libraries to common-main
+add_library(common-main OBJECT common-main.c)
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
+if(Intl_FOUND)
+	target_link_libraries(common-main ${Intl_LIBRARIES})
+endif()
+if(Iconv_FOUND)
+	target_link_libraries(common-main ${Iconv_LIBRARIES})
+endif()
+
+
+set(git_SOURCES
+	builtin/add.c builtin/am.c builtin/annotate.c builtin/apply.c
+	builtin/archive.c builtin/bisect--helper.c builtin/blame.c
+	builtin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c
+	builtin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c
+	builtin/checkout-index.c builtin/checkout.c builtin/clean.c
+	builtin/clone.c builtin/column.c builtin/commit-tree.c
+	builtin/commit.c builtin/commit-graph.c builtin/config.c
+	builtin/count-objects.c builtin/credential.c builtin/describe.c
+	builtin/diff-files.c builtin/diff-index.c builtin/diff-tree.c
+	builtin/diff.c builtin/difftool.c builtin/env--helper.c
+	builtin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c
+	builtin/for-each-ref.c builtin/fsck.c builtin/gc.c
+	builtin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c
+	builtin/help.c builtin/index-pack.c builtin/init-db.c
+	builtin/interpret-trailers.c builtin/log.c builtin/ls-files.c
+	builtin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c
+	builtin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c
+	builtin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c
+	builtin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c
+	builtin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c
+	builtin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c
+	builtin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c
+	builtin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c
+	builtin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c
+	builtin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c
+	builtin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c
+	builtin/show-branch.c builtin/show-index.c builtin/show-ref.c
+	builtin/sparse-checkout.c builtin/stash.c builtin/stripspace.c
+	builtin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c
+	builtin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c
+	builtin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c
+	builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c
+	builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)
+
+add_executable(git git.c ${git_SOURCES})
+target_link_libraries(git common-main )
+
+add_executable(git-bugreport bugreport.c)
+target_link_libraries(git-bugreport common-main)
+
+add_executable(git-credential-store credential-store.c)
+target_link_libraries(git-credential-store common-main)
+
+add_executable(git-daemon daemon.c)
+target_link_libraries(git-daemon common-main)
+
+add_executable(git-fast-import fast-import.c)
+target_link_libraries(git-fast-import common-main)
+
+add_executable(git-http-backend http-backend.c)
+target_link_libraries(git-http-backend common-main)
+
+add_executable(git-sh-i18n--envsubst sh-i18n--envsubst.c)
+target_link_libraries(git-sh-i18n--envsubst common-main)
+
+add_executable(git-shell shell.c)
+target_link_libraries(git-shell common-main)
+
+if(CURL_FOUND)
+	add_library(http_obj OBJECT http.c)
+
+	add_executable(git-imap-send imap-send.c)
+	target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})
+
+	add_executable(git-http-fetch http-walker.c http-fetch.c)
+	target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})
+
+	add_executable(git-remote-http http-walker.c remote-curl.c)
+	target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )
+
+	if(EXPAT_FOUND)
+		add_executable(git-http-push http-push.c)
+		target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
+	endif()
+endif()
+
+add_executable(git-remote-testsvn remote-testsvn.c)
+target_link_libraries(git-remote-testsvn common-main vcs-svn)
+
+add_executable(git-credential-cache credential-cache.c)
+target_link_libraries(git-credential-cache common-main)
+
+add_executable(git-credential-cache--daemon credential-cache--daemon.c)
+target_link_libraries(git-credential-cache--daemon common-main)
+
+
+set(git_builtin_extra
+	cherry cherry-pick format-patch fsck-objects
+	init merge-subtree restore show
+	stage status switch whatchanged)
+
+#Creating hardlinks
+foreach(s ${git_SOURCES} ${git_builtin_extra})
+	string(REPLACE "builtin/" "" s ${s})
+	string(REPLACE ".c" "" s ${s})
+	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
+	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
+endforeach()
+
+if(CURL_FOUND)
+	set(remote_exes
+		git-remote-https git-remote-ftp git-remote-ftps)
+	foreach(s ${remote_exes})
+		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
+		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+	endforeach()
+endif()
+
+add_custom_command(OUTPUT ${git_links} ${git_http_links}
+		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
+		DEPENDS git git-remote-http)
+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
\ No newline at end of file
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH 2/8] cmake: generate the shell/perl/python scripts and templates, translations
  2020-04-24  4:01 [PATCH 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
  2020-04-24  4:01 ` [PATCH 1/8] Introduce CMake support for configuring Git on Linux Sibi Siddharthan via GitGitGadget
@ 2020-04-24  4:01 ` Sibi Siddharthan via GitGitGadget
  2020-04-24 17:19   ` Danh Doan
  2020-04-24  4:01 ` [PATCH 3/8] cmake: installation support for git Sibi Siddharthan via GitGitGadget
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-04-24  4:01 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch implements the placeholder substitution to generate, say,
`git-request-pull` from `git-request-pull.sh`.

The shell/perl/python scripts and template are generated using CMake
(very similar to what sed does).

The text translations are only build if `msgfmt` is found in your path.

NOTE: The scripts and templates are generated during configuration.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 CMakeLists.txt | 107 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 106 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 73703bd321f..788b53be873 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -51,6 +51,11 @@ endif()
 
 find_program(SH_EXE sh)
 
+find_program(MSGFMT_EXE msgfmt)
+if(NOT MSGFMT_EXE)
+	message(WARNING "Text Translations won't be build")
+endif()
+
 #default behaviour
 include_directories(${CMAKE_SOURCE_DIR})
 add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
@@ -525,4 +530,104 @@ endif()
 add_custom_command(OUTPUT ${git_links} ${git_http_links}
 		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
 		DEPENDS git git-remote-http)
-add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
\ No newline at end of file
+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
+
+
+#creating required scripts
+set(SHELL_PATH /bin/sh)
+set(PERL_PATH /usr/bin/perl)
+set(LOCALEDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
+set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
+set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)
+
+#shell scripts
+set(git_shell_scripts
+	git-bisect git-difftool--helper git-filter-branch
+	git-merge-octopus git-merge-one-file git-merge-resolve
+	git-mergetool git-quiltimport
+	git-request-pull git-submodule git-web--browse
+	git-mergetool--lib git-parse-remote git-rebase--preserve-merges
+	git-sh-setup git-sh-i18n git-instaweb)
+
+foreach(script ${git_shell_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)
+	string(REPLACE "@SHELL_PATH@" "${SHELL_PATH}" content "${content}")
+	string(REPLACE "@@DIFF@@" "diff" content "${content}")
+	string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@GITWEBDIR@" "${GITWEBDIR}" content "${content}")
+	string(REPLACE "@@NO_CURL@@" "" content "${content}")
+	string(REPLACE "@@USE_GETTEXT_SCHEME@@" "" content "${content}")
+	string(REPLACE "# @@BROKEN_PATH_FIX@@" "" content "${content}")
+	string(REPLACE "@@PERL@@" "${PERL_PATH}" content "${content}")
+	string(REPLACE "@@SANE_TEXT_GREP@@" "-a" content "${content}")
+	string(REPLACE "@@PAGER_ENV@@" "LESS=FRX LV=-c" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+endforeach()
+
+#perl scripts
+set(git_perl_scripts
+	git-add--interactive git-archimport git-cvsexportcommit
+	git-cvsimport git-cvsserver git-send-email git-svn)
+
+#create perl header
+file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
+string(REPLACE "@@PATHSEP@@" ":" perl_header "${perl_header}")
+string(REPLACE "@@INSTLIBDIR@@" "${INSTLIBDIR}" perl_header "${perl_header}")
+
+foreach(script ${git_perl_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)
+	string(REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n${perl_header}\n" content "${content}")
+	string(REPLACE "@@GIT_VERSION@@" "${PROJECT_VERSION}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+endforeach()
+
+#python script
+file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)
+string(REPLACE "#!/usr/bin/env python" "#!/usr/bin/python" content "${content}")
+file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})
+
+#perl modules
+file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
+
+foreach(pm ${perl_modules})
+	string(REPLACE "${CMAKE_SOURCE_DIR}/perl/" "" file_path ${pm})
+	file(STRINGS ${pm} content NEWLINE_CONSUME)
+	string(REPLACE "@@LOCALEDIR@@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@@NO_PERL_CPAN_FALLBACKS@@" "" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})
+#test-lib.sh requires perl/build/lib to be the build directory of perl modules
+endforeach()
+
+
+#templates
+file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
+set(hooks_templates
+	applypatch-msg.sample pre-applypatch.sample pre-push.sample
+	commit-msg.sample pre-commit.sample pre-rebase.sample
+	fsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample
+	post-update.sample prepare-commit-msg.sample update.sample)
+
+#templates have @.*@ replacement so use configure_file instead
+#hooks
+foreach(tm ${hooks_templates})
+	configure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)
+endforeach()
+
+#info
+configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)
+
+#this
+configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)
+
+
+#translations
+if(MSGFMT_EXE)
+	set(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)
+	foreach(po ${po_files})
+		file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo
+				COMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)
+		list(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)
+	endforeach()
+	add_custom_target(po-gen ALL DEPENDS ${po_gen})
+endif()
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH 3/8] cmake: installation support for git
  2020-04-24  4:01 [PATCH 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
  2020-04-24  4:01 ` [PATCH 1/8] Introduce CMake support for configuring Git on Linux Sibi Siddharthan via GitGitGadget
  2020-04-24  4:01 ` [PATCH 2/8] cmake: generate the shell/perl/python scripts and templates, translations Sibi Siddharthan via GitGitGadget
@ 2020-04-24  4:01 ` Sibi Siddharthan via GitGitGadget
  2020-04-24 17:23   ` Danh Doan
  2020-04-24  4:01 ` [PATCH 4/8] cmake: support for testing git with ctest Sibi Siddharthan via GitGitGadget
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-04-24  4:01 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch provides the facility to install the built binaries and
scripts.

This is very similar to `make install`.
By default the destination directory(DESTDIR) is /usr/local/ on Linux
To set a custom installation path do this:
cmake `relative-path-to-srcdir`
	-DCMAKE_INSTALL_PREFIX=`preferred-install-path`

Then run `make install`

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 CMakeLists.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 788b53be873..25de5b5bc35 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,6 +13,8 @@ project(git
 	VERSION ${git_version}
 	LANGUAGES C)
 
+#TODO gitk git-gui gitweb
+#TODO Add pcre support
 
 include(CheckTypeSize)
 include(CheckCSourceRuns)
@@ -631,3 +633,50 @@ if(MSGFMT_EXE)
 	endforeach()
 	add_custom_target(po-gen ALL DEPENDS ${po_gen})
 endif()
+
+
+#to help with the install
+list(TRANSFORM git_shell_scripts PREPEND "${CMAKE_BINARY_DIR}/")
+list(TRANSFORM git_perl_scripts PREPEND "${CMAKE_BINARY_DIR}/")
+
+#install
+install(TARGETS git git-shell
+	RUNTIME DESTINATION bin)
+install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver  #${CMAKE_SOURCE_DIR}/gitk-git/gitk check
+	DESTINATION bin)
+
+list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)
+install(TARGETS ${PROGRAMS_BUILT}
+	RUNTIME DESTINATION libexec/git-core)
+
+set(bin_links
+	git-receive-pack git-upload-archive git-upload-pack)
+
+foreach(b ${bin_links})
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
+endforeach()
+
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
+
+foreach(b ${git_links})
+	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
+	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+endforeach()
+
+foreach(b ${git_http_links})
+	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
+	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+endforeach()
+
+install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
+	DESTINATION libexec/git-core)
+
+install(DIRECTORY mergetools DESTINATION libexec/git-core)
+install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5
+	FILES_MATCHING PATTERN "*.pm")
+install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)
+
+if(MSGFMT_EXE)
+	install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
+endif()
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH 4/8] cmake: support for testing git with ctest
  2020-04-24  4:01 [PATCH 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                   ` (2 preceding siblings ...)
  2020-04-24  4:01 ` [PATCH 3/8] cmake: installation support for git Sibi Siddharthan via GitGitGadget
@ 2020-04-24  4:01 ` Sibi Siddharthan via GitGitGadget
  2020-04-24 17:28   ` Danh Doan
  2020-04-24  4:01 ` [PATCH 5/8] cmake: support for testing git when building out of the source tree Sibi Siddharthan via GitGitGadget
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-04-24  4:01 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch provides an alternate way to test git using ctest.
CTest ships with CMake, so there is no additional dependency being
introduced.

To perform the tests with ctest do this after building:
ctest -j[number of jobs]

NOTE: -j is optional, the default number of jobs is 1

Each of the jobs does this:
cd t/ && sh t[something].sh

The reason for using CTest is that it logs the output of the tests
in a neat way, which can be helpful during diagnosis of failures.

After the tests have run ctest generates three log files located in
`build-directory`/Testing/Temporary/

These log files are:

CTestCostData.txt:
This file contains the time taken to complete each test.

LastTestsFailed.log:
This log file contains the names of the tests that have failed in the
run.

LastTest.log:
This log file contains the log of all the tests that have run.
A snippet of the file is given below.

10/901 Testing: D:/my/git-master/t/t0009-prio-queue.sh
10/901 Test: D:/my/git-master/t/t0009-prio-queue.sh
Command: "sh.exe" "D:/my/git-master/t/t0009-prio-queue.sh"
Directory: D:/my/git-master/t
"D:/my/git-master/t/t0009-prio-queue.sh"
Output:
----------------------------------------------------------
ok 1 - basic ordering
ok 2 - mixed put and get
ok 3 - notice empty queue
ok 4 - stack order
passed all 4 test(s)
1..4
<end of output>
Test time =   1.11 sec

NOTE: Testing only works when building in source for now.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 CMakeLists.txt | 142 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 142 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 25de5b5bc35..141ccefa559 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,6 +23,7 @@ include(CheckIncludeFile)
 include(CheckFunctionExists)
 include(CheckSymbolExists)
 include(CheckStructHasMember)
+include(CTest)
 
 find_package(ZLIB REQUIRED)
 find_package(CURL)
@@ -680,3 +681,144 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/
 if(MSGFMT_EXE)
 	install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
 endif()
+
+
+if(BUILD_TESTING)
+
+#tests-helpers
+add_executable(test-fake-ssh t/helper/test-fake-ssh.c)
+target_link_libraries(test-fake-ssh common-main)
+
+add_executable(test-line-buffer t/helper/test-line-buffer.c)
+target_link_libraries(test-line-buffer common-main vcs-svn)
+
+add_executable(test-svn-fe t/helper/test-svn-fe.c)
+target_link_libraries(test-svn-fe common-main vcs-svn)
+
+set(test_helper_sources
+	t/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c
+	t/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c
+	t/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c
+	t/helper/test-dump-fsmonitor.c t/helper/test-dump-split-index.c
+	t/helper/test-dump-untracked-cache.c t/helper/test-example-decorate.c
+	t/helper/test-genrandom.c t/helper/test-genzeros.c t/helper/test-hash.c
+	t/helper/test-hashmap.c t/helper/test-hash-speed.c t/helper/test-index-version.c
+	t/helper/test-json-writer.c t/helper/test-lazy-init-name-hash.c
+	t/helper/test-match-trees.c t/helper/test-mergesort.c t/helper/test-mktemp.c
+	t/helper/test-oidmap.c t/helper/test-online-cpus.c t/helper/test-parse-options.c
+	t/helper/test-parse-pathspec-file.c t/helper/test-path-utils.c t/helper/test-pkt-line.c
+	t/helper/test-prio-queue.c t/helper/test-progress.c t/helper/test-reach.c
+	t/helper/test-read-cache.c t/helper/test-read-graph.c t/helper/test-read-midx.c
+	t/helper/test-ref-store.c t/helper/test-regex.c t/helper/test-repository.c
+	t/helper/test-revision-walking.c t/helper/test-run-command.c t/helper/test-scrap-cache-tree.c
+	t/helper/test-serve-v2.c t/helper/test-sha1.c t/helper/test-oid-array.c t/helper/test-sha256.c
+	t/helper/test-sigchain.c t/helper/test-strcmp-offset.c t/helper/test-string-list.c
+	t/helper/test-submodule-config.c t/helper/test-submodule-nested-repo-config.c t/helper/test-subprocess.c
+	t/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c
+	t/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)
+
+add_executable(test-tool ${test_helper_sources})
+target_link_libraries(test-tool common-main)
+
+set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+			PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)
+
+#wrapper scripts
+set(wrapper_scripts
+	git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)
+
+set(wrapper_test_scripts
+	test-fake-ssh test-line-buffer test-svn-fe test-tool)
+
+
+foreach(script ${wrapper_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@@PROG@@" "${script}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
+endforeach()
+
+foreach(script ${wrapper_test_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
+endforeach()
+
+file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+string(REPLACE "@@PROG@@" "git-cvsserver" content "${content}")
+file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
+
+#options for configuring test options
+option(PERL_TESTS "Perform tests that use perl" ON)
+option(PYTHON_TESTS "Perform tests that use python" ON)
+
+#GIT-BUILD-OPTIONS
+set(TEST_SHELL_PATH ${SHELL_PATH})
+set(DIFF diff)
+set(PYTHON_PATH /usr/bin/python)
+set(TAR tar)
+set(NO_CURL )
+set(NO_EXPAT )
+set(USE_LIBPCRE1 )
+set(USE_LIBPCRE2 )
+set(NO_LIBPCRE1_JIT )
+set(NO_PERL )
+set(NO_PTHREADS )
+set(NO_PYTHON )
+set(PAGER_ENV "LESS=FRX LV=-c")
+set(DC_SHA1 YesPlease)
+set(RUNTIME_PREFIX true)
+set(NO_GETTEXT )
+
+if(NOT CURL_FOUND)
+	set(NO_CURL 1)
+endif()
+
+if(NOT EXPAT_FOUND)
+	set(NO_EXPAT 1)
+endif()
+
+if(NOT Intl_FOUND)
+	set(NO_GETTEXT 1)
+endif()
+
+if(NOT PERL_TESTS)
+	set(NO_PERL 1)
+endif()
+
+if(NOT PYTHON_TESTS)
+	set(NO_PYTHON 1)
+endif()
+
+file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "SHELL_PATH='${SHELL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TEST_SHELL_PATH='${TEST_SHELL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PERL_PATH='${PERL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DIFF='${DIFF}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PYTHON_PATH='${PYTHON_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TAR='${TAR}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_CURL='${NO_CURL}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_EXPAT='${NO_EXPAT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "USE_LIBPCRE1='${USE_LIBPCRE1}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PERL='${NO_PERL}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
+
+file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
+
+#test
+foreach(tsh ${test_scipts})
+	add_test(NAME ${tsh}
+		COMMAND ${SH_EXE} ${tsh}
+		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)
+endforeach()
+
+endif()#BUILD_TESTING
\ No newline at end of file
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH 5/8] cmake: support for testing git when building out of the source tree
  2020-04-24  4:01 [PATCH 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                   ` (3 preceding siblings ...)
  2020-04-24  4:01 ` [PATCH 4/8] cmake: support for testing git with ctest Sibi Siddharthan via GitGitGadget
@ 2020-04-24  4:01 ` Sibi Siddharthan via GitGitGadget
  2020-04-24 17:34   ` Danh Doan
  2020-04-24  4:01 ` [PATCH 6/8] cmake: support for building git on windows with mingw Sibi Siddharthan via GitGitGadget
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-04-24  4:01 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch allows git to be tested when performin out of source builds.

This involves changing GIT_BUILD_DIR in t/test-lib.sh to point to the
build directory. Also some miscellaneous copies from the source directory
to the build directory.
The copies are:
t/chainlint.sed needed by a bunch of test scripts
po/is.po needed by t0204-gettext-rencode-sanity
mergetools/tkdiff needed by t7800-difftool
contrib/completion/git-prompt.sh needed by t9903-bash-prompt
contrib/completion/git-completion.bash needed by t9902-completion
contrib/svn-fe/svnrdump_sim.py needed by t9020-remote-svn

NOTE: t/test-lib.sh is only modified when tests are run not during
the build or configure.
The trash directory is still srcdir/t

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 CMakeLists.txt | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 141ccefa559..29a23eb11f7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -812,6 +812,25 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n"
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
 
+#Make the tests work when building out of the source tree
+if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
+	file(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)
+	string(REPLACE "/CMakeCache.txt" "" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})
+	#Setting the build directory in test-lib.sh before running tests
+	file(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake
+		"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \"GIT_BUILD_DIR=(.*)\")\n"
+		"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\n"
+		"string(REPLACE \"\${GIT_BUILD_DIR_REPL}\" \"GIT_BUILD_DIR=\\\"$TEST_DIRECTORY\\\"/../${BUILD_DIR_RELATIVE}\" content \"\${content}\")\n"
+		"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \${content})")
+	#misc copies
+	file(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)
+	file(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)
+	file(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/svn-fe/svnrdump_sim.py DESTINATION ${CMAKE_BINARY_DIR}/contrib/svn-fe/)
+endif()
+
 file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
 
 #test
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH 6/8] cmake: support for building git on windows with mingw
  2020-04-24  4:01 [PATCH 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                   ` (4 preceding siblings ...)
  2020-04-24  4:01 ` [PATCH 5/8] cmake: support for testing git when building out of the source tree Sibi Siddharthan via GitGitGadget
@ 2020-04-24  4:01 ` Sibi Siddharthan via GitGitGadget
  2020-04-24 17:39   ` Philip Oakley
  2020-04-24  4:01 ` [PATCH 7/8] cmake: support for building git on windows with msvc and clang Sibi Siddharthan via GitGitGadget
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-04-24  4:01 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch facilitates building git on Windows with CMake using MinGW

NOTE: The funtions unsetenv and hstrerror are not checked in Windows
builds.
Reasons
NO_UNSETENV is not compatible with Windows builds.
lines 262-264 compat/mingw.h

compat/mingw.h(line 25) provides a definition of hstrerror which
conflicts with the definition provided in
git-compat-util.h(lines 733-736).

To use CMake on Windows with MinGW do this:
cmake `relative-path-to-srcdir` -G "MinGW Makefiles"

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 CMakeLists.txt | 120 +++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 97 insertions(+), 23 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 29a23eb11f7..d9eb1060390 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,9 +13,12 @@ project(git
 	VERSION ${git_version}
 	LANGUAGES C)
 
+
 #TODO gitk git-gui gitweb
+#TODO Enable NLS on windows natively
 #TODO Add pcre support
 
+
 include(CheckTypeSize)
 include(CheckCSourceRuns)
 include(CheckCSourceCompiles)
@@ -31,6 +34,7 @@ find_package(EXPAT)
 find_package(Iconv)
 find_package(Intl)
 
+
 if(NOT Intl_FOUND)
 	add_compile_definitions(NO_GETTEXT)
 	if(NOT Iconv_FOUND)
@@ -53,6 +57,16 @@ if(Intl_FOUND)
 endif()
 
 find_program(SH_EXE sh)
+if(NOT SH_EXE)
+	message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")
+endif()
+
+if(WIN32)
+	find_program(WINDRES_EXE windres)
+	if(NOT WINDRES_EXE)
+		message(FATAL_ERROR "Install windres on Windows for resource files")
+	endif()
+endif()
 
 find_program(MSGFMT_EXE msgfmt)
 if(NOT MSGFMT_EXE)
@@ -85,11 +99,39 @@ add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
 			BINDIR="bin"
 			GIT_BUILT_FROM_COMMIT="")
 
-set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
-add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+if(WIN32)
+	set(FALLBACK_RUNTIME_PREFIX /mingw64)
+	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+else()
+	set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+endif()
 
-add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
-list(APPEND compat_SOURCES unix-socket.c)
+
+#Platform Specific
+if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+	include_directories(compat/win32)
+	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
+				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
+				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT
+				USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
+				UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
+	list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
+		compat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c
+		compat/win32/trace2_win32_process_info.c compat/win32/dirent.c
+		compat/nedmalloc/nedmalloc.c compat/strdup.c)
+	set(NO_UNIX_SOCKETS 1)
+
+elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
+	add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
+	list(APPEND compat_SOURCES unix-socket.c)
+endif()
+
+if(WIN32)
+	set(EXE_EXTENSION .exe)
+else()
+	set(EXE_EXTENSION)
+endif()
 
 #header checks
 check_include_file(libgen.h HAVE_LIBGEN_H)
@@ -150,7 +192,12 @@ endif()
 #function checks
 set(function_checks
 	strcasestr memmem strlcpy strtoimax strtoumax strtoull
-	setenv  mkdtemp poll pread  memmem unsetenv hstrerror)
+	setenv  mkdtemp poll pread  memmem)
+
+#unsetenv,hstrerror are incompatible with windows build
+if(NOT WIN32)
+	list(APPEND function_checks unsetenv hstrerror)
+endif()
 
 foreach(f ${function_checks})
 	string(TOUPPER ${f} uf)
@@ -309,7 +356,13 @@ endif()
 #programs
 set(PROGRAMS_BUILT
 	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
-	git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
+	git-shell git-remote-testsvn)
+
+if(NO_UNIX_SOCKETS)
+	list(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)
+else()
+	list(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)
+endif()
 
 if(NOT CURL_FOUND)
 	list(APPEND excluded_progs git-http-fetch git-http-push)
@@ -410,15 +463,34 @@ set(libvcs-svn_SOURCES
 	vcs-svn/svndiff.c vcs-svn/svndump.c)
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
 
+#add git.rc for gcc
+if(WIN32)
+	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+			COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
+				-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
+				-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			VERBATIM)
+	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
+endif()
+
 #link all required libraries to common-main
 add_library(common-main OBJECT common-main.c)
-target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
+
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})
 if(Intl_FOUND)
 	target_link_libraries(common-main ${Intl_LIBRARIES})
 endif()
 if(Iconv_FOUND)
 	target_link_libraries(common-main ${Iconv_LIBRARIES})
 endif()
+if(WIN32)
+	target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
+	add_dependencies(common-main git-rc)
+	target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+elseif(UNIX)
+	target_link_libraries(common-main pthread rt)
+endif()
 
 
 set(git_SOURCES
@@ -501,11 +573,13 @@ endif()
 add_executable(git-remote-testsvn remote-testsvn.c)
 target_link_libraries(git-remote-testsvn common-main vcs-svn)
 
-add_executable(git-credential-cache credential-cache.c)
-target_link_libraries(git-credential-cache common-main)
+if(NOT NO_UNIX_SOCKETS)
+	add_executable(git-credential-cache credential-cache.c)
+	target_link_libraries(git-credential-cache common-main)
 
-add_executable(git-credential-cache--daemon credential-cache--daemon.c)
-target_link_libraries(git-credential-cache--daemon common-main)
+	add_executable(git-credential-cache--daemon credential-cache--daemon.c)
+	target_link_libraries(git-credential-cache--daemon common-main)
+endif()
 
 
 set(git_builtin_extra
@@ -517,16 +591,16 @@ set(git_builtin_extra
 foreach(s ${git_SOURCES} ${git_builtin_extra})
 	string(REPLACE "builtin/" "" s ${s})
 	string(REPLACE ".c" "" s ${s})
-	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
-	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
+	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\n")
+	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})
 endforeach()
 
 if(CURL_FOUND)
 	set(remote_exes
 		git-remote-https git-remote-ftp git-remote-ftps)
 	foreach(s ${remote_exes})
-		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
-		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http${EXE_EXTENSION} ${s}${EXE_EXTENSION})\n")
+		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s}${EXE_EXTENSION})
 	endforeach()
 endif()
 
@@ -654,20 +728,20 @@ set(bin_links
 	git-receive-pack git-upload-archive git-upload-pack)
 
 foreach(b ${bin_links})
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/bin/${b}${EXE_EXTENSION})")
 endforeach()
 
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git${EXE_EXTENSION})")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell${EXE_EXTENSION})")
 
 foreach(b ${git_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
 endforeach()
 
 foreach(b ${git_http_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
 endforeach()
 
 install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
@@ -734,14 +808,14 @@ set(wrapper_test_scripts
 foreach(script ${wrapper_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "${script}" content "${content}")
+	string(REPLACE "@@PROG@@" "${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
 foreach(script ${wrapper_test_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
+	string(REPLACE "@@PROG@@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
@@ -807,7 +881,7 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X='${EXE_EXTENSION}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH 7/8] cmake: support for building git on windows with msvc and clang.
  2020-04-24  4:01 [PATCH 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                   ` (5 preceding siblings ...)
  2020-04-24  4:01 ` [PATCH 6/8] cmake: support for building git on windows with mingw Sibi Siddharthan via GitGitGadget
@ 2020-04-24  4:01 ` Sibi Siddharthan via GitGitGadget
  2020-04-24 17:39   ` Danh Doan
  2020-04-24  4:01 ` [PATCH 8/8] ci: modification of main.yml to use cmake for vs-build job Sibi Siddharthan via GitGitGadget
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-04-24  4:01 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch adds support for Visual Studio and Clang builds

The minimum required version of CMake is upgraded to 3.15 because
this version offers proper support for Clang builds on Windows.

Libintl is not searched for when building with Visual Studio or Clang
because there is no binary compatible version available yet.

NOTE: In the link options invalidcontinue.obj has to be included.
The reason for this is because by default, Windows calls abort()'s
instead of setting errno=EINVAL when invalid arguments are passed to
standard functions.
This commit explains it in detail:
4b623d80f73528a632576990ca51e34c333d5dd6

On Windows the default generator is Visual Studio,so for Visual Studio
builds do this:

cmake `relative-path-to-srcdir`

NOTE: Visual Studio generator is a multi config generator, which means
that Debug and Release builds can be done on the same build directory.

For Clang builds do this:

On bash
CC=Clang cmake `relative-path-to-srcdir` -G Ninja
		-DCMAKE_BUILD_TYPE=[Debug or Release]

On cmd
set CC=Clang
cmake `relative-path-to-srcdir` -G Ninja
		-DCMAKE_BUILD_TYPE=[Debug or Release]

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 CMakeLists.txt | 57 ++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 46 insertions(+), 11 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d9eb1060390..5ad3a2557f7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,7 @@
 #	Copyright (c) 2020 Sibi Siddharthan
 #
 
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.15)
 
 #Parse GIT-VERSION-GEN to get the version
 file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
@@ -32,8 +32,11 @@ find_package(ZLIB REQUIRED)
 find_package(CURL)
 find_package(EXPAT)
 find_package(Iconv)
-find_package(Intl)
 
+#Don't use libintl on Windows Visual Studio and Clang builds
+if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")))
+	find_package(Intl)
+endif()
 
 if(NOT Intl_FOUND)
 	add_compile_definitions(NO_GETTEXT)
@@ -61,7 +64,7 @@ if(NOT SH_EXE)
 	message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")
 endif()
 
-if(WIN32)
+if(WIN32 AND NOT MSVC)#not required for visual studio builds
 	find_program(WINDRES_EXE windres)
 	if(NOT WINDRES_EXE)
 		message(FATAL_ERROR "Install windres on Windows for resource files")
@@ -73,6 +76,13 @@ if(NOT MSGFMT_EXE)
 	message(WARNING "Text Translations won't be build")
 endif()
 
+#Force all visual studio outputs to CMAKE_BINARY_DIR
+if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
+	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
+	add_compile_options(/MP)
+endif()
+
 #default behaviour
 include_directories(${CMAKE_SOURCE_DIR})
 add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
@@ -110,6 +120,10 @@ endif()
 
 #Platform Specific
 if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+	if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+		include_directories(compat/vcbuild/include)
+		add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
+	endif()
 	include_directories(compat/win32)
 	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
 				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
@@ -463,14 +477,22 @@ set(libvcs-svn_SOURCES
 	vcs-svn/svndiff.c vcs-svn/svndump.c)
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
 
-#add git.rc for gcc
 if(WIN32)
-	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
-			COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
-				-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
-				-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
-			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-			VERBATIM)
+	if(NOT MSVC)#use windres when compiling with gcc and clang
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+				COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
+					-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
+					-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
+				WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+				VERBATIM)
+	else()#MSVC use rc
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+				COMMAND ${CMAKE_RC_COMPILER} /d MAJOR=${PROJECT_VERSION_MAJOR} /d MINOR=${PROJECT_VERSION_MINOR}
+					/d MICRO=${PROJECT_VERSION_PATCH} /d PATCHLEVEL=0 /d GIT_VERSION="${PROJECT_VERSION}.GIT"
+					/fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_SOURCE_DIR}/git.rc
+				WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+				VERBATIM)
+	endif()
 	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
 endif()
 
@@ -487,7 +509,13 @@ endif()
 if(WIN32)
 	target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
 	add_dependencies(common-main git-rc)
-	target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+	if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+		target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+	elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+		target_link_options(common-main PUBLIC -municode -Wl,-nxcompat -Wl,-dynamicbase -Wl,-entry:wmainCRTStartup -Wl,invalidcontinue.obj)
+	elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+		target_link_options(common-main PUBLIC /IGNORE:4217 /IGNORE:4049 /NOLOGO /ENTRY:wmainCRTStartup /SUBSYSTEM:CONSOLE invalidcontinue.obj)
+	endif()
 elseif(UNIX)
 	target_link_libraries(common-main pthread rt)
 endif()
@@ -797,6 +825,13 @@ target_link_libraries(test-tool common-main)
 set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
 			PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)
 
+if(MSVC)
+	set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+				PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)
+	set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+				PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)
+endif()
+
 #wrapper scripts
 set(wrapper_scripts
 	git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH 8/8] ci: modification of main.yml to use cmake for vs-build job
  2020-04-24  4:01 [PATCH 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                   ` (6 preceding siblings ...)
  2020-04-24  4:01 ` [PATCH 7/8] cmake: support for building git on windows with msvc and clang Sibi Siddharthan via GitGitGadget
@ 2020-04-24  4:01 ` Sibi Siddharthan via GitGitGadget
  2020-04-24 17:45   ` Danh Doan
  2020-04-24 18:56 ` [PATCH 0/8] CMake build system for git Junio C Hamano
  2020-05-12 16:50 ` [PATCH v2 00/11] " Sibi Siddharthan via GitGitGadget
  9 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-04-24  4:01 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch modifies .github/workflows/main.yml to use CMake for
Visual Studio builds.

Modified the vs-test step to match windows-test step. This speeds
up the vs-test. Calling git-cmd from powershell and then calling git-bash
to perform the tests slows things down(factor of about 6). So git-bash
is directly called from powershell to perform the tests using prove.

NOTE: Since GitHub keeps the same directory for each job
(with respect to path) absolute paths are used in the bin-wrapper
scripts.

GitHub has switched to CMake 3.17.1 which changed the behaviour of
FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been
added to revert to the old behaviour.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 .github/workflows/main.yml | 43 ++++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index fd4df939b50..94f9a385225 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -80,13 +80,6 @@ jobs:
     - name: download git-sdk-64-minimal
       shell: bash
       run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
-    - name: generate Visual Studio solution
-      shell: powershell
-      run: |
-        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
-          make NDEBUG=1 DEVELOPER=1 vcxproj
-        "@
-        if (!$?) { exit(1) }
     - name: download vcpkg artifacts
       shell: powershell
       run: |
@@ -98,6 +91,13 @@ jobs:
         Remove-Item compat.zip
     - name: add msbuild to PATH
       uses: microsoft/setup-msbuild@v1.0.0
+    - name: generate Visual Studio solution
+      shell: powershell
+      run: |
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
+          cmake . -DCMAKE_PREFIX_PATH=./compat/vcbuild/vcpkg/installed/x64-windows -DMSGFMT_EXE=./git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
+        "@
+        if (!$?) { exit(1) }
     - name: MSBuild
       run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
     - name: bundle artifact tar
@@ -125,9 +125,9 @@ jobs:
         nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
     steps:
     - uses: actions/checkout@v1
-    - name: download git-64-portable
+    - name: download git-sdk-64-minimal
       shell: bash
-      run: a=git-64-portable && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
+      run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
     - name: download build artifacts
       uses: actions/download-artifact@v1
       with:
@@ -136,23 +136,30 @@ jobs:
     - name: extract build artifacts
       shell: bash
       run: tar xf artifacts.tar.gz
-    - name: test (parallel)
+    - name: test
       shell: powershell
       env:
         MSYSTEM: MINGW64
         NO_SVN_TESTS: 1
         GIT_TEST_SKIP_REBASE_P: 1
       run: |
-        & git-64-portable\git-cmd.exe --command=usr\bin\bash.exe -lc @"
-          # Let Git ignore the SDK and the test-cache
-          printf '%s\n' /git-64-portable/ /test-cache/ >>.git/info/exclude
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
+          # Let Git ignore the SDK
+          printf '%s\n' /git-sdk-64-minimal/ >>.git/info/exclude
 
-          cd t &&
-          PATH=\"`$PWD/helper:`$PATH\" &&
-          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \
-                  `$(test-tool.exe path-utils slice-tests \
-                          ${{matrix.nr}} 10 t[0-9]*.sh)
+          ci/run-test-slice.sh ${{matrix.nr}} 10
         "@
+    - name: ci/print-test-failures.sh
+      if: failure()
+      shell: powershell
+      run: |
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc ci/print-test-failures.sh
+    - name: Upload failed tests' directories
+      if: failure() && env.FAILED_TEST_ARTIFACTS != ''
+      uses: actions/upload-artifact@v1
+      with:
+        name: failed-tests-windows
+        path: ${{env.FAILED_TEST_ARTIFACTS}}
   regular:
     strategy:
       matrix:
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 179+ messages in thread

* Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux
  2020-04-24  4:01 ` [PATCH 1/8] Introduce CMake support for configuring Git on Linux Sibi Siddharthan via GitGitGadget
@ 2020-04-24 17:05   ` Danh Doan
  2020-04-24 21:06     ` Sibi Siddharthan
  2020-04-25 13:34     ` Johannes Schindelin
  2020-04-25 17:07   ` brian m. carlson
  1 sibling, 2 replies; 179+ messages in thread
From: Danh Doan @ 2020-04-24 17:05 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

On 2020-04-24 04:01:30+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:

Please excuse my hatred for CMake.

I guess it's my own fault for not learning how to write CMake
properly, or is it too hard to write correct CMake?

> To make this a little less awkward, the Git for Windows project offers
> the `vs/master` branch which has a full Visual Studio solution generated
> and committed. This branch can therefore be used to tinker with Git in
> Visual Studio _without_ having to download the full Git for Windows SDK.
> Unfortunatly, that branch is auto-generated from Git for Windows'
> `master`. If a developer wants to tinker, say, with `pu`, they are out
> of luck.

I thought:
	make NDEBUG=1 DEVELOPER=1 vcxproj

was invented for this use case?

> CMake was invented to make this sort of problem go away, by providing a
> more standardized, cross-platform way to configure builds.

There is something fun with that *cross*
Is cmake able to cross-compile cmake by cmake now?
 
> With a working support CMake, developers on Windows need only install
> CMake, configure their build, load the generated Visual Studio solution
> and immediately start modifying the code and build their own version of
> Git. Likewise, developers on other platforms can use the convenient GUI
> tools provided by CMake to configure their build.

OK, that's fine if it works for you.
Please don't drop support for autoconf and Makefile, though.
(I haven't look into other patches)

> So let's start building CMake support for Git.
> 
> This is only the first step, and to make it easier to review, it only
> allows for configuring builds on the platform that is easiest to
> configure for: Linux.
> 
> The CMake script checks whether the headers are present(eg. libgen.h),
> whether the functions are present(eg. memmem), whether the funtions work
> properly (eg. snprintf) and generate the required compile definitions
> for the platform. The script also searches for the required libraries,
> if it fails to find the required libraries the respective executables
> won't be built.(eg. If libcurl is not found then git-remote-http won't
> be built). This will help building Git easier.
> 
> With a CMake script an out of source build of git is possible resulting
> in a clean source tree.
> 
> Note: earlier endeavors on the Git mailing list to introduce CMake ended
> up in dead water. The primary reason for that was that reviewers
> _expected_ CMake support to fall out of maintenance, unless the
> contributor would promise to keep an eye on keeping CMake support up to
> date. However, in the meantime, support for automated testing has been
> introduced in Git's source code, and a later patch will modify the
> (still experimental) GitHub workflow to continually verify that CMake
> support is still complete. That will make maintenance reasonably easy.
> 
> Note: this patch asks for the minimum version v3.14 of CMake (which is
> not all that old as of time of writing) because that is the first

Debian Buster (current stable) ships v3.13.4, I think I don't need to
mention old-stable of Debian (Stretch or Jessie).


> version to offer a platform-independent way to generate hardlinks as
> part of the build. This is needed to generate all those hardlinks for
> the built-in commands of Git.
> 
> Instructions to run CMake:
> 
> cmake `relative-path-to-srcdir` -DCMAKE_BUILD_TYPE=Release
> 
> Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
> compiler flags
> Debug : -g
> Release: -O3

IIRC, Linus and Junio used to said noone ever needs "-03"

> RelWithDebInfo : -O2 -g
> MinSizeRel : -Os
> empty(default) :
> 
> NOTE: -DCMAKE_BUILD_TYPE is optional
> 
> This process generates a Makefile.
> Then run `make` to build Git.
> 
> NOTE: By default CMake uses Makefile as the build tool on Linux, to use
> another tool say `ninja` add this to the command line when configuring.
> `-G Ninja`
> 
> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> ---
>  CMakeLists.txt | 528 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 528 insertions(+)
>  create mode 100644 CMakeLists.txt
> 
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> new file mode 100644
> index 00000000000..73703bd321f
> --- /dev/null
> +++ b/CMakeLists.txt
> @@ -0,0 +1,528 @@
> +#
> +#	Copyright (c) 2020 Sibi Siddharthan
> +#
> +
> +cmake_minimum_required(VERSION 3.14)
> +
> +#Parse GIT-VERSION-GEN to get the version
> +file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
> +string(REPLACE "DEF_VER=v" "" git_version ${git_version})
> +string(REPLACE ".GIT" ".0" git_version ${git_version})#for building from a snapshot

Does it work with e.g. 2.26.1?

> +
> +project(git
> +	VERSION ${git_version}
> +	LANGUAGES C)
> +
> +
> +include(CheckTypeSize)
> +include(CheckCSourceRuns)
> +include(CheckCSourceCompiles)
> +include(CheckIncludeFile)
> +include(CheckFunctionExists)
> +include(CheckSymbolExists)
> +include(CheckStructHasMember)
> +
> +find_package(ZLIB REQUIRED)
> +find_package(CURL)

Right now, we should --with-zlib=/path/to/zlib/root
Does this `find_package` support it?

> +find_package(EXPAT)
> +find_package(Iconv)
> +find_package(Intl)
> +

> +if(NOT Intl_FOUND)
> +	add_compile_definitions(NO_GETTEXT)

find_package(Gettext)?

> +	if(NOT Iconv_FOUND)
> +		add_compile_definitions(NO_ICONV)
> +	endif()
> +endif()

ICONV_OMITS_BOM?

> +
> +include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
> +if(CURL_FOUND)
> +	include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
> +endif()
> +if(EXPAT_FOUND)
> +	include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
> +endif()
> +if(Iconv_FOUND)
> +	include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
> +endif()
> +if(Intl_FOUND)
> +	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
> +endif()
> +
> +find_program(SH_EXE sh)

We want to find usable sh, not just sh, no?

It's matter on Solaris, HP-UX

> +
> +#default behaviour
> +include_directories(${CMAKE_SOURCE_DIR})
> +add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
> +add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)
> +add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES
> +			SHA1DC_INIT_SAFE_HASH_DEFAULT=0
> +			SHA1DC_CUSTOM_INCLUDE_SHA1_C="cache.h"
> +			SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="git-compat-util.h" )
> +list(APPEND compat_SOURCES sha1dc_git.c sha1dc/sha1.c sha1dc/ubc_check.c block-sha1/sha1.c sha256/block/sha256.c compat/qsort_s.c)
> +
> +
> +add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
> +			ETC_GITATTRIBUTES="etc/gitattributes"
> +			ETC_GITCONFIG="etc/gitconfig"
> +			GIT_EXEC_PATH="libexec/git-core"
> +			GIT_LOCALE_PATH="share/locale"
> +			GIT_MAN_PATH="share/man"
> +			GIT_INFO_PATH="share/info"
> +			GIT_HTML_PATH="share/doc/git-doc"
> +			DEFAULT_HELP_FORMAT="html"
> +			DEFAULT_GIT_TEMPLATE_DIR="share/git-core/templates"
> +			GIT_VERSION="${PROJECT_VERSION}.GIT"
> +			GIT_USER_AGENT="git/${PROJECT_VERSION}.GIT"
> +			BINDIR="bin"
> +			GIT_BUILT_FROM_COMMIT="")

I wish I could verify this.
Have you check this part on a default build system for a Linux distro,
FreeBSD? For things started with "etc/"

> +
> +set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
> +add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
> +
> +add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )

/proc/self/exe is Linux only, no?

> +list(APPEND compat_SOURCES unix-socket.c)
> +
> +#header checks
> +check_include_file(libgen.h HAVE_LIBGEN_H)
> +if(NOT HAVE_LIBGEN_H)
> +	add_compile_definitions(NO_LIBGEN_H)
> +	list(APPEND compat_SOURCES compat/basename.c)
> +endif()
> +
> +check_include_file(sys/sysinfo.h HAVE_SYSINFO)
> +if(HAVE_SYSINFO)
> +	add_compile_definitions(HAVE_SYSINFO)
> +endif()
> +
> +check_c_source_compiles("
> +#include <alloca.h>
> +int
> +main ()
> +{
> +char *p = (char *) alloca (2 * sizeof (int));
> +	if (p) return 0;
> +	return 0;

All code path will return 0?

> +}"
> +HAVE_ALLOCA_H)
> +if(HAVE_ALLOCA_H)
> +	add_compile_definitions(HAVE_ALLOCA_H)
> +endif()
> +
> +check_include_file(strings.h HAVE_STRINGS_H)
> +if(HAVE_STRINGS_H)
> +	add_compile_definitions(HAVE_STRINGS_H)
> +endif()
> +
> +check_include_file(sys/select.h HAVE_SYS_SELECT_H)
> +if(NOT HAVE_SYS_SELECT_H)
> +	add_compile_definitions(NO_SYS_SELECT_H)
> +endif()
> +
> +check_include_file(sys/poll.h HAVE_SYS_POLL_H)
> +if(NOT HAVE_SYS_POLL_H)
> +	add_compile_definitions(NO_SYS_POLL_H)
> +endif()
> +
> +check_include_file(poll.h HAVE_POLL_H)

POSIX defined poll.h instead of sys/poll.h

> +if(NOT HAVE_POLL_H)
> +	add_compile_definitions(NO_POLL_H)
> +endif()
> +
> +check_include_file(inttypes.h HAVE_INTTYPES_H)
> +if(NOT HAVE_INTTYPES_H)
> +	add_compile_definitions(NO_INTTYPES_H)
> +endif()
> +
> +check_include_file(paths.h HAVE_PATHS_H)
> +if(HAVE_PATHS_H)
> +	add_compile_definitions(HAVE_PATHS_H)
> +endif()
> +
> +#function checks
> +set(function_checks
> +	strcasestr memmem strlcpy strtoimax strtoumax strtoull
> +	setenv  mkdtemp poll pread  memmem unsetenv hstrerror)
> +
> +foreach(f ${function_checks})
> +	string(TOUPPER ${f} uf)
> +	check_function_exists(${f} HAVE_${uf})
> +	if(NOT HAVE_${uf})
> +		add_compile_definitions(NO_${uf})
> +	endif()
> +endforeach()
> +
> +if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)
> +	include_directories(compat/poll)
> +	add_compile_definitions(NO_POLL)
> +	list(APPEND compat_SOURCES compat/poll/poll.c)
> +endif()
> +
> +if(NOT HAVE_STRCASESTR)
> +	list(APPEND compat_SOURCES compat/strcasestr.c)
> +endif()
> +
> +if(NOT HAVE_STRLCPY)
> +	list(APPEND compat_SOURCES compat/strlcpy.c)
> +endif()
> +
> +if(NOT HAVE_STRTOUMAX)
> +	list(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c)
> +endif()
> +
> +if(NOT HAVE_SETENV)
> +	list(APPEND compat_SOURCES compat/setenv.c)
> +endif()
> +
> +if(NOT HAVE_MKDTEMP)
> +	list(APPEND compat_SOURCES compat/mkdtemp.c)
> +endif()
> +
> +if(NOT HAVE_PREAD)
> +	list(APPEND compat_SOURCES compat/pread.c)
> +endif()
> +
> +if(NOT HAVE_MEMMEM)
> +	list(APPEND compat_SOURCES compat/memmem.c)
> +endif()
> +
> +if(NOT WIN32)
> +	if(NOT HAVE_UNSETENV)
> +		list(APPEND compat_SOURCES compat/unsetenv.c)
> +	endif()
> +
> +	if(NOT HAVE_HSTRERROR)
> +		list(APPEND compat_SOURCES compat/hstrerror.c)
> +	endif()
> +endif()
> +
> +check_function_exists(getdelim HAVE_GETDELIM)
> +if(HAVE_GETDELIM)
> +	add_compile_definitions(HAVE_GETDELIM)
> +endif()
> +
> +check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
> +check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC)
> +if(HAVE_CLOCK_GETTIME)
> +	add_compile_definitions(HAVE_CLOCK_GETTIME)
> +endif()
> +if(HAVE_CLOCK_MONOTONIC)
> +	add_compile_definitions(HAVE_CLOCK_MONOTONIC)
> +endif()
> +
> +
> +#compile checks
> +check_c_source_runs("
> +#include<stdio.h>
> +#include<stdarg.h>
> +#include<string.h>
> +#include<stdlib.h>
> +int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
> +{
> +	int ret;
> +	va_list ap;
> +
> +	va_start(ap, format);
> +	ret = vsnprintf(str, maxsize, format, ap);
> +	va_end(ap);
> +	return ret;
> +}
> +
> +int
> +main ()
> +{
> +	char buf[6];
> +	if (test_vsnprintf(buf, 3, \"%s\", \"12345\") != 5
> +		|| strcmp(buf, \"12\")) return 1;
> +	if (snprintf(buf, 3, \"%s\", \"12345\") != 5
> +		|| strcmp(buf, \"12\")) return 1;
> +
> +	return 0;
> +}"
> +SNPRINTF_OK)
> +if(NOT SNPRINTF_OK)
> +	add_compile_definitions(SNPRINTF_RETURNS_BOGUS)
> +	list(APPEND compat_SOURCES compat/snprintf.c)
> +endif()
> +
> +check_c_source_runs("
> +#include<stdio.h>
> +int
> +main ()
> +{
> +	FILE *f = fopen(\".\", \"r\");
> +	return f != NULL;
> +
> +	return 0;
> +}"
> +FREAD_READS_DIRECTORIES_NO)
> +if(NOT FREAD_READS_DIRECTORIES_NO)
> +	add_compile_definitions(FREAD_READS_DIRECTORIES)
> +	list(APPEND compat_SOURCES compat/fopen.c)
> +endif()
> +
> +check_c_source_compiles("
> +#include <regex.h>
> +#ifndef REG_STARTEND
> +#error oops we dont have it
> +#endif
> +int main(){return 0;}"
> +HAVE_REGEX)
> +if(NOT HAVE_REGEX)
> +	include_directories(compat/regex )
> +	list(APPEND compat_SOURCES compat/regex/regex.c )
> +	add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
> +endif()
> +
> +
> +check_c_source_compiles("
> +#include <stddef.h>
> +#include <sys/types.h>
> +#include <sys/sysctl.h>
> +
> +int
> +main ()
> +{
> +	int val, mib[2];
> +	size_t len;
> +
> +	mib[0] = CTL_HW;
> +	mib[1] = 1;
> +	len = sizeof(val);
> +	return sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;
> +
> +	return 0;
> +}"
> +HAVE_BSD_SYSCTL)
> +if(HAVE_BSD_SYSCTL)
> +	add_compile_definitions(HAVE_BSD_SYSCTL)
> +endif()
> +
> +#programs
> +set(PROGRAMS_BUILT
> +	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
> +	git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
> +
> +if(NOT CURL_FOUND)
> +	list(APPEND excluded_progs git-http-fetch git-http-push)
> +	add_compile_definitions(NO_CURL)
> +	message(WARNING "git-http-push and git-http-fetch will not be built")
> +else()
> +	list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
> +	if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
> +		add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
> +	endif()
> +endif()
> +
> +if(NOT EXPAT_FOUND)
> +	list(APPEND excluded_progs git-http-push)
> +	add_compile_definitions(NO_EXPAT)
> +else()
> +	list(APPEND PROGRAMS_BUILT git-http-push)
> +	if(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2)
> +		add_compile_definitions(EXPAT_NEEDS_XMLPARSE_H)
> +	endif()
> +endif()
> +
> +list(REMOVE_DUPLICATES excluded_progs)
> +list(REMOVE_DUPLICATES PROGRAMS_BUILT)
> +
> +
> +foreach(p ${excluded_progs})
> +	list(APPEND EXCLUSION_PROGS --exclude-program ${p} )
> +endforeach()
> +
> +#for comparing null values
> +list(APPEND EXCLUSION_PROGS empty)
> +set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" FORCE)
> +
> +if(NOT EXISTS ${CMAKE_SOURCE_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
> +	list(REMOVE_ITEM EXCLUSION_PROGS empty)
> +	message("Generating command-list.h")
> +	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
> +			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
> +			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/command-list.h)
> +endif()
> +
> +if(NOT EXISTS ${CMAKE_SOURCE_DIR}/config-list.h)
> +	message("Generating config-list.h")
> +	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
> +			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
> +			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/config-list.h)
> +endif()
> +
> +
> +#build
> +set(libgit_SOURCES
> +	abspath.c add-interactive.c add-patch.c advice.c alias.c
> +	alloc.c apply.c archive.c archive-tar.c archive-zip.c argv-array.c
> +	attr.c base85.c bisect.c blame.c blob.c bloom.c branch.c bulk-checkin.c
> +	bundle.c cache-tree.c chdir-notify.c checkout.c color.c column.c
> +	combine-diff.c commit.c commit-graph.c commit-reach.c compat/obstack.c
> +	compat/terminal.c config.c connect.c connected.c convert.c copy.c credential.c
> +	csum-file.c ctype.c date.c decorate.c delta-islands.c diffcore-break.c
> +	diffcore-delta.c diffcore-order.c diffcore-pickaxe.c diffcore-rename.c
> +	diff-delta.c diff-lib.c diff-no-index.c diff.c dir.c dir-iterator.c editor.c
> +	entry.c environment.c ewah/bitmap.c ewah/ewah_bitmap.c ewah/ewah_io.c
> +	ewah/ewah_rlw.c exec-cmd.c fetch-negotiator.c fetch-pack.c fmt-merge-msg.c fsck.c fsmonitor.c
> +	gettext.c gpg-interface.c graph.c grep.c hashmap.c linear-assignment.c help.c hex.c
> +	ident.c interdiff.c json-writer.c kwset.c levenshtein.c line-log.c line-range.c list-objects.c
> +	list-objects-filter.c list-objects-filter-options.c ll-merge.c lockfile.c
> +	log-tree.c ls-refs.c mailinfo.c mailmap.c match-trees.c mem-pool.c merge.c merge-blobs.c
> +	merge-recursive.c mergesort.c midx.c name-hash.c negotiator/default.c
> +	negotiator/skipping.c notes.c notes-cache.c notes-merge.c notes-utils.c object.c oidmap.c
> +	oidset.c oid-array.c packfile.c pack-bitmap.c pack-bitmap-write.c pack-check.c pack-objects.c
> +	pack-revindex.c pack-write.c pager.c parse-options.c parse-options-cb.c patch-delta.c
> +	patch-ids.c path.c pathspec.c pkt-line.c preload-index.c pretty.c prio-queue.c progress.c
> +	promisor-remote.c prompt.c protocol.c prune-packed.c quote.c range-diff.c reachable.c read-cache.c rebase.c
> +	rebase-interactive.c reflog-walk.c refs.c refs/files-backend.c refs/iterator.c
> +	refs/packed-backend.c refs/ref-cache.c refspec.c ref-filter.c remote.c replace-object.c
> +	repo-settings.c repository.c rerere.c reset.c resolve-undo.c revision.c run-command.c
> +	send-pack.c sequencer.c serve.c server-info.c setup.c sha1-lookup.c
> +	sha1-file.c sha1-name.c shallow.c sideband.c sigchain.c split-index.c
> +	stable-qsort.c strbuf.c streaming.c string-list.c submodule.c submodule-config.c
> +	sub-process.c symlinks.c tag.c tempfile.c thread-utils.c tmp-objdir.c
> +	trace.c trace2.c trace2/tr2_cfg.c trace2/tr2_cmd_name.c trace2/tr2_dst.c
> +	trace2/tr2_sid.c trace2/tr2_sysenv.c trace2/tr2_tbuf.c trace2/tr2_tgt_event.c
> +	trace2/tr2_tgt_normal.c trace2/tr2_tgt_perf.c trace2/tr2_tls.c trailer.c transport.c
> +	transport-helper.c tree-diff.c tree.c tree-walk.c unpack-trees.c upload-pack.c url.c
> +	urlmatch.c usage.c userdiff.c utf8.c varint.c version.c versioncmp.c walker.c wildmatch.c
> +	worktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c
> +	zlib.c)
> +
> +add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
> +
> +set(libxdiff_SOURCES
> +	xdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c
> +	xdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)
> +add_library(xdiff STATIC ${libxdiff_SOURCES})
> +
> +set(libvcs-svn_SOURCES
> +	vcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c
> +	vcs-svn/svndiff.c vcs-svn/svndump.c)
> +add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
> +
> +#link all required libraries to common-main
> +add_library(common-main OBJECT common-main.c)
> +target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
> +if(Intl_FOUND)
> +	target_link_libraries(common-main ${Intl_LIBRARIES})
> +endif()
> +if(Iconv_FOUND)
> +	target_link_libraries(common-main ${Iconv_LIBRARIES})
> +endif()
> +
> +
> +set(git_SOURCES
> +	builtin/add.c builtin/am.c builtin/annotate.c builtin/apply.c
> +	builtin/archive.c builtin/bisect--helper.c builtin/blame.c
> +	builtin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c
> +	builtin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c
> +	builtin/checkout-index.c builtin/checkout.c builtin/clean.c
> +	builtin/clone.c builtin/column.c builtin/commit-tree.c
> +	builtin/commit.c builtin/commit-graph.c builtin/config.c
> +	builtin/count-objects.c builtin/credential.c builtin/describe.c
> +	builtin/diff-files.c builtin/diff-index.c builtin/diff-tree.c
> +	builtin/diff.c builtin/difftool.c builtin/env--helper.c
> +	builtin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c
> +	builtin/for-each-ref.c builtin/fsck.c builtin/gc.c
> +	builtin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c
> +	builtin/help.c builtin/index-pack.c builtin/init-db.c
> +	builtin/interpret-trailers.c builtin/log.c builtin/ls-files.c
> +	builtin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c
> +	builtin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c
> +	builtin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c
> +	builtin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c
> +	builtin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c
> +	builtin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c
> +	builtin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c
> +	builtin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c
> +	builtin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c
> +	builtin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c
> +	builtin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c
> +	builtin/show-branch.c builtin/show-index.c builtin/show-ref.c
> +	builtin/sparse-checkout.c builtin/stash.c builtin/stripspace.c
> +	builtin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c
> +	builtin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c
> +	builtin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c
> +	builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c
> +	builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)
> +
> +add_executable(git git.c ${git_SOURCES})
> +target_link_libraries(git common-main )
> +
> +add_executable(git-bugreport bugreport.c)
> +target_link_libraries(git-bugreport common-main)
> +
> +add_executable(git-credential-store credential-store.c)
> +target_link_libraries(git-credential-store common-main)
> +
> +add_executable(git-daemon daemon.c)
> +target_link_libraries(git-daemon common-main)
> +
> +add_executable(git-fast-import fast-import.c)
> +target_link_libraries(git-fast-import common-main)
> +
> +add_executable(git-http-backend http-backend.c)
> +target_link_libraries(git-http-backend common-main)
> +
> +add_executable(git-sh-i18n--envsubst sh-i18n--envsubst.c)
> +target_link_libraries(git-sh-i18n--envsubst common-main)
> +
> +add_executable(git-shell shell.c)
> +target_link_libraries(git-shell common-main)
> +
> +if(CURL_FOUND)
> +	add_library(http_obj OBJECT http.c)
> +
> +	add_executable(git-imap-send imap-send.c)
> +	target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})
> +
> +	add_executable(git-http-fetch http-walker.c http-fetch.c)
> +	target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})
> +
> +	add_executable(git-remote-http http-walker.c remote-curl.c)
> +	target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )
> +
> +	if(EXPAT_FOUND)
> +		add_executable(git-http-push http-push.c)
> +		target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
> +	endif()
> +endif()
> +
> +add_executable(git-remote-testsvn remote-testsvn.c)
> +target_link_libraries(git-remote-testsvn common-main vcs-svn)
> +
> +add_executable(git-credential-cache credential-cache.c)
> +target_link_libraries(git-credential-cache common-main)
> +
> +add_executable(git-credential-cache--daemon credential-cache--daemon.c)
> +target_link_libraries(git-credential-cache--daemon common-main)
> +
> +
> +set(git_builtin_extra
> +	cherry cherry-pick format-patch fsck-objects
> +	init merge-subtree restore show
> +	stage status switch whatchanged)
> +
> +#Creating hardlinks
> +foreach(s ${git_SOURCES} ${git_builtin_extra})
> +	string(REPLACE "builtin/" "" s ${s})
> +	string(REPLACE ".c" "" s ${s})
> +	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
> +	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
> +endforeach()
> +
> +if(CURL_FOUND)
> +	set(remote_exes
> +		git-remote-https git-remote-ftp git-remote-ftps)
> +	foreach(s ${remote_exes})
> +		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
> +		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
> +	endforeach()
> +endif()
> +
> +add_custom_command(OUTPUT ${git_links} ${git_http_links}
> +		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
> +		DEPENDS git git-remote-http)
> +add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
> \ No newline at end of file

No new line at end of line always leave a bad taste in my mount!


-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 2/8] cmake: generate the shell/perl/python scripts and templates, translations
  2020-04-24  4:01 ` [PATCH 2/8] cmake: generate the shell/perl/python scripts and templates, translations Sibi Siddharthan via GitGitGadget
@ 2020-04-24 17:19   ` Danh Doan
  2020-04-24 21:19     ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Danh Doan @ 2020-04-24 17:19 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

On 2020-04-24 04:01:31+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> 
> This patch implements the placeholder substitution to generate, say,
> `git-request-pull` from `git-request-pull.sh`.
> 
> The shell/perl/python scripts and template are generated using CMake
> (very similar to what sed does).
> 
> The text translations are only build if `msgfmt` is found in your path.
> 
> NOTE: The scripts and templates are generated during configuration.
> 
> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> ---
>  CMakeLists.txt | 107 ++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 106 insertions(+), 1 deletion(-)
> 
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 73703bd321f..788b53be873 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -51,6 +51,11 @@ endif()
>  
>  find_program(SH_EXE sh)
>  
> +find_program(MSGFMT_EXE msgfmt)

I suppose find_package(Gettext) can do most of this work?

> +if(NOT MSGFMT_EXE)
> +	message(WARNING "Text Translations won't be build")
> +endif()
> +
>  #default behaviour
>  include_directories(${CMAKE_SOURCE_DIR})
>  add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
> @@ -525,4 +530,104 @@ endif()
>  add_custom_command(OUTPUT ${git_links} ${git_http_links}
>  		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
>  		DEPENDS git git-remote-http)
> -add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
> \ No newline at end of file

No newline at end of file?

> +add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
> +
> +
> +#creating required scripts
> +set(SHELL_PATH /bin/sh)
> +set(PERL_PATH /usr/bin/perl)

Really?
Have you tried on, let's say FreeBSD?

> +set(LOCALEDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
> +set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
> +set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)
> +
> +#shell scripts
> +set(git_shell_scripts
> +	git-bisect git-difftool--helper git-filter-branch
> +	git-merge-octopus git-merge-one-file git-merge-resolve
> +	git-mergetool git-quiltimport
> +	git-request-pull git-submodule git-web--browse
> +	git-mergetool--lib git-parse-remote git-rebase--preserve-merges
> +	git-sh-setup git-sh-i18n git-instaweb)
> +
> +foreach(script ${git_shell_scripts})
> +	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)
> +	string(REPLACE "@SHELL_PATH@" "${SHELL_PATH}" content "${content}")
> +	string(REPLACE "@@DIFF@@" "diff" content "${content}")
> +	string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
> +	string(REPLACE "@GITWEBDIR@" "${GITWEBDIR}" content "${content}")
> +	string(REPLACE "@@NO_CURL@@" "" content "${content}")
> +	string(REPLACE "@@USE_GETTEXT_SCHEME@@" "" content "${content}")
> +	string(REPLACE "# @@BROKEN_PATH_FIX@@" "" content "${content}")
> +	string(REPLACE "@@PERL@@" "${PERL_PATH}" content "${content}")
> +	string(REPLACE "@@SANE_TEXT_GREP@@" "-a" content "${content}")
> +	string(REPLACE "@@PAGER_ENV@@" "LESS=FRX LV=-c" content "${content}")
> +	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
> +endforeach()

I assume this do most of sed magic?

> +
> +#perl scripts
> +set(git_perl_scripts
> +	git-add--interactive git-archimport git-cvsexportcommit
> +	git-cvsimport git-cvsserver git-send-email git-svn)
> +
> +#create perl header
> +file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
> +string(REPLACE "@@PATHSEP@@" ":" perl_header "${perl_header}")
> +string(REPLACE "@@INSTLIBDIR@@" "${INSTLIBDIR}" perl_header "${perl_header}")
> +
> +foreach(script ${git_perl_scripts})
> +	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)
> +	string(REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n${perl_header}\n" content "${content}")

Hoped that this is tried on BSD?

> +	string(REPLACE "@@GIT_VERSION@@" "${PROJECT_VERSION}" content "${content}")
> +	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
> +endforeach()
> +
> +#python script
> +file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)
> +string(REPLACE "#!/usr/bin/env python" "#!/usr/bin/python" content "${content}")
> +file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})
> +
> +#perl modules
> +file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
> +
> +foreach(pm ${perl_modules})
> +	string(REPLACE "${CMAKE_SOURCE_DIR}/perl/" "" file_path ${pm})

So, the real source code have reference to CMAKE_SOURCE_DIR?
I don't think so? It's purely my guess from previous patch, this
function will do
string(REPLACE from to file something_I_have_not_checked)

> +	file(STRINGS ${pm} content NEWLINE_CONSUME)
> +	string(REPLACE "@@LOCALEDIR@@" "${LOCALEDIR}" content "${content}")
> +	string(REPLACE "@@NO_PERL_CPAN_FALLBACKS@@" "" content "${content}")
> +	file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})
> +#test-lib.sh requires perl/build/lib to be the build directory of perl modules
> +endforeach()
> +
> +
> +#templates
> +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
> +set(hooks_templates
> +	applypatch-msg.sample pre-applypatch.sample pre-push.sample
> +	commit-msg.sample pre-commit.sample pre-rebase.sample
> +	fsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample
> +	post-update.sample prepare-commit-msg.sample update.sample)

Too much things merged into one line, I hate it.

> +
> +#templates have @.*@ replacement so use configure_file instead
> +#hooks
> +foreach(tm ${hooks_templates})
> +	configure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)
> +endforeach()

What does this really means?

> +
> +#info
> +configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)
> +
> +#this
> +configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)
> +
> +
> +#translations
> +if(MSGFMT_EXE)
> +	set(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)

hard coded, so this is a regression, compared to old Makefile?

> +	foreach(po ${po_files})
> +		file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)
> +		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo
> +				COMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)

find_package(Gettext) defines MSGFMT_EXECUTABLE, I think.
Have you check Solaris option?
Or is this tranlated from current Makefile?
I haven't checked current source code!

> +		list(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)
> +	endforeach()
> +	add_custom_target(po-gen ALL DEPENDS ${po_gen})
> +endif()
> -- 
> gitgitgadget
> 

-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 3/8] cmake: installation support for git
  2020-04-24  4:01 ` [PATCH 3/8] cmake: installation support for git Sibi Siddharthan via GitGitGadget
@ 2020-04-24 17:23   ` Danh Doan
  2020-04-24 21:24     ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Danh Doan @ 2020-04-24 17:23 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

On 2020-04-24 04:01:32+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> 
> This patch provides the facility to install the built binaries and
> scripts.
> 
> This is very similar to `make install`.
> By default the destination directory(DESTDIR) is /usr/local/ on Linux
> To set a custom installation path do this:
> cmake `relative-path-to-srcdir`
> 	-DCMAKE_INSTALL_PREFIX=`preferred-install-path`
> 
> Then run `make install`
> 
> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> ---
>  CMakeLists.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 49 insertions(+)
> 
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 788b53be873..25de5b5bc35 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -13,6 +13,8 @@ project(git
>  	VERSION ${git_version}
>  	LANGUAGES C)
>  
> +#TODO gitk git-gui gitweb
> +#TODO Add pcre support
>  
>  include(CheckTypeSize)
>  include(CheckCSourceRuns)
> @@ -631,3 +633,50 @@ if(MSGFMT_EXE)
>  	endforeach()
>  	add_custom_target(po-gen ALL DEPENDS ${po_gen})
>  endif()
> +
> +
> +#to help with the install
> +list(TRANSFORM git_shell_scripts PREPEND "${CMAKE_BINARY_DIR}/")
> +list(TRANSFORM git_perl_scripts PREPEND "${CMAKE_BINARY_DIR}/")
> +
> +#install
> +install(TARGETS git git-shell
> +	RUNTIME DESTINATION bin)
> +install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver  #${CMAKE_SOURCE_DIR}/gitk-git/gitk check

check? What does it mean?

> +	DESTINATION bin)
> +
> +list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)
> +install(TARGETS ${PROGRAMS_BUILT}
> +	RUNTIME DESTINATION libexec/git-core)

Ubuntu install exec file to /usr/lib/git-core?

> +
> +set(bin_links
> +	git-receive-pack git-upload-archive git-upload-pack)
> +
> +foreach(b ${bin_links})
> +install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
> +endforeach()
> +
> +install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
> +install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
> +
> +foreach(b ${git_links})
> +	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
> +	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
> +endforeach()
> +
> +foreach(b ${git_http_links})
> +	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
> +	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
> +endforeach()
> +
> +install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
> +	DESTINATION libexec/git-core)
> +
> +install(DIRECTORY mergetools DESTINATION libexec/git-core)
> +install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5
> +	FILES_MATCHING PATTERN "*.pm")

I think distro gonna complans about this pattern!

> +install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)
> +
> +if(MSGFMT_EXE)
> +	install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
> +endif()

I thought we want to check for NO_GETTEXT?

-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 4/8] cmake: support for testing git with ctest
  2020-04-24  4:01 ` [PATCH 4/8] cmake: support for testing git with ctest Sibi Siddharthan via GitGitGadget
@ 2020-04-24 17:28   ` Danh Doan
  2020-04-24 21:26     ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Danh Doan @ 2020-04-24 17:28 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

On 2020-04-24 04:01:33+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> 
> This patch provides an alternate way to test git using ctest.
> CTest ships with CMake, so there is no additional dependency being
> introduced.
> 
> To perform the tests with ctest do this after building:
> ctest -j[number of jobs]
> 
> NOTE: -j is optional, the default number of jobs is 1
> 
> Each of the jobs does this:
> cd t/ && sh t[something].sh
> 
> The reason for using CTest is that it logs the output of the tests
> in a neat way, which can be helpful during diagnosis of failures.
> 
> After the tests have run ctest generates three log files located in
> `build-directory`/Testing/Temporary/
> 
> These log files are:
> 
> CTestCostData.txt:
> This file contains the time taken to complete each test.
> 
> LastTestsFailed.log:
> This log file contains the names of the tests that have failed in the
> run.
> 
> LastTest.log:
> This log file contains the log of all the tests that have run.
> A snippet of the file is given below.
> 
> 10/901 Testing: D:/my/git-master/t/t0009-prio-queue.sh
> 10/901 Test: D:/my/git-master/t/t0009-prio-queue.sh
> Command: "sh.exe" "D:/my/git-master/t/t0009-prio-queue.sh"
> Directory: D:/my/git-master/t
> "D:/my/git-master/t/t0009-prio-queue.sh"
> Output:
> ----------------------------------------------------------
> ok 1 - basic ordering
> ok 2 - mixed put and get
> ok 3 - notice empty queue
> ok 4 - stack order
> passed all 4 test(s)
> 1..4
> <end of output>
> Test time =   1.11 sec
> 
> NOTE: Testing only works when building in source for now.
> 
> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> ---
>  CMakeLists.txt | 142 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 142 insertions(+)
> 
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 25de5b5bc35..141ccefa559 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -23,6 +23,7 @@ include(CheckIncludeFile)
>  include(CheckFunctionExists)
>  include(CheckSymbolExists)
>  include(CheckStructHasMember)
> +include(CTest)
>  
>  find_package(ZLIB REQUIRED)
>  find_package(CURL)
> @@ -680,3 +681,144 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/
>  if(MSGFMT_EXE)
>  	install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
>  endif()
> +
> +
> +if(BUILD_TESTING)
> +
> +#tests-helpers
> +add_executable(test-fake-ssh t/helper/test-fake-ssh.c)
> +target_link_libraries(test-fake-ssh common-main)
> +
> +add_executable(test-line-buffer t/helper/test-line-buffer.c)
> +target_link_libraries(test-line-buffer common-main vcs-svn)
> +
> +add_executable(test-svn-fe t/helper/test-svn-fe.c)
> +target_link_libraries(test-svn-fe common-main vcs-svn)
> +
> +set(test_helper_sources
> +	t/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c
> +	t/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c
> +	t/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c
> +	t/helper/test-dump-fsmonitor.c t/helper/test-dump-split-index.c
> +	t/helper/test-dump-untracked-cache.c t/helper/test-example-decorate.c
> +	t/helper/test-genrandom.c t/helper/test-genzeros.c t/helper/test-hash.c
> +	t/helper/test-hashmap.c t/helper/test-hash-speed.c t/helper/test-index-version.c
> +	t/helper/test-json-writer.c t/helper/test-lazy-init-name-hash.c
> +	t/helper/test-match-trees.c t/helper/test-mergesort.c t/helper/test-mktemp.c
> +	t/helper/test-oidmap.c t/helper/test-online-cpus.c t/helper/test-parse-options.c
> +	t/helper/test-parse-pathspec-file.c t/helper/test-path-utils.c t/helper/test-pkt-line.c
> +	t/helper/test-prio-queue.c t/helper/test-progress.c t/helper/test-reach.c
> +	t/helper/test-read-cache.c t/helper/test-read-graph.c t/helper/test-read-midx.c
> +	t/helper/test-ref-store.c t/helper/test-regex.c t/helper/test-repository.c
> +	t/helper/test-revision-walking.c t/helper/test-run-command.c t/helper/test-scrap-cache-tree.c
> +	t/helper/test-serve-v2.c t/helper/test-sha1.c t/helper/test-oid-array.c t/helper/test-sha256.c
> +	t/helper/test-sigchain.c t/helper/test-strcmp-offset.c t/helper/test-string-list.c
> +	t/helper/test-submodule-config.c t/helper/test-submodule-nested-repo-config.c t/helper/test-subprocess.c
> +	t/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c
> +	t/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)
> +
> +add_executable(test-tool ${test_helper_sources})
> +target_link_libraries(test-tool common-main)
> +
> +set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
> +			PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)
> +
> +#wrapper scripts
> +set(wrapper_scripts
> +	git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)
> +
> +set(wrapper_test_scripts
> +	test-fake-ssh test-line-buffer test-svn-fe test-tool)
> +
> +
> +foreach(script ${wrapper_scripts})
> +	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
> +	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
> +	string(REPLACE "@@PROG@@" "${script}" content "${content}")
> +	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
> +endforeach()
> +
> +foreach(script ${wrapper_test_scripts})
> +	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
> +	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
> +	string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
> +	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
> +endforeach()
> +
> +file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
> +string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
> +string(REPLACE "@@PROG@@" "git-cvsserver" content "${content}")
> +file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
> +
> +#options for configuring test options
> +option(PERL_TESTS "Perform tests that use perl" ON)
> +option(PYTHON_TESTS "Perform tests that use python" ON)
> +
> +#GIT-BUILD-OPTIONS
> +set(TEST_SHELL_PATH ${SHELL_PATH})
> +set(DIFF diff)
> +set(PYTHON_PATH /usr/bin/python)
> +set(TAR tar)
> +set(NO_CURL )
> +set(NO_EXPAT )
> +set(USE_LIBPCRE1 )
> +set(USE_LIBPCRE2 )

Hm, really?


> +set(NO_LIBPCRE1_JIT )
> +set(NO_PERL )
> +set(NO_PTHREADS )
> +set(NO_PYTHON )
> +set(PAGER_ENV "LESS=FRX LV=-c")
> +set(DC_SHA1 YesPlease)
> +set(RUNTIME_PREFIX true)
> +set(NO_GETTEXT )
> +
> +if(NOT CURL_FOUND)
> +	set(NO_CURL 1)
> +endif()
> +
> +if(NOT EXPAT_FOUND)
> +	set(NO_EXPAT 1)
> +endif()
> +
> +if(NOT Intl_FOUND)
> +	set(NO_GETTEXT 1)
> +endif()
> +
> +if(NOT PERL_TESTS)
> +	set(NO_PERL 1)
> +endif()
> +
> +if(NOT PYTHON_TESTS)
> +	set(NO_PYTHON 1)
> +endif()

I hope we have something like:

PYTHON_PATH=/path/to/my/yet/to/release/python/to/check/if/it/works/with/current/git

If it's ready, thanks.
If it isn't, no, I'm stressed enough by CMake.

> +
> +file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "SHELL_PATH='${SHELL_PATH}'\n")
> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TEST_SHELL_PATH='${TEST_SHELL_PATH}'\n")
> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PERL_PATH='${PERL_PATH}'\n")
> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DIFF='${DIFF}'\n")
> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PYTHON_PATH='${PYTHON_PATH}'\n")
> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TAR='${TAR}'\n")
> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_CURL='${NO_CURL}'\n")
> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_EXPAT='${NO_EXPAT}'\n")
> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "USE_LIBPCRE1='${USE_LIBPCRE1}'\n")
> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\n")
> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PERL='${NO_PERL}'\n")
> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\n")
> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
> +
> +file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")

CMake recommends to not use GLOB for this kind of things, themselves, no?

> +
> +#test
> +foreach(tsh ${test_scipts})
> +	add_test(NAME ${tsh}
> +		COMMAND ${SH_EXE} ${tsh}
> +		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)
> +endforeach()
> +
> +endif()#BUILD_TESTING
> \ No newline at end of file

Please fix your editor!

-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 5/8] cmake: support for testing git when building out of the source tree
  2020-04-24  4:01 ` [PATCH 5/8] cmake: support for testing git when building out of the source tree Sibi Siddharthan via GitGitGadget
@ 2020-04-24 17:34   ` Danh Doan
  2020-04-24 21:32     ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Danh Doan @ 2020-04-24 17:34 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

On 2020-04-24 04:01:34+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> 
> This patch allows git to be tested when performin out of source builds.
> 
> This involves changing GIT_BUILD_DIR in t/test-lib.sh to point to the
> build directory. Also some miscellaneous copies from the source directory
> to the build directory.
> The copies are:
> t/chainlint.sed needed by a bunch of test scripts
> po/is.po needed by t0204-gettext-rencode-sanity
> mergetools/tkdiff needed by t7800-difftool
> contrib/completion/git-prompt.sh needed by t9903-bash-prompt
> contrib/completion/git-completion.bash needed by t9902-completion
> contrib/svn-fe/svnrdump_sim.py needed by t9020-remote-svn
> 
> NOTE: t/test-lib.sh is only modified when tests are run not during
> the build or configure.
> The trash directory is still srcdir/t
> 
> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> ---
>  CMakeLists.txt | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 141ccefa559..29a23eb11f7 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -812,6 +812,25 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n"
>  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
>  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
>  
> +#Make the tests work when building out of the source tree
> +if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})

IIRC, CMake recommends _NOT_ expand variable inside if()
This very inconsistent recommendation of CMake (when should I use
${var} and when should I use var?) is one of reason I hate CMake

> +	file(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)
> +	string(REPLACE "/CMakeCache.txt" "" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})

I don't know what is going on here!

> +	#Setting the build directory in test-lib.sh before running tests
> +	file(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake
> +		"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \"GIT_BUILD_DIR=(.*)\")\n"
> +		"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\n"
> +		"string(REPLACE \"\${GIT_BUILD_DIR_REPL}\" \"GIT_BUILD_DIR=\\\"$TEST_DIRECTORY\\\"/../${BUILD_DIR_RELATIVE}\" content \"\${content}\")\n"
> +		"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \${content})")
> +	#misc copies
> +	file(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)

So, some sed will be used in Windows without POSIX-like system,
interesting!

> +	file(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)
> +	file(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)
> +	file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
> +	file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
> +	file(COPY ${CMAKE_SOURCE_DIR}/contrib/svn-fe/svnrdump_sim.py DESTINATION ${CMAKE_BINARY_DIR}/contrib/svn-fe/)
> +endif()
> +
>  file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")

Remember cmake won't be re-run if nothing was changed in CMakeList.txt
If I only change some code, and I decided the change I make should be
tested by a-new-and-independent-test-script.
I need to re-run cmake manually! I don't like it, at all.


-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 6/8] cmake: support for building git on windows with mingw
  2020-04-24  4:01 ` [PATCH 6/8] cmake: support for building git on windows with mingw Sibi Siddharthan via GitGitGadget
@ 2020-04-24 17:39   ` Philip Oakley
  2020-04-24 20:29     ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Philip Oakley @ 2020-04-24 17:39 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget, git; +Cc: Sibi Siddharthan

Hi Sibi,

On 24/04/2020 05:01, Sibi Siddharthan via GitGitGadget wrote:
> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
>
> This patch facilitates building git on Windows with CMake using MinGW
>
> NOTE: The funtions unsetenv and hstrerror are not checked in Windows
> builds.
> Reasons
> NO_UNSETENV is not compatible with Windows builds.
> lines 262-264 compat/mingw.h
>
> compat/mingw.h(line 25) provides a definition of hstrerror which
> conflicts with the definition provided in
> git-compat-util.h(lines 733-736).
>
> To use CMake on Windows with MinGW do this:
> cmake `relative-path-to-srcdir` -G "MinGW Makefiles"
>
> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> ---
>  CMakeLists.txt | 120 +++++++++++++++++++++++++++++++++++++++----------
>  1 file changed, 97 insertions(+), 23 deletions(-)
>
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 29a23eb11f7..d9eb1060390 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -13,9 +13,12 @@ project(git
>  	VERSION ${git_version}
>  	LANGUAGES C)
>  
> +
>  #TODO gitk git-gui gitweb
> +#TODO Enable NLS on windows natively
>  #TODO Add pcre support
>  
> +
>  include(CheckTypeSize)
>  include(CheckCSourceRuns)
>  include(CheckCSourceCompiles)
> @@ -31,6 +34,7 @@ find_package(EXPAT)
>  find_package(Iconv)
>  find_package(Intl)
>  
> +
>  if(NOT Intl_FOUND)
>  	add_compile_definitions(NO_GETTEXT)
>  	if(NOT Iconv_FOUND)
> @@ -53,6 +57,16 @@ if(Intl_FOUND)
>  endif()
>  
>  find_program(SH_EXE sh)
> +if(NOT SH_EXE)
> +	message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")
Either the error message or the web page it points to need to coordinate
on the 'sh interpreter' reference to help the script kiddies follow the
thread. At the moment there is no 'interp..' on the gitforwindows web
page. Would someone attempting to use cmake need to use the Download or
the Contribute buttons, or some other route to acquire the missing SH_EXE?

(this is also a context line in the next patch)
> +endif()
> +
> +if(WIN32)
> +	find_program(WINDRES_EXE windres)
> +	if(NOT WINDRES_EXE)
> +		message(FATAL_ERROR "Install windres on Windows for resource files")
> +	endif()
> +endif()
>  
>  find_program(MSGFMT_EXE msgfmt)
>  if(NOT MSGFMT_EXE)
> @@ -85,11 +99,39 @@ add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
>  			BINDIR="bin"
>  			GIT_BUILT_FROM_COMMIT="")
>  
> -set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
> -add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
> +if(WIN32)
> +	set(FALLBACK_RUNTIME_PREFIX /mingw64)
> +	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
> +else()
> +	set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
> +	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
> +endif()
>  
> -add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
> -list(APPEND compat_SOURCES unix-socket.c)
> +
> +#Platform Specific
> +if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
> +	include_directories(compat/win32)
> +	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
> +				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
> +				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT
> +				USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
> +				UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
> +	list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
> +		compat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c
> +		compat/win32/trace2_win32_process_info.c compat/win32/dirent.c
> +		compat/nedmalloc/nedmalloc.c compat/strdup.c)
> +	set(NO_UNIX_SOCKETS 1)
> +
> +elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
> +	add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
> +	list(APPEND compat_SOURCES unix-socket.c)
> +endif()
> +
> +if(WIN32)
> +	set(EXE_EXTENSION .exe)
> +else()
> +	set(EXE_EXTENSION)
> +endif()
>  
>  #header checks
>  check_include_file(libgen.h HAVE_LIBGEN_H)
> @@ -150,7 +192,12 @@ endif()
>  #function checks
>  set(function_checks
>  	strcasestr memmem strlcpy strtoimax strtoumax strtoull
> -	setenv  mkdtemp poll pread  memmem unsetenv hstrerror)
> +	setenv  mkdtemp poll pread  memmem)
> +
> +#unsetenv,hstrerror are incompatible with windows build
> +if(NOT WIN32)
> +	list(APPEND function_checks unsetenv hstrerror)
> +endif()
>  
>  foreach(f ${function_checks})
>  	string(TOUPPER ${f} uf)
> @@ -309,7 +356,13 @@ endif()
>  #programs
>  set(PROGRAMS_BUILT
>  	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
> -	git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
> +	git-shell git-remote-testsvn)
> +
> +if(NO_UNIX_SOCKETS)
> +	list(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)
> +else()
> +	list(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)
> +endif()
>  
>  if(NOT CURL_FOUND)
>  	list(APPEND excluded_progs git-http-fetch git-http-push)
> @@ -410,15 +463,34 @@ set(libvcs-svn_SOURCES
>  	vcs-svn/svndiff.c vcs-svn/svndump.c)
>  add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
>  
> +#add git.rc for gcc
> +if(WIN32)
> +	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
> +			COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
> +				-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
> +				-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
> +			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
> +			VERBATIM)
> +	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
> +endif()
> +
>  #link all required libraries to common-main
>  add_library(common-main OBJECT common-main.c)
> -target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
> +
> +target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})
>  if(Intl_FOUND)
>  	target_link_libraries(common-main ${Intl_LIBRARIES})
>  endif()
>  if(Iconv_FOUND)
>  	target_link_libraries(common-main ${Iconv_LIBRARIES})
>  endif()
> +if(WIN32)
> +	target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
> +	add_dependencies(common-main git-rc)
> +	target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
> +elseif(UNIX)
> +	target_link_libraries(common-main pthread rt)
> +endif()
>  
>  
>  set(git_SOURCES
> @@ -501,11 +573,13 @@ endif()
>  add_executable(git-remote-testsvn remote-testsvn.c)
>  target_link_libraries(git-remote-testsvn common-main vcs-svn)
>  
> -add_executable(git-credential-cache credential-cache.c)
> -target_link_libraries(git-credential-cache common-main)
> +if(NOT NO_UNIX_SOCKETS)
> +	add_executable(git-credential-cache credential-cache.c)
> +	target_link_libraries(git-credential-cache common-main)
>  
> -add_executable(git-credential-cache--daemon credential-cache--daemon.c)
> -target_link_libraries(git-credential-cache--daemon common-main)
> +	add_executable(git-credential-cache--daemon credential-cache--daemon.c)
> +	target_link_libraries(git-credential-cache--daemon common-main)
> +endif()
>  
>  
>  set(git_builtin_extra
> @@ -517,16 +591,16 @@ set(git_builtin_extra
>  foreach(s ${git_SOURCES} ${git_builtin_extra})
>  	string(REPLACE "builtin/" "" s ${s})
>  	string(REPLACE ".c" "" s ${s})
> -	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
> -	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
> +	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\n")
> +	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})
>  endforeach()
>  
>  if(CURL_FOUND)
>  	set(remote_exes
>  		git-remote-https git-remote-ftp git-remote-ftps)
>  	foreach(s ${remote_exes})
> -		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
> -		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
> +		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http${EXE_EXTENSION} ${s}${EXE_EXTENSION})\n")
> +		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s}${EXE_EXTENSION})
>  	endforeach()
>  endif()
>  
> @@ -654,20 +728,20 @@ set(bin_links
>  	git-receive-pack git-upload-archive git-upload-pack)
>  
>  foreach(b ${bin_links})
> -install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
> +install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/bin/${b}${EXE_EXTENSION})")
>  endforeach()
>  
> -install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
> -install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
> +install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git${EXE_EXTENSION})")
> +install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell${EXE_EXTENSION})")
>  
>  foreach(b ${git_links})
>  	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
> -	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
> +	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
>  endforeach()
>  
>  foreach(b ${git_http_links})
>  	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
> -	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
> +	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
>  endforeach()
>  
>  install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
> @@ -734,14 +808,14 @@ set(wrapper_test_scripts
>  foreach(script ${wrapper_scripts})
>  	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
>  	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
> -	string(REPLACE "@@PROG@@" "${script}" content "${content}")
> +	string(REPLACE "@@PROG@@" "${script}${EXE_EXTENSION}" content "${content}")
>  	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
>  endforeach()
>  
>  foreach(script ${wrapper_test_scripts})
>  	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
>  	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
> -	string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
> +	string(REPLACE "@@PROG@@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
>  	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
>  endforeach()
>  
> @@ -807,7 +881,7 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\
>  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
>  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
>  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
> -file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
> +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X='${EXE_EXTENSION}'\n")
>  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
>  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
>  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")


^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 7/8] cmake: support for building git on windows with msvc and clang.
  2020-04-24  4:01 ` [PATCH 7/8] cmake: support for building git on windows with msvc and clang Sibi Siddharthan via GitGitGadget
@ 2020-04-24 17:39   ` Danh Doan
  2020-04-24 21:35     ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Danh Doan @ 2020-04-24 17:39 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

On 2020-04-24 04:01:36+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> 
> This patch adds support for Visual Studio and Clang builds
> 
> The minimum required version of CMake is upgraded to 3.15 because
> this version offers proper support for Clang builds on Windows.
> 
> Libintl is not searched for when building with Visual Studio or Clang
> because there is no binary compatible version available yet.
> 
> NOTE: In the link options invalidcontinue.obj has to be included.
> The reason for this is because by default, Windows calls abort()'s
> instead of setting errno=EINVAL when invalid arguments are passed to
> standard functions.
> This commit explains it in detail:
> 4b623d80f73528a632576990ca51e34c333d5dd6
> 
> On Windows the default generator is Visual Studio,so for Visual Studio
> builds do this:
> 
> cmake `relative-path-to-srcdir`
> 
> NOTE: Visual Studio generator is a multi config generator, which means
> that Debug and Release builds can be done on the same build directory.
> 
> For Clang builds do this:
> 
> On bash
> CC=Clang cmake `relative-path-to-srcdir` -G Ninja
> 		-DCMAKE_BUILD_TYPE=[Debug or Release]
> 
> On cmd
> set CC=Clang
> cmake `relative-path-to-srcdir` -G Ninja
> 		-DCMAKE_BUILD_TYPE=[Debug or Release]
> 
> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> ---
>  CMakeLists.txt | 57 ++++++++++++++++++++++++++++++++++++++++----------
>  1 file changed, 46 insertions(+), 11 deletions(-)
> 
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index d9eb1060390..5ad3a2557f7 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -2,7 +2,7 @@
>  #	Copyright (c) 2020 Sibi Siddharthan
>  #
>  
> -cmake_minimum_required(VERSION 3.14)
> +cmake_minimum_required(VERSION 3.15)

3.14 is a step too far, and, now, we want CMake 3.15?

>  
>  #Parse GIT-VERSION-GEN to get the version
>  file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
> @@ -32,8 +32,11 @@ find_package(ZLIB REQUIRED)
>  find_package(CURL)
>  find_package(EXPAT)
>  find_package(Iconv)
> -find_package(Intl)
>  
> +#Don't use libintl on Windows Visual Studio and Clang builds
> +if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")))
> +	find_package(Intl)
> +endif()
>  
>  if(NOT Intl_FOUND)
>  	add_compile_definitions(NO_GETTEXT)
> @@ -61,7 +64,7 @@ if(NOT SH_EXE)
>  	message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")
>  endif()
>  
> -if(WIN32)
> +if(WIN32 AND NOT MSVC)#not required for visual studio builds
>  	find_program(WINDRES_EXE windres)
>  	if(NOT WINDRES_EXE)
>  		message(FATAL_ERROR "Install windres on Windows for resource files")
> @@ -73,6 +76,13 @@ if(NOT MSGFMT_EXE)
>  	message(WARNING "Text Translations won't be build")
>  endif()
>  
> +#Force all visual studio outputs to CMAKE_BINARY_DIR
> +if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
> +	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
> +	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
> +	add_compile_options(/MP)
> +endif()
> +
>  #default behaviour
>  include_directories(${CMAKE_SOURCE_DIR})
>  add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
> @@ -110,6 +120,10 @@ endif()
>  
>  #Platform Specific
>  if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
> +	if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
> +		include_directories(compat/vcbuild/include)
> +		add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)

This is fair, I hate those warning, too.

Is _CRT_NONSTDC_NO_DEPRECATE implied when _CRT_SECURE_NO_WARNINGS
defined? Or otherwise around?


-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 8/8] ci: modification of main.yml to use cmake for vs-build job
  2020-04-24  4:01 ` [PATCH 8/8] ci: modification of main.yml to use cmake for vs-build job Sibi Siddharthan via GitGitGadget
@ 2020-04-24 17:45   ` Danh Doan
  2020-04-24 21:41     ` Sibi Siddharthan
  2020-04-24 21:44     ` Johannes Schindelin
  0 siblings, 2 replies; 179+ messages in thread
From: Danh Doan @ 2020-04-24 17:45 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

On 2020-04-24 04:01:37+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> 
> This patch modifies .github/workflows/main.yml to use CMake for
> Visual Studio builds.
> 
> Modified the vs-test step to match windows-test step. This speeds
> up the vs-test. Calling git-cmd from powershell and then calling git-bash
> to perform the tests slows things down(factor of about 6). So git-bash
> is directly called from powershell to perform the tests using prove.
> 
> NOTE: Since GitHub keeps the same directory for each job
> (with respect to path) absolute paths are used in the bin-wrapper
> scripts.
> 
> GitHub has switched to CMake 3.17.1 which changed the behaviour of
> FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been
> added to revert to the old behaviour.
> 
> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> ---
>  .github/workflows/main.yml | 43 ++++++++++++++++++++++----------------
>  1 file changed, 25 insertions(+), 18 deletions(-)
> 
> diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
> index fd4df939b50..94f9a385225 100644
> --- a/.github/workflows/main.yml
> +++ b/.github/workflows/main.yml
> @@ -80,13 +80,6 @@ jobs:
>      - name: download git-sdk-64-minimal
>        shell: bash
>        run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
> -    - name: generate Visual Studio solution
> -      shell: powershell
> -      run: |
> -        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
> -          make NDEBUG=1 DEVELOPER=1 vcxproj
> -        "@
> -        if (!$?) { exit(1) }
>      - name: download vcpkg artifacts
>        shell: powershell
>        run: |
> @@ -98,6 +91,13 @@ jobs:
>          Remove-Item compat.zip
>      - name: add msbuild to PATH
>        uses: microsoft/setup-msbuild@v1.0.0
> +    - name: generate Visual Studio solution
> +      shell: powershell
> +      run: |
> +        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
> +          cmake . -DCMAKE_PREFIX_PATH=./compat/vcbuild/vcpkg/installed/x64-windows -DMSGFMT_EXE=./git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
> +        "@
> +        if (!$?) { exit(1) }

If you intended to modified some steps to provide a better script for
that step, I believe you should change in that step.

If the order of those steps need to be changed, please clarify your
reasoning!

>      - name: MSBuild
>        run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
>      - name: bundle artifact tar
> @@ -125,9 +125,9 @@ jobs:
>          nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>      steps:
>      - uses: actions/checkout@v1
> -    - name: download git-64-portable
> +    - name: download git-sdk-64-minimal
>        shell: bash
> -      run: a=git-64-portable && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
> +      run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
>      - name: download build artifacts
>        uses: actions/download-artifact@v1
>        with:
> @@ -136,23 +136,30 @@ jobs:
>      - name: extract build artifacts
>        shell: bash
>        run: tar xf artifacts.tar.gz
> -    - name: test (parallel)
> +    - name: test

So the test couldn't be run in parallel anymore?
It's a regression!
And we don't need the matrix anymore!!!!!

I wonder if Dscho's effort is wasted, he tried very hard to make
those tests run in parallel.
He even tried to re-order the matrix in GfW project to let longest
test run first!


>        shell: powershell
>        env:
>          MSYSTEM: MINGW64
>          NO_SVN_TESTS: 1
>          GIT_TEST_SKIP_REBASE_P: 1
>        run: |
> -        & git-64-portable\git-cmd.exe --command=usr\bin\bash.exe -lc @"
> -          # Let Git ignore the SDK and the test-cache
> -          printf '%s\n' /git-64-portable/ /test-cache/ >>.git/info/exclude
> +        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
> +          # Let Git ignore the SDK
> +          printf '%s\n' /git-sdk-64-minimal/ >>.git/info/exclude
>  
> -          cd t &&
> -          PATH=\"`$PWD/helper:`$PATH\" &&
> -          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \
> -                  `$(test-tool.exe path-utils slice-tests \
> -                          ${{matrix.nr}} 10 t[0-9]*.sh)
> +          ci/run-test-slice.sh ${{matrix.nr}} 10
>          "@
> +    - name: ci/print-test-failures.sh
> +      if: failure()
> +      shell: powershell
> +      run: |
> +        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc ci/print-test-failures.sh

What is changed?

-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-24  4:01 [PATCH 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                   ` (7 preceding siblings ...)
  2020-04-24  4:01 ` [PATCH 8/8] ci: modification of main.yml to use cmake for vs-build job Sibi Siddharthan via GitGitGadget
@ 2020-04-24 18:56 ` Junio C Hamano
  2020-04-24 19:50   ` Sibi Siddharthan
  2020-05-12 16:50 ` [PATCH v2 00/11] " Sibi Siddharthan via GitGitGadget
  9 siblings, 1 reply; 179+ messages in thread
From: Junio C Hamano @ 2020-04-24 18:56 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

"Sibi Siddharthan via GitGitGadget" <gitgitgadget@gmail.com> writes:

> This is an attempt to build Git using CMake.

What is your longer-term plan on this one?  Would the ultimate goal
be 

 (1) to maintain both CMake and Makefile and keep them in sync?

 (2) force all the Git developers (not users or binary packagers)
     start using cmake and abandon Makefile, and let CMake generate
     Makefile?

 (3) something else?

Given that bootstrapping CMake typically takes a working "make", by
definition, if you drop Makefile from our shipped source tree, the
audience you can support on minority platforms would be smaller than
what we have.  It is not negotiable that we keep Makefile as a valid
way to build Git, and the Makefile must be tweakable for those on a
minority platforms when things do not go the way they want to (the
tweakability is most needed on minority/exotic platforms).

W ith either (1) or (2) above, I have a feeling that engineering
burden to divert resources to add cmake support (with sustainable
plan to keep "fixable/tweakable" Makefile that is in sync) alone
would already be high enough.  It is unclear the reason why we want
to pay all that cost---to gain what?  Other than to make those who
like CMake feel happier, that is.

I do not want to sound overly negative in my first response, but you
might thank whoever says "no" early before you invest too much time
on this topic, so I'll send the above before even reading these 8
patches.

Thanks for your interest in the project.


^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-24 18:56 ` [PATCH 0/8] CMake build system for git Junio C Hamano
@ 2020-04-24 19:50   ` Sibi Siddharthan
  2020-04-24 21:43     ` Junio C Hamano
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-04-24 19:50 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Sibi Siddharthan via GitGitGadget, git

On Sat, Apr 25, 2020 at 12:26 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Sibi Siddharthan via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > This is an attempt to build Git using CMake.
>
> What is your longer-term plan on this one?  Would the ultimate goal
> be
>
>  (1) to maintain both CMake and Makefile and keep them in sync?
>
>  (2) force all the Git developers (not users or binary packagers)
>      start using cmake and abandon Makefile, and let CMake generate
>      Makefile?
>
>  (3) something else?
>
> Given that bootstrapping CMake typically takes a working "make", by
> definition, if you drop Makefile from our shipped source tree, the
> audience you can support on minority platforms would be smaller than
> what we have.  It is not negotiable that we keep Makefile as a valid
> way to build Git, and the Makefile must be tweakable for those on a
> minority platforms when things do not go the way they want to (the
> tweakability is most needed on minority/exotic platforms).
>
> W ith either (1) or (2) above, I have a feeling that engineering
> burden to divert resources to add cmake support (with sustainable
> plan to keep "fixable/tweakable" Makefile that is in sync) alone
> would already be high enough.  It is unclear the reason why we want
> to pay all that cost---to gain what?  Other than to make those who
> like CMake feel happier, that is.
>
> I do not want to sound overly negative in my first response, but you
> might thank whoever says "no" early before you invest too much time
> on this topic, so I'll send the above before even reading these 8
> patches.
>
> Thanks for your interest in the project.
>

Hi Junio,

The goal would be to maintain a CMake build for Git keeping it in sync
with the Makefile.
The Makefile is not going to be replaced at all. The CMake script for
now only supports Linux and Windows.
It does not support BSD, Solaris and others, whereas the Makefile does
support them.

The reason for introducing CMake is primarily for compiling git on
Windows and to do out of source builds.
I think the CMake script makes it easier to build Git as it does the
necessary function and header checks and generates the
required compile definitions.

I would like to say that the proposed CMake build system is meant to
complement the currently used Makefile, not to replace it at all.

Thank You,
Sibi Siddharthan

PS: Sorry for the multiple emails:)

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 6/8] cmake: support for building git on windows with mingw
  2020-04-24 17:39   ` Philip Oakley
@ 2020-04-24 20:29     ` Sibi Siddharthan
  2020-04-25 11:37       ` Philip Oakley
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-04-24 20:29 UTC (permalink / raw)
  To: Philip Oakley; +Cc: Sibi Siddharthan via GitGitGadget, git

Hi Philip,

On Fri, Apr 24, 2020 at 11:09 PM Philip Oakley <philipoakley@iee.email> wrote:
>
> Hi Sibi,
>
> On 24/04/2020 05:01, Sibi Siddharthan via GitGitGadget wrote:
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >
> > This patch facilitates building git on Windows with CMake using MinGW
> >
> > NOTE: The funtions unsetenv and hstrerror are not checked in Windows
> > builds.
> > Reasons
> > NO_UNSETENV is not compatible with Windows builds.
> > lines 262-264 compat/mingw.h
> >
> > compat/mingw.h(line 25) provides a definition of hstrerror which
> > conflicts with the definition provided in
> > git-compat-util.h(lines 733-736).
> >
> > To use CMake on Windows with MinGW do this:
> > cmake `relative-path-to-srcdir` -G "MinGW Makefiles"
> >
> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> > ---
> >  CMakeLists.txt | 120 +++++++++++++++++++++++++++++++++++++++----------
> >  1 file changed, 97 insertions(+), 23 deletions(-)
> >
> > diff --git a/CMakeLists.txt b/CMakeLists.txt
> > index 29a23eb11f7..d9eb1060390 100644
> > --- a/CMakeLists.txt
> > +++ b/CMakeLists.txt
> > @@ -13,9 +13,12 @@ project(git
> >       VERSION ${git_version}
> >       LANGUAGES C)
> >
> > +
> >  #TODO gitk git-gui gitweb
> > +#TODO Enable NLS on windows natively
> >  #TODO Add pcre support
> >
> > +
> >  include(CheckTypeSize)
> >  include(CheckCSourceRuns)
> >  include(CheckCSourceCompiles)
> > @@ -31,6 +34,7 @@ find_package(EXPAT)
> >  find_package(Iconv)
> >  find_package(Intl)
> >
> > +
> >  if(NOT Intl_FOUND)
> >       add_compile_definitions(NO_GETTEXT)
> >       if(NOT Iconv_FOUND)
> > @@ -53,6 +57,16 @@ if(Intl_FOUND)
> >  endif()
> >
> >  find_program(SH_EXE sh)
> > +if(NOT SH_EXE)
> > +     message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")
> Either the error message or the web page it points to need to coordinate
> on the 'sh interpreter' reference to help the script kiddies follow the
> thread. At the moment there is no 'interp..' on the gitforwindows web
> page. Would someone attempting to use cmake need to use the Download or
> the Contribute buttons, or some other route to acquire the missing SH_EXE?
>
On Windows, if you are using Git Bash, then you don't have a problem.
This message was for people trying to Git on Windows without a bash shell.

I can rephrase the message saying
"On Windows go to https://gitforwindows.org/ and download the Git
installer which ships with a sh interpreter(bash)."

Would you suggest something else?

> (this is also a context line in the next patch)
> > +endif()
> > +
> > +if(WIN32)
> > +     find_program(WINDRES_EXE windres)
> > +     if(NOT WINDRES_EXE)
> > +             message(FATAL_ERROR "Install windres on Windows for resource files")
> > +     endif()
> > +endif()
> >
> >  find_program(MSGFMT_EXE msgfmt)
> >  if(NOT MSGFMT_EXE)
> > @@ -85,11 +99,39 @@ add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
> >                       BINDIR="bin"
> >                       GIT_BUILT_FROM_COMMIT="")
> >
> > -set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
> > -add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
> > +if(WIN32)
> > +     set(FALLBACK_RUNTIME_PREFIX /mingw64)
> > +     add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
> > +else()
> > +     set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
> > +     add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
> > +endif()
> >
> > -add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
> > -list(APPEND compat_SOURCES unix-socket.c)
> > +
> > +#Platform Specific
> > +if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
> > +     include_directories(compat/win32)
> > +     add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
> > +                             _CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
> > +                             NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT
> > +                             USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
> > +                             UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
> > +     list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
> > +             compat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c
> > +             compat/win32/trace2_win32_process_info.c compat/win32/dirent.c
> > +             compat/nedmalloc/nedmalloc.c compat/strdup.c)
> > +     set(NO_UNIX_SOCKETS 1)
> > +
> > +elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
> > +     add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
> > +     list(APPEND compat_SOURCES unix-socket.c)
> > +endif()
> > +
> > +if(WIN32)
> > +     set(EXE_EXTENSION .exe)
> > +else()
> > +     set(EXE_EXTENSION)
> > +endif()
> >
> >  #header checks
> >  check_include_file(libgen.h HAVE_LIBGEN_H)
> > @@ -150,7 +192,12 @@ endif()
> >  #function checks
> >  set(function_checks
> >       strcasestr memmem strlcpy strtoimax strtoumax strtoull
> > -     setenv  mkdtemp poll pread  memmem unsetenv hstrerror)
> > +     setenv  mkdtemp poll pread  memmem)
> > +
> > +#unsetenv,hstrerror are incompatible with windows build
> > +if(NOT WIN32)
> > +     list(APPEND function_checks unsetenv hstrerror)
> > +endif()
> >
> >  foreach(f ${function_checks})
> >       string(TOUPPER ${f} uf)
> > @@ -309,7 +356,13 @@ endif()
> >  #programs
> >  set(PROGRAMS_BUILT
> >       git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
> > -     git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
> > +     git-shell git-remote-testsvn)
> > +
> > +if(NO_UNIX_SOCKETS)
> > +     list(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)
> > +else()
> > +     list(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)
> > +endif()
> >
> >  if(NOT CURL_FOUND)
> >       list(APPEND excluded_progs git-http-fetch git-http-push)
> > @@ -410,15 +463,34 @@ set(libvcs-svn_SOURCES
> >       vcs-svn/svndiff.c vcs-svn/svndump.c)
> >  add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
> >
> > +#add git.rc for gcc
> > +if(WIN32)
> > +     add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
> > +                     COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
> > +                             -DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
> > +                             -i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
> > +                     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
> > +                     VERBATIM)
> > +     add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
> > +endif()
> > +
> >  #link all required libraries to common-main
> >  add_library(common-main OBJECT common-main.c)
> > -target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
> > +
> > +target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})
> >  if(Intl_FOUND)
> >       target_link_libraries(common-main ${Intl_LIBRARIES})
> >  endif()
> >  if(Iconv_FOUND)
> >       target_link_libraries(common-main ${Iconv_LIBRARIES})
> >  endif()
> > +if(WIN32)
> > +     target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
> > +     add_dependencies(common-main git-rc)
> > +     target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
> > +elseif(UNIX)
> > +     target_link_libraries(common-main pthread rt)
> > +endif()
> >
> >
> >  set(git_SOURCES
> > @@ -501,11 +573,13 @@ endif()
> >  add_executable(git-remote-testsvn remote-testsvn.c)
> >  target_link_libraries(git-remote-testsvn common-main vcs-svn)
> >
> > -add_executable(git-credential-cache credential-cache.c)
> > -target_link_libraries(git-credential-cache common-main)
> > +if(NOT NO_UNIX_SOCKETS)
> > +     add_executable(git-credential-cache credential-cache.c)
> > +     target_link_libraries(git-credential-cache common-main)
> >
> > -add_executable(git-credential-cache--daemon credential-cache--daemon.c)
> > -target_link_libraries(git-credential-cache--daemon common-main)
> > +     add_executable(git-credential-cache--daemon credential-cache--daemon.c)
> > +     target_link_libraries(git-credential-cache--daemon common-main)
> > +endif()
> >
> >
> >  set(git_builtin_extra
> > @@ -517,16 +591,16 @@ set(git_builtin_extra
> >  foreach(s ${git_SOURCES} ${git_builtin_extra})
> >       string(REPLACE "builtin/" "" s ${s})
> >       string(REPLACE ".c" "" s ${s})
> > -     file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
> > -     list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
> > +     file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\n")
> > +     list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})
> >  endforeach()
> >
> >  if(CURL_FOUND)
> >       set(remote_exes
> >               git-remote-https git-remote-ftp git-remote-ftps)
> >       foreach(s ${remote_exes})
> > -             file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
> > -             list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
> > +             file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http${EXE_EXTENSION} ${s}${EXE_EXTENSION})\n")
> > +             list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s}${EXE_EXTENSION})
> >       endforeach()
> >  endif()
> >
> > @@ -654,20 +728,20 @@ set(bin_links
> >       git-receive-pack git-upload-archive git-upload-pack)
> >
> >  foreach(b ${bin_links})
> > -install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
> > +install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/bin/${b}${EXE_EXTENSION})")
> >  endforeach()
> >
> > -install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
> > -install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
> > +install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git${EXE_EXTENSION})")
> > +install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell${EXE_EXTENSION})")
> >
> >  foreach(b ${git_links})
> >       string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
> > -     install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
> > +     install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
> >  endforeach()
> >
> >  foreach(b ${git_http_links})
> >       string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
> > -     install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
> > +     install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
> >  endforeach()
> >
> >  install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
> > @@ -734,14 +808,14 @@ set(wrapper_test_scripts
> >  foreach(script ${wrapper_scripts})
> >       file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
> >       string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
> > -     string(REPLACE "@@PROG@@" "${script}" content "${content}")
> > +     string(REPLACE "@@PROG@@" "${script}${EXE_EXTENSION}" content "${content}")
> >       file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
> >  endforeach()
> >
> >  foreach(script ${wrapper_test_scripts})
> >       file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
> >       string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
> > -     string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
> > +     string(REPLACE "@@PROG@@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
> >       file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
> >  endforeach()
> >
> > @@ -807,7 +881,7 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\
> >  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
> >  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
> >  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
> > -file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X='${EXE_EXTENSION}'\n")
> >  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
> >  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
> >  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
>

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux
  2020-04-24 17:05   ` Danh Doan
@ 2020-04-24 21:06     ` Sibi Siddharthan
  2020-04-24 22:56       ` Danh Doan
  2020-04-25 13:34     ` Johannes Schindelin
  1 sibling, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-04-24 21:06 UTC (permalink / raw)
  To: Danh Doan; +Cc: Sibi Siddharthan via GitGitGadget, git

Hi Danh,
Thank You for your feedback.
Before I answer your comments, I would like to say that the CMake script
only supports Linux and Windows.
I don't have BSD, Solaris or Apple systems to test the script on.
The Makefile will still be used for those systems and won't be replaced.
Also, I am sorry for not leaving a newline at the end.

On Fri, Apr 24, 2020 at 10:35 PM Danh Doan <congdanhqx@gmail.com> wrote:
>
> On 2020-04-24 04:01:30+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
>
> Please excuse my hatred for CMake.
>
> I guess it's my own fault for not learning how to write CMake
> properly, or is it too hard to write correct CMake?
>
> > To make this a little less awkward, the Git for Windows project offers
> > the `vs/master` branch which has a full Visual Studio solution generated
> > and committed. This branch can therefore be used to tinker with Git in
> > Visual Studio _without_ having to download the full Git for Windows SDK.
> > Unfortunatly, that branch is auto-generated from Git for Windows'
> > `master`. If a developer wants to tinker, say, with `pu`, they are out
> > of luck.
>
> I thought:
>         make NDEBUG=1 DEVELOPER=1 vcxproj
>
> was invented for this use case?
>

Yes,
But with CMake a lot more can be done with Visual Studio. For example
we can also target clang-cl now.

> > CMake was invented to make this sort of problem go away, by providing a
> > more standardized, cross-platform way to configure builds.
>
> There is something fun with that *cross*
> Is cmake able to cross-compile cmake by cmake now?
>
> > With a working support CMake, developers on Windows need only install
> > CMake, configure their build, load the generated Visual Studio solution
> > and immediately start modifying the code and build their own version of
> > Git. Likewise, developers on other platforms can use the convenient GUI
> > tools provided by CMake to configure their build.
>
> OK, that's fine if it works for you.
> Please don't drop support for autoconf and Makefile, though.
> (I haven't look into other patches)
>

The Makefile is not going away at all. The CMake script is intended to
complement
the already existing Makefile by giving people flexibility.

> > So let's start building CMake support for Git.
> >
> > This is only the first step, and to make it easier to review, it only
> > allows for configuring builds on the platform that is easiest to
> > configure for: Linux.
> >
> > The CMake script checks whether the headers are present(eg. libgen.h),
> > whether the functions are present(eg. memmem), whether the funtions work
> > properly (eg. snprintf) and generate the required compile definitions
> > for the platform. The script also searches for the required libraries,
> > if it fails to find the required libraries the respective executables
> > won't be built.(eg. If libcurl is not found then git-remote-http won't
> > be built). This will help building Git easier.
> >
> > With a CMake script an out of source build of git is possible resulting
> > in a clean source tree.
> >
> > Note: earlier endeavors on the Git mailing list to introduce CMake ended
> > up in dead water. The primary reason for that was that reviewers
> > _expected_ CMake support to fall out of maintenance, unless the
> > contributor would promise to keep an eye on keeping CMake support up to
> > date. However, in the meantime, support for automated testing has been
> > introduced in Git's source code, and a later patch will modify the
> > (still experimental) GitHub workflow to continually verify that CMake
> > support is still complete. That will make maintenance reasonably easy.
> >
> > Note: this patch asks for the minimum version v3.14 of CMake (which is
> > not all that old as of time of writing) because that is the first
>
> Debian Buster (current stable) ships v3.13.4, I think I don't need to
> mention old-stable of Debian (Stretch or Jessie).
>
>
> > version to offer a platform-independent way to generate hardlinks as
> > part of the build. This is needed to generate all those hardlinks for
> > the built-in commands of Git.
> >
> > Instructions to run CMake:
> >
> > cmake `relative-path-to-srcdir` -DCMAKE_BUILD_TYPE=Release
> >
> > Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
> > compiler flags
> > Debug : -g
> > Release: -O3
>
> IIRC, Linus and Junio used to said noone ever needs "-03"
>

Okay, there is still a way to for "-O2" on Release builds, if you
prefer to do that.

> > RelWithDebInfo : -O2 -g
> > MinSizeRel : -Os
> > empty(default) :
> >
> > NOTE: -DCMAKE_BUILD_TYPE is optional
> >
> > This process generates a Makefile.
> > Then run `make` to build Git.
> >
> > NOTE: By default CMake uses Makefile as the build tool on Linux, to use
> > another tool say `ninja` add this to the command line when configuring.
> > `-G Ninja`
> >
> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> > ---
> >  CMakeLists.txt | 528 +++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 528 insertions(+)
> >  create mode 100644 CMakeLists.txt
> >
> > diff --git a/CMakeLists.txt b/CMakeLists.txt
> > new file mode 100644
> > index 00000000000..73703bd321f
> > --- /dev/null
> > +++ b/CMakeLists.txt
> > @@ -0,0 +1,528 @@
> > +#
> > +#    Copyright (c) 2020 Sibi Siddharthan
> > +#
> > +
> > +cmake_minimum_required(VERSION 3.14)
> > +
> > +#Parse GIT-VERSION-GEN to get the version
> > +file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
> > +string(REPLACE "DEF_VER=v" "" git_version ${git_version})
> > +string(REPLACE ".GIT" ".0" git_version ${git_version})#for building from a snapshot
>
> Does it work with e.g. 2.26.1?
>

Yes it does, the snapshots have ".GIT" at the end the versions whereas
the tags have "2.26.1".
This was a hack for setting the patch level to 0 for the snapshot builds.

> > +
> > +project(git
> > +     VERSION ${git_version}
> > +     LANGUAGES C)
> > +
> > +
> > +include(CheckTypeSize)
> > +include(CheckCSourceRuns)
> > +include(CheckCSourceCompiles)
> > +include(CheckIncludeFile)
> > +include(CheckFunctionExists)
> > +include(CheckSymbolExists)
> > +include(CheckStructHasMember)
> > +
> > +find_package(ZLIB REQUIRED)
> > +find_package(CURL)
>
> Right now, we should --with-zlib=/path/to/zlib/root
> Does this `find_package` support it?
>

Yes it does,
all you have to do is -DZLIB_ROOT=/path/to/zlib/root

> > +find_package(EXPAT)
> > +find_package(Iconv)
> > +find_package(Intl)
> > +
>
> > +if(NOT Intl_FOUND)
> > +     add_compile_definitions(NO_GETTEXT)
>
> find_package(Gettext)?
>

find_package(Gettext) does not define libintl and libintl.h.
If NO_GETTEXT is not defined, it means that libintl.h is present.
So, we use find_package(Intl) for libintl

> > +     if(NOT Iconv_FOUND)
> > +             add_compile_definitions(NO_ICONV)
> > +     endif()
> > +endif()
>
> ICONV_OMITS_BOM?
>

Forgot about this, will add it.

> > +
> > +include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
> > +if(CURL_FOUND)
> > +     include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
> > +endif()
> > +if(EXPAT_FOUND)
> > +     include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
> > +endif()
> > +if(Iconv_FOUND)
> > +     include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
> > +endif()
> > +if(Intl_FOUND)
> > +     include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
> > +endif()
> > +
> > +find_program(SH_EXE sh)
>
> We want to find usable sh, not just sh, no?
>
> It's matter on Solaris, HP-UX
>

How do I check for this, can you help?
Also, the script is not supported on Solaris and HP-UX.

> > +
> > +#default behaviour
> > +include_directories(${CMAKE_SOURCE_DIR})
> > +add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
> > +add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)
> > +add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES
> > +                     SHA1DC_INIT_SAFE_HASH_DEFAULT=0
> > +                     SHA1DC_CUSTOM_INCLUDE_SHA1_C="cache.h"
> > +                     SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="git-compat-util.h" )
> > +list(APPEND compat_SOURCES sha1dc_git.c sha1dc/sha1.c sha1dc/ubc_check.c block-sha1/sha1.c sha256/block/sha256.c compat/qsort_s.c)
> > +
> > +
> > +add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
> > +                     ETC_GITATTRIBUTES="etc/gitattributes"
> > +                     ETC_GITCONFIG="etc/gitconfig"
> > +                     GIT_EXEC_PATH="libexec/git-core"
> > +                     GIT_LOCALE_PATH="share/locale"
> > +                     GIT_MAN_PATH="share/man"
> > +                     GIT_INFO_PATH="share/info"
> > +                     GIT_HTML_PATH="share/doc/git-doc"
> > +                     DEFAULT_HELP_FORMAT="html"
> > +                     DEFAULT_GIT_TEMPLATE_DIR="share/git-core/templates"
> > +                     GIT_VERSION="${PROJECT_VERSION}.GIT"
> > +                     GIT_USER_AGENT="git/${PROJECT_VERSION}.GIT"
> > +                     BINDIR="bin"
> > +                     GIT_BUILT_FROM_COMMIT="")
>
> I wish I could verify this.
> Have you check this part on a default build system for a Linux distro,
> FreeBSD? For things started with "etc/"
>

These are the values I got when I looked at the build logs from the
Makefile (make -n) in Linux and Windows.
Don't know about FreeBSD

> > +
> > +set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
> > +add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
> > +
> > +add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
>
> /proc/self/exe is Linux only, no?
>

Yes, it is. This first patch only supports Linux build.

> > +list(APPEND compat_SOURCES unix-socket.c)
> > +
> > +#header checks
> > +check_include_file(libgen.h HAVE_LIBGEN_H)
> > +if(NOT HAVE_LIBGEN_H)
> > +     add_compile_definitions(NO_LIBGEN_H)
> > +     list(APPEND compat_SOURCES compat/basename.c)
> > +endif()
> > +
> > +check_include_file(sys/sysinfo.h HAVE_SYSINFO)
> > +if(HAVE_SYSINFO)
> > +     add_compile_definitions(HAVE_SYSINFO)
> > +endif()
> > +
> > +check_c_source_compiles("
> > +#include <alloca.h>
> > +int
> > +main ()
> > +{
> > +char *p = (char *) alloca (2 * sizeof (int));
> > +     if (p) return 0;
> > +     return 0;
>
> All code path will return 0?
>

This check is for a working alloca.h.
Some systems define alloca in malloc.h (Windows)

> > +}"
> > +HAVE_ALLOCA_H)
> > +if(HAVE_ALLOCA_H)
> > +     add_compile_definitions(HAVE_ALLOCA_H)
> > +endif()
> > +
> > +check_include_file(strings.h HAVE_STRINGS_H)
> > +if(HAVE_STRINGS_H)
> > +     add_compile_definitions(HAVE_STRINGS_H)
> > +endif()
> > +
> > +check_include_file(sys/select.h HAVE_SYS_SELECT_H)
> > +if(NOT HAVE_SYS_SELECT_H)
> > +     add_compile_definitions(NO_SYS_SELECT_H)
> > +endif()
> > +
> > +check_include_file(sys/poll.h HAVE_SYS_POLL_H)
> > +if(NOT HAVE_SYS_POLL_H)
> > +     add_compile_definitions(NO_SYS_POLL_H)
> > +endif()
> > +
> > +check_include_file(poll.h HAVE_POLL_H)
>
> POSIX defined poll.h instead of sys/poll.h
>
> > +if(NOT HAVE_POLL_H)
> > +     add_compile_definitions(NO_POLL_H)
> > +endif()
> > +
> > +check_include_file(inttypes.h HAVE_INTTYPES_H)
> > +if(NOT HAVE_INTTYPES_H)
> > +     add_compile_definitions(NO_INTTYPES_H)
> > +endif()
> > +
> > +check_include_file(paths.h HAVE_PATHS_H)
> > +if(HAVE_PATHS_H)
> > +     add_compile_definitions(HAVE_PATHS_H)
> > +endif()
> > +
> > +#function checks
> > +set(function_checks
> > +     strcasestr memmem strlcpy strtoimax strtoumax strtoull
> > +     setenv  mkdtemp poll pread  memmem unsetenv hstrerror)
> > +
> > +foreach(f ${function_checks})
> > +     string(TOUPPER ${f} uf)
> > +     check_function_exists(${f} HAVE_${uf})
> > +     if(NOT HAVE_${uf})
> > +             add_compile_definitions(NO_${uf})
> > +     endif()
> > +endforeach()
> > +
> > +if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)
> > +     include_directories(compat/poll)
> > +     add_compile_definitions(NO_POLL)
> > +     list(APPEND compat_SOURCES compat/poll/poll.c)
> > +endif()
> > +
> > +if(NOT HAVE_STRCASESTR)
> > +     list(APPEND compat_SOURCES compat/strcasestr.c)
> > +endif()
> > +
> > +if(NOT HAVE_STRLCPY)
> > +     list(APPEND compat_SOURCES compat/strlcpy.c)
> > +endif()
> > +
> > +if(NOT HAVE_STRTOUMAX)
> > +     list(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c)
> > +endif()
> > +
> > +if(NOT HAVE_SETENV)
> > +     list(APPEND compat_SOURCES compat/setenv.c)
> > +endif()
> > +
> > +if(NOT HAVE_MKDTEMP)
> > +     list(APPEND compat_SOURCES compat/mkdtemp.c)
> > +endif()
> > +
> > +if(NOT HAVE_PREAD)
> > +     list(APPEND compat_SOURCES compat/pread.c)
> > +endif()
> > +
> > +if(NOT HAVE_MEMMEM)
> > +     list(APPEND compat_SOURCES compat/memmem.c)
> > +endif()
> > +
> > +if(NOT WIN32)
> > +     if(NOT HAVE_UNSETENV)
> > +             list(APPEND compat_SOURCES compat/unsetenv.c)
> > +     endif()
> > +
> > +     if(NOT HAVE_HSTRERROR)
> > +             list(APPEND compat_SOURCES compat/hstrerror.c)
> > +     endif()
> > +endif()
> > +
> > +check_function_exists(getdelim HAVE_GETDELIM)
> > +if(HAVE_GETDELIM)
> > +     add_compile_definitions(HAVE_GETDELIM)
> > +endif()
> > +
> > +check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
> > +check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC)
> > +if(HAVE_CLOCK_GETTIME)
> > +     add_compile_definitions(HAVE_CLOCK_GETTIME)
> > +endif()
> > +if(HAVE_CLOCK_MONOTONIC)
> > +     add_compile_definitions(HAVE_CLOCK_MONOTONIC)
> > +endif()
> > +
> > +
> > +#compile checks
> > +check_c_source_runs("
> > +#include<stdio.h>
> > +#include<stdarg.h>
> > +#include<string.h>
> > +#include<stdlib.h>
> > +int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
> > +{
> > +     int ret;
> > +     va_list ap;
> > +
> > +     va_start(ap, format);
> > +     ret = vsnprintf(str, maxsize, format, ap);
> > +     va_end(ap);
> > +     return ret;
> > +}
> > +
> > +int
> > +main ()
> > +{
> > +     char buf[6];
> > +     if (test_vsnprintf(buf, 3, \"%s\", \"12345\") != 5
> > +             || strcmp(buf, \"12\")) return 1;
> > +     if (snprintf(buf, 3, \"%s\", \"12345\") != 5
> > +             || strcmp(buf, \"12\")) return 1;
> > +
> > +     return 0;
> > +}"
> > +SNPRINTF_OK)
> > +if(NOT SNPRINTF_OK)
> > +     add_compile_definitions(SNPRINTF_RETURNS_BOGUS)
> > +     list(APPEND compat_SOURCES compat/snprintf.c)
> > +endif()
> > +
> > +check_c_source_runs("
> > +#include<stdio.h>
> > +int
> > +main ()
> > +{
> > +     FILE *f = fopen(\".\", \"r\");
> > +     return f != NULL;
> > +
> > +     return 0;
> > +}"
> > +FREAD_READS_DIRECTORIES_NO)
> > +if(NOT FREAD_READS_DIRECTORIES_NO)
> > +     add_compile_definitions(FREAD_READS_DIRECTORIES)
> > +     list(APPEND compat_SOURCES compat/fopen.c)
> > +endif()
> > +
> > +check_c_source_compiles("
> > +#include <regex.h>
> > +#ifndef REG_STARTEND
> > +#error oops we dont have it
> > +#endif
> > +int main(){return 0;}"
> > +HAVE_REGEX)
> > +if(NOT HAVE_REGEX)
> > +     include_directories(compat/regex )
> > +     list(APPEND compat_SOURCES compat/regex/regex.c )
> > +     add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
> > +endif()
> > +
> > +
> > +check_c_source_compiles("
> > +#include <stddef.h>
> > +#include <sys/types.h>
> > +#include <sys/sysctl.h>
> > +
> > +int
> > +main ()
> > +{
> > +     int val, mib[2];
> > +     size_t len;
> > +
> > +     mib[0] = CTL_HW;
> > +     mib[1] = 1;
> > +     len = sizeof(val);
> > +     return sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;
> > +
> > +     return 0;
> > +}"
> > +HAVE_BSD_SYSCTL)
> > +if(HAVE_BSD_SYSCTL)
> > +     add_compile_definitions(HAVE_BSD_SYSCTL)
> > +endif()
> > +
> > +#programs
> > +set(PROGRAMS_BUILT
> > +     git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
> > +     git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
> > +
> > +if(NOT CURL_FOUND)
> > +     list(APPEND excluded_progs git-http-fetch git-http-push)
> > +     add_compile_definitions(NO_CURL)
> > +     message(WARNING "git-http-push and git-http-fetch will not be built")
> > +else()
> > +     list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
> > +     if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
> > +             add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
> > +     endif()
> > +endif()
> > +
> > +if(NOT EXPAT_FOUND)
> > +     list(APPEND excluded_progs git-http-push)
> > +     add_compile_definitions(NO_EXPAT)
> > +else()
> > +     list(APPEND PROGRAMS_BUILT git-http-push)
> > +     if(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2)
> > +             add_compile_definitions(EXPAT_NEEDS_XMLPARSE_H)
> > +     endif()
> > +endif()
> > +
> > +list(REMOVE_DUPLICATES excluded_progs)
> > +list(REMOVE_DUPLICATES PROGRAMS_BUILT)
> > +
> > +
> > +foreach(p ${excluded_progs})
> > +     list(APPEND EXCLUSION_PROGS --exclude-program ${p} )
> > +endforeach()
> > +
> > +#for comparing null values
> > +list(APPEND EXCLUSION_PROGS empty)
> > +set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" FORCE)
> > +
> > +if(NOT EXISTS ${CMAKE_SOURCE_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
> > +     list(REMOVE_ITEM EXCLUSION_PROGS empty)
> > +     message("Generating command-list.h")
> > +     execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
> > +                     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
> > +                     OUTPUT_FILE ${CMAKE_SOURCE_DIR}/command-list.h)
> > +endif()
> > +
> > +if(NOT EXISTS ${CMAKE_SOURCE_DIR}/config-list.h)
> > +     message("Generating config-list.h")
> > +     execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
> > +                     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
> > +                     OUTPUT_FILE ${CMAKE_SOURCE_DIR}/config-list.h)
> > +endif()
> > +
> > +
> > +#build
> > +set(libgit_SOURCES
> > +     abspath.c add-interactive.c add-patch.c advice.c alias.c
> > +     alloc.c apply.c archive.c archive-tar.c archive-zip.c argv-array.c
> > +     attr.c base85.c bisect.c blame.c blob.c bloom.c branch.c bulk-checkin.c
> > +     bundle.c cache-tree.c chdir-notify.c checkout.c color.c column.c
> > +     combine-diff.c commit.c commit-graph.c commit-reach.c compat/obstack.c
> > +     compat/terminal.c config.c connect.c connected.c convert.c copy.c credential.c
> > +     csum-file.c ctype.c date.c decorate.c delta-islands.c diffcore-break.c
> > +     diffcore-delta.c diffcore-order.c diffcore-pickaxe.c diffcore-rename.c
> > +     diff-delta.c diff-lib.c diff-no-index.c diff.c dir.c dir-iterator.c editor.c
> > +     entry.c environment.c ewah/bitmap.c ewah/ewah_bitmap.c ewah/ewah_io.c
> > +     ewah/ewah_rlw.c exec-cmd.c fetch-negotiator.c fetch-pack.c fmt-merge-msg.c fsck.c fsmonitor.c
> > +     gettext.c gpg-interface.c graph.c grep.c hashmap.c linear-assignment.c help.c hex.c
> > +     ident.c interdiff.c json-writer.c kwset.c levenshtein.c line-log.c line-range.c list-objects.c
> > +     list-objects-filter.c list-objects-filter-options.c ll-merge.c lockfile.c
> > +     log-tree.c ls-refs.c mailinfo.c mailmap.c match-trees.c mem-pool.c merge.c merge-blobs.c
> > +     merge-recursive.c mergesort.c midx.c name-hash.c negotiator/default.c
> > +     negotiator/skipping.c notes.c notes-cache.c notes-merge.c notes-utils.c object.c oidmap.c
> > +     oidset.c oid-array.c packfile.c pack-bitmap.c pack-bitmap-write.c pack-check.c pack-objects.c
> > +     pack-revindex.c pack-write.c pager.c parse-options.c parse-options-cb.c patch-delta.c
> > +     patch-ids.c path.c pathspec.c pkt-line.c preload-index.c pretty.c prio-queue.c progress.c
> > +     promisor-remote.c prompt.c protocol.c prune-packed.c quote.c range-diff.c reachable.c read-cache.c rebase.c
> > +     rebase-interactive.c reflog-walk.c refs.c refs/files-backend.c refs/iterator.c
> > +     refs/packed-backend.c refs/ref-cache.c refspec.c ref-filter.c remote.c replace-object.c
> > +     repo-settings.c repository.c rerere.c reset.c resolve-undo.c revision.c run-command.c
> > +     send-pack.c sequencer.c serve.c server-info.c setup.c sha1-lookup.c
> > +     sha1-file.c sha1-name.c shallow.c sideband.c sigchain.c split-index.c
> > +     stable-qsort.c strbuf.c streaming.c string-list.c submodule.c submodule-config.c
> > +     sub-process.c symlinks.c tag.c tempfile.c thread-utils.c tmp-objdir.c
> > +     trace.c trace2.c trace2/tr2_cfg.c trace2/tr2_cmd_name.c trace2/tr2_dst.c
> > +     trace2/tr2_sid.c trace2/tr2_sysenv.c trace2/tr2_tbuf.c trace2/tr2_tgt_event.c
> > +     trace2/tr2_tgt_normal.c trace2/tr2_tgt_perf.c trace2/tr2_tls.c trailer.c transport.c
> > +     transport-helper.c tree-diff.c tree.c tree-walk.c unpack-trees.c upload-pack.c url.c
> > +     urlmatch.c usage.c userdiff.c utf8.c varint.c version.c versioncmp.c walker.c wildmatch.c
> > +     worktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c
> > +     zlib.c)
> > +
> > +add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
> > +
> > +set(libxdiff_SOURCES
> > +     xdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c
> > +     xdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)
> > +add_library(xdiff STATIC ${libxdiff_SOURCES})
> > +
> > +set(libvcs-svn_SOURCES
> > +     vcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c
> > +     vcs-svn/svndiff.c vcs-svn/svndump.c)
> > +add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
> > +
> > +#link all required libraries to common-main
> > +add_library(common-main OBJECT common-main.c)
> > +target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
> > +if(Intl_FOUND)
> > +     target_link_libraries(common-main ${Intl_LIBRARIES})
> > +endif()
> > +if(Iconv_FOUND)
> > +     target_link_libraries(common-main ${Iconv_LIBRARIES})
> > +endif()
> > +
> > +
> > +set(git_SOURCES
> > +     builtin/add.c builtin/am.c builtin/annotate.c builtin/apply.c
> > +     builtin/archive.c builtin/bisect--helper.c builtin/blame.c
> > +     builtin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c
> > +     builtin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c
> > +     builtin/checkout-index.c builtin/checkout.c builtin/clean.c
> > +     builtin/clone.c builtin/column.c builtin/commit-tree.c
> > +     builtin/commit.c builtin/commit-graph.c builtin/config.c
> > +     builtin/count-objects.c builtin/credential.c builtin/describe.c
> > +     builtin/diff-files.c builtin/diff-index.c builtin/diff-tree.c
> > +     builtin/diff.c builtin/difftool.c builtin/env--helper.c
> > +     builtin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c
> > +     builtin/for-each-ref.c builtin/fsck.c builtin/gc.c
> > +     builtin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c
> > +     builtin/help.c builtin/index-pack.c builtin/init-db.c
> > +     builtin/interpret-trailers.c builtin/log.c builtin/ls-files.c
> > +     builtin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c
> > +     builtin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c
> > +     builtin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c
> > +     builtin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c
> > +     builtin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c
> > +     builtin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c
> > +     builtin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c
> > +     builtin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c
> > +     builtin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c
> > +     builtin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c
> > +     builtin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c
> > +     builtin/show-branch.c builtin/show-index.c builtin/show-ref.c
> > +     builtin/sparse-checkout.c builtin/stash.c builtin/stripspace.c
> > +     builtin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c
> > +     builtin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c
> > +     builtin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c
> > +     builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c
> > +     builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)
> > +
> > +add_executable(git git.c ${git_SOURCES})
> > +target_link_libraries(git common-main )
> > +
> > +add_executable(git-bugreport bugreport.c)
> > +target_link_libraries(git-bugreport common-main)
> > +
> > +add_executable(git-credential-store credential-store.c)
> > +target_link_libraries(git-credential-store common-main)
> > +
> > +add_executable(git-daemon daemon.c)
> > +target_link_libraries(git-daemon common-main)
> > +
> > +add_executable(git-fast-import fast-import.c)
> > +target_link_libraries(git-fast-import common-main)
> > +
> > +add_executable(git-http-backend http-backend.c)
> > +target_link_libraries(git-http-backend common-main)
> > +
> > +add_executable(git-sh-i18n--envsubst sh-i18n--envsubst.c)
> > +target_link_libraries(git-sh-i18n--envsubst common-main)
> > +
> > +add_executable(git-shell shell.c)
> > +target_link_libraries(git-shell common-main)
> > +
> > +if(CURL_FOUND)
> > +     add_library(http_obj OBJECT http.c)
> > +
> > +     add_executable(git-imap-send imap-send.c)
> > +     target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})
> > +
> > +     add_executable(git-http-fetch http-walker.c http-fetch.c)
> > +     target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})
> > +
> > +     add_executable(git-remote-http http-walker.c remote-curl.c)
> > +     target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )
> > +
> > +     if(EXPAT_FOUND)
> > +             add_executable(git-http-push http-push.c)
> > +             target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
> > +     endif()
> > +endif()
> > +
> > +add_executable(git-remote-testsvn remote-testsvn.c)
> > +target_link_libraries(git-remote-testsvn common-main vcs-svn)
> > +
> > +add_executable(git-credential-cache credential-cache.c)
> > +target_link_libraries(git-credential-cache common-main)
> > +
> > +add_executable(git-credential-cache--daemon credential-cache--daemon.c)
> > +target_link_libraries(git-credential-cache--daemon common-main)
> > +
> > +
> > +set(git_builtin_extra
> > +     cherry cherry-pick format-patch fsck-objects
> > +     init merge-subtree restore show
> > +     stage status switch whatchanged)
> > +
> > +#Creating hardlinks
> > +foreach(s ${git_SOURCES} ${git_builtin_extra})
> > +     string(REPLACE "builtin/" "" s ${s})
> > +     string(REPLACE ".c" "" s ${s})
> > +     file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
> > +     list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
> > +endforeach()
> > +
> > +if(CURL_FOUND)
> > +     set(remote_exes
> > +             git-remote-https git-remote-ftp git-remote-ftps)
> > +     foreach(s ${remote_exes})
> > +             file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
> > +             list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
> > +     endforeach()
> > +endif()
> > +
> > +add_custom_command(OUTPUT ${git_links} ${git_http_links}
> > +             COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
> > +             DEPENDS git git-remote-http)
> > +add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
> > \ No newline at end of file
>
> No new line at end of line always leave a bad taste in my mount!
>
>
> --
> Danh

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 2/8] cmake: generate the shell/perl/python scripts and templates, translations
  2020-04-24 17:19   ` Danh Doan
@ 2020-04-24 21:19     ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-04-24 21:19 UTC (permalink / raw)
  To: Danh Doan; +Cc: Sibi Siddharthan via GitGitGadget, git

On Fri, Apr 24, 2020 at 10:50 PM Danh Doan <congdanhqx@gmail.com> wrote:
>
> On 2020-04-24 04:01:31+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >
> > This patch implements the placeholder substitution to generate, say,
> > `git-request-pull` from `git-request-pull.sh`.
> >
> > The shell/perl/python scripts and template are generated using CMake
> > (very similar to what sed does).
> >
> > The text translations are only build if `msgfmt` is found in your path.
> >
> > NOTE: The scripts and templates are generated during configuration.
> >
> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> > ---
> >  CMakeLists.txt | 107 ++++++++++++++++++++++++++++++++++++++++++++++++-
> >  1 file changed, 106 insertions(+), 1 deletion(-)
> >
> > diff --git a/CMakeLists.txt b/CMakeLists.txt
> > index 73703bd321f..788b53be873 100644
> > --- a/CMakeLists.txt
> > +++ b/CMakeLists.txt
> > @@ -51,6 +51,11 @@ endif()
> >
> >  find_program(SH_EXE sh)
> >
> > +find_program(MSGFMT_EXE msgfmt)
>
> I suppose find_package(Gettext) can do most of this work?
>

Will change it using gettext.

> > +if(NOT MSGFMT_EXE)
> > +     message(WARNING "Text Translations won't be build")
> > +endif()
> > +
> >  #default behaviour
> >  include_directories(${CMAKE_SOURCE_DIR})
> >  add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
> > @@ -525,4 +530,104 @@ endif()
> >  add_custom_command(OUTPUT ${git_links} ${git_http_links}
> >               COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
> >               DEPENDS git git-remote-http)
> > -add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
> > \ No newline at end of file
>
> No newline at end of file?
>
> > +add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
> > +
> > +
> > +#creating required scripts
> > +set(SHELL_PATH /bin/sh)
> > +set(PERL_PATH /usr/bin/perl)
>
> Really?
> Have you tried on, let's say FreeBSD?
>
> > +set(LOCALEDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
> > +set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
> > +set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)
> > +
> > +#shell scripts
> > +set(git_shell_scripts
> > +     git-bisect git-difftool--helper git-filter-branch
> > +     git-merge-octopus git-merge-one-file git-merge-resolve
> > +     git-mergetool git-quiltimport
> > +     git-request-pull git-submodule git-web--browse
> > +     git-mergetool--lib git-parse-remote git-rebase--preserve-merges
> > +     git-sh-setup git-sh-i18n git-instaweb)
> > +
> > +foreach(script ${git_shell_scripts})
> > +     file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)
> > +     string(REPLACE "@SHELL_PATH@" "${SHELL_PATH}" content "${content}")
> > +     string(REPLACE "@@DIFF@@" "diff" content "${content}")
> > +     string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
> > +     string(REPLACE "@GITWEBDIR@" "${GITWEBDIR}" content "${content}")
> > +     string(REPLACE "@@NO_CURL@@" "" content "${content}")
> > +     string(REPLACE "@@USE_GETTEXT_SCHEME@@" "" content "${content}")
> > +     string(REPLACE "# @@BROKEN_PATH_FIX@@" "" content "${content}")
> > +     string(REPLACE "@@PERL@@" "${PERL_PATH}" content "${content}")
> > +     string(REPLACE "@@SANE_TEXT_GREP@@" "-a" content "${content}")
> > +     string(REPLACE "@@PAGER_ENV@@" "LESS=FRX LV=-c" content "${content}")
> > +     file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
> > +endforeach()
>
> I assume this do most of sed magic?
>

Yes

> > +
> > +#perl scripts
> > +set(git_perl_scripts
> > +     git-add--interactive git-archimport git-cvsexportcommit
> > +     git-cvsimport git-cvsserver git-send-email git-svn)
> > +
> > +#create perl header
> > +file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
> > +string(REPLACE "@@PATHSEP@@" ":" perl_header "${perl_header}")
> > +string(REPLACE "@@INSTLIBDIR@@" "${INSTLIBDIR}" perl_header "${perl_header}")
> > +
> > +foreach(script ${git_perl_scripts})
> > +     file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)
> > +     string(REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n${perl_header}\n" content "${content}")
>
> Hoped that this is tried on BSD?
>
> > +     string(REPLACE "@@GIT_VERSION@@" "${PROJECT_VERSION}" content "${content}")
> > +     file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
> > +endforeach()
> > +
> > +#python script
> > +file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)
> > +string(REPLACE "#!/usr/bin/env python" "#!/usr/bin/python" content "${content}")
> > +file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})
> > +
> > +#perl modules
> > +file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
> > +
> > +foreach(pm ${perl_modules})
> > +     string(REPLACE "${CMAKE_SOURCE_DIR}/perl/" "" file_path ${pm})
>
> So, the real source code have reference to CMAKE_SOURCE_DIR?
> I don't think so? It's purely my guess from previous patch, this
> function will do
> string(REPLACE from to file something_I_have_not_checked)
>

This if for getting the built perl modules in the right place "perl/build/lib"
Once I glob the files, their paths are absolute, hence a replacement.

> > +     file(STRINGS ${pm} content NEWLINE_CONSUME)
> > +     string(REPLACE "@@LOCALEDIR@@" "${LOCALEDIR}" content "${content}")
> > +     string(REPLACE "@@NO_PERL_CPAN_FALLBACKS@@" "" content "${content}")
> > +     file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})
> > +#test-lib.sh requires perl/build/lib to be the build directory of perl modules
> > +endforeach()
> > +
> > +
> > +#templates
> > +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
> > +set(hooks_templates
> > +     applypatch-msg.sample pre-applypatch.sample pre-push.sample
> > +     commit-msg.sample pre-commit.sample pre-rebase.sample
> > +     fsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample
> > +     post-update.sample prepare-commit-msg.sample update.sample)
>
> Too much things merged into one line, I hate it.
>

would you prefer something like this
set(hooks_templates
    applypatch-msg.sample
    pre-applypatch.sample
    ...)


> > +
> > +#templates have @.*@ replacement so use configure_file instead
> > +#hooks
> > +foreach(tm ${hooks_templates})
> > +     configure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)
> > +endforeach()
>
> What does this really means?
>

The way above replacements(sed magic) use @@.*@@, whereas the
templates use @.*@.
This pattern is what autoconf uses to configure Makefile.in, CMake
also has a similar feature (configure_file)

> > +
> > +#info
> > +configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)
> > +
> > +#this
> > +configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)
> > +
> > +
> > +#translations
> > +if(MSGFMT_EXE)
> > +     set(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)
>
> hard coded, so this is a regression, compared to old Makefile?
>
> > +     foreach(po ${po_files})
> > +             file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)
> > +             add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo
> > +                             COMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)
>
> find_package(Gettext) defines MSGFMT_EXECUTABLE, I think.
> Have you check Solaris option?
> Or is this tranlated from current Makefile?
> I haven't checked current source code!
>
> > +             list(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)
> > +     endforeach()
> > +     add_custom_target(po-gen ALL DEPENDS ${po_gen})
> > +endif()
> > --
> > gitgitgadget
> >
>
> --
> Danh

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 3/8] cmake: installation support for git
  2020-04-24 17:23   ` Danh Doan
@ 2020-04-24 21:24     ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-04-24 21:24 UTC (permalink / raw)
  To: Danh Doan; +Cc: Sibi Siddharthan via GitGitGadget, git

On Fri, Apr 24, 2020 at 10:53 PM Danh Doan <congdanhqx@gmail.com> wrote:
>
> On 2020-04-24 04:01:32+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >
> > This patch provides the facility to install the built binaries and
> > scripts.
> >
> > This is very similar to `make install`.
> > By default the destination directory(DESTDIR) is /usr/local/ on Linux
> > To set a custom installation path do this:
> > cmake `relative-path-to-srcdir`
> >       -DCMAKE_INSTALL_PREFIX=`preferred-install-path`
> >
> > Then run `make install`
> >
> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> > ---
> >  CMakeLists.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 49 insertions(+)
> >
> > diff --git a/CMakeLists.txt b/CMakeLists.txt
> > index 788b53be873..25de5b5bc35 100644
> > --- a/CMakeLists.txt
> > +++ b/CMakeLists.txt
> > @@ -13,6 +13,8 @@ project(git
> >       VERSION ${git_version}
> >       LANGUAGES C)
> >
> > +#TODO gitk git-gui gitweb
> > +#TODO Add pcre support
> >
> >  include(CheckTypeSize)
> >  include(CheckCSourceRuns)
> > @@ -631,3 +633,50 @@ if(MSGFMT_EXE)
> >       endforeach()
> >       add_custom_target(po-gen ALL DEPENDS ${po_gen})
> >  endif()
> > +
> > +
> > +#to help with the install
> > +list(TRANSFORM git_shell_scripts PREPEND "${CMAKE_BINARY_DIR}/")
> > +list(TRANSFORM git_perl_scripts PREPEND "${CMAKE_BINARY_DIR}/")
> > +
> > +#install
> > +install(TARGETS git git-shell
> > +     RUNTIME DESTINATION bin)
> > +install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver  #${CMAKE_SOURCE_DIR}/gitk-git/gitk check
>
> check? What does it mean?
>

It is part of a TODO for gitk, will remove it. Sorry

> > +     DESTINATION bin)
> > +
> > +list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)
> > +install(TARGETS ${PROGRAMS_BUILT}
> > +     RUNTIME DESTINATION libexec/git-core)
>
> Ubuntu install exec file to /usr/lib/git-core?
>

Yes it does, but when I do `make install` the programs go to libexec/git-core

> > +
> > +set(bin_links
> > +     git-receive-pack git-upload-archive git-upload-pack)
> > +
> > +foreach(b ${bin_links})
> > +install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
> > +endforeach()
> > +
> > +install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
> > +install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
> > +
> > +foreach(b ${git_links})
> > +     string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
> > +     install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
> > +endforeach()
> > +
> > +foreach(b ${git_http_links})
> > +     string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
> > +     install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
> > +endforeach()
> > +
> > +install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
> > +     DESTINATION libexec/git-core)
> > +
> > +install(DIRECTORY mergetools DESTINATION libexec/git-core)
> > +install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5
> > +     FILES_MATCHING PATTERN "*.pm")
>
> I think distro gonna complans about this pattern!
>

What are you trying to say? Can you explain a bit more.

> > +install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)
> > +
> > +if(MSGFMT_EXE)
> > +     install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
> > +endif()
>
> I thought we want to check for NO_GETTEXT?
>
> --
> Danh

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 4/8] cmake: support for testing git with ctest
  2020-04-24 17:28   ` Danh Doan
@ 2020-04-24 21:26     ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-04-24 21:26 UTC (permalink / raw)
  To: Danh Doan; +Cc: Sibi Siddharthan via GitGitGadget, git

On Fri, Apr 24, 2020 at 10:58 PM Danh Doan <congdanhqx@gmail.com> wrote:
>
> On 2020-04-24 04:01:33+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >
> > This patch provides an alternate way to test git using ctest.
> > CTest ships with CMake, so there is no additional dependency being
> > introduced.
> >
> > To perform the tests with ctest do this after building:
> > ctest -j[number of jobs]
> >
> > NOTE: -j is optional, the default number of jobs is 1
> >
> > Each of the jobs does this:
> > cd t/ && sh t[something].sh
> >
> > The reason for using CTest is that it logs the output of the tests
> > in a neat way, which can be helpful during diagnosis of failures.
> >
> > After the tests have run ctest generates three log files located in
> > `build-directory`/Testing/Temporary/
> >
> > These log files are:
> >
> > CTestCostData.txt:
> > This file contains the time taken to complete each test.
> >
> > LastTestsFailed.log:
> > This log file contains the names of the tests that have failed in the
> > run.
> >
> > LastTest.log:
> > This log file contains the log of all the tests that have run.
> > A snippet of the file is given below.
> >
> > 10/901 Testing: D:/my/git-master/t/t0009-prio-queue.sh
> > 10/901 Test: D:/my/git-master/t/t0009-prio-queue.sh
> > Command: "sh.exe" "D:/my/git-master/t/t0009-prio-queue.sh"
> > Directory: D:/my/git-master/t
> > "D:/my/git-master/t/t0009-prio-queue.sh"
> > Output:
> > ----------------------------------------------------------
> > ok 1 - basic ordering
> > ok 2 - mixed put and get
> > ok 3 - notice empty queue
> > ok 4 - stack order
> > passed all 4 test(s)
> > 1..4
> > <end of output>
> > Test time =   1.11 sec
> >
> > NOTE: Testing only works when building in source for now.
> >
> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> > ---
> >  CMakeLists.txt | 142 +++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 142 insertions(+)
> >
> > diff --git a/CMakeLists.txt b/CMakeLists.txt
> > index 25de5b5bc35..141ccefa559 100644
> > --- a/CMakeLists.txt
> > +++ b/CMakeLists.txt
> > @@ -23,6 +23,7 @@ include(CheckIncludeFile)
> >  include(CheckFunctionExists)
> >  include(CheckSymbolExists)
> >  include(CheckStructHasMember)
> > +include(CTest)
> >
> >  find_package(ZLIB REQUIRED)
> >  find_package(CURL)
> > @@ -680,3 +681,144 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/
> >  if(MSGFMT_EXE)
> >       install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
> >  endif()
> > +
> > +
> > +if(BUILD_TESTING)
> > +
> > +#tests-helpers
> > +add_executable(test-fake-ssh t/helper/test-fake-ssh.c)
> > +target_link_libraries(test-fake-ssh common-main)
> > +
> > +add_executable(test-line-buffer t/helper/test-line-buffer.c)
> > +target_link_libraries(test-line-buffer common-main vcs-svn)
> > +
> > +add_executable(test-svn-fe t/helper/test-svn-fe.c)
> > +target_link_libraries(test-svn-fe common-main vcs-svn)
> > +
> > +set(test_helper_sources
> > +     t/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c
> > +     t/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c
> > +     t/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c
> > +     t/helper/test-dump-fsmonitor.c t/helper/test-dump-split-index.c
> > +     t/helper/test-dump-untracked-cache.c t/helper/test-example-decorate.c
> > +     t/helper/test-genrandom.c t/helper/test-genzeros.c t/helper/test-hash.c
> > +     t/helper/test-hashmap.c t/helper/test-hash-speed.c t/helper/test-index-version.c
> > +     t/helper/test-json-writer.c t/helper/test-lazy-init-name-hash.c
> > +     t/helper/test-match-trees.c t/helper/test-mergesort.c t/helper/test-mktemp.c
> > +     t/helper/test-oidmap.c t/helper/test-online-cpus.c t/helper/test-parse-options.c
> > +     t/helper/test-parse-pathspec-file.c t/helper/test-path-utils.c t/helper/test-pkt-line.c
> > +     t/helper/test-prio-queue.c t/helper/test-progress.c t/helper/test-reach.c
> > +     t/helper/test-read-cache.c t/helper/test-read-graph.c t/helper/test-read-midx.c
> > +     t/helper/test-ref-store.c t/helper/test-regex.c t/helper/test-repository.c
> > +     t/helper/test-revision-walking.c t/helper/test-run-command.c t/helper/test-scrap-cache-tree.c
> > +     t/helper/test-serve-v2.c t/helper/test-sha1.c t/helper/test-oid-array.c t/helper/test-sha256.c
> > +     t/helper/test-sigchain.c t/helper/test-strcmp-offset.c t/helper/test-string-list.c
> > +     t/helper/test-submodule-config.c t/helper/test-submodule-nested-repo-config.c t/helper/test-subprocess.c
> > +     t/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c
> > +     t/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)
> > +
> > +add_executable(test-tool ${test_helper_sources})
> > +target_link_libraries(test-tool common-main)
> > +
> > +set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
> > +                     PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)
> > +
> > +#wrapper scripts
> > +set(wrapper_scripts
> > +     git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)
> > +
> > +set(wrapper_test_scripts
> > +     test-fake-ssh test-line-buffer test-svn-fe test-tool)
> > +
> > +
> > +foreach(script ${wrapper_scripts})
> > +     file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
> > +     string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
> > +     string(REPLACE "@@PROG@@" "${script}" content "${content}")
> > +     file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
> > +endforeach()
> > +
> > +foreach(script ${wrapper_test_scripts})
> > +     file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
> > +     string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
> > +     string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
> > +     file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
> > +endforeach()
> > +
> > +file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
> > +string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
> > +string(REPLACE "@@PROG@@" "git-cvsserver" content "${content}")
> > +file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
> > +
> > +#options for configuring test options
> > +option(PERL_TESTS "Perform tests that use perl" ON)
> > +option(PYTHON_TESTS "Perform tests that use python" ON)
> > +
> > +#GIT-BUILD-OPTIONS
> > +set(TEST_SHELL_PATH ${SHELL_PATH})
> > +set(DIFF diff)
> > +set(PYTHON_PATH /usr/bin/python)
> > +set(TAR tar)
> > +set(NO_CURL )
> > +set(NO_EXPAT )
> > +set(USE_LIBPCRE1 )
> > +set(USE_LIBPCRE2 )
>
> Hm, really?
>
>

These are generated by default on the Makefile also.

> > +set(NO_LIBPCRE1_JIT )
> > +set(NO_PERL )
> > +set(NO_PTHREADS )
> > +set(NO_PYTHON )
> > +set(PAGER_ENV "LESS=FRX LV=-c")
> > +set(DC_SHA1 YesPlease)
> > +set(RUNTIME_PREFIX true)
> > +set(NO_GETTEXT )
> > +
> > +if(NOT CURL_FOUND)
> > +     set(NO_CURL 1)
> > +endif()
> > +
> > +if(NOT EXPAT_FOUND)
> > +     set(NO_EXPAT 1)
> > +endif()
> > +
> > +if(NOT Intl_FOUND)
> > +     set(NO_GETTEXT 1)
> > +endif()
> > +
> > +if(NOT PERL_TESTS)
> > +     set(NO_PERL 1)
> > +endif()
> > +
> > +if(NOT PYTHON_TESTS)
> > +     set(NO_PYTHON 1)
> > +endif()
>
> I hope we have something like:
>
> PYTHON_PATH=/path/to/my/yet/to/release/python/to/check/if/it/works/with/current/git
>
> If it's ready, thanks.
> If it isn't, no, I'm stressed enough by CMake.
>

Yes it can be done.

> > +
> > +file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "SHELL_PATH='${SHELL_PATH}'\n")
> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TEST_SHELL_PATH='${TEST_SHELL_PATH}'\n")
> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PERL_PATH='${PERL_PATH}'\n")
> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DIFF='${DIFF}'\n")
> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PYTHON_PATH='${PYTHON_PATH}'\n")
> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TAR='${TAR}'\n")
> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_CURL='${NO_CURL}'\n")
> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_EXPAT='${NO_EXPAT}'\n")
> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "USE_LIBPCRE1='${USE_LIBPCRE1}'\n")
> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\n")
> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PERL='${NO_PERL}'\n")
> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\n")
> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
> > +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
> > +
> > +file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
>
> CMake recommends to not use GLOB for this kind of things, themselves, no?
>
> > +
> > +#test
> > +foreach(tsh ${test_scipts})
> > +     add_test(NAME ${tsh}
> > +             COMMAND ${SH_EXE} ${tsh}
> > +             WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)
> > +endforeach()
> > +
> > +endif()#BUILD_TESTING
> > \ No newline at end of file
>
> Please fix your editor!
>
> --
> Danh

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 5/8] cmake: support for testing git when building out of the source tree
  2020-04-24 17:34   ` Danh Doan
@ 2020-04-24 21:32     ` Sibi Siddharthan
  2020-04-24 23:09       ` Danh Doan
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-04-24 21:32 UTC (permalink / raw)
  To: Danh Doan; +Cc: Sibi Siddharthan via GitGitGadget, git

On Fri, Apr 24, 2020 at 11:04 PM Danh Doan <congdanhqx@gmail.com> wrote:
>
> On 2020-04-24 04:01:34+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >
> > This patch allows git to be tested when performin out of source builds.
> >
> > This involves changing GIT_BUILD_DIR in t/test-lib.sh to point to the
> > build directory. Also some miscellaneous copies from the source directory
> > to the build directory.
> > The copies are:
> > t/chainlint.sed needed by a bunch of test scripts
> > po/is.po needed by t0204-gettext-rencode-sanity
> > mergetools/tkdiff needed by t7800-difftool
> > contrib/completion/git-prompt.sh needed by t9903-bash-prompt
> > contrib/completion/git-completion.bash needed by t9902-completion
> > contrib/svn-fe/svnrdump_sim.py needed by t9020-remote-svn
> >
> > NOTE: t/test-lib.sh is only modified when tests are run not during
> > the build or configure.
> > The trash directory is still srcdir/t
> >
> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> > ---
> >  CMakeLists.txt | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> >
> > diff --git a/CMakeLists.txt b/CMakeLists.txt
> > index 141ccefa559..29a23eb11f7 100644
> > --- a/CMakeLists.txt
> > +++ b/CMakeLists.txt
> > @@ -812,6 +812,25 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n"
> >  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
> >  file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
> >
> > +#Make the tests work when building out of the source tree
> > +if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
>
> IIRC, CMake recommends _NOT_ expand variable inside if()
> This very inconsistent recommendation of CMake (when should I use
> ${var} and when should I use var?) is one of reason I hate CMake
>

I know, I got taken aback at first, but then you get used to it.

> > +     file(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)
> > +     string(REPLACE "/CMakeCache.txt" "" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})
>
> I don't know what is going on here!
>

We are trying find the relative path to the build directory from the
source directory
file(RELATIVE_PATH ...)  requires a file in the to "whatever" directory.
The one file that is always present in the build directory after a
CMake configure is CMakeCache.txt, so we use that.
Then we remove "CMakeCache.txt" from the variable "BUILD_DIR_RELATIVE"
to get the actual relative path.

> > +     #Setting the build directory in test-lib.sh before running tests
> > +     file(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake
> > +             "file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \"GIT_BUILD_DIR=(.*)\")\n"
> > +             "file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\n"
> > +             "string(REPLACE \"\${GIT_BUILD_DIR_REPL}\" \"GIT_BUILD_DIR=\\\"$TEST_DIRECTORY\\\"/../${BUILD_DIR_RELATIVE}\" content \"\${content}\")\n"
> > +             "file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \${content})")
> > +     #misc copies
> > +     file(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)
>
> So, some sed will be used in Windows without POSIX-like system,
> interesting!
>
> > +     file(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)
> > +     file(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)
> > +     file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
> > +     file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
> > +     file(COPY ${CMAKE_SOURCE_DIR}/contrib/svn-fe/svnrdump_sim.py DESTINATION ${CMAKE_BINARY_DIR}/contrib/svn-fe/)
> > +endif()
> > +
> >  file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
>
> Remember cmake won't be re-run if nothing was changed in CMakeList.txt
> If I only change some code, and I decided the change I make should be
> tested by a-new-and-independent-test-script.
> I need to re-run cmake manually! I don't like it, at all.
>

No you don't have re-run CMake.

>
> --
> Danh

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 7/8] cmake: support for building git on windows with msvc and clang.
  2020-04-24 17:39   ` Danh Doan
@ 2020-04-24 21:35     ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-04-24 21:35 UTC (permalink / raw)
  To: Danh Doan; +Cc: Sibi Siddharthan via GitGitGadget, git

On Fri, Apr 24, 2020 at 11:09 PM Danh Doan <congdanhqx@gmail.com> wrote:
>
> On 2020-04-24 04:01:36+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >
> > This patch adds support for Visual Studio and Clang builds
> >
> > The minimum required version of CMake is upgraded to 3.15 because
> > this version offers proper support for Clang builds on Windows.
> >
> > Libintl is not searched for when building with Visual Studio or Clang
> > because there is no binary compatible version available yet.
> >
> > NOTE: In the link options invalidcontinue.obj has to be included.
> > The reason for this is because by default, Windows calls abort()'s
> > instead of setting errno=EINVAL when invalid arguments are passed to
> > standard functions.
> > This commit explains it in detail:
> > 4b623d80f73528a632576990ca51e34c333d5dd6
> >
> > On Windows the default generator is Visual Studio,so for Visual Studio
> > builds do this:
> >
> > cmake `relative-path-to-srcdir`
> >
> > NOTE: Visual Studio generator is a multi config generator, which means
> > that Debug and Release builds can be done on the same build directory.
> >
> > For Clang builds do this:
> >
> > On bash
> > CC=Clang cmake `relative-path-to-srcdir` -G Ninja
> >               -DCMAKE_BUILD_TYPE=[Debug or Release]
> >
> > On cmd
> > set CC=Clang
> > cmake `relative-path-to-srcdir` -G Ninja
> >               -DCMAKE_BUILD_TYPE=[Debug or Release]
> >
> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> > ---
> >  CMakeLists.txt | 57 ++++++++++++++++++++++++++++++++++++++++----------
> >  1 file changed, 46 insertions(+), 11 deletions(-)
> >
> > diff --git a/CMakeLists.txt b/CMakeLists.txt
> > index d9eb1060390..5ad3a2557f7 100644
> > --- a/CMakeLists.txt
> > +++ b/CMakeLists.txt
> > @@ -2,7 +2,7 @@
> >  #    Copyright (c) 2020 Sibi Siddharthan
> >  #
> >
> > -cmake_minimum_required(VERSION 3.14)
> > +cmake_minimum_required(VERSION 3.15)
>
> 3.14 is a step too far, and, now, we want CMake 3.15?
>
> >
> >  #Parse GIT-VERSION-GEN to get the version
> >  file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
> > @@ -32,8 +32,11 @@ find_package(ZLIB REQUIRED)
> >  find_package(CURL)
> >  find_package(EXPAT)
> >  find_package(Iconv)
> > -find_package(Intl)
> >
> > +#Don't use libintl on Windows Visual Studio and Clang builds
> > +if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")))
> > +     find_package(Intl)
> > +endif()
> >
> >  if(NOT Intl_FOUND)
> >       add_compile_definitions(NO_GETTEXT)
> > @@ -61,7 +64,7 @@ if(NOT SH_EXE)
> >       message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")
> >  endif()
> >
> > -if(WIN32)
> > +if(WIN32 AND NOT MSVC)#not required for visual studio builds
> >       find_program(WINDRES_EXE windres)
> >       if(NOT WINDRES_EXE)
> >               message(FATAL_ERROR "Install windres on Windows for resource files")
> > @@ -73,6 +76,13 @@ if(NOT MSGFMT_EXE)
> >       message(WARNING "Text Translations won't be build")
> >  endif()
> >
> > +#Force all visual studio outputs to CMAKE_BINARY_DIR
> > +if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
> > +     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
> > +     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
> > +     add_compile_options(/MP)
> > +endif()
> > +
> >  #default behaviour
> >  include_directories(${CMAKE_SOURCE_DIR})
> >  add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
> > @@ -110,6 +120,10 @@ endif()
> >
> >  #Platform Specific
> >  if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
> > +     if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
> > +             include_directories(compat/vcbuild/include)
> > +             add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
>
> This is fair, I hate those warning, too.
>
> Is _CRT_NONSTDC_NO_DEPRECATE implied when _CRT_SECURE_NO_WARNINGS
> defined? Or otherwise around?
>
>

They both are independent

> --
> Danh

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 8/8] ci: modification of main.yml to use cmake for vs-build job
  2020-04-24 17:45   ` Danh Doan
@ 2020-04-24 21:41     ` Sibi Siddharthan
  2020-04-24 21:44     ` Johannes Schindelin
  1 sibling, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-04-24 21:41 UTC (permalink / raw)
  To: Danh Doan; +Cc: Sibi Siddharthan via GitGitGadget, git

On Fri, Apr 24, 2020 at 11:15 PM Danh Doan <congdanhqx@gmail.com> wrote:
>
> On 2020-04-24 04:01:37+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >
> > This patch modifies .github/workflows/main.yml to use CMake for
> > Visual Studio builds.
> >
> > Modified the vs-test step to match windows-test step. This speeds
> > up the vs-test. Calling git-cmd from powershell and then calling git-bash
> > to perform the tests slows things down(factor of about 6). So git-bash
> > is directly called from powershell to perform the tests using prove.
> >
> > NOTE: Since GitHub keeps the same directory for each job
> > (with respect to path) absolute paths are used in the bin-wrapper
> > scripts.
> >
> > GitHub has switched to CMake 3.17.1 which changed the behaviour of
> > FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been
> > added to revert to the old behaviour.
> >
> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> > ---
> >  .github/workflows/main.yml | 43 ++++++++++++++++++++++----------------
> >  1 file changed, 25 insertions(+), 18 deletions(-)
> >
> > diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
> > index fd4df939b50..94f9a385225 100644
> > --- a/.github/workflows/main.yml
> > +++ b/.github/workflows/main.yml
> > @@ -80,13 +80,6 @@ jobs:
> >      - name: download git-sdk-64-minimal
> >        shell: bash
> >        run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
> > -    - name: generate Visual Studio solution
> > -      shell: powershell
> > -      run: |
> > -        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
> > -          make NDEBUG=1 DEVELOPER=1 vcxproj
> > -        "@
> > -        if (!$?) { exit(1) }
> >      - name: download vcpkg artifacts
> >        shell: powershell
> >        run: |
> > @@ -98,6 +91,13 @@ jobs:
> >          Remove-Item compat.zip
> >      - name: add msbuild to PATH
> >        uses: microsoft/setup-msbuild@v1.0.0
> > +    - name: generate Visual Studio solution
> > +      shell: powershell
> > +      run: |
> > +        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
> > +          cmake . -DCMAKE_PREFIX_PATH=./compat/vcbuild/vcpkg/installed/x64-windows -DMSGFMT_EXE=./git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
> > +        "@
> > +        if (!$?) { exit(1) }
>
> If you intended to modified some steps to provide a better script for
> that step, I believe you should change in that step.
>
> If the order of those steps need to be changed, please clarify your
> reasoning!
>

Previously, the Visual Studio solution was generated, then the vcpkg
artifacts were downloaded.
With CMake, as it searched for the libraries during configure the
vcpkg artifacts are now downloaded before the configure step.

> >      - name: MSBuild
> >        run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
> >      - name: bundle artifact tar
> > @@ -125,9 +125,9 @@ jobs:
> >          nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
> >      steps:
> >      - uses: actions/checkout@v1
> > -    - name: download git-64-portable
> > +    - name: download git-sdk-64-minimal
> >        shell: bash
> > -      run: a=git-64-portable && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
> > +      run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
> >      - name: download build artifacts
> >        uses: actions/download-artifact@v1
> >        with:
> > @@ -136,23 +136,30 @@ jobs:
> >      - name: extract build artifacts
> >        shell: bash
> >        run: tar xf artifacts.tar.gz
> > -    - name: test (parallel)
> > +    - name: test
>
> So the test couldn't be run in parallel anymore?
> It's a regression!
> And we don't need the matrix anymore!!!!!
>
> I wonder if Dscho's effort is wasted, he tried very hard to make
> those tests run in parallel.
> He even tried to re-order the matrix in GfW project to let longest
> test run first!
>
>

Okay, When I removed "(parallel)" does not mean that the tests are not
run in parallel.
Now they are run in the same way how windows-test(step) is run.
The tests(vs-test) actually completes before than the windows-test in the CI

> >        shell: powershell
> >        env:
> >          MSYSTEM: MINGW64
> >          NO_SVN_TESTS: 1
> >          GIT_TEST_SKIP_REBASE_P: 1
> >        run: |
> > -        & git-64-portable\git-cmd.exe --command=usr\bin\bash.exe -lc @"
> > -          # Let Git ignore the SDK and the test-cache
> > -          printf '%s\n' /git-64-portable/ /test-cache/ >>.git/info/exclude
> > +        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
> > +          # Let Git ignore the SDK
> > +          printf '%s\n' /git-sdk-64-minimal/ >>.git/info/exclude
> >
> > -          cd t &&
> > -          PATH=\"`$PWD/helper:`$PATH\" &&
> > -          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \
> > -                  `$(test-tool.exe path-utils slice-tests \
> > -                          ${{matrix.nr}} 10 t[0-9]*.sh)
> > +          ci/run-test-slice.sh ${{matrix.nr}} 10
> >          "@
> > +    - name: ci/print-test-failures.sh
> > +      if: failure()
> > +      shell: powershell
> > +      run: |
> > +        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc ci/print-test-failures.sh
>
> What is changed?
>
> --
> Danh

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-24 19:50   ` Sibi Siddharthan
@ 2020-04-24 21:43     ` Junio C Hamano
  2020-04-25  4:09       ` Sibi Siddharthan
  2020-04-25 12:24       ` Johannes Schindelin
  0 siblings, 2 replies; 179+ messages in thread
From: Junio C Hamano @ 2020-04-24 21:43 UTC (permalink / raw)
  To: Sibi Siddharthan; +Cc: Sibi Siddharthan via GitGitGadget, git

Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:

> The goal would be to maintain a CMake build for Git keeping it in sync
> with the Makefile.
> The Makefile is not going to be replaced at all. The CMake script for
> now only supports Linux and Windows.
> It does not support BSD, Solaris and others, whereas the Makefile does
> support them.

So you are doing (1).  I already said that I feel that engineering
burden to divert resources for CMake support would be unacceptably
high.

Whenever any of our developers need to add source files, Makefile
configuration knobs that people can add to config.mak, etc., you are
forcing them to figure out where in the CMakefile to add them or
devise ways to allow builders who do not use config.mak (because
they use CMake) to do similar tweaks.

Any patch that is acceptable to the current project would become
unacceptable because they lack updates to CMake part, but I suspect
we do not have enough people who are so much devoted to give a good
review if updates to CMake part are added.  And it is unclear why it
would be beneficial to slow our existing developers down by forcing
them to become familiar with CMake.

So..., I am not just "still not convinced", but I am even more
convinced that we do not want this series, after thinking about it
longer.

Thanks.


^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 8/8] ci: modification of main.yml to use cmake for vs-build job
  2020-04-24 17:45   ` Danh Doan
  2020-04-24 21:41     ` Sibi Siddharthan
@ 2020-04-24 21:44     ` Johannes Schindelin
  1 sibling, 0 replies; 179+ messages in thread
From: Johannes Schindelin @ 2020-04-24 21:44 UTC (permalink / raw)
  To: Danh Doan; +Cc: Sibi Siddharthan via GitGitGadget, git, Sibi Siddharthan

Hi Danh,

On Sat, 25 Apr 2020, Danh Doan wrote:

> On 2020-04-24 04:01:37+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >
> > @@ -98,6 +91,13 @@ jobs:
> >          Remove-Item compat.zip
> >      - name: add msbuild to PATH
> >        uses: microsoft/setup-msbuild@v1.0.0
> > +    - name: generate Visual Studio solution
> > +      shell: powershell
> > +      run: |
> > +        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
> > +          cmake . -DCMAKE_PREFIX_PATH=./compat/vcbuild/vcpkg/installed/x64-windows -DMSGFMT_EXE=./git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
> > +        "@
> > +        if (!$?) { exit(1) }
>
> If you intended to modified some steps to provide a better script for
> that step, I believe you should change in that step.
>
> If the order of those steps need to be changed, please clarify your
> reasoning!

It is the order that needs to be changed, indeed: The CMake step requires
the vcpkg artifacts (i.e. pre-built dependencies like curl), whereas the
previous `make vcxproj` did not require them.

And yes, that's good material for the commit message!

> >      - name: MSBuild
> >        run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
> >      - name: bundle artifact tar
> > @@ -125,9 +125,9 @@ jobs:
> >          nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
> >      steps:
> >      - uses: actions/checkout@v1
> > -    - name: download git-64-portable
> > +    - name: download git-sdk-64-minimal
> >        shell: bash
> > -      run: a=git-64-portable && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
> > +      run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
> >      - name: download build artifacts
> >        uses: actions/download-artifact@v1
> >        with:
> > @@ -136,23 +136,30 @@ jobs:
> >      - name: extract build artifacts
> >        shell: bash
> >        run: tar xf artifacts.tar.gz
> > -    - name: test (parallel)
> > +    - name: test
>
> So the test couldn't be run in parallel anymore?
> It's a regression!
> And we don't need the matrix anymore!!!!!
>
> I wonder if Dscho's effort is wasted, he tried very hard to make
> those tests run in parallel.

No need to worry, it's still parallel.

The reason why it looks incorrect is that Sibi used the `windows-test` job
as an example rather than the `vs-test` one. For that reason, it is the
full `git-sdk-64-minimal` rather than the portable Git in which the tests
are run.

I would prefer to re-revert this again, to use the `(parallel)` and the
`git-64-portable` again.

> He even tried to re-order the matrix in GfW project to let longest
> test run first!

I did! And it was quite a bit of manual work because the times are not
really obvious from the logs, you have to script something to get at them.
In the end, it was not worth the effort, as the overall runtime was only
minimally faster, and I did not like how the order could become stale and
less helpful over time.

> >        shell: powershell
> >        env:
> >          MSYSTEM: MINGW64
> >          NO_SVN_TESTS: 1
> >          GIT_TEST_SKIP_REBASE_P: 1
> >        run: |
> > -        & git-64-portable\git-cmd.exe --command=usr\bin\bash.exe -lc @"
> > -          # Let Git ignore the SDK and the test-cache
> > -          printf '%s\n' /git-64-portable/ /test-cache/ >>.git/info/exclude
> > +        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
> > +          # Let Git ignore the SDK
> > +          printf '%s\n' /git-sdk-64-minimal/ >>.git/info/exclude
> >
> > -          cd t &&
> > -          PATH=\"`$PWD/helper:`$PATH\" &&
> > -          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \
> > -                  `$(test-tool.exe path-utils slice-tests \
> > -                          ${{matrix.nr}} 10 t[0-9]*.sh)
> > +          ci/run-test-slice.sh ${{matrix.nr}} 10
> >          "@
> > +    - name: ci/print-test-failures.sh
> > +      if: failure()
> > +      shell: powershell
> > +      run: |
> > +        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc ci/print-test-failures.sh
>
> What is changed?

This also is a consequence of copy/editing the `windows-test` job instead
of the `vs-test` one: The portable Git does not bring enough stuff to run
`prove`, therefore we have to "roll our own runner" here.

Unless we use the substantially larger `git-sdk-64-minimal`. But the idea
here _was_ to test in as similar a fashion to developers on Windows: they
would not want to download the full Git for Windows SDK, but run the test
in the Bash of a regular Git for Windows instead.

Indeed, you could say that in a way, this entire patch series is about
trying to make it unnecessary for developers on Windows to download more
than 500MB just to start tinkering with the Git source code.

Or maybe the patch series is about more than just that, but that alone
would be reason enough to want it. And I think we do want it.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux
  2020-04-24 21:06     ` Sibi Siddharthan
@ 2020-04-24 22:56       ` Danh Doan
  2020-04-25  3:50         ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Danh Doan @ 2020-04-24 22:56 UTC (permalink / raw)
  To: Sibi Siddharthan; +Cc: Sibi Siddharthan via GitGitGadget, git

On 2020-04-25 02:36:12+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:
> Yes it does,
> all you have to do is -DZLIB_ROOT=/path/to/zlib/root

OK, I need to learn this syntax

> > > +find_package(EXPAT)
> > > +find_package(Iconv)
> > > +find_package(Intl)
> > > +
> >
> > > +if(NOT Intl_FOUND)
> > > +     add_compile_definitions(NO_GETTEXT)
> >
> > find_package(Gettext)?
> >
> 
> find_package(Gettext) does not define libintl and libintl.h.
> If NO_GETTEXT is not defined, it means that libintl.h is present.
> So, we use find_package(Intl) for libintl

People do weird things.

But, I bet that a lot of people have system that have libintl.h
installed, but they don't install gettext tools. ;-)

Anyway, can I override NO_GETTEXT from command line?

Let's say, I want to bootstrap a new distro?
In the boostrap step, I don't want to build any i18n things,
because the bootstrap package will be thrown away and rebuild again.
I don't want to waste time on building such translation things.

> 
> > > +     if(NOT Iconv_FOUND)
> > > +             add_compile_definitions(NO_ICONV)
> > > +     endif()
> > > +endif()
> >
> > ICONV_OMITS_BOM?
> >
> 
> Forgot about this, will add it.

Thanks, my platform relies on this definition!

> > > +
> > > +include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
> > > +if(CURL_FOUND)
> > > +     include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
> > > +endif()
> > > +if(EXPAT_FOUND)
> > > +     include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
> > > +endif()
> > > +if(Iconv_FOUND)
> > > +     include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
> > > +endif()
> > > +if(Intl_FOUND)
> > > +     include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
> > > +endif()
> > > +
> > > +find_program(SH_EXE sh)
> >
> > We want to find usable sh, not just sh, no?
> >
> > It's matter on Solaris, HP-UX
> >
> 
> How do I check for this, can you help?

Sorry, Please ask someone else, check Makefile to see who fixed build
for Solaris and HP-UX.

> Also, the script is not supported on Solaris and HP-UX.

If Solaris or HP-UX is out of equation,
I'll just write: SH_EXE=/bin/sh ;-)


> 
> > > +
> > > +#default behaviour
> > > +include_directories(${CMAKE_SOURCE_DIR})
> > > +add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
> > > +add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)
> > > +add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES
> > > +                     SHA1DC_INIT_SAFE_HASH_DEFAULT=0
> > > +                     SHA1DC_CUSTOM_INCLUDE_SHA1_C="cache.h"
> > > +                     SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="git-compat-util.h" )
> > > +list(APPEND compat_SOURCES sha1dc_git.c sha1dc/sha1.c sha1dc/ubc_check.c block-sha1/sha1.c sha256/block/sha256.c compat/qsort_s.c)
> > > +
> > > +
> > > +add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
> > > +                     ETC_GITATTRIBUTES="etc/gitattributes"
> > > +                     ETC_GITCONFIG="etc/gitconfig"
> > > +                     GIT_EXEC_PATH="libexec/git-core"
> > > +                     GIT_LOCALE_PATH="share/locale"
> > > +                     GIT_MAN_PATH="share/man"
> > > +                     GIT_INFO_PATH="share/info"
> > > +                     GIT_HTML_PATH="share/doc/git-doc"
> > > +                     DEFAULT_HELP_FORMAT="html"
> > > +                     DEFAULT_GIT_TEMPLATE_DIR="share/git-core/templates"
> > > +                     GIT_VERSION="${PROJECT_VERSION}.GIT"
> > > +                     GIT_USER_AGENT="git/${PROJECT_VERSION}.GIT"
> > > +                     BINDIR="bin"
> > > +                     GIT_BUILT_FROM_COMMIT="")
> >
> > I wish I could verify this.
> > Have you check this part on a default build system for a Linux distro,
> > FreeBSD? For things started with "etc/"
> >
> 
> These are the values I got when I looked at the build logs from the
> Makefile (make -n) in Linux and Windows.
> Don't know about FreeBSD

Linux will install configuration to /etc, Windows (by using msys),
will also do that.

*BSD port installs git with /usr/local prefix, and install
configuration to /usr/local/etc

> 
> > > +
> > > +set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
> > > +add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
> > > +
> > > +add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
> >
> > /proc/self/exe is Linux only, no?
> >
> 
> Yes, it is. This first patch only supports Linux build.
> 
> > > +list(APPEND compat_SOURCES unix-socket.c)
> > > +
> > > +#header checks
> > > +check_include_file(libgen.h HAVE_LIBGEN_H)
> > > +if(NOT HAVE_LIBGEN_H)
> > > +     add_compile_definitions(NO_LIBGEN_H)
> > > +     list(APPEND compat_SOURCES compat/basename.c)
> > > +endif()
> > > +
> > > +check_include_file(sys/sysinfo.h HAVE_SYSINFO)
> > > +if(HAVE_SYSINFO)
> > > +     add_compile_definitions(HAVE_SYSINFO)
> > > +endif()
> > > +
> > > +check_c_source_compiles("
> > > +#include <alloca.h>
> > > +int
> > > +main ()
> > > +{
> > > +char *p = (char *) alloca (2 * sizeof (int));
> > > +     if (p) return 0;
> > > +     return 0;
> >
> > All code path will return 0?
> >
> 
> This check is for a working alloca.h.
> Some systems define alloca in malloc.h (Windows)

Does CMake have a macro for check function in which include files?

> 
> > > +}"
> > > +HAVE_ALLOCA_H)
> > > +if(HAVE_ALLOCA_H)
> > > +     add_compile_definitions(HAVE_ALLOCA_H)
> > > +endif()
> > > +
> > > +
> > > +if(CURL_FOUND)
> > > +     set(remote_exes
> > > +             git-remote-https git-remote-ftp git-remote-ftps)
> > > +     foreach(s ${remote_exes})
> > > +             file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")

Now, I looked at this again.
I didn't see the creatation of CreateLinks.cmake anywhere!

> > > +             list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
> > > +     endforeach()
> > > +endif()
> > > +
> > > +add_custom_command(OUTPUT ${git_links} ${git_http_links}
> > > +             COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
> > > +             DEPENDS git git-remote-http)
> > > +add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
> > > \ No newline at end of file
> >
> > No new line at end of line always leave a bad taste in my mount!
> >

-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 5/8] cmake: support for testing git when building out of the source tree
  2020-04-24 21:32     ` Sibi Siddharthan
@ 2020-04-24 23:09       ` Danh Doan
  2020-04-25  3:57         ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Danh Doan @ 2020-04-24 23:09 UTC (permalink / raw)
  To: Sibi Siddharthan; +Cc: Sibi Siddharthan via GitGitGadget, git

On 2020-04-25 03:02:49+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:
> > >  file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
> >
> > Remember cmake won't be re-run if nothing was changed in CMakeList.txt
> > If I only change some code, and I decided the change I make should be
> > tested by a-new-and-independent-test-script.
> > I need to re-run cmake manually! I don't like it, at all.
> >
> 
> No you don't have re-run CMake.

Yes, you have to re-run CMake.
https://cmake.org/cmake/help/v3.14/command/file.html#glob

> Note
>
> We do not recommend using GLOB to collect a list of source files
> from your source tree. If no CMakeLists.txt file changes when
> a source is added or removed then the generated build system cannot
> know when to ask CMake to regenerate. The CONFIGURE_DEPENDS flag may
> not work reliably on all generators, or if a new generator is added
> in the future that cannot support it, projects using it will be
> stuck. Even if CONFIGURE_DEPENDS works reliably, there is still
> a cost to perform the check on every rebuild. 

* Run CMake now.
* Don't touch anything
* Create new test-script, let's say t9904-just-for-cmake.sh

* Check if it's run or not, I bet the answer is not

Anyway, Junio said NO, I don't need to be a CMake hater here, anymore.

-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux
  2020-04-24 22:56       ` Danh Doan
@ 2020-04-25  3:50         ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-04-25  3:50 UTC (permalink / raw)
  To: Danh Doan; +Cc: Sibi Siddharthan via GitGitGadget, git

On Sat, Apr 25, 2020 at 4:26 AM Danh Doan <congdanhqx@gmail.com> wrote:
>
> On 2020-04-25 02:36:12+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:
> > Yes it does,
> > all you have to do is -DZLIB_ROOT=/path/to/zlib/root
>
> OK, I need to learn this syntax
>
> > > > +find_package(EXPAT)
> > > > +find_package(Iconv)
> > > > +find_package(Intl)
> > > > +
> > >
> > > > +if(NOT Intl_FOUND)
> > > > +     add_compile_definitions(NO_GETTEXT)
> > >
> > > find_package(Gettext)?
> > >
> >
> > find_package(Gettext) does not define libintl and libintl.h.
> > If NO_GETTEXT is not defined, it means that libintl.h is present.
> > So, we use find_package(Intl) for libintl
>
> People do weird things.
>
> But, I bet that a lot of people have system that have libintl.h
> installed, but they don't install gettext tools. ;-)
>
> Anyway, can I override NO_GETTEXT from command line?
>
> Let's say, I want to bootstrap a new distro?
> In the boostrap step, I don't want to build any i18n things,
> because the bootstrap package will be thrown away and rebuild again.
> I don't want to waste time on building such translation things.
>

So, you are trying to build two times and configuring it only once. Am I right?
If so I don't think you bootstrap with CMake. Will let you know if I
figure something out.

> >
> > > > +     if(NOT Iconv_FOUND)
> > > > +             add_compile_definitions(NO_ICONV)
> > > > +     endif()
> > > > +endif()
> > >
> > > ICONV_OMITS_BOM?
> > >
> >
> > Forgot about this, will add it.
>
> Thanks, my platform relies on this definition!
>
> > > > +
> > > > +include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
> > > > +if(CURL_FOUND)
> > > > +     include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
> > > > +endif()
> > > > +if(EXPAT_FOUND)
> > > > +     include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
> > > > +endif()
> > > > +if(Iconv_FOUND)
> > > > +     include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
> > > > +endif()
> > > > +if(Intl_FOUND)
> > > > +     include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
> > > > +endif()
> > > > +
> > > > +find_program(SH_EXE sh)
> > >
> > > We want to find usable sh, not just sh, no?
> > >
> > > It's matter on Solaris, HP-UX
> > >
> >
> > How do I check for this, can you help?
>
> Sorry, Please ask someone else, check Makefile to see who fixed build
> for Solaris and HP-UX.
>
> > Also, the script is not supported on Solaris and HP-UX.
>
> If Solaris or HP-UX is out of equation,
> I'll just write: SH_EXE=/bin/sh ;-)
>
>

This is exactly what the current definition does.

> >
> > > > +
> > > > +#default behaviour
> > > > +include_directories(${CMAKE_SOURCE_DIR})
> > > > +add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
> > > > +add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)
> > > > +add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES
> > > > +                     SHA1DC_INIT_SAFE_HASH_DEFAULT=0
> > > > +                     SHA1DC_CUSTOM_INCLUDE_SHA1_C="cache.h"
> > > > +                     SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="git-compat-util.h" )
> > > > +list(APPEND compat_SOURCES sha1dc_git.c sha1dc/sha1.c sha1dc/ubc_check.c block-sha1/sha1.c sha256/block/sha256.c compat/qsort_s.c)
> > > > +
> > > > +
> > > > +add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
> > > > +                     ETC_GITATTRIBUTES="etc/gitattributes"
> > > > +                     ETC_GITCONFIG="etc/gitconfig"
> > > > +                     GIT_EXEC_PATH="libexec/git-core"
> > > > +                     GIT_LOCALE_PATH="share/locale"
> > > > +                     GIT_MAN_PATH="share/man"
> > > > +                     GIT_INFO_PATH="share/info"
> > > > +                     GIT_HTML_PATH="share/doc/git-doc"
> > > > +                     DEFAULT_HELP_FORMAT="html"
> > > > +                     DEFAULT_GIT_TEMPLATE_DIR="share/git-core/templates"
> > > > +                     GIT_VERSION="${PROJECT_VERSION}.GIT"
> > > > +                     GIT_USER_AGENT="git/${PROJECT_VERSION}.GIT"
> > > > +                     BINDIR="bin"
> > > > +                     GIT_BUILT_FROM_COMMIT="")
> > >
> > > I wish I could verify this.
> > > Have you check this part on a default build system for a Linux distro,
> > > FreeBSD? For things started with "etc/"
> > >
> >
> > These are the values I got when I looked at the build logs from the
> > Makefile (make -n) in Linux and Windows.
> > Don't know about FreeBSD
>
> Linux will install configuration to /etc, Windows (by using msys),
> will also do that.
>
> *BSD port installs git with /usr/local prefix, and install
> configuration to /usr/local/etc
>

Aren't the above definitions relative paths?(With RUNTIME_PREFIX)
Once you decide to install, you have INSTALL_PREFIX(similar to
DESTDIR) with which you
can achieve the above.

> >
> > > > +
> > > > +set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
> > > > +add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
> > > > +
> > > > +add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
> > >
> > > /proc/self/exe is Linux only, no?
> > >
> >
> > Yes, it is. This first patch only supports Linux build.
> >
> > > > +list(APPEND compat_SOURCES unix-socket.c)
> > > > +
> > > > +#header checks
> > > > +check_include_file(libgen.h HAVE_LIBGEN_H)
> > > > +if(NOT HAVE_LIBGEN_H)
> > > > +     add_compile_definitions(NO_LIBGEN_H)
> > > > +     list(APPEND compat_SOURCES compat/basename.c)
> > > > +endif()
> > > > +
> > > > +check_include_file(sys/sysinfo.h HAVE_SYSINFO)
> > > > +if(HAVE_SYSINFO)
> > > > +     add_compile_definitions(HAVE_SYSINFO)
> > > > +endif()
> > > > +
> > > > +check_c_source_compiles("
> > > > +#include <alloca.h>
> > > > +int
> > > > +main ()
> > > > +{
> > > > +char *p = (char *) alloca (2 * sizeof (int));
> > > > +     if (p) return 0;
> > > > +     return 0;
> > >
> > > All code path will return 0?
> > >
> >
> > This check is for a working alloca.h.
> > Some systems define alloca in malloc.h (Windows)
>
> Does CMake have a macro for check function in which include files?
>

The check functions is something that was used to match the automake behaviour.
If you want to check whether a function exists in a particulae header
file use check_symbol_exists().

> >
> > > > +}"
> > > > +HAVE_ALLOCA_H)
> > > > +if(HAVE_ALLOCA_H)
> > > > +     add_compile_definitions(HAVE_ALLOCA_H)
> > > > +endif()
> > > > +
> > > > +
> > > > +if(CURL_FOUND)
> > > > +     set(remote_exes
> > > > +             git-remote-https git-remote-ftp git-remote-ftps)
> > > > +     foreach(s ${remote_exes})
> > > > +             file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
>
> Now, I looked at this again.
> I didn't see the creatation of CreateLinks.cmake anywhere!
>
> > > > +             list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
> > > > +     endforeach()
> > > > +endif()
> > > > +
> > > > +add_custom_command(OUTPUT ${git_links} ${git_http_links}
> > > > +             COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
> > > > +             DEPENDS git git-remote-http)
> > > > +add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
> > > > \ No newline at end of file
> > >
> > > No new line at end of line always leave a bad taste in my mount!
> > >
>
> --
> Danh

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 5/8] cmake: support for testing git when building out of the source tree
  2020-04-24 23:09       ` Danh Doan
@ 2020-04-25  3:57         ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-04-25  3:57 UTC (permalink / raw)
  To: Danh Doan; +Cc: Sibi Siddharthan via GitGitGadget, git

If you are adding a new test script you will have re-configure.
Even in automake you are expected to do this, unless you have a glob
pattern in Makefile.in somewhere.

On Sat, Apr 25, 2020 at 4:39 AM Danh Doan <congdanhqx@gmail.com> wrote:
>
> On 2020-04-25 03:02:49+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:
> > > >  file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
> > >
> > > Remember cmake won't be re-run if nothing was changed in CMakeList.txt
> > > If I only change some code, and I decided the change I make should be
> > > tested by a-new-and-independent-test-script.
> > > I need to re-run cmake manually! I don't like it, at all.
> > >
> >
> > No you don't have re-run CMake.
>
> Yes, you have to re-run CMake.
> https://cmake.org/cmake/help/v3.14/command/file.html#glob
>
> > Note
> >
> > We do not recommend using GLOB to collect a list of source files
> > from your source tree. If no CMakeLists.txt file changes when
> > a source is added or removed then the generated build system cannot
> > know when to ask CMake to regenerate. The CONFIGURE_DEPENDS flag may
> > not work reliably on all generators, or if a new generator is added
> > in the future that cannot support it, projects using it will be
> > stuck. Even if CONFIGURE_DEPENDS works reliably, there is still
> > a cost to perform the check on every rebuild.
>
> * Run CMake now.
> * Don't touch anything
> * Create new test-script, let's say t9904-just-for-cmake.sh
>
> * Check if it's run or not, I bet the answer is not
>

The new test script is not added to list of test scripts.
So yes, you will have to re-run CMake.
A reconfigure in CMake is going to take less than 2 seconds, not like
automake which can take as long as the initial configure itself.

> Anyway, Junio said NO, I don't need to be a CMake hater here, anymore.
>
> --
> Danh

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-24 21:43     ` Junio C Hamano
@ 2020-04-25  4:09       ` Sibi Siddharthan
  2020-04-25 12:56         ` Philip Oakley
  2020-04-25 12:24       ` Johannes Schindelin
  1 sibling, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-04-25  4:09 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Sibi Siddharthan via GitGitGadget, git

On Sat, Apr 25, 2020 at 3:13 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:
>
> > The goal would be to maintain a CMake build for Git keeping it in sync
> > with the Makefile.
> > The Makefile is not going to be replaced at all. The CMake script for
> > now only supports Linux and Windows.
> > It does not support BSD, Solaris and others, whereas the Makefile does
> > support them.
>
> So you are doing (1).  I already said that I feel that engineering
> burden to divert resources for CMake support would be unacceptably
> high.
>
> Whenever any of our developers need to add source files, Makefile
> configuration knobs that people can add to config.mak, etc., you are
> forcing them to figure out where in the CMakefile to add them or
> devise ways to allow builders who do not use config.mak (because
> they use CMake) to do similar tweaks.
>

Adding source files to the CMakefile is going to just as long as
adding it to the Makefile,
anyone can figure this out and this is not going to take much time at all.

As for the configuration knobs I agree that adding the same to CMake
is going to a bit longer.
But anyone who is hacking Git is going to do it with the Makefile or
(if accepted)CMake script, but not both while hacking.
So they will continue to make progress with the system they feel comfortable in.
They will only run into an issue when they try for a PR. Currently the
CMake script is only used for generating the visual studio solution.
We can add a (continue-on-error) to vs-build job to make this process
less of a hindrance.
If people take the time to hack Git, figuring out how to do the
configuration knobs in the CMake script is not going to that much take
time
compared to the time they spend making Git better.


> Any patch that is acceptable to the current project would become
> unacceptable because they lack updates to CMake part, but I suspect
> we do not have enough people who are so much devoted to give a good
> review if updates to CMake part are added.  And it is unclear why it
> would be beneficial to slow our existing developers down by forcing
> them to become familiar with CMake.
>
> So..., I am not just "still not convinced", but I am even more
> convinced that we do not want this series, after thinking about it
> longer.
>
> Thanks.
>

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 6/8] cmake: support for building git on windows with mingw
  2020-04-24 20:29     ` Sibi Siddharthan
@ 2020-04-25 11:37       ` Philip Oakley
  2020-04-25 12:09         ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Philip Oakley @ 2020-04-25 11:37 UTC (permalink / raw)
  To: Sibi Siddharthan; +Cc: Sibi Siddharthan via GitGitGadget, git

Hi Sibi,

On 24/04/2020 21:29, Sibi Siddharthan wrote:
> Hi Philip,
>
> On Fri, Apr 24, 2020 at 11:09 PM Philip Oakley <philipoakley@iee.email> wrote:
>> Hi Sibi,
>>
>> On 24/04/2020 05:01, Sibi Siddharthan via GitGitGadget wrote:
>>> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
>>>
>>> This patch facilitates building git on Windows with CMake using MinGW
>>>
>>> NOTE: The funtions unsetenv and hstrerror are not checked in Windows
>>> builds.
>>> Reasons
>>> NO_UNSETENV is not compatible with Windows builds.
>>> lines 262-264 compat/mingw.h
>>>
>>> compat/mingw.h(line 25) provides a definition of hstrerror which
>>> conflicts with the definition provided in
>>> git-compat-util.h(lines 733-736).
>>>
>>> To use CMake on Windows with MinGW do this:
>>> cmake `relative-path-to-srcdir` -G "MinGW Makefiles"
>>>
>>> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
>>> ---
>>>  CMakeLists.txt | 120 +++++++++++++++++++++++++++++++++++++++----------
>>>  1 file changed, 97 insertions(+), 23 deletions(-)
>>>
>>> diff --git a/CMakeLists.txt b/CMakeLists.txt
>>> index 29a23eb11f7..d9eb1060390 100644
>>> [snip..]
>>>  find_program(SH_EXE sh)
>>> +if(NOT SH_EXE)
>>> +     message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")
>> Either the error message or the web page it points to need to coordinate
>> on the 'sh interpreter' reference to help the script kiddies follow the
>> thread. At the moment there is no 'interp..' on the gitforwindows web
>> page. Would someone attempting to use cmake need to use the Download or
>> the Contribute buttons, or some other route to acquire the missing SH_EXE?
>>
> On Windows, if you are using Git Bash, then you don't have a problem.
> This message was for people trying to Git on Windows without a bash shell.
>
> I can rephrase the message saying
> "On Windows go to https://gitforwindows.org/ and download the Git
> installer which ships with a sh interpreter(bash)."
>
> Would you suggest something else?

Filling the message out a little, I'm thinking of:

"sh: shell interpreter was not found in your path, please install one.
On Windows, you can get it as part of 'Git for Windows' install at
https://gitforwindows.org/"

The second 'install' could be dropped, but may be needed to fully
qualify the instructions for some readers.

The key feature I was checking was the clarity of the 'install' action,
as opposed to the way sh is integrated within Git for Windows (which is
a whole new topic of conversation for some users!)
>
>> (this is also a context line in the next patch)
>>
[snip..]

--
Philip

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 6/8] cmake: support for building git on windows with mingw
  2020-04-25 11:37       ` Philip Oakley
@ 2020-04-25 12:09         ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-04-25 12:09 UTC (permalink / raw)
  To: Philip Oakley; +Cc: Sibi Siddharthan via GitGitGadget, git

Hi Philip,

On Sat, Apr 25, 2020 at 5:07 PM Philip Oakley <philipoakley@iee.email> wrote:
>
> Hi Sibi,
>
> On 24/04/2020 21:29, Sibi Siddharthan wrote:
> > Hi Philip,
> >
> > On Fri, Apr 24, 2020 at 11:09 PM Philip Oakley <philipoakley@iee.email> wrote:
> >> Hi Sibi,
> >>
> >> On 24/04/2020 05:01, Sibi Siddharthan via GitGitGadget wrote:
> >>> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >>>
> >>> This patch facilitates building git on Windows with CMake using MinGW
> >>>
> >>> NOTE: The funtions unsetenv and hstrerror are not checked in Windows
> >>> builds.
> >>> Reasons
> >>> NO_UNSETENV is not compatible with Windows builds.
> >>> lines 262-264 compat/mingw.h
> >>>
> >>> compat/mingw.h(line 25) provides a definition of hstrerror which
> >>> conflicts with the definition provided in
> >>> git-compat-util.h(lines 733-736).
> >>>
> >>> To use CMake on Windows with MinGW do this:
> >>> cmake `relative-path-to-srcdir` -G "MinGW Makefiles"
> >>>
> >>> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >>> ---
> >>>  CMakeLists.txt | 120 +++++++++++++++++++++++++++++++++++++++----------
> >>>  1 file changed, 97 insertions(+), 23 deletions(-)
> >>>
> >>> diff --git a/CMakeLists.txt b/CMakeLists.txt
> >>> index 29a23eb11f7..d9eb1060390 100644
> >>> [snip..]
> >>>  find_program(SH_EXE sh)
> >>> +if(NOT SH_EXE)
> >>> +     message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")
> >> Either the error message or the web page it points to need to coordinate
> >> on the 'sh interpreter' reference to help the script kiddies follow the
> >> thread. At the moment there is no 'interp..' on the gitforwindows web
> >> page. Would someone attempting to use cmake need to use the Download or
> >> the Contribute buttons, or some other route to acquire the missing SH_EXE?
> >>
> > On Windows, if you are using Git Bash, then you don't have a problem.
> > This message was for people trying to Git on Windows without a bash shell.
> >
> > I can rephrase the message saying
> > "On Windows go to https://gitforwindows.org/ and download the Git
> > installer which ships with a sh interpreter(bash)."
> >
> > Would you suggest something else?
>
> Filling the message out a little, I'm thinking of:
>
> "sh: shell interpreter was not found in your path, please install one.
> On Windows, you can get it as part of 'Git for Windows' install at
> https://gitforwindows.org/"
>
> The second 'install' could be dropped, but may be needed to fully
> qualify the instructions for some readers.
>
> The key feature I was checking was the clarity of the 'install' action,
> as opposed to the way sh is integrated within Git for Windows (which is
> a whole new topic of conversation for some users!)

Sure, We can incorporate this message.

> >
> >> (this is also a context line in the next patch)
> >>
> [snip..]
>
> --
> Philip

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-24 21:43     ` Junio C Hamano
  2020-04-25  4:09       ` Sibi Siddharthan
@ 2020-04-25 12:24       ` Johannes Schindelin
  2020-04-27 20:08         ` Jeff King
  1 sibling, 1 reply; 179+ messages in thread
From: Johannes Schindelin @ 2020-04-25 12:24 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Sibi Siddharthan, Sibi Siddharthan via GitGitGadget, git

Hi Junio,

On Fri, 24 Apr 2020, Junio C Hamano wrote:

> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:
>
> > The goal would be to maintain a CMake build for Git keeping it in sync
> > with the Makefile. The Makefile is not going to be replaced at all.
> > The CMake script for now only supports Linux and Windows. It does not
> > support BSD, Solaris and others, whereas the Makefile does support
> > them.
>
> So you are doing (1).  I already said that I feel that engineering
> burden to divert resources for CMake support would be unacceptably
> high.

Would your position change if Sibi was interested in maintaining this, and
helping with keeping CMake support in shape?

If you have a look at https://github.com/git-for-windows/git/pull/2580 and
at https://github.com/gitgitgadget/git/pull/614, you will probably get the
same impression as I: in contrast to earlier contributors who just talked
about adding CMake support, Sibi went ahead and did it, and then polished
the heck out of the patches, was very responsive and active.

I have a pretty good feeling about this.

> Whenever any of our developers need to add source files, Makefile
> configuration knobs that people can add to config.mak, etc., you are
> forcing them to figure out where in the CMakefile to add them or devise
> ways to allow builders who do not use config.mak (because they use
> CMake) to do similar tweaks.

To be honest, I don't think that that happens all that often, and quite
honestly, I think anybody who has had a look at the Makefile and at
CMakeLists.txt will have a pretty good idea where new files should go.

> Any patch that is acceptable to the current project would become
> unacceptable because they lack updates to CMake part, but I suspect
> we do not have enough people who are so much devoted to give a good
> review if updates to CMake part are added.  And it is unclear why it
> would be beneficial to slow our existing developers down by forcing
> them to become familiar with CMake.

When it comes to new Makefile knobs, I do agree that it would place an
unacceptable burden on contributors if we expected them to add the same
knob to CMakeLists.txt. But we already don't do that for our autoconf
support, so why would we expect it for CMake?

When it comes to adding new, and/or removing, files, I fail to see the
problem. It is dead easy to keep the Makefile and CMakeLists.txt in sync
when it comes to lists of files.

Another thing that strikes me as much more favorable this time as compared
to earlier attempts at adding CMake support is that we now have pretty
good automated builds that will definitely help with keeping CMake support
up to date.

So now that I have covered the "it's not all that bad to maintain this"
angle, let's cover the much more important part: "why would we even bother
with this?". And that's pretty easy to answer for me: first-class Visual
Studio support.

It is totally unacceptable to expect a contributor to download three
quarters of a gigabyte and then let the Git for Windows SDK occupy around
two full gigabytes on disk, just to get going. This is an upfront cost we
currently expect from any developer on Windows, whether someone familiar
with Visual Studio or more familiar with the command-line and GCC or not.

And guess what? Whenever I try to encourage a developer who uses Git and
who is pretty good with C to "just check out the Git for Windows SDK, run
`make vcxproj`, then load the generated Visual Studio solution and then
start developing", the odds are really, really, really high that that's
the last of it.

This is frustrating. And not only for me: Why should a contributor fight
so hard just to get started, when all they want to do is to tinker with
the code in order to see whether there is a chance that they can easily
make it do what they want?

For some time now, I have an automated build which auto-generates the
`vs/master` branch from Git for Windows' `master` branch, which has all of
this preconfigured. But it is too hard to find, and it is definitely too
hard to go from there to contributing the patches back to the Git project,
so I think that maybe one contributor used that venue in the last years.
One. Just one. That's very little return for the effort spent on getting
Visual Studio support back to functional ever after it was broken with
Visual Studio 2010's release. And it demonstrates a level of being
uninviting that I am simply uncomfortable with.

There's more.

If you are a developer who feels at home in IDEs, running `make` in the
command-line, and finding out about options in the Makefile and how to
specify them on the command-line, is just very awkward. CMake recognizes
this, and offers GUIs to configure the builds. So that's nice.

But there's more.

It would appear that in recent years, ARM64-based Windows laptops have
made great progress. They are affordable, they are fast, and they have
long battery life. If I could use and develop Git for Windows on one of
these beauties, I would.

But I can't, because the obstacles to building Git on ARM64 Windows are
just too high. The mingw-w64 version of GCC "does not really support"
that. We have literally no ARM64 support whatsoever from MSYS2's side,
i.e. no Bash, no Perl, no OpenSSH.

And then Sibi comes along and offers CMake support for Git.

CMake can target Visual Studio and clang. Both have pretty good support
for ARM64 Windows.

So while this is not a complete solution for the ARM64 Windows problem, it
is at least the most exciting opportunity in that regard that I have seen
in _years_.

Given all these benefits, I would like to believe that the cost is rather
minimal in comparison.

And that's coming from me, who is not a fan of CMake at all.

> So..., I am not just "still not convinced", but I am even more
> convinced that we do not want this series, after thinking about it
> longer.

Of course, I do hope that I have convinced you above that it might not
look all that bleak.

But even if I haven't, I would like to propose to run with Sibi's patches
and merge them first to `pu`, and then to `next`, and let that cook for a
while (I will merge them into Git for Windows early so that there is also
some support stream from that side).

I know you think that the maintenance cost is too high, but I think it
might be more than just manageable. And I don't think that the risk is too
high to give the patches a try, at least inside `next`, for a couple of
weeks or even months.

If it turns out that they _do_ add too much of a maintenance burden, big
deal: we just drop the patches, and that's that. No hard feelings, we gave
it a try, a scientific test, if you want, and we now have evidence to back
up your initial suspicion.

If it turns out that they _do_ add value _and_ are easy to maintain, then
that's good, right? And then, at your leisurely leisure, you can merge
them down to `master` and eventually into an official release.

What do you think? Doesn't that sound like a good plan?

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-25  4:09       ` Sibi Siddharthan
@ 2020-04-25 12:56         ` Philip Oakley
  2020-04-25 13:29           ` Johannes Schindelin
  0 siblings, 1 reply; 179+ messages in thread
From: Philip Oakley @ 2020-04-25 12:56 UTC (permalink / raw)
  To: Sibi Siddharthan, Junio C Hamano; +Cc: Sibi Siddharthan via GitGitGadget, git

Hi Sibi,

On 25/04/2020 05:09, Sibi Siddharthan wrote:
> On Sat, Apr 25, 2020 at 3:13 AM Junio C Hamano <gitster@pobox.com> wrote:
>> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:
>>
>>> The goal would be to maintain a CMake build for Git keeping it in sync
>>> with the Makefile.
>>> The Makefile is not going to be replaced at all. The CMake script for
>>> now only supports Linux and Windows.
>>> It does not support BSD, Solaris and others, whereas the Makefile does
>>> support them.
>> So you are doing (1).  I already said that I feel that engineering
>> burden to divert resources for CMake support would be unacceptably
>> high.
>>
>> Whenever any of our developers need to add source files, Makefile
>> configuration knobs that people can add to config.mak, etc., you are
>> forcing them to figure out where in the CMakefile to add them or
>> devise ways to allow builders who do not use config.mak (because
>> they use CMake) to do similar tweaks.
>>
> Adding source files to the CMakefile is going to just as long as
> adding it to the Makefile,
> anyone can figure this out and this is not going to take much time at all.
While figuring these things out isn't /hard/ it can be tedious and time
consuming for those who are not familiar with the particular tool set
(as evidenced, in my mind, by the poor dev support for Git for Windows
because of the need to understand two operating systems and their
awkward interactions) - those that are familiar and understand the/their
whole tool set are usually the x10 folks.
>
> As for the configuration knobs I agree that adding the same to CMake
> is going to a bit longer.
> But anyone who is hacking Git is going to do it with the Makefile or
> (if accepted)CMake script, but not both while hacking.
> So they will continue to make progress with the system they feel comfortable in.
> They will only run into an issue when they try for a PR. Currently the
> CMake script is only used for generating the visual studio solution.
> We can add a (continue-on-error) to vs-build job to make this process
> less of a hindrance.
> If people take the time to hack Git, figuring out how to do the
> configuration knobs in the CMake script is not going to that much take
> time
> compared to the time they spend making Git better.
>
>
>> Any patch that is acceptable to the current project would become
>> unacceptable because they lack updates to CMake part, but I suspect
>> we do not have enough people who are so much devoted to give a good
>> review if updates to CMake part are added.  And it is unclear why it
>> would be beneficial to slow our existing developers down by forcing
>> them to become familiar with CMake.
>>
>> So..., I am not just "still not convinced", but I am even more
>> convinced that we do not want this series, after thinking about it
>> longer.
>>
>> Thanks.
>>

Is there a middle way, given that IIUC there is most benefit on the
Windows side, that on the git.git side the Makefile could contain a
suitable comment directing those interested in CMake to the relevant
part of Git-for-Windows. Is there a part that could hold, and track, the
matching changes to the primary Makefile? 

Are there tools that track and compare CMake and Make variants, or at
least indicate any divergences to help separately maintaining the CMake
series?
> Thank You,
> Sibi Siddharthan
--
Philip

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-25 12:56         ` Philip Oakley
@ 2020-04-25 13:29           ` Johannes Schindelin
  2020-04-25 14:12             ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Johannes Schindelin @ 2020-04-25 13:29 UTC (permalink / raw)
  To: Philip Oakley
  Cc: Sibi Siddharthan, Junio C Hamano, Sibi Siddharthan via GitGitGadget, git

[-- Attachment #1: Type: text/plain, Size: 4706 bytes --]

Hi Philip,

On Sat, 25 Apr 2020, Philip Oakley wrote:

> On 25/04/2020 05:09, Sibi Siddharthan wrote:
> > On Sat, Apr 25, 2020 at 3:13 AM Junio C Hamano <gitster@pobox.com> wrote:
> >> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:
> >>
> >>> The goal would be to maintain a CMake build for Git keeping it in
> >>> sync with the Makefile. The Makefile is not going to be replaced at
> >>> all. The CMake script for now only supports Linux and Windows. It
> >>> does not support BSD, Solaris and others, whereas the Makefile does
> >>> support them.
> >>
> >> So you are doing (1).  I already said that I feel that engineering
> >> burden to divert resources for CMake support would be unacceptably
> >> high.
> >>
> >> Whenever any of our developers need to add source files, Makefile
> >> configuration knobs that people can add to config.mak, etc., you are
> >> forcing them to figure out where in the CMakefile to add them or
> >> devise ways to allow builders who do not use config.mak (because they
> >> use CMake) to do similar tweaks.
> >
> > Adding source files to the CMakefile is going to just as long as
> > adding it to the Makefile, anyone can figure this out and this is not
> > going to take much time at all.
>
> While figuring these things out isn't /hard/ it can be tedious and time
> consuming for those who are not familiar with the particular tool set
> (as evidenced, in my mind, by the poor dev support for Git for Windows
> because of the need to understand two operating systems and their
> awkward interactions) - those that are familiar and understand the/their
> whole tool set are usually the x10 folks.

Is it fair to compare the complexities of the differences between what Git
expects and what Windows provides to the difference to add files to
Makefile _and_ CMakeLists.txt?

When I add a file to the Makefile, what I do (and imagine that _everybody_
is doing in that circumstance) is to find an already-existing file that is
similar to the one I want to add. For example, if adding
`builtin/oakley--helper.c`, I will try to imitate
`builtin/submodule--helper.c`.

And when you do that, you don't really need to understand Makefiles or
CMake. You find the list(s) and add your file there, paying attention to
whether it is maintained alphabetically or append-only.

That is a _far_ cry from the hoops through which you have to jump to
understand, say, the important background details in order to start
working on `compat/mingw.c`.

At least from my point of view, there is very little analogy between the
subject under discussion and what you brought up.

Having said that...

> > As for the configuration knobs I agree that adding the same to CMake
> > is going to a bit longer.
> > But anyone who is hacking Git is going to do it with the Makefile or
> > (if accepted)CMake script, but not both while hacking.
> > So they will continue to make progress with the system they feel comfortable in.
> > They will only run into an issue when they try for a PR. Currently the
> > CMake script is only used for generating the visual studio solution.
> > We can add a (continue-on-error) to vs-build job to make this process
> > less of a hindrance.
> > If people take the time to hack Git, figuring out how to do the
> > configuration knobs in the CMake script is not going to that much take
> > time
> > compared to the time they spend making Git better.
> >
> >
> >> Any patch that is acceptable to the current project would become
> >> unacceptable because they lack updates to CMake part, but I suspect
> >> we do not have enough people who are so much devoted to give a good
> >> review if updates to CMake part are added.  And it is unclear why it
> >> would be beneficial to slow our existing developers down by forcing
> >> them to become familiar with CMake.
> >>
> >> So..., I am not just "still not convinced", but I am even more
> >> convinced that we do not want this series, after thinking about it
> >> longer.
> >>
> >> Thanks.
> >>
>
> Is there a middle way, given that IIUC there is most benefit on the
> Windows side, that on the git.git side the Makefile could contain a
> suitable comment directing those interested in CMake to the relevant
> part of Git-for-Windows. Is there a part that could hold, and track, the
> matching changes to the primary Makefile? 

We already use `GIT-VERSION-GEN` as the authoritative source for the Git
version, by parsing the line that contains.

It would look very similar, at least in my mind, to generate the list of
source/script files by parsing the `Makefile`.

Sibi, what do you think?

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux
  2020-04-24 17:05   ` Danh Doan
  2020-04-24 21:06     ` Sibi Siddharthan
@ 2020-04-25 13:34     ` Johannes Schindelin
  1 sibling, 0 replies; 179+ messages in thread
From: Johannes Schindelin @ 2020-04-25 13:34 UTC (permalink / raw)
  To: Danh Doan; +Cc: Sibi Siddharthan via GitGitGadget, git, Sibi Siddharthan

Hi Danh,

On Sat, 25 Apr 2020, Danh Doan wrote:

> Please excuse my hatred for CMake.

I share that distaste. However, is it really productive to bring that up
here?

You know what I also hate? I also hate vulnerabilities, and find it
_really_ taxing and tiring to work on them. Yet I frequently find myself
focusing on security bug fixes. Why? Because it's important.

In this instance, while there's no love lost on CMake from my side, I do
see tremendous benefits in having support for it in Git, in particular in
supporting Windows-based developers instead of treating them like
third-class citizens.

You had so many good and helpful comments and suggestions how to improve
the CMake patches, maybe we can have more of those?

Thank you,
Dscho

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-25 13:29           ` Johannes Schindelin
@ 2020-04-25 14:12             ` Sibi Siddharthan
  2020-04-25 14:28               ` Johannes Schindelin
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-04-25 14:12 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: Philip Oakley, Junio C Hamano, Sibi Siddharthan via GitGitGadget, git

Hi Philip and Dscho

On Sat, Apr 25, 2020 at 6:59 PM Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
>
> Hi Philip,
>
> On Sat, 25 Apr 2020, Philip Oakley wrote:
>
> > On 25/04/2020 05:09, Sibi Siddharthan wrote:
> > > On Sat, Apr 25, 2020 at 3:13 AM Junio C Hamano <gitster@pobox.com> wrote:
> > >> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:
> > >>
> > >>> The goal would be to maintain a CMake build for Git keeping it in
> > >>> sync with the Makefile. The Makefile is not going to be replaced at
> > >>> all. The CMake script for now only supports Linux and Windows. It
> > >>> does not support BSD, Solaris and others, whereas the Makefile does
> > >>> support them.
> > >>
> > >> So you are doing (1).  I already said that I feel that engineering
> > >> burden to divert resources for CMake support would be unacceptably
> > >> high.
> > >>
> > >> Whenever any of our developers need to add source files, Makefile
> > >> configuration knobs that people can add to config.mak, etc., you are
> > >> forcing them to figure out where in the CMakefile to add them or
> > >> devise ways to allow builders who do not use config.mak (because they
> > >> use CMake) to do similar tweaks.
> > >
> > > Adding source files to the CMakefile is going to just as long as
> > > adding it to the Makefile, anyone can figure this out and this is not
> > > going to take much time at all.
> >
> > While figuring these things out isn't /hard/ it can be tedious and time
> > consuming for those who are not familiar with the particular tool set
> > (as evidenced, in my mind, by the poor dev support for Git for Windows
> > because of the need to understand two operating systems and their
> > awkward interactions) - those that are familiar and understand the/their
> > whole tool set are usually the x10 folks.

One way of reducing the tediousness is to guide the developers in the
Contribuiting document
as to where to add the new source files for both the Makefile and CMake script.

>
> Is it fair to compare the complexities of the differences between what Git
> expects and what Windows provides to the difference to add files to
> Makefile _and_ CMakeLists.txt?
>
> When I add a file to the Makefile, what I do (and imagine that _everybody_
> is doing in that circumstance) is to find an already-existing file that is
> similar to the one I want to add. For example, if adding
> `builtin/oakley--helper.c`, I will try to imitate
> `builtin/submodule--helper.c`.
>
> And when you do that, you don't really need to understand Makefiles or
> CMake. You find the list(s) and add your file there, paying attention to
> whether it is maintained alphabetically or append-only.
>
> That is a _far_ cry from the hoops through which you have to jump to
> understand, say, the important background details in order to start
> working on `compat/mingw.c`.
>
> At least from my point of view, there is very little analogy between the
> subject under discussion and what you brought up.
>
> Having said that...
>
> > > As for the configuration knobs I agree that adding the same to CMake
> > > is going to a bit longer.
> > > But anyone who is hacking Git is going to do it with the Makefile or
> > > (if accepted)CMake script, but not both while hacking.
> > > So they will continue to make progress with the system they feel comfortable in.
> > > They will only run into an issue when they try for a PR. Currently the
> > > CMake script is only used for generating the visual studio solution.
> > > We can add a (continue-on-error) to vs-build job to make this process
> > > less of a hindrance.
> > > If people take the time to hack Git, figuring out how to do the
> > > configuration knobs in the CMake script is not going to that much take
> > > time
> > > compared to the time they spend making Git better.
> > >
> > >
> > >> Any patch that is acceptable to the current project would become
> > >> unacceptable because they lack updates to CMake part, but I suspect
> > >> we do not have enough people who are so much devoted to give a good
> > >> review if updates to CMake part are added.  And it is unclear why it
> > >> would be beneficial to slow our existing developers down by forcing
> > >> them to become familiar with CMake.
> > >>
> > >> So..., I am not just "still not convinced", but I am even more
> > >> convinced that we do not want this series, after thinking about it
> > >> longer.
> > >>
> > >> Thanks.
> > >>
> >
> > Is there a middle way, given that IIUC there is most benefit on the
> > Windows side, that on the git.git side the Makefile could contain a
> > suitable comment directing those interested in CMake to the relevant
> > part of Git-for-Windows. Is there a part that could hold, and track, the
> > matching changes to the primary Makefile?
>
> We already use `GIT-VERSION-GEN` as the authoritative source for the Git
> version, by parsing the line that contains.
>
> It would look very similar, at least in my mind, to generate the list of
> source/script files by parsing the `Makefile`.
>
> Sibi, what do you think?
>

One way of doing it is to track if the Makefile is changed in a
commit, run a hook
to see if it contains any new OBJs and match it with the CMake script.
But this is too much work, in my opinion.

For the scripts, things are a bit complicated, suppose people use sed
and grep to
do their logic in the Makefile, we add "sed" and "grep" dependencies
to the build process
This is not a bad thing, but the same logic can be implemented in
CMake without "grep" and "sed".
Also, the Makefile script generation logics are path relative, which
should be modified in CMake
to have arbitrary build and source directories.

The better option is to guide developers how to add their build
changes to CMake also. (This is not hard at all)

> Ciao,
> Dscho

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-25 14:12             ` Sibi Siddharthan
@ 2020-04-25 14:28               ` Johannes Schindelin
  2020-04-25 14:38                 ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Johannes Schindelin @ 2020-04-25 14:28 UTC (permalink / raw)
  To: Sibi Siddharthan
  Cc: Philip Oakley, Junio C Hamano, Sibi Siddharthan via GitGitGadget, git

Hi Sibi,

On Sat, 25 Apr 2020, Sibi Siddharthan wrote:

> On Sat, Apr 25, 2020 at 6:59 PM Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
>
> >
> > We already use `GIT-VERSION-GEN` as the authoritative source for the Git
> > version, by parsing the line that contains.
> >
> > It would look very similar, at least in my mind, to generate the list of
> > source/script files by parsing the `Makefile`.
> >
> > Sibi, what do you think?
>
> One way of doing it is to track if the Makefile is changed in a commit,
> run a hook to see if it contains any new OBJs and match it with the
> CMake script. But this is too much work, in my opinion.

Oh, sorry, I should have clarified: We already parse the
`DEF_VER=v2.26.GIT` line in `GIT-VERSION-GEN` to determine the Git
version.

We should be able to do the very exact same thing to parse the `SCRIPT_SH`
lines like

	SCRIPT_SH += git-bisect.sh

in the `Makefile` to accumulate the list of shell scripts, and likewise
the list of object files could be accumulated by parsing the `LIB_OBJS`
lines like

	LIB_OBJS += abspath.o

(We would of course need to substitute the `.o` with `.c`, but that should
be easy.)

That way, nobody will ever need to touch the CMakeLists.txt file when they
add a new source file to libgit.a.

I was not trying to auto-detect what `sed` invocation changed. Those
changes _will_ need manual forward-porting to CMakeLists.txt. Thankfully,
those events are really rare.

Makes sense?

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-25 14:28               ` Johannes Schindelin
@ 2020-04-25 14:38                 ` Sibi Siddharthan
  2020-04-25 14:49                   ` Johannes Schindelin
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-04-25 14:38 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: Philip Oakley, Junio C Hamano, Sibi Siddharthan via GitGitGadget, git

Hi Dscho

On Sat, Apr 25, 2020 at 7:58 PM Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
>
> Hi Sibi,
>
> On Sat, 25 Apr 2020, Sibi Siddharthan wrote:
>
> > On Sat, Apr 25, 2020 at 6:59 PM Johannes Schindelin
> > <Johannes.Schindelin@gmx.de> wrote:
> >
> > >
> > > We already use `GIT-VERSION-GEN` as the authoritative source for the Git
> > > version, by parsing the line that contains.
> > >
> > > It would look very similar, at least in my mind, to generate the list of
> > > source/script files by parsing the `Makefile`.
> > >
> > > Sibi, what do you think?
> >
> > One way of doing it is to track if the Makefile is changed in a commit,
> > run a hook to see if it contains any new OBJs and match it with the
> > CMake script. But this is too much work, in my opinion.
>
> Oh, sorry, I should have clarified: We already parse the
> `DEF_VER=v2.26.GIT` line in `GIT-VERSION-GEN` to determine the Git
> version.
>
> We should be able to do the very exact same thing to parse the `SCRIPT_SH`
> lines like
>
>         SCRIPT_SH += git-bisect.sh
>
> in the `Makefile` to accumulate the list of shell scripts, and likewise
> the list of object files could be accumulated by parsing the `LIB_OBJS`
> lines like
>
>         LIB_OBJS += abspath.o
>
> (We would of course need to substitute the `.o` with `.c`, but that should
> be easy.)
>
> That way, nobody will ever need to touch the CMakeLists.txt file when they
> add a new source file to libgit.a.
>

I understand what you are trying to say, this is not impossible to do but doing
so will make the CMake script dependent on the Makefile for the sources.
I am not fan of this approach.

We should write a separate script (say python) to match each of the sources in
the Makefile and the CMake file automatically whenever the changes detected.
This excludes the platform specific/compatibility stuff in config.mak.uname.

> I was not trying to auto-detect what `sed` invocation changed. Those
> changes _will_ need manual forward-porting to CMakeLists.txt. Thankfully,
> those events are really rare.
>
> Makes sense?
>
> Ciao,
> Dscho

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-25 14:38                 ` Sibi Siddharthan
@ 2020-04-25 14:49                   ` Johannes Schindelin
  2020-04-25 14:57                     ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Johannes Schindelin @ 2020-04-25 14:49 UTC (permalink / raw)
  To: Sibi Siddharthan
  Cc: Philip Oakley, Junio C Hamano, Sibi Siddharthan via GitGitGadget, git

Hi Sibi,

On Sat, 25 Apr 2020, Sibi Siddharthan wrote:

> On Sat, Apr 25, 2020 at 7:58 PM Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
> >
> > On Sat, 25 Apr 2020, Sibi Siddharthan wrote:
> >
> > > On Sat, Apr 25, 2020 at 6:59 PM Johannes Schindelin
> > > <Johannes.Schindelin@gmx.de> wrote:
> > >
> > > >
> > > > We already use `GIT-VERSION-GEN` as the authoritative source for the Git
> > > > version, by parsing the line that contains.
> > > >
> > > > It would look very similar, at least in my mind, to generate the list of
> > > > source/script files by parsing the `Makefile`.
> > > >
> > > > Sibi, what do you think?
> > >
> > > One way of doing it is to track if the Makefile is changed in a commit,
> > > run a hook to see if it contains any new OBJs and match it with the
> > > CMake script. But this is too much work, in my opinion.
> >
> > Oh, sorry, I should have clarified: We already parse the
> > `DEF_VER=v2.26.GIT` line in `GIT-VERSION-GEN` to determine the Git
> > version.
> >
> > We should be able to do the very exact same thing to parse the `SCRIPT_SH`
> > lines like
> >
> >         SCRIPT_SH += git-bisect.sh
> >
> > in the `Makefile` to accumulate the list of shell scripts, and likewise
> > the list of object files could be accumulated by parsing the `LIB_OBJS`
> > lines like
> >
> >         LIB_OBJS += abspath.o
> >
> > (We would of course need to substitute the `.o` with `.c`, but that should
> > be easy.)
> >
> > That way, nobody will ever need to touch the CMakeLists.txt file when they
> > add a new source file to libgit.a.
> >
>
> I understand what you are trying to say, this is not impossible to do but doing
> so will make the CMake script dependent on the Makefile for the sources.
> I am not fan of this approach.
>
> We should write a separate script (say python) to match each of the sources in
> the Makefile and the CMake file automatically whenever the changes detected.
> This excludes the platform specific/compatibility stuff in config.mak.uname.

Hmm. That is an approach that _I_ don't like. Why duplicate the
information when you don't have to?

I don't see any issue with keeping CMakeLists.txt dependent on Makefile.
We could of course extract the lists into a separate file that is sourced
both from the Makefile and from CMakeLists.txt, but that would actually
not reflect that the Makefile _is_ authoritative. CMakeLists.txt will
never be the authoritative source.

Ciao,
Dscho

>
> > I was not trying to auto-detect what `sed` invocation changed. Those
> > changes _will_ need manual forward-porting to CMakeLists.txt. Thankfully,
> > those events are really rare.
> >
> > Makes sense?
> >
> > Ciao,
> > Dscho
>
> Thank You,
> Sibi Siddharthan
>
>

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-25 14:49                   ` Johannes Schindelin
@ 2020-04-25 14:57                     ` Sibi Siddharthan
  2020-04-26  0:41                       ` Danh Doan
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-04-25 14:57 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: Philip Oakley, Junio C Hamano, Sibi Siddharthan via GitGitGadget, git

Hi Dscho,

I guess this is a pain point having to manage two separate build systems.
I will modify CMake script to get its sources from the Makefile.

Thank You,
Sibi Siddharthan

On Sat, Apr 25, 2020 at 8:19 PM Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
>
> Hi Sibi,
>
> On Sat, 25 Apr 2020, Sibi Siddharthan wrote:
>
> > On Sat, Apr 25, 2020 at 7:58 PM Johannes Schindelin
> > <Johannes.Schindelin@gmx.de> wrote:
> > >
> > > On Sat, 25 Apr 2020, Sibi Siddharthan wrote:
> > >
> > > > On Sat, Apr 25, 2020 at 6:59 PM Johannes Schindelin
> > > > <Johannes.Schindelin@gmx.de> wrote:
> > > >
> > > > >
> > > > > We already use `GIT-VERSION-GEN` as the authoritative source for the Git
> > > > > version, by parsing the line that contains.
> > > > >
> > > > > It would look very similar, at least in my mind, to generate the list of
> > > > > source/script files by parsing the `Makefile`.
> > > > >
> > > > > Sibi, what do you think?
> > > >
> > > > One way of doing it is to track if the Makefile is changed in a commit,
> > > > run a hook to see if it contains any new OBJs and match it with the
> > > > CMake script. But this is too much work, in my opinion.
> > >
> > > Oh, sorry, I should have clarified: We already parse the
> > > `DEF_VER=v2.26.GIT` line in `GIT-VERSION-GEN` to determine the Git
> > > version.
> > >
> > > We should be able to do the very exact same thing to parse the `SCRIPT_SH`
> > > lines like
> > >
> > >         SCRIPT_SH += git-bisect.sh
> > >
> > > in the `Makefile` to accumulate the list of shell scripts, and likewise
> > > the list of object files could be accumulated by parsing the `LIB_OBJS`
> > > lines like
> > >
> > >         LIB_OBJS += abspath.o
> > >
> > > (We would of course need to substitute the `.o` with `.c`, but that should
> > > be easy.)
> > >
> > > That way, nobody will ever need to touch the CMakeLists.txt file when they
> > > add a new source file to libgit.a.
> > >
> >
> > I understand what you are trying to say, this is not impossible to do but doing
> > so will make the CMake script dependent on the Makefile for the sources.
> > I am not fan of this approach.
> >
> > We should write a separate script (say python) to match each of the sources in
> > the Makefile and the CMake file automatically whenever the changes detected.
> > This excludes the platform specific/compatibility stuff in config.mak.uname.
>
> Hmm. That is an approach that _I_ don't like. Why duplicate the
> information when you don't have to?
>
> I don't see any issue with keeping CMakeLists.txt dependent on Makefile.
> We could of course extract the lists into a separate file that is sourced
> both from the Makefile and from CMakeLists.txt, but that would actually
> not reflect that the Makefile _is_ authoritative. CMakeLists.txt will
> never be the authoritative source.
>
> Ciao,
> Dscho
>
> >
> > > I was not trying to auto-detect what `sed` invocation changed. Those
> > > changes _will_ need manual forward-porting to CMakeLists.txt. Thankfully,
> > > those events are really rare.
> > >
> > > Makes sense?
> > >
> > > Ciao,
> > > Dscho
> >
> > Thank You,
> > Sibi Siddharthan
> >
> >

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux
  2020-04-24  4:01 ` [PATCH 1/8] Introduce CMake support for configuring Git on Linux Sibi Siddharthan via GitGitGadget
  2020-04-24 17:05   ` Danh Doan
@ 2020-04-25 17:07   ` brian m. carlson
  2020-04-25 17:36     ` Randall S. Becker
  2020-04-25 18:11     ` Sibi Siddharthan
  1 sibling, 2 replies; 179+ messages in thread
From: brian m. carlson @ 2020-04-25 17:07 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

[-- Attachment #1: Type: text/plain, Size: 910 bytes --]

On 2020-04-24 at 04:01:30, Sibi Siddharthan via GitGitGadget wrote:
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> new file mode 100644
> index 00000000000..73703bd321f
> --- /dev/null
> +++ b/CMakeLists.txt
> @@ -0,0 +1,528 @@
> +#
> +#	Copyright (c) 2020 Sibi Siddharthan
> +#
> +
> +cmake_minimum_required(VERSION 3.14)

I don't plan a full review of this series, but I wanted to point out
that this version is newer than what's in Debian 10, so this isn't
practically buildable on many systems.

If we wanted to add CMake support, even just for Linux and Windows, I'd
want to see it functional on the latest versions of the major distros,
at the very least.  Ideally it would function using the system packages
on all security-supported versions of the major distros, since our
Makefile does right now.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

^ permalink raw reply	[flat|nested] 179+ messages in thread

* RE: [PATCH 1/8] Introduce CMake support for configuring Git on Linux
  2020-04-25 17:07   ` brian m. carlson
@ 2020-04-25 17:36     ` Randall S. Becker
  2020-04-25 18:01       ` Philip Oakley
  2020-04-25 18:11     ` Sibi Siddharthan
  1 sibling, 1 reply; 179+ messages in thread
From: Randall S. Becker @ 2020-04-25 17:36 UTC (permalink / raw)
  To: 'brian m. carlson', 'Sibi Siddharthan via GitGitGadget'
  Cc: git, 'Sibi Siddharthan'

On April 25, 2020 1:08 PM, brian m. carlson Wrote:
> On 2020-04-24 at 04:01:30, Sibi Siddharthan via GitGitGadget wrote:
> > diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644
> > index 00000000000..73703bd321f
> > --- /dev/null
> > +++ b/CMakeLists.txt
> > @@ -0,0 +1,528 @@
> > +#
> > +#	Copyright (c) 2020 Sibi Siddharthan
> > +#
> > +
> > +cmake_minimum_required(VERSION 3.14)
> 
> I don't plan a full review of this series, but I wanted to point out that this
> version is newer than what's in Debian 10, so this isn't practically buildable on
> many systems.

I am unsure about this, but are non-git-foundation copyrights consistent GPL v2? Just asking for curiosity.


^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux
  2020-04-25 17:36     ` Randall S. Becker
@ 2020-04-25 18:01       ` Philip Oakley
  0 siblings, 0 replies; 179+ messages in thread
From: Philip Oakley @ 2020-04-25 18:01 UTC (permalink / raw)
  To: Randall S. Becker, 'brian m. carlson',
	'Sibi Siddharthan via GitGitGadget'
  Cc: git, 'Sibi Siddharthan'

On 25/04/2020 18:36, Randall S. Becker wrote:
> On April 25, 2020 1:08 PM, brian m. carlson Wrote:
>> On 2020-04-24 at 04:01:30, Sibi Siddharthan via GitGitGadget wrote:
>>> diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644
>>> index 00000000000..73703bd321f
>>> --- /dev/null
>>> +++ b/CMakeLists.txt
>>> @@ -0,0 +1,528 @@
>>> +#
>>> +#	Copyright (c) 2020 Sibi Siddharthan
>>> +#
>>> +
>>> +cmake_minimum_required(VERSION 3.14)
>> I don't plan a full review of this series, but I wanted to point out that this
>> version is newer than what's in Debian 10, so this isn't practically buildable on
>> many systems.
> I am unsure about this, but are non-git-foundation copyrights consistent GPL v2? Just asking for curiosity.
>
grep'ing for copyright gave plenty of examples, so it looks OK. Someone
had to author it.

Philip


^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 1/8] Introduce CMake support for configuring Git on Linux
  2020-04-25 17:07   ` brian m. carlson
  2020-04-25 17:36     ` Randall S. Becker
@ 2020-04-25 18:11     ` Sibi Siddharthan
  1 sibling, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-04-25 18:11 UTC (permalink / raw)
  To: brian m. carlson, Sibi Siddharthan via GitGitGadget, git,
	Sibi Siddharthan

Hi Brian,

On Sat, Apr 25, 2020 at 10:37 PM brian m. carlson
<sandals@crustytoothpaste.net> wrote:
>
> On 2020-04-24 at 04:01:30, Sibi Siddharthan via GitGitGadget wrote:
> > diff --git a/CMakeLists.txt b/CMakeLists.txt
> > new file mode 100644
> > index 00000000000..73703bd321f
> > --- /dev/null
> > +++ b/CMakeLists.txt
> > @@ -0,0 +1,528 @@
> > +#
> > +#    Copyright (c) 2020 Sibi Siddharthan
> > +#
> > +
> > +cmake_minimum_required(VERSION 3.14)
>
> I don't plan a full review of this series, but I wanted to point out
> that this version is newer than what's in Debian 10, so this isn't
> practically buildable on many systems.
>
> If we wanted to add CMake support, even just for Linux and Windows, I'd
> want to see it functional on the latest versions of the major distros,
> at the very least.  Ideally it would function using the system packages
> on all security-supported versions of the major distros, since our
> Makefile does right now.

I know that version 3.14 is asking a lot, but without this version the
script would
have a lot platform specific stuff related to how hard links are created.
Windows -> mklink
Other systems -> ln

This is why this version was chosen.
I would also like to say that this CMake script is not a replacement for
the Makefile.

> --
> brian m. carlson: Houston, Texas, US
> OpenPGP: https://keybase.io/bk2204

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-25 14:57                     ` Sibi Siddharthan
@ 2020-04-26  0:41                       ` Danh Doan
  2020-04-26  4:30                         ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Danh Doan @ 2020-04-26  0:41 UTC (permalink / raw)
  To: Sibi Siddharthan
  Cc: Johannes Schindelin, Philip Oakley, Junio C Hamano,
	Sibi Siddharthan via GitGitGadget, git

On 2020-04-25 20:27:37+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:
> Hi Dscho,
> 
> I guess this is a pain point having to manage two separate build systems.
> I will modify CMake script to get its sources from the Makefile.
> 
> > > I understand what you are trying to say, this is not impossible to do but doing
> > > so will make the CMake script dependent on the Makefile for the sources.
> > > I am not fan of this approach.
> > >
> > > We should write a separate script (say python) to match each of the sources in
> > > the Makefile and the CMake file automatically whenever the changes detected.
> > > This excludes the platform specific/compatibility stuff in config.mak.uname.
> >
> > Hmm. That is an approach that _I_ don't like. Why duplicate the
> > information when you don't have to?
> >
> > I don't see any issue with keeping CMakeLists.txt dependent on Makefile.
> > We could of course extract the lists into a separate file that is sourced
> > both from the Makefile and from CMakeLists.txt, but that would actually
> > not reflect that the Makefile _is_ authoritative. CMakeLists.txt will
> > never be the authoritative source.

(This email is hard to be replied, because Sibi do top-posting.
And, I want to quote both on this).

I'm still not a fan of CMake despite that I need to write it at
previous $DAYJOBS.

I would like to keep Makefile as authoritative source of information,
and to convince other developers, we need to keep Makefile as
authoritative source of information. Let's say this way, I dislike it,
but if it works for you, that's fine, just don't add more burden for
existing people.

Remember that with CMake support, we will never able to use CMake
generated build in-tree because we have an existing Makefile in-tree
(not a problem since it's expected to be built out-of-tree if CMake is used),
but please don't complain if it people accidentally break it.
./configure doesn't work correctly with `--without-<pkg>` and people
seems to not interest in my series to respect it, for example.

When writing this, I intended to write something to support
out-of-tree build with current Makefile. Hopefully, it won't be rocket
science.

Last but not least, (this point was discussed with Sibi off-list)
about our test infrastructure, when we add a new test,
we can simply run:

	make test

Makefile will pick it up, and run all tests just fine.

CMake's glob only works at CMake configuration time.
If there's a new test after CMake was run, and nothing changed in
CMakeList.txt. The list generated by CMake will still be the same,
ctest wouldn't know that there's a new test.
People need to manually run cmake again to pick it up (or as Sibi
told me off-list, that developer is question can run by hand

	path/to/git/source/t/t-9999-true.sh

That's not a problem for the person write that test,
but it'll be problem for other people, who will fetch the new source
to their own repo, and naively run msbuild and ctest.

It's analogue to this habit in git (me in my previous $DAYJOBS)

	yes | git add -p

Anyway, get back to the solution (should this series be accepted),
I think it'll work if we can split:

	SOURCE_FILES += cmake.c

into a source-list.mak

Then, cmake will do some magic with `configure_file` or something
similar, IIRC, it's a reduced functionallity of sed.

-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-26  0:41                       ` Danh Doan
@ 2020-04-26  4:30                         ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-04-26  4:30 UTC (permalink / raw)
  To: Danh Doan
  Cc: Johannes Schindelin, Philip Oakley, Junio C Hamano,
	Sibi Siddharthan via GitGitGadget, git

On Sun, Apr 26, 2020 at 6:11 AM Danh Doan <congdanhqx@gmail.com> wrote:
>
> On 2020-04-25 20:27:37+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:
> > Hi Dscho,
> >
> > I guess this is a pain point having to manage two separate build systems.
> > I will modify CMake script to get its sources from the Makefile.
> >
> > > > I understand what you are trying to say, this is not impossible to do but doing
> > > > so will make the CMake script dependent on the Makefile for the sources.
> > > > I am not fan of this approach.
> > > >
> > > > We should write a separate script (say python) to match each of the sources in
> > > > the Makefile and the CMake file automatically whenever the changes detected.
> > > > This excludes the platform specific/compatibility stuff in config.mak.uname.
> > >
> > > Hmm. That is an approach that _I_ don't like. Why duplicate the
> > > information when you don't have to?
> > >
> > > I don't see any issue with keeping CMakeLists.txt dependent on Makefile.
> > > We could of course extract the lists into a separate file that is sourced
> > > both from the Makefile and from CMakeLists.txt, but that would actually
> > > not reflect that the Makefile _is_ authoritative. CMakeLists.txt will
> > > never be the authoritative source.
>
> (This email is hard to be replied, because Sibi do top-posting.
> And, I want to quote both on this).
>
> I'm still not a fan of CMake despite that I need to write it at
> previous $DAYJOBS.
>
> I would like to keep Makefile as authoritative source of information,
> and to convince other developers, we need to keep Makefile as
> authoritative source of information. Let's say this way, I dislike it,
> but if it works for you, that's fine, just don't add more burden for
> existing people.
>
> Remember that with CMake support, we will never able to use CMake
> generated build in-tree because we have an existing Makefile in-tree
> (not a problem since it's expected to be built out-of-tree if CMake is used),
> but please don't complain if it people accidentally break it.
> ./configure doesn't work correctly with `--without-<pkg>` and people
> seems to not interest in my series to respect it, for example.
>

To prevent the CMake script from overwriting the current Makefile,
I can add a check at the beginning to stop the configure if the build
is done in source.

> When writing this, I intended to write something to support
> out-of-tree build with current Makefile. Hopefully, it won't be rocket
> science.
>
> Last but not least, (this point was discussed with Sibi off-list)
> about our test infrastructure, when we add a new test,
> we can simply run:
>
>         make test
>
> Makefile will pick it up, and run all tests just fine.
>
> CMake's glob only works at CMake configuration time.
> If there's a new test after CMake was run, and nothing changed in
> CMakeList.txt. The list generated by CMake will still be the same,
> ctest wouldn't know that there's a new test.
> People need to manually run cmake again to pick it up (or as Sibi
> told me off-list, that developer is question can run by hand
>
>         path/to/git/source/t/t-9999-true.sh
>
> That's not a problem for the person write that test,
> but it'll be problem for other people, who will fetch the new source
> to their own repo, and naively run msbuild and ctest.
>
> It's analogue to this habit in git (me in my previous $DAYJOBS)
>
>         yes | git add -p
>
> Anyway, get back to the solution (should this series be accepted),
> I think it'll work if we can split:
>
>         SOURCE_FILES += cmake.c
>
> into a source-list.mak
>
> Then, cmake will do some magic with `configure_file` or something
> similar, IIRC, it's a reduced functionallity of sed.
>

Me and Dscho discussed that we will use the Makefile for getting the
source list.
So we will basically parse the Makefile for the requires sourced to be
used( in CMake itself).
So devs can just maintain the Makefile alone.
This approach works for
SCRIPT_SH
SCRIPT_LIB
SCRIPT_PERL
SCRIPT_PYTHON
TEST_BUILTINS_OBJS
LIB_OBJS
BUILTIN_OBJS
XDIFF_OBJS
VCSSVN_OBJS

PROGRAM_OBJS do not work, as a few of them link with curl and expat.
As git-bugreport was added recently to the next branch.
This should not be major issue I guess.

> --
> Danh

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-25 12:24       ` Johannes Schindelin
@ 2020-04-27 20:08         ` Jeff King
  2020-04-27 20:12           ` Jeff King
  2020-04-27 21:17           ` Junio C Hamano
  0 siblings, 2 replies; 179+ messages in thread
From: Jeff King @ 2020-04-27 20:08 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: Junio C Hamano, Sibi Siddharthan, Sibi Siddharthan via GitGitGadget, git

On Sat, Apr 25, 2020 at 02:24:34PM +0200, Johannes Schindelin wrote:

> > > The goal would be to maintain a CMake build for Git keeping it in sync
> > > with the Makefile. The Makefile is not going to be replaced at all.
> > > The CMake script for now only supports Linux and Windows. It does not
> > > support BSD, Solaris and others, whereas the Makefile does support
> > > them.
> >
> > So you are doing (1).  I already said that I feel that engineering
> > burden to divert resources for CMake support would be unacceptably
> > high.
> 
> Would your position change if Sibi was interested in maintaining this, and
> helping with keeping CMake support in shape?

I have mixed feelings.

Imagine we say that the Makefile is the official build mechanism and
that cmake support is a second-class citizen. I.e., somebody is willing
to be the maintainer of that feature and port over changes for people
who want to use cmake. That removes the issue of developers spending
time dealing with a new make tool that they don't care about (and might
not even have, or might not be available for their platform).

That's basically what we do with autoconf. But I haven't been all that
pleased with the results. The autoconf code is frequently out-of-date or
just plain wrong (e.g., the recent inet_ntop issues) and a frequent
response to questions on the list is "have you tried just building
without autoconf". I'm not sure if we are doing users a disservice to
pretend that we have maintained autoconf support.

On the other hand, if it is helping people avoid turning Makefile knobs
manually, we'd never hear complaints if it Just Works for some folks. So
maybe autoconf is a necessary evil (evil from the perspective of
developers, not users) that does pull its own weight.

Getting back to cmake: I can plausibly believe it's in the same boat. I
don't have any interest in Visual Studio, but I can believe that it's an
important convenience for some people / platforms, and that cmake is the
best way to get there.

So if you are proposing to declare this as an experiment which will be
maintained independently, and we can see how often it becomes a problem
and how many people it helps, that makes more sense to me.

Skimming the patches, I do wish I didn't see so much repetition with the
existing Makefile. I know that some of the logic will just have to be
ported manually, but surely we could be pulling things like the list of
libgit_SOURCES from the Makefile as the single source of truth?

> > Any patch that is acceptable to the current project would become
> > unacceptable because they lack updates to CMake part, but I suspect
> > we do not have enough people who are so much devoted to give a good
> > review if updates to CMake part are added.  And it is unclear why it
> > would be beneficial to slow our existing developers down by forcing
> > them to become familiar with CMake.
> 
> When it comes to new Makefile knobs, I do agree that it would place an
> unacceptable burden on contributors if we expected them to add the same
> knob to CMakeLists.txt. But we already don't do that for our autoconf
> support, so why would we expect it for CMake?

My concern here would be that the various knobs and behaviors are going
to fall out of date, and nobody will notice. Because there aren't many
cmake users, and because some of the logic is subtle (e.g., if it picked
the wrong sha1-implementation default, who would notice?). But again, if
we're willing to say "cmake support is an experiment" and let the
maintenance burden fall to people who are interested, then we can at
least have some data on how it works in practice.

> When it comes to adding new, and/or removing, files, I fail to see the
> problem. It is dead easy to keep the Makefile and CMakeLists.txt in sync
> when it comes to lists of files.

It's _conceptually_ dead easy, but now there's a new tool and a new step
people have to know about. Automated builds let you know when there's a
problem, but somebody still has to fix it. I'd hope that basic stuff
like file lists could be written so that there's no need to fix at all:
they'd just pull from the same source as the Makefile.

> But even if I haven't, I would like to propose to run with Sibi's patches
> and merge them first to `pu`, and then to `next`, and let that cook for a
> while (I will merge them into Git for Windows early so that there is also
> some support stream from that side).
> 
> I know you think that the maintenance cost is too high, but I think it
> might be more than just manageable. And I don't think that the risk is too
> high to give the patches a try, at least inside `next`, for a couple of
> weeks or even months.
> 
> If it turns out that they _do_ add too much of a maintenance burden, big
> deal: we just drop the patches, and that's that. No hard feelings, we gave
> it a try, a scientific test, if you want, and we now have evidence to back
> up your initial suspicion.
> 
> If it turns out that they _do_ add value _and_ are easy to maintain, then
> that's good, right? And then, at your leisurely leisure, you can merge
> them down to `master` and eventually into an official release.
> 
> What do you think? Doesn't that sound like a good plan?

I think what I'm suggesting is not all that different from this, except
that I'd suspect "next" would not get enough exposure. So in my mind
merging to master is not so much "hooray, we now have visual studio
support" but rather the first step in getting data. But we'd have to be
very clear about how the project regards the cmake support: it's there
for now, you're encouraged to play with it, but don't be upset if it
needs some coaxing to behave like the normal Makefile or if it goes away
in the future.

-Peff

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-27 20:08         ` Jeff King
@ 2020-04-27 20:12           ` Jeff King
  2020-04-28 13:52             ` Danh Doan
  2020-04-27 21:17           ` Junio C Hamano
  1 sibling, 1 reply; 179+ messages in thread
From: Jeff King @ 2020-04-27 20:12 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: Junio C Hamano, Sibi Siddharthan, Sibi Siddharthan via GitGitGadget, git

On Mon, Apr 27, 2020 at 04:08:52PM -0400, Jeff King wrote:

> Skimming the patches, I do wish I didn't see so much repetition with the
> existing Makefile. I know that some of the logic will just have to be
> ported manually, but surely we could be pulling things like the list of
> libgit_SOURCES from the Makefile as the single source of truth?

Thinking I surely couldn't be the only one to think of this, I dug
further into some of the sub-threads. And indeed, it seems like you are
on the same page here.

IMHO it is worth making the cmake file depend as much as possible on
what's in the Makefile.

-Peff

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-27 20:08         ` Jeff King
  2020-04-27 20:12           ` Jeff King
@ 2020-04-27 21:17           ` Junio C Hamano
  2020-04-27 21:56             ` Michal Suchánek
  2020-04-27 22:09             ` Jeff King
  1 sibling, 2 replies; 179+ messages in thread
From: Junio C Hamano @ 2020-04-27 21:17 UTC (permalink / raw)
  To: Jeff King
  Cc: Johannes Schindelin, Sibi Siddharthan,
	Sibi Siddharthan via GitGitGadget, git

Jeff King <peff@peff.net> writes:

> I think what I'm suggesting is not all that different from this, except
> that I'd suspect "next" would not get enough exposure. So in my mind
> merging to master is not so much "hooray, we now have visual studio
> support" but rather the first step in getting data. But we'd have to be
> very clear about how the project regards the cmake support: it's there
> for now, you're encouraged to play with it, but don't be upset if it
> needs some coaxing to behave like the normal Makefile or if it goes away
> in the future.

I think you said almost everything I would have said.  

If we were to adopt it as an experiment, hoping to gain exposure,
nothing above 'master' (or tagged releases) won't work.  And once a
thing is in 'master', users will ignore the "this is merely an
experiment" warning and expect it to be fully functional and usable.

Given the observation in the thread that it would take a fairly
recent version to benefit platform-agnostic usability features, I
did not get an impression that it is ready to be anywhere near that,
not even ready for 'next'.  It is *not* like "Sibi's patches were
bad but they can become ready with further polishing".  The
impression I got was that the large part of why it is not ready is
because it needs time for larger set of distros to adopt more recent
versions of cmake.

And I somehow think that rewriting Sibi's patches to lose the parts
that takes advantage of more recent cmake (abstracting "mklink" vs
"ln" out was mentioned as an example---there may be a lot more) is
going in a wrong direction.  The world will eventually catch up, and
Git does not need cmake immediately.  Using the more recent features
while waiting for the right time would be a more sensible approach
than aiming for an outdated version.

So, perhaps we'll try again in 3 years, perhaps, to consider if it
makes sense to add the cmake support to _my_ tree.

But in the meantime, those who are interested in building Git with
cmake do not have to wait, doing nothing, I would imagine.  I wonder
if they can work on a separate project (let's call it git-on-cmake)
whose sole purpose is to develop and polish CMakeLists.txt, waiting
for an advanced enough version of cmake becomes commonplace.  Then,
anybody who are interested and has recent cmake can subtree-merge
git-on-cmake project into their own clone of our project somewhere,
and help developing git-on-cmake further.

Then we'll meet again in 3 years and see if the world got new enough
;-)

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-27 21:17           ` Junio C Hamano
@ 2020-04-27 21:56             ` Michal Suchánek
  2020-04-27 22:09             ` Jeff King
  1 sibling, 0 replies; 179+ messages in thread
From: Michal Suchánek @ 2020-04-27 21:56 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Jeff King, Johannes Schindelin, Sibi Siddharthan,
	Sibi Siddharthan via GitGitGadget, git

On Mon, 27 Apr 2020 14:17:32 -0700
Junio C Hamano <gitster@pobox.com> wrote:

> Jeff King <peff@peff.net> writes:
> 
> > I think what I'm suggesting is not all that different from this, except
> > that I'd suspect "next" would not get enough exposure. So in my mind
> > merging to master is not so much "hooray, we now have visual studio
> > support" but rather the first step in getting data. But we'd have to be
> > very clear about how the project regards the cmake support: it's there
> > for now, you're encouraged to play with it, but don't be upset if it
> > needs some coaxing to behave like the normal Makefile or if it goes away
> > in the future.  
> 
> I think you said almost everything I would have said.  
> 
> If we were to adopt it as an experiment, hoping to gain exposure,
> nothing above 'master' (or tagged releases) won't work.  And once a
> thing is in 'master', users will ignore the "this is merely an
> experiment" warning and expect it to be fully functional and usable.
> 
> Given the observation in the thread that it would take a fairly
> recent version to benefit platform-agnostic usability features, I
> did not get an impression that it is ready to be anywhere near that,
> not even ready for 'next'.  It is *not* like "Sibi's patches were
> bad but they can become ready with further polishing".  The
> impression I got was that the large part of why it is not ready is
> because it needs time for larger set of distros to adopt more recent
> versions of cmake.
> 
Why do you need distros to adopt more recent versions of cmake?

The cmake support is mainly for VS and you can install current version
of cmake with VS, there is no distro there. It can also work on
distros with recent cmake but that's not really the goal so it's not a
problem if many distros don't work.

Thanks

Michal

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-27 21:17           ` Junio C Hamano
  2020-04-27 21:56             ` Michal Suchánek
@ 2020-04-27 22:09             ` Jeff King
  2020-04-27 22:23               ` Elijah Newren
  1 sibling, 1 reply; 179+ messages in thread
From: Jeff King @ 2020-04-27 22:09 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Johannes Schindelin, Sibi Siddharthan,
	Sibi Siddharthan via GitGitGadget, git

On Mon, Apr 27, 2020 at 02:17:32PM -0700, Junio C Hamano wrote:

> If we were to adopt it as an experiment, hoping to gain exposure,
> nothing above 'master' (or tagged releases) won't work.  And once a
> thing is in 'master', users will ignore the "this is merely an
> experiment" warning and expect it to be fully functional and usable.

Yeah, that is a problem. I wonder if the state would be more obvious if
it lived in contrib/. We already have contrib/buildsystems,
which seems like an earlier attempt at this exact problem?

> But in the meantime, those who are interested in building Git with
> cmake do not have to wait, doing nothing, I would imagine.  I wonder
> if they can work on a separate project (let's call it git-on-cmake)
> whose sole purpose is to develop and polish CMakeLists.txt, waiting
> for an advanced enough version of cmake becomes commonplace.  Then,
> anybody who are interested and has recent cmake can subtree-merge
> git-on-cmake project into their own clone of our project somewhere,
> and help developing git-on-cmake further.

I think there's actually a good reason to have it in your tree: people
use your tree as the basis to build (and submit!) changes.

I noticed the same thing with trying to play with CI changes. As a
contributor, yes I _can_ make my CI changes, and then base my branches
on that. But it gets rather awkward juggling branches that contain some
changes that should go upstream, and some which should not. And quite a
bit more difficult if people want to use tools like GitGitGadget to just
target a PR against git.git and send it to the mailing list.

If it lived in contrib/ that might strike a good balance between making
it available for people to experiment with, but not having people
confuse it for the official build system.

-Peff

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-27 22:09             ` Jeff King
@ 2020-04-27 22:23               ` Elijah Newren
  2020-04-27 23:16                 ` Junio C Hamano
  2020-04-28  5:36                 ` Jeff King
  0 siblings, 2 replies; 179+ messages in thread
From: Elijah Newren @ 2020-04-27 22:23 UTC (permalink / raw)
  To: Jeff King
  Cc: Junio C Hamano, Johannes Schindelin, Sibi Siddharthan,
	Sibi Siddharthan via GitGitGadget, Git Mailing List

On Mon, Apr 27, 2020 at 3:12 PM Jeff King <peff@peff.net> wrote:
>
> On Mon, Apr 27, 2020 at 02:17:32PM -0700, Junio C Hamano wrote:
>
> > If we were to adopt it as an experiment, hoping to gain exposure,
> > nothing above 'master' (or tagged releases) won't work.  And once a
> > thing is in 'master', users will ignore the "this is merely an
> > experiment" warning and expect it to be fully functional and usable.
>
> Yeah, that is a problem. I wonder if the state would be more obvious if
> it lived in contrib/. We already have contrib/buildsystems,
> which seems like an earlier attempt at this exact problem?
>
> > But in the meantime, those who are interested in building Git with
> > cmake do not have to wait, doing nothing, I would imagine.  I wonder
> > if they can work on a separate project (let's call it git-on-cmake)
> > whose sole purpose is to develop and polish CMakeLists.txt, waiting
> > for an advanced enough version of cmake becomes commonplace.  Then,
> > anybody who are interested and has recent cmake can subtree-merge
> > git-on-cmake project into their own clone of our project somewhere,
> > and help developing git-on-cmake further.
>
> I think there's actually a good reason to have it in your tree: people
> use your tree as the basis to build (and submit!) changes.
>
> I noticed the same thing with trying to play with CI changes. As a
> contributor, yes I _can_ make my CI changes, and then base my branches
> on that. But it gets rather awkward juggling branches that contain some
> changes that should go upstream, and some which should not. And quite a
> bit more difficult if people want to use tools like GitGitGadget to just
> target a PR against git.git and send it to the mailing list.
>
> If it lived in contrib/ that might strike a good balance between making
> it available for people to experiment with, but not having people
> confuse it for the official build system.

Maybe we could move configure.ac and config.mak.in into contrib as well?

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-27 22:23               ` Elijah Newren
@ 2020-04-27 23:16                 ` Junio C Hamano
  2020-04-28  5:36                 ` Jeff King
  1 sibling, 0 replies; 179+ messages in thread
From: Junio C Hamano @ 2020-04-27 23:16 UTC (permalink / raw)
  To: Elijah Newren
  Cc: Jeff King, Johannes Schindelin, Sibi Siddharthan,
	Sibi Siddharthan via GitGitGadget, Git Mailing List

Elijah Newren <newren@gmail.com> writes:

>> If it lived in contrib/ that might strike a good balance between making
>> it available for people to experiment with, but not having people
>> confuse it for the official build system.

If we declare cmake support is only for VS and throw it into
somewhere like contrib/buildsystems, that may be good enough.

> Maybe we could move configure.ac and config.mak.in into contrib as well?

Perhaps.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-27 22:23               ` Elijah Newren
  2020-04-27 23:16                 ` Junio C Hamano
@ 2020-04-28  5:36                 ` Jeff King
  1 sibling, 0 replies; 179+ messages in thread
From: Jeff King @ 2020-04-28  5:36 UTC (permalink / raw)
  To: Elijah Newren
  Cc: Junio C Hamano, Johannes Schindelin, Sibi Siddharthan,
	Sibi Siddharthan via GitGitGadget, Git Mailing List

On Mon, Apr 27, 2020 at 03:23:22PM -0700, Elijah Newren wrote:

> > If it lived in contrib/ that might strike a good balance between making
> > it available for people to experiment with, but not having people
> > confuse it for the official build system.
> 
> Maybe we could move configure.ac and config.mak.in into contrib as well?

Maybe. I have a feeling that most folks who use autoconf do it from the
tarballs, which have the generated ./configure anyway.

-Peff

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-27 20:12           ` Jeff King
@ 2020-04-28 13:52             ` Danh Doan
  2020-04-28 21:07               ` Jeff King
  0 siblings, 1 reply; 179+ messages in thread
From: Danh Doan @ 2020-04-28 13:52 UTC (permalink / raw)
  To: Jeff King
  Cc: Johannes Schindelin, Junio C Hamano, Sibi Siddharthan,
	Sibi Siddharthan via GitGitGadget, git

On 2020-04-27 16:12:28-0400, Jeff King <peff@peff.net> wrote:
> On Mon, Apr 27, 2020 at 04:08:52PM -0400, Jeff King wrote:
> 
> > Skimming the patches, I do wish I didn't see so much repetition with the
> > existing Makefile. I know that some of the logic will just have to be
> > ported manually, but surely we could be pulling things like the list of
> > libgit_SOURCES from the Makefile as the single source of truth?
> 
> Thinking I surely couldn't be the only one to think of this, I dug
> further into some of the sub-threads. And indeed, it seems like you are
> on the same page here.
> 
> IMHO it is worth making the cmake file depend as much as possible on
> what's in the Makefile.

Please correct me if I were wrong (I recall this from my memory
without checking anything).

The worst thing about CMake is we can't override (Make's) variable
in Makefile generated by CMake.

I've made some comment in Sibi's patch about some make's variable,
because Sibi naively translates them from current Makefile.
Namely, the location of some system configuration files, $(libexecdir)
and build conditional macro.

With current Makefile, we can just:

	make VAR=VALUE target

or:
	echo "VAR=VALUE" >> config.mak
	make target

With cmake, we need to define all of them as CMake options (this will
brings along a big burden), whenever we need to change any options,
we need to (assume that cmake generates Makefile):

	cmake -DVAR=VALUE path/to/src/dir
	make target

How many make variables that we need to define in CMakeList.txt,
I don't know.

-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-28 13:52             ` Danh Doan
@ 2020-04-28 21:07               ` Jeff King
  2020-04-29  8:42                 ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Jeff King @ 2020-04-28 21:07 UTC (permalink / raw)
  To: Danh Doan
  Cc: Johannes Schindelin, Junio C Hamano, Sibi Siddharthan,
	Sibi Siddharthan via GitGitGadget, git

On Tue, Apr 28, 2020 at 08:52:37PM +0700, Danh Doan wrote:

> On 2020-04-27 16:12:28-0400, Jeff King <peff@peff.net> wrote:
> > On Mon, Apr 27, 2020 at 04:08:52PM -0400, Jeff King wrote:
> > 
> > > Skimming the patches, I do wish I didn't see so much repetition with the
> > > existing Makefile. I know that some of the logic will just have to be
> > > ported manually, but surely we could be pulling things like the list of
> > > libgit_SOURCES from the Makefile as the single source of truth?
> > 
> > Thinking I surely couldn't be the only one to think of this, I dug
> > further into some of the sub-threads. And indeed, it seems like you are
> > on the same page here.
> > 
> > IMHO it is worth making the cmake file depend as much as possible on
> > what's in the Makefile.
> 
> Please correct me if I were wrong (I recall this from my memory
> without checking anything).
> 
> The worst thing about CMake is we can't override (Make's) variable
> in Makefile generated by CMake.

I really don't know enough about cmake to say one way or the other. I
can well believe there are parts of the Makefile that will need to be
manually translated, and that it may not ever hit full parity.

But as long as it just a tool for people using Visual Studio, and if
they are happier being able to use that tool, even with a few
deficiencies, then it may still be worth doing.

-Peff

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-28 21:07               ` Jeff King
@ 2020-04-29  8:42                 ` Sibi Siddharthan
  2020-05-01 19:32                   ` Johannes Schindelin
  2020-05-02 13:21                   ` Danh Doan
  0 siblings, 2 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-04-29  8:42 UTC (permalink / raw)
  To: Jeff King
  Cc: Danh Doan, Johannes Schindelin, Junio C Hamano,
	Sibi Siddharthan via GitGitGadget, git

Adding the CMake script to contrib/buildsystem is a good option.
Is there any changes (apart from the CMakeLists.txt critique and) that
I have to do on my part?

Thank You,
Sibi Siddharthan

On Wed, Apr 29, 2020 at 2:37 AM Jeff King <peff@peff.net> wrote:
>
> On Tue, Apr 28, 2020 at 08:52:37PM +0700, Danh Doan wrote:
>
> > On 2020-04-27 16:12:28-0400, Jeff King <peff@peff.net> wrote:
> > > On Mon, Apr 27, 2020 at 04:08:52PM -0400, Jeff King wrote:
> > >
> > > > Skimming the patches, I do wish I didn't see so much repetition with the
> > > > existing Makefile. I know that some of the logic will just have to be
> > > > ported manually, but surely we could be pulling things like the list of
> > > > libgit_SOURCES from the Makefile as the single source of truth?
> > >
> > > Thinking I surely couldn't be the only one to think of this, I dug
> > > further into some of the sub-threads. And indeed, it seems like you are
> > > on the same page here.
> > >
> > > IMHO it is worth making the cmake file depend as much as possible on
> > > what's in the Makefile.
> >
> > Please correct me if I were wrong (I recall this from my memory
> > without checking anything).
> >
> > The worst thing about CMake is we can't override (Make's) variable
> > in Makefile generated by CMake.
>
> I really don't know enough about cmake to say one way or the other. I
> can well believe there are parts of the Makefile that will need to be
> manually translated, and that it may not ever hit full parity.
>
> But as long as it just a tool for people using Visual Studio, and if
> they are happier being able to use that tool, even with a few
> deficiencies, then it may still be worth doing.
>
> -Peff

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-29  8:42                 ` Sibi Siddharthan
@ 2020-05-01 19:32                   ` Johannes Schindelin
  2020-05-02 14:31                     ` Sibi Siddharthan
  2020-05-02 13:21                   ` Danh Doan
  1 sibling, 1 reply; 179+ messages in thread
From: Johannes Schindelin @ 2020-05-01 19:32 UTC (permalink / raw)
  To: Sibi Siddharthan
  Cc: Jeff King, Danh Doan, Junio C Hamano,
	Sibi Siddharthan via GitGitGadget, git

Hi Sibi,

[please avoid top-posting on this list, but do reply inline instead, that
is much preferred.]

On Wed, 29 Apr 2020, Sibi Siddharthan wrote:

> Adding the CMake script to contrib/buildsystem is a good option.

I'd actually prefer it to live in a different subdirectory: what is in
contrib/buildsystem/ uses the technique of running `make` in a dry-run
mode, parsing the output, and then generating project files. But that is
not what CMakeLists.txt is about.

How about contrib/cmake/?

> Is there any changes (apart from the CMakeLists.txt critique and) that
> I have to do on my part?

No, I think that's it!

Thanks,
Dscho

>
> Thank You,
> Sibi Siddharthan
>
> On Wed, Apr 29, 2020 at 2:37 AM Jeff King <peff@peff.net> wrote:
> >
> > On Tue, Apr 28, 2020 at 08:52:37PM +0700, Danh Doan wrote:
> >
> > > On 2020-04-27 16:12:28-0400, Jeff King <peff@peff.net> wrote:
> > > > On Mon, Apr 27, 2020 at 04:08:52PM -0400, Jeff King wrote:
> > > >
> > > > > Skimming the patches, I do wish I didn't see so much repetition with the
> > > > > existing Makefile. I know that some of the logic will just have to be
> > > > > ported manually, but surely we could be pulling things like the list of
> > > > > libgit_SOURCES from the Makefile as the single source of truth?
> > > >
> > > > Thinking I surely couldn't be the only one to think of this, I dug
> > > > further into some of the sub-threads. And indeed, it seems like you are
> > > > on the same page here.
> > > >
> > > > IMHO it is worth making the cmake file depend as much as possible on
> > > > what's in the Makefile.
> > >
> > > Please correct me if I were wrong (I recall this from my memory
> > > without checking anything).
> > >
> > > The worst thing about CMake is we can't override (Make's) variable
> > > in Makefile generated by CMake.
> >
> > I really don't know enough about cmake to say one way or the other. I
> > can well believe there are parts of the Makefile that will need to be
> > manually translated, and that it may not ever hit full parity.
> >
> > But as long as it just a tool for people using Visual Studio, and if
> > they are happier being able to use that tool, even with a few
> > deficiencies, then it may still be worth doing.
> >
> > -Peff
>

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-04-29  8:42                 ` Sibi Siddharthan
  2020-05-01 19:32                   ` Johannes Schindelin
@ 2020-05-02 13:21                   ` Danh Doan
  2020-05-02 14:50                     ` Sibi Siddharthan
  1 sibling, 1 reply; 179+ messages in thread
From: Danh Doan @ 2020-05-02 13:21 UTC (permalink / raw)
  To: Sibi Siddharthan
  Cc: Jeff King, Johannes Schindelin, Junio C Hamano,
	Sibi Siddharthan via GitGitGadget, git

Hi Sibi,

On 2020-04-29 14:12:43+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:
> > > Please correct me if I were wrong (I recall this from my memory
> > > without checking anything).
> > >
> > > The worst thing about CMake is we can't override (Make's) variable
> > > in Makefile generated by CMake.
> >
> > I really don't know enough about cmake to say one way or the other. I
> > can well believe there are parts of the Makefile that will need to be
> > manually translated, and that it may not ever hit full parity.
> >
> > But as long as it just a tool for people using Visual Studio, and if
> > they are happier being able to use that tool, even with a few
> > deficiencies, then it may still be worth doing.
> Adding the CMake script to contrib/buildsystem is a good option.
> Is there any changes (apart from the CMakeLists.txt critique and) that
> I have to do on my part?

(Sorry for this late reply, it's holiday over here).

It's long time since last time I worked with CMake, but I have some
suggestion, maybe it was written in my previous comment, maybe not.

- If we could find anything in CMake that equivalent with `sysconfdir`
  in autotools, please use it for configuration files instead of
  relative to `CMAKE_INSTALL_PREFIX`
- I'll change (this and alikes)
  	find_program(SH_PATH, "sh")
  with:
  	option(SHELL_PATH "path to POSIX compliance shell" "/bin/sh")
  in order to support Solaris people, should they want to try CMake
- I'll wrap the incompatible option of gettext under uname check
- and remove ${} around variable in `if`

-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-05-01 19:32                   ` Johannes Schindelin
@ 2020-05-02 14:31                     ` Sibi Siddharthan
  2020-05-02 14:58                       ` Randall S. Becker
  2020-05-02 15:48                       ` Junio C Hamano
  0 siblings, 2 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-02 14:31 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: Jeff King, Danh Doan, Junio C Hamano,
	Sibi Siddharthan via GitGitGadget, git

On Sat, May 2, 2020 at 1:02 AM Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
>
> Hi Sibi,
>
> [please avoid top-posting on this list, but do reply inline instead, that
> is much preferred.]
>
> On Wed, 29 Apr 2020, Sibi Siddharthan wrote:
>
> > Adding the CMake script to contrib/buildsystem is a good option.
>
> I'd actually prefer it to live in a different subdirectory: what is in
> contrib/buildsystem/ uses the technique of running `make` in a dry-run
> mode, parsing the output, and then generating project files. But that is
> not what CMakeLists.txt is about.
>
> How about contrib/cmake/?
>

The CMakeLists.txt will be non-functional if it in any other directory except
the root source directory. To help users we can,
add some instructions in INSTALL on how to use the script.
OR
create a dummy CMakeLists.txt in the root directory which just
says
`message("Copy and Replace the CMakeLists from `whatever-folder` to here")`
along with some instructions if necessary. This is what LLVM does for autoconf.

Thank You,
Sibi Siddharthan

> > Is there any changes (apart from the CMakeLists.txt critique and) that
> > I have to do on my part?
>
> No, I think that's it!
>
> Thanks,
> Dscho
>
> >
> > Thank You,
> > Sibi Siddharthan
> >
> > On Wed, Apr 29, 2020 at 2:37 AM Jeff King <peff@peff.net> wrote:
> > >
> > > On Tue, Apr 28, 2020 at 08:52:37PM +0700, Danh Doan wrote:
> > >
> > > > On 2020-04-27 16:12:28-0400, Jeff King <peff@peff.net> wrote:
> > > > > On Mon, Apr 27, 2020 at 04:08:52PM -0400, Jeff King wrote:
> > > > >
> > > > > > Skimming the patches, I do wish I didn't see so much repetition with the
> > > > > > existing Makefile. I know that some of the logic will just have to be
> > > > > > ported manually, but surely we could be pulling things like the list of
> > > > > > libgit_SOURCES from the Makefile as the single source of truth?
> > > > >
> > > > > Thinking I surely couldn't be the only one to think of this, I dug
> > > > > further into some of the sub-threads. And indeed, it seems like you are
> > > > > on the same page here.
> > > > >
> > > > > IMHO it is worth making the cmake file depend as much as possible on
> > > > > what's in the Makefile.
> > > >
> > > > Please correct me if I were wrong (I recall this from my memory
> > > > without checking anything).
> > > >
> > > > The worst thing about CMake is we can't override (Make's) variable
> > > > in Makefile generated by CMake.
> > >
> > > I really don't know enough about cmake to say one way or the other. I
> > > can well believe there are parts of the Makefile that will need to be
> > > manually translated, and that it may not ever hit full parity.
> > >
> > > But as long as it just a tool for people using Visual Studio, and if
> > > they are happier being able to use that tool, even with a few
> > > deficiencies, then it may still be worth doing.
> > >
> > > -Peff
> >

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-05-02 13:21                   ` Danh Doan
@ 2020-05-02 14:50                     ` Sibi Siddharthan
  2020-05-02 15:02                       ` Danh Doan
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-02 14:50 UTC (permalink / raw)
  To: Danh Doan
  Cc: Jeff King, Johannes Schindelin, Junio C Hamano,
	Sibi Siddharthan via GitGitGadget, git

On Sat, May 2, 2020 at 6:51 PM Danh Doan <congdanhqx@gmail.com> wrote:
>
> Hi Sibi,
>
> On 2020-04-29 14:12:43+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:
> > > > Please correct me if I were wrong (I recall this from my memory
> > > > without checking anything).
> > > >
> > > > The worst thing about CMake is we can't override (Make's) variable
> > > > in Makefile generated by CMake.
> > >
> > > I really don't know enough about cmake to say one way or the other. I
> > > can well believe there are parts of the Makefile that will need to be
> > > manually translated, and that it may not ever hit full parity.
> > >
> > > But as long as it just a tool for people using Visual Studio, and if
> > > they are happier being able to use that tool, even with a few
> > > deficiencies, then it may still be worth doing.
> > Adding the CMake script to contrib/buildsystem is a good option.
> > Is there any changes (apart from the CMakeLists.txt critique and) that
> > I have to do on my part?
>
> (Sorry for this late reply, it's holiday over here).
>
> It's long time since last time I worked with CMake, but I have some
> suggestion, maybe it was written in my previous comment, maybe not.
>
> - If we could find anything in CMake that equivalent with `sysconfdir`
>   in autotools, please use it for configuration files instead of
>   relative to `CMAKE_INSTALL_PREFIX`

The module GNUInstallDirs does what you ask.

> - I'll change (this and alikes)
>         find_program(SH_PATH, "sh")
>   with:
>         option(SHELL_PATH "path to POSIX compliance shell" "/bin/sh")
>   in order to support Solaris people, should they want to try CMake
> - I'll wrap the incompatible option of gettext under uname check
> - and remove ${} around variable in `if`
>

The thing with options in cmake is the values it takes are boolean only.
To do what you want I think you have to do something along the lines of this.
if(NOT DEFINED SHELL_PATH)
set(SHELL_PATH  <default value> CACHE STRING "path to POSIX compliance shell")
endif()

Then if you want to change this value, edit this value in CMakeCache.txt.

Thank You,
Sibi Siddharthan

> --
> Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* RE: [PATCH 0/8] CMake build system for git
  2020-05-02 14:31                     ` Sibi Siddharthan
@ 2020-05-02 14:58                       ` Randall S. Becker
  2020-05-02 15:48                       ` Junio C Hamano
  1 sibling, 0 replies; 179+ messages in thread
From: Randall S. Becker @ 2020-05-02 14:58 UTC (permalink / raw)
  To: 'Sibi Siddharthan', 'Johannes Schindelin'
  Cc: 'Jeff King', 'Danh Doan',
	'Junio C Hamano',
	'Sibi Siddharthan via GitGitGadget',
	git

On May 2, 2020 10:32 AM, Sibi Siddharthan Wrote:
> On Sat, May 2, 2020 at 1:02 AM Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
> > On Wed, 29 Apr 2020, Sibi Siddharthan wrote:
> >
> > > Adding the CMake script to contrib/buildsystem is a good option.
> >
> > I'd actually prefer it to live in a different subdirectory: what is in
> > contrib/buildsystem/ uses the technique of running `make` in a dry-run
> > mode, parsing the output, and then generating project files. But that
> > is not what CMakeLists.txt is about.
> >
> > How about contrib/cmake/?
> >
> 
> The CMakeLists.txt will be non-functional if it in any other directory except
> the root source directory. To help users we can, add some instructions in
> INSTALL on how to use the script.
> OR
> create a dummy CMakeLists.txt in the root directory which just says
> `message("Copy and Replace the CMakeLists from `whatever-folder` to
> here")` along with some instructions if necessary. This is what LLVM does for
> autoconf.
> > > Is there any changes (apart from the CMakeLists.txt critique and)
> > > that I have to do on my part?
> >
> > No, I think that's it!
> >
> > Thanks,
> > Dscho
> >
> > >
> > > Thank You,
> > > Sibi Siddharthan
> > >
> > > On Wed, Apr 29, 2020 at 2:37 AM Jeff King <peff@peff.net> wrote:
> > > >
> > > > On Tue, Apr 28, 2020 at 08:52:37PM +0700, Danh Doan wrote:
> > > >
> > > > > On 2020-04-27 16:12:28-0400, Jeff King <peff@peff.net> wrote:
> > > > > > On Mon, Apr 27, 2020 at 04:08:52PM -0400, Jeff King wrote:
> > > > > >
> > > > > > > Skimming the patches, I do wish I didn't see so much
> > > > > > > repetition with the existing Makefile. I know that some of
> > > > > > > the logic will just have to be ported manually, but surely
> > > > > > > we could be pulling things like the list of libgit_SOURCES from the
> Makefile as the single source of truth?
> > > > > >
> > > > > > Thinking I surely couldn't be the only one to think of this, I
> > > > > > dug further into some of the sub-threads. And indeed, it seems
> > > > > > like you are on the same page here.
> > > > > >
> > > > > > IMHO it is worth making the cmake file depend as much as
> > > > > > possible on what's in the Makefile.
> > > > >
> > > > > Please correct me if I were wrong (I recall this from my memory
> > > > > without checking anything).
> > > > >
> > > > > The worst thing about CMake is we can't override (Make's)
> > > > > variable in Makefile generated by CMake.
> > > >
> > > > I really don't know enough about cmake to say one way or the
> > > > other. I can well believe there are parts of the Makefile that
> > > > will need to be manually translated, and that it may not ever hit full
> parity.
> > > >
> > > > But as long as it just a tool for people using Visual Studio, and
> > > > if they are happier being able to use that tool, even with a few
> > > > deficiencies, then it may still be worth doing.
> > > >
> > > > -Peff
> > >

Just a head's up that neither the HPE NonStop OSS nor IBM z/OS USS platforms currently have any support for CMake nor do I expect any support in the foreseeable future. We are seeing very strong adoption rates on both platforms (sorry, cannot share statistics at this time).

Regards,
Randall

-- Brief whoami:
 NonStop developer since approximately 211288444200000000
 UNIX developer since approximately 421664400
-- In my real life, I talk too much.




^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-05-02 14:50                     ` Sibi Siddharthan
@ 2020-05-02 15:02                       ` Danh Doan
  2020-05-02 15:16                         ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Danh Doan @ 2020-05-02 15:02 UTC (permalink / raw)
  To: Sibi Siddharthan
  Cc: Jeff King, Johannes Schindelin, Junio C Hamano,
	Sibi Siddharthan via GitGitGadget, git

On 2020-05-02 20:20:50+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:
> On Sat, May 2, 2020 at 6:51 PM Danh Doan <congdanhqx@gmail.com> wrote:
> The thing with options in cmake is the values it takes are boolean only.
> To do what you want I think you have to do something along the lines of this.
> if(NOT DEFINED SHELL_PATH)
> set(SHELL_PATH  <default value> CACHE STRING "path to POSIX compliance shell")
> endif()
> 
> Then if you want to change this value, edit this value in CMakeCache.txt.

Ah, this is what I mean, I think it's better to use this (without
if_not_define)

	set(SHELL_PATH  "/bin/sh" CACHE PATH "path to POSIX compliance shell")

Then, we can use this:

	cmake -DSHELL_PATH=/path/to/good/sh ...

-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-05-02 15:02                       ` Danh Doan
@ 2020-05-02 15:16                         ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-02 15:16 UTC (permalink / raw)
  To: Danh Doan
  Cc: Jeff King, Johannes Schindelin, Junio C Hamano,
	Sibi Siddharthan via GitGitGadget, git

On Sat, May 2, 2020 at 8:32 PM Danh Doan <congdanhqx@gmail.com> wrote:
>
> On 2020-05-02 20:20:50+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:
> > On Sat, May 2, 2020 at 6:51 PM Danh Doan <congdanhqx@gmail.com> wrote:
> > The thing with options in cmake is the values it takes are boolean only.
> > To do what you want I think you have to do something along the lines of this.
> > if(NOT DEFINED SHELL_PATH)
> > set(SHELL_PATH  <default value> CACHE STRING "path to POSIX compliance shell")
> > endif()
> >
> > Then if you want to change this value, edit this value in CMakeCache.txt.
>
> Ah, this is what I mean, I think it's better to use this (without
> if_not_define)
>
>         set(SHELL_PATH  "/bin/sh" CACHE PATH "path to POSIX compliance shell")
>
> Then, we can use this:
>
>         cmake -DSHELL_PATH=/path/to/good/sh ...
>

If you CACHE the variable, you have to do this
 cmake -USHELL_PATH -DSHELL_PATH=/path/to/good/sh

I know it is bad.
Otherwise you can modify the cache entry directly in CMakeCache.txt.

Thank You,
Sibi Siddharthan

> --
> Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-05-02 14:31                     ` Sibi Siddharthan
  2020-05-02 14:58                       ` Randall S. Becker
@ 2020-05-02 15:48                       ` Junio C Hamano
  2020-05-03 15:33                         ` Sibi Siddharthan
  1 sibling, 1 reply; 179+ messages in thread
From: Junio C Hamano @ 2020-05-02 15:48 UTC (permalink / raw)
  To: Sibi Siddharthan
  Cc: Johannes Schindelin, Jeff King, Danh Doan,
	Sibi Siddharthan via GitGitGadget, git

Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:

>> How about contrib/cmake/?
>>
>
> The CMakeLists.txt will be non-functional if it in any other directory except
> the root source directory. To help users we can,
> add some instructions in INSTALL on how to use the script.
> OR
> create a dummy CMakeLists.txt in the root directory which just
> says
> `message("Copy and Replace the CMakeLists from `whatever-folder` to here")`
> along with some instructions if necessary. This is what LLVM does for autoconf.

Isn't there a corresponding feature to make's "-f" option to specify
which file to read instructions from?

As you say, an extra instruction in INSTALL file to tell users to
copy from contrib/cmake may workable, though it is unsatisfactory.
But the other one will not simply work.  If we need to have a new
file with string "CMake" in its name at the top-level *anyway*, we
should have the real thing to reduce one step from those who want to
use it.  Those who do not want to see "CMake" at the toplevel are
already harmed either way, if is a dummy or if it is the real thing.

Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-05-02 15:48                       ` Junio C Hamano
@ 2020-05-03 15:33                         ` Sibi Siddharthan
  2020-05-03 17:21                           ` Junio C Hamano
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-03 15:33 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Johannes Schindelin, Jeff King, Danh Doan,
	Sibi Siddharthan via GitGitGadget, git

On Sat, May 2, 2020 at 9:18 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:
>
> >> How about contrib/cmake/?
> >>
> >
> > The CMakeLists.txt will be non-functional if it in any other directory except
> > the root source directory. To help users we can,
> > add some instructions in INSTALL on how to use the script.
> > OR
> > create a dummy CMakeLists.txt in the root directory which just
> > says
> > `message("Copy and Replace the CMakeLists from `whatever-folder` to here")`
> > along with some instructions if necessary. This is what LLVM does for autoconf.
>
> Isn't there a corresponding feature to make's "-f" option to specify
> which file to read instructions from?

Sadly, CMake expects CMakeLists.txt only, nothing else.

>
> As you say, an extra instruction in INSTALL file to tell users to
> copy from contrib/cmake may workable, though it is unsatisfactory.
> But the other one will not simply work.  If we need to have a new
> file with string "CMake" in its name at the top-level *anyway*, we
> should have the real thing to reduce one step from those who want to
> use it.  Those who do not want to see "CMake" at the toplevel are
> already harmed either way, if is a dummy or if it is the real thing.

In your opinion, what would be the best way to communicate with users, there is
an optional CMake build system for git?

Thank You,
Sibi Siddharthan

>
> Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-05-03 15:33                         ` Sibi Siddharthan
@ 2020-05-03 17:21                           ` Junio C Hamano
  2020-05-03 19:42                             ` Konstantin Tokarev
  0 siblings, 1 reply; 179+ messages in thread
From: Junio C Hamano @ 2020-05-03 17:21 UTC (permalink / raw)
  To: Sibi Siddharthan
  Cc: Johannes Schindelin, Jeff King, Danh Doan,
	Sibi Siddharthan via GitGitGadget, git

Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:

>> As you say, an extra instruction in INSTALL file to tell users to
>> copy from contrib/cmake may workable, though it is unsatisfactory.
>> But the other one will not simply work.  If we need to have a new
>> file with string "CMake" in its name at the top-level *anyway*, we
>> should have the real thing to reduce one step from those who want to
>> use it.  Those who do not want to see "CMake" at the toplevel are
>> already harmed either way, if is a dummy or if it is the real thing.
>
> In your opinion, what would be the best way to communicate with users, there is
> an optional CMake build system for git?

You do not want to hear my opinion, as my priorities would be
different from yours ;-)

Given that we all agreed that the only reason we contemplate use of
CMake in our project is strictly to help Windows build, i.e. due to
the same reason why we have contrib/buildsystems/, it is not one of
my goals to communicate with general users about optional CMake
support in the first place.  It has lower priority than keeping the
project tree and the project history less cluttered.

So my first preference would be an instruction somewhere in install
or readme that tells those who want to build for windows to copy
from (or perhaps update cmake to offer the "-f" option and tell it
to read from) contrib/cmake/CMakeLists.txt to the toplevel before
doing anything [*1*].

If there are many people who want to help the cmake effort, however,
shipping a real CMakeLists.txt at the top-level of the tree, with
all the instructions at the beginning of *that* file, would be an
easier way for them to discover and polish.  It would also be my
preference but only under the "if there are many people" condition.

Thanks.


[Footnote]

*1* It probably is too error prone to tell people who do the real
    work to "copy", as they are prone to modify the copy and forget
    updating the source.  So the instruction may tell them to create
    a symlink at the toplevel that points to the real file in the
    contrib/cmake/ directory, or if the filesystem does not support
    symbolic links (which is very likely given the target audience
    of this are all on Windows), tell them copy a small skeleton
    file that is also shipped in contrib/cmake/ directory to the
    top-level.  That skeleton file would "include" the real thing
    that lives in contrib/cmake/ directory (I am assuming that
    CMakeLists.txt can include other CMakeLists.txt file here).


^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-05-03 17:21                           ` Junio C Hamano
@ 2020-05-03 19:42                             ` Konstantin Tokarev
  2020-05-03 19:50                               ` Junio C Hamano
  2020-05-04 14:31                               ` Johannes Schindelin
  0 siblings, 2 replies; 179+ messages in thread
From: Konstantin Tokarev @ 2020-05-03 19:42 UTC (permalink / raw)
  To: Junio C Hamano, Sibi Siddharthan
  Cc: Johannes Schindelin, Jeff King, Danh Doan,
	Sibi Siddharthan via GitGitGadget, git



03.05.2020, 20:21, "Junio C Hamano" <gitster@pobox.com>:
> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:
>
>>>  As you say, an extra instruction in INSTALL file to tell users to
>>>  copy from contrib/cmake may workable, though it is unsatisfactory.
>>>  But the other one will not simply work. If we need to have a new
>>>  file with string "CMake" in its name at the top-level *anyway*, we
>>>  should have the real thing to reduce one step from those who want to
>>>  use it. Those who do not want to see "CMake" at the toplevel are
>>>  already harmed either way, if is a dummy or if it is the real thing.
>>
>>  In your opinion, what would be the best way to communicate with users, there is
>>  an optional CMake build system for git?
>
> You do not want to hear my opinion, as my priorities would be
> different from yours ;-)
>
> Given that we all agreed that the only reason we contemplate use of
> CMake in our project is strictly to help Windows build, i.e. due to
> the same reason why we have contrib/buildsystems/, it is not one of
> my goals to communicate with general users about optional CMake
> support in the first place. It has lower priority than keeping the
> project tree and the project history less cluttered.
>
> So my first preference would be an instruction somewhere in install
> or readme that tells those who want to build for windows to copy
> from (or perhaps update cmake to offer the "-f" option and tell it
> to read from) contrib/cmake/CMakeLists.txt to the toplevel before
> doing anything [*1*].

FWIW, CMakeLists.txt doesn't have to be in the root of source tree in
order to work. It can perfectly work from contrib/cmake after necessary
changes in relative paths.

>
> If there are many people who want to help the cmake effort, however,
> shipping a real CMakeLists.txt at the top-level of the tree, with
> all the instructions at the beginning of *that* file, would be an
> easier way for them to discover and polish. It would also be my
> preference but only under the "if there are many people" condition.
>
> Thanks.
>
> [Footnote]
>
> *1* It probably is too error prone to tell people who do the real
>     work to "copy", as they are prone to modify the copy and forget
>     updating the source. So the instruction may tell them to create
>     a symlink at the toplevel that points to the real file in the
>     contrib/cmake/ directory, or if the filesystem does not support
>     symbolic links (which is very likely given the target audience
>     of this are all on Windows), tell them copy a small skeleton
>     file that is also shipped in contrib/cmake/ directory to the
>     top-level. That skeleton file would "include" the real thing
>     that lives in contrib/cmake/ directory (I am assuming that
>     CMakeLists.txt can include other CMakeLists.txt file here).

-- 
Regards,
Konstantin


^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-05-03 19:42                             ` Konstantin Tokarev
@ 2020-05-03 19:50                               ` Junio C Hamano
  2020-05-04 14:31                               ` Johannes Schindelin
  1 sibling, 0 replies; 179+ messages in thread
From: Junio C Hamano @ 2020-05-03 19:50 UTC (permalink / raw)
  To: Konstantin Tokarev
  Cc: Sibi Siddharthan, Johannes Schindelin, Jeff King, Danh Doan,
	Sibi Siddharthan via GitGitGadget, git

Konstantin Tokarev <annulen@yandex.ru> writes:

> FWIW, CMakeLists.txt doesn't have to be in the root of source tree in
> order to work. It can perfectly work from contrib/cmake after necessary
> changes in relative paths.

That's great to know---perhaps you can work with Sibi to help
whipping the CMakeLists.txt into shape, placing it in contrib/cmake/
directory?

When that is in place, my answer to Sibi's question, i.e. "what is
the best way to tell users they can use CMake for their Windows
build?" would be "the same way as we advertise contrib/buildsystems
and/or compat/vcbuild to them", I think.

Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-05-03 19:42                             ` Konstantin Tokarev
  2020-05-03 19:50                               ` Junio C Hamano
@ 2020-05-04 14:31                               ` Johannes Schindelin
  2020-05-04 21:59                                 ` Konstantin Tokarev
  1 sibling, 1 reply; 179+ messages in thread
From: Johannes Schindelin @ 2020-05-04 14:31 UTC (permalink / raw)
  To: Konstantin Tokarev
  Cc: Junio C Hamano, Sibi Siddharthan, Jeff King, Danh Doan,
	Sibi Siddharthan via GitGitGadget, git

[-- Attachment #1: Type: text/plain, Size: 1991 bytes --]

Hi Konst,

On Sun, 3 May 2020, Konstantin Tokarev wrote:

>
>
> 03.05.2020, 20:21, "Junio C Hamano" <gitster@pobox.com>:
> > Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:
> >
> >>>  As you say, an extra instruction in INSTALL file to tell users to
> >>>  copy from contrib/cmake may workable, though it is unsatisfactory.
> >>>  But the other one will not simply work. If we need to have a new
> >>>  file with string "CMake" in its name at the top-level *anyway*, we
> >>>  should have the real thing to reduce one step from those who want to
> >>>  use it. Those who do not want to see "CMake" at the toplevel are
> >>>  already harmed either way, if is a dummy or if it is the real thing.
> >>
> >>  In your opinion, what would be the best way to communicate with users, there is
> >>  an optional CMake build system for git?
> >
> > You do not want to hear my opinion, as my priorities would be
> > different from yours ;-)
> >
> > Given that we all agreed that the only reason we contemplate use of
> > CMake in our project is strictly to help Windows build, i.e. due to
> > the same reason why we have contrib/buildsystems/, it is not one of
> > my goals to communicate with general users about optional CMake
> > support in the first place. It has lower priority than keeping the
> > project tree and the project history less cluttered.
> >
> > So my first preference would be an instruction somewhere in install
> > or readme that tells those who want to build for windows to copy
> > from (or perhaps update cmake to offer the "-f" option and tell it
> > to read from) contrib/cmake/CMakeLists.txt to the toplevel before
> > doing anything [*1*].
>
> FWIW, CMakeLists.txt doesn't have to be in the root of source tree in
> order to work. It can perfectly work from contrib/cmake after necessary
> changes in relative paths.

Would you have an example handy, or a link to an article describing this?

Ciao,
Johannes

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-05-04 14:31                               ` Johannes Schindelin
@ 2020-05-04 21:59                                 ` Konstantin Tokarev
  2020-05-05  4:16                                   ` Sibi Siddharthan
  2020-05-07 20:54                                   ` Johannes Schindelin
  0 siblings, 2 replies; 179+ messages in thread
From: Konstantin Tokarev @ 2020-05-04 21:59 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: Junio C Hamano, Sibi Siddharthan, Jeff King, Danh Doan,
	Sibi Siddharthan via GitGitGadget, git



05.05.2020, 00:32, "Johannes Schindelin" <johannes.schindelin@gmx.de>:
> Hi Konst,
>
> On Sun, 3 May 2020, Konstantin Tokarev wrote:
>
>>  03.05.2020, 20:21, "Junio C Hamano" <gitster@pobox.com>:
>>  > Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:
>>  >
>>  >>>  As you say, an extra instruction in INSTALL file to tell users to
>>  >>>  copy from contrib/cmake may workable, though it is unsatisfactory.
>>  >>>  But the other one will not simply work. If we need to have a new
>>  >>>  file with string "CMake" in its name at the top-level *anyway*, we
>>  >>>  should have the real thing to reduce one step from those who want to
>>  >>>  use it. Those who do not want to see "CMake" at the toplevel are
>>  >>>  already harmed either way, if is a dummy or if it is the real thing.
>>  >>
>>  >>  In your opinion, what would be the best way to communicate with users, there is
>>  >>  an optional CMake build system for git?
>>  >
>>  > You do not want to hear my opinion, as my priorities would be
>>  > different from yours ;-)
>>  >
>>  > Given that we all agreed that the only reason we contemplate use of
>>  > CMake in our project is strictly to help Windows build, i.e. due to
>>  > the same reason why we have contrib/buildsystems/, it is not one of
>>  > my goals to communicate with general users about optional CMake
>>  > support in the first place. It has lower priority than keeping the
>>  > project tree and the project history less cluttered.
>>  >
>>  > So my first preference would be an instruction somewhere in install
>>  > or readme that tells those who want to build for windows to copy
>>  > from (or perhaps update cmake to offer the "-f" option and tell it
>>  > to read from) contrib/cmake/CMakeLists.txt to the toplevel before
>>  > doing anything [*1*].
>>
>>  FWIW, CMakeLists.txt doesn't have to be in the root of source tree in
>>  order to work. It can perfectly work from contrib/cmake after necessary
>>  changes in relative paths.
>
> Would you have an example handy, or a link to an article describing this?

It's so trivial that I'm not sure what such an article would have to describe.

https://github.com/annulen/cmake-example

-- 
Regards,
Konstantin


^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-05-04 21:59                                 ` Konstantin Tokarev
@ 2020-05-05  4:16                                   ` Sibi Siddharthan
  2020-05-05  6:16                                     ` Junio C Hamano
  2020-05-07 20:54                                   ` Johannes Schindelin
  1 sibling, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-05  4:16 UTC (permalink / raw)
  To: Konstantin Tokarev
  Cc: Johannes Schindelin, Junio C Hamano, Jeff King, Danh Doan,
	Sibi Siddharthan via GitGitGadget, git

On Tue, May 5, 2020 at 3:29 AM Konstantin Tokarev <annulen@yandex.ru> wrote:
>
>
>
> 05.05.2020, 00:32, "Johannes Schindelin" <johannes.schindelin@gmx.de>:
> > Hi Konst,
> >
> > On Sun, 3 May 2020, Konstantin Tokarev wrote:
> >
> >>  03.05.2020, 20:21, "Junio C Hamano" <gitster@pobox.com>:
> >>  > Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:
> >>  >
> >>  >>>  As you say, an extra instruction in INSTALL file to tell users to
> >>  >>>  copy from contrib/cmake may workable, though it is unsatisfactory.
> >>  >>>  But the other one will not simply work. If we need to have a new
> >>  >>>  file with string "CMake" in its name at the top-level *anyway*, we
> >>  >>>  should have the real thing to reduce one step from those who want to
> >>  >>>  use it. Those who do not want to see "CMake" at the toplevel are
> >>  >>>  already harmed either way, if is a dummy or if it is the real thing.
> >>  >>
> >>  >>  In your opinion, what would be the best way to communicate with users, there is
> >>  >>  an optional CMake build system for git?
> >>  >
> >>  > You do not want to hear my opinion, as my priorities would be
> >>  > different from yours ;-)
> >>  >
> >>  > Given that we all agreed that the only reason we contemplate use of
> >>  > CMake in our project is strictly to help Windows build, i.e. due to
> >>  > the same reason why we have contrib/buildsystems/, it is not one of
> >>  > my goals to communicate with general users about optional CMake
> >>  > support in the first place. It has lower priority than keeping the
> >>  > project tree and the project history less cluttered.
> >>  >
> >>  > So my first preference would be an instruction somewhere in install
> >>  > or readme that tells those who want to build for windows to copy
> >>  > from (or perhaps update cmake to offer the "-f" option and tell it
> >>  > to read from) contrib/cmake/CMakeLists.txt to the toplevel before
> >>  > doing anything [*1*].
> >>
> >>  FWIW, CMakeLists.txt doesn't have to be in the root of source tree in
> >>  order to work. It can perfectly work from contrib/cmake after necessary
> >>  changes in relative paths.
> >
> > Would you have an example handy, or a link to an article describing this?
>
> It's so trivial that I'm not sure what such an article would have to describe.
>
> https://github.com/annulen/cmake-example
>

Yes, this is trivial, but doing so is bad practice in general and
difficult to maintain.
Won't it be better just to copy the CMakeLists.txt to the root
directory for configuring.

Thank You,
Sibi Siddharthan

> --
> Regards,
> Konstantin
>

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-05-05  4:16                                   ` Sibi Siddharthan
@ 2020-05-05  6:16                                     ` Junio C Hamano
  2020-05-05 16:23                                       ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Junio C Hamano @ 2020-05-05  6:16 UTC (permalink / raw)
  To: Sibi Siddharthan
  Cc: Konstantin Tokarev, Johannes Schindelin, Jeff King, Danh Doan,
	Sibi Siddharthan via GitGitGadget, git

Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:

> Yes, this is trivial, but doing so is bad practice in general and
> difficult to maintain.

Can you substantiate "bad" and "difficult" in the above sentence?

They are so subjective words and sounds more of your "opinion" than
generally accepted "fact".

> Won't it be better just to copy the CMakeLists.txt to the root
> directory for configuring.

I do not know it is better or not compared to using directly from a
subdirectory.  But it is easy to see that it is a bad practice to
keep the source of truth in contrib/cmake/CMakeLists.txt and use it
by copying it to the top of the working tree.  

The reason would be obvious once you imagine what happens when those
who are helping to improve CMake support find that they need to make
changes.  It is too easy to edit the one they copied to the top of
the working tree until they manage to get it working, and then
forget to copy it back to contrib/cmake/ before committing the
change [*1*].

Compared to that, the way Konstantin showed, which is just to be at
the top of the working tree and run the cmake command with a single
argument, which is the path to the CMakeList.txt file, looked quite
simple and straight-forward to an untrained eye that hsan't seen a
real use of CMake.  But there must be reasons, coming from lessons
learned by using CMake with a CMakeList.txt file in a subdirectory
and suffering the consequences of doing so, that makes you say it is
a bad practice and difficult to maintain.  It needs to be spelled
out to help those who do not know CMake understand.

Thanks.


[Footnote]

*1* Creating a symlink CMakeLists.txt at the top of the working tree
that points into contrib/cmake/CMakeLists.txt (and it needs to be
done only once) would avoid such a problem, but if your filesystem
does not let you use a symlink, copying a skeletal CMakeLists.txt
that nobody is expected to modify to the top of the working tree
might be an acceptable workaround.  The sole purpose of that
skeletal CMakeLists.txt at the top of the working tree would be to
include the "real" thing in contrib/cmake/ directory (I am assuming
that CMake is capable of including a CMakeLists.txt file that exists
elsewhere in another CMakeLists.txt file).

With either of these arrangements, it is much less likely for the
user to accidentally edit a "wrong" copy and forgets to update the
real thing---the real thing stored in contrib/cmake will be the only
one that would be edited.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-05-05  6:16                                     ` Junio C Hamano
@ 2020-05-05 16:23                                       ` Sibi Siddharthan
  2020-05-05 18:17                                         ` Junio C Hamano
  2020-05-06 21:27                                         ` Johannes Schindelin
  0 siblings, 2 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-05 16:23 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Konstantin Tokarev, Johannes Schindelin, Jeff King, Danh Doan,
	Sibi Siddharthan via GitGitGadget, git

Hi there,

I have made the following changes as suggested:
1) The CMake script works from contrib/cmake now.
2) The CMake script parses the Makefile for
SCRIPT_SH
SCRIPT_PERL
TEST_BUILTINS_OBJS
LIB_OBJS
BUILTIN_OBJS
XDIFF_OBJS
VCSSVN_OBJS
3) Philip suggested to change the error message if sh/bash was not
found on windows.
4) CMake now tests for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT.

Regarding the commits, since 1,2,4 are additions to the script, is it
acceptable for those changes to be staged in the next commits?
Regarding the workflow file(main.yml), I modified the vs-build and
test steps, should I drop the commit or should I keep the changes(a
modification is further needed if CMake is going to be used for
vs-build)

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-05-05 16:23                                       ` Sibi Siddharthan
@ 2020-05-05 18:17                                         ` Junio C Hamano
  2020-05-06 18:43                                           ` Sibi Siddharthan
  2020-05-06 21:27                                         ` Johannes Schindelin
  1 sibling, 1 reply; 179+ messages in thread
From: Junio C Hamano @ 2020-05-05 18:17 UTC (permalink / raw)
  To: Sibi Siddharthan
  Cc: Konstantin Tokarev, Johannes Schindelin, Jeff King, Danh Doan,
	Sibi Siddharthan via GitGitGadget, git

Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:

> I have made the following changes as suggested:
> 1) The CMake script works from contrib/cmake now.
> 2) The CMake script parses the Makefile for
> SCRIPT_SH
> SCRIPT_PERL
> TEST_BUILTINS_OBJS
> LIB_OBJS
> BUILTIN_OBJS
> XDIFF_OBJS
> VCSSVN_OBJS
> 3) Philip suggested to change the error message if sh/bash was not
> found on windows.
> 4) CMake now tests for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT.
>
> Regarding the commits, since 1,2,4 are additions to the script, is it
> acceptable for those changes to be staged in the next commits?

I am not sure what you exactly mean by "to be staged in the next
commits".  But as a new topic (from the point of view of the general
public), please avoid adding a known-broken one in patch 1 and then
following up with a series of "oops, that was wrong and here is to
fix the breakage" patches.

On the other hand, if the final contents added by the resulting
topic is easier to explain and review if built incrementally in
logical steps, please do so.  In other words, a series of follow up
"now we have basics there, teach the machinery to do this, too"
patches is perfectly fine, as opposed to "oops, that was wrong and
here is to fix".

> Regarding the workflow file(main.yml), I modified the vs-build and
> test steps, should I drop the commit or should I keep the changes(a
> modification is further needed if CMake is going to be used for
> vs-build)

It sounds like an integral part of the end result we would want to
get out of this series, so if that is the case, I do not see a
reason to exclude it.

Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-05-05 18:17                                         ` Junio C Hamano
@ 2020-05-06 18:43                                           ` Sibi Siddharthan
  2020-05-07 11:48                                             ` Đoàn Trần Công Danh
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-06 18:43 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Konstantin Tokarev, Johannes Schindelin, Jeff King, Danh Doan,
	Sibi Siddharthan via GitGitGadget, git

On Tue, May 5, 2020 at 11:47 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:
>
> > I have made the following changes as suggested:
> > 1) The CMake script works from contrib/cmake now.
> > 2) The CMake script parses the Makefile for
> > SCRIPT_SH
> > SCRIPT_PERL
> > TEST_BUILTINS_OBJS
> > LIB_OBJS
> > BUILTIN_OBJS
> > XDIFF_OBJS
> > VCSSVN_OBJS
> > 3) Philip suggested to change the error message if sh/bash was not
> > found on windows.
> > 4) CMake now tests for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT.
> >
> > Regarding the commits, since 1,2,4 are additions to the script, is it
> > acceptable for those changes to be staged in the next commits?
>
> I am not sure what you exactly mean by "to be staged in the next
> commits".  But as a new topic (from the point of view of the general
> public), please avoid adding a known-broken one in patch 1 and then
> following up with a series of "oops, that was wrong and here is to
> fix the breakage" patches.
>
> On the other hand, if the final contents added by the resulting
> topic is easier to explain and review if built incrementally in
> logical steps, please do so.  In other words, a series of follow up
> "now we have basics there, teach the machinery to do this, too"
> patches is perfectly fine, as opposed to "oops, that was wrong and
> here is to fix".
>

2 and 4 are additions to the capability of the script, which means
they have to be added
as separate commits (between 7/8 and 8/8).

3 is clearly an edit (fixup 6/8)

I am confused for 1 though.
I think it would be better to add it as a new commit (between 7/8 and 8/8).
Is this acceptable?

Thank You,
Sibi Siddharthan


> > Regarding the workflow file(main.yml), I modified the vs-build and
> > test steps, should I drop the commit or should I keep the changes(a
> > modification is further needed if CMake is going to be used for
> > vs-build)
>
> It sounds like an integral part of the end result we would want to
> get out of this series, so if that is the case, I do not see a
> reason to exclude it.
>
> Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-05-05 16:23                                       ` Sibi Siddharthan
  2020-05-05 18:17                                         ` Junio C Hamano
@ 2020-05-06 21:27                                         ` Johannes Schindelin
  1 sibling, 0 replies; 179+ messages in thread
From: Johannes Schindelin @ 2020-05-06 21:27 UTC (permalink / raw)
  To: Sibi Siddharthan
  Cc: Junio C Hamano, Konstantin Tokarev, Jeff King, Danh Doan,
	Sibi Siddharthan via GitGitGadget, git

Hi Sibi,

On Tue, 5 May 2020, Sibi Siddharthan wrote:

> Hi there,
>
> I have made the following changes as suggested:
> 1) The CMake script works from contrib/cmake now.
> 2) The CMake script parses the Makefile for
> SCRIPT_SH
> SCRIPT_PERL
> TEST_BUILTINS_OBJS
> LIB_OBJS
> BUILTIN_OBJS
> XDIFF_OBJS
> VCSSVN_OBJS
> 3) Philip suggested to change the error message if sh/bash was not
> found on windows.
> 4) CMake now tests for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT.
>
> Regarding the commits, since 1,2,4 are additions to the script, is it
> acceptable for those changes to be staged in the next commits?
> Regarding the workflow file(main.yml), I modified the vs-build and
> test steps, should I drop the commit or should I keep the changes(a
> modification is further needed if CMake is going to be used for
> vs-build)

Yes, I think it will be crucial to use CMake for vs-build, to keep the
CMake support functional.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-05-06 18:43                                           ` Sibi Siddharthan
@ 2020-05-07 11:48                                             ` Đoàn Trần Công Danh
  0 siblings, 0 replies; 179+ messages in thread
From: Đoàn Trần Công Danh @ 2020-05-07 11:48 UTC (permalink / raw)
  To: Sibi Siddharthan
  Cc: Junio C Hamano, Konstantin Tokarev, Johannes Schindelin,
	Jeff King, Sibi Siddharthan via GitGitGadget, git

On 2020-05-07 00:13:25+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:
> On Tue, May 5, 2020 at 11:47 PM Junio C Hamano <gitster@pobox.com> wrote:
> >
> > Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:
> >
> > > I have made the following changes as suggested:
> > > 1) The CMake script works from contrib/cmake now.
> I am confused for 1 though.
> I think it would be better to add it as a new commit (between 7/8 and 8/8).
> Is this acceptable?

Please make CMake works from contrib/cmake from the first patch in the
series.

-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH 0/8] CMake build system for git
  2020-05-04 21:59                                 ` Konstantin Tokarev
  2020-05-05  4:16                                   ` Sibi Siddharthan
@ 2020-05-07 20:54                                   ` Johannes Schindelin
  1 sibling, 0 replies; 179+ messages in thread
From: Johannes Schindelin @ 2020-05-07 20:54 UTC (permalink / raw)
  To: Konstantin Tokarev
  Cc: Junio C Hamano, Sibi Siddharthan, Jeff King, Danh Doan,
	Sibi Siddharthan via GitGitGadget, git

[-- Attachment #1: Type: text/plain, Size: 2695 bytes --]

Hi Konst,

On Tue, 5 May 2020, Konstantin Tokarev wrote:

> 05.05.2020, 00:32, "Johannes Schindelin" <johannes.schindelin@gmx.de>:
> > Hi Konst,
> >
> > On Sun, 3 May 2020, Konstantin Tokarev wrote:
> >
> >>  03.05.2020, 20:21, "Junio C Hamano" <gitster@pobox.com>:
> >>  > Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:
> >>  >
> >>  >>>  As you say, an extra instruction in INSTALL file to tell users to
> >>  >>>  copy from contrib/cmake may workable, though it is unsatisfactory.
> >>  >>>  But the other one will not simply work. If we need to have a new
> >>  >>>  file with string "CMake" in its name at the top-level *anyway*, we
> >>  >>>  should have the real thing to reduce one step from those who want to
> >>  >>>  use it. Those who do not want to see "CMake" at the toplevel are
> >>  >>>  already harmed either way, if is a dummy or if it is the real thing.
> >>  >>
> >>  >>  In your opinion, what would be the best way to communicate with users, there is
> >>  >>  an optional CMake build system for git?
> >>  >
> >>  > You do not want to hear my opinion, as my priorities would be
> >>  > different from yours ;-)
> >>  >
> >>  > Given that we all agreed that the only reason we contemplate use of
> >>  > CMake in our project is strictly to help Windows build, i.e. due to
> >>  > the same reason why we have contrib/buildsystems/, it is not one of
> >>  > my goals to communicate with general users about optional CMake
> >>  > support in the first place. It has lower priority than keeping the
> >>  > project tree and the project history less cluttered.
> >>  >
> >>  > So my first preference would be an instruction somewhere in install
> >>  > or readme that tells those who want to build for windows to copy
> >>  > from (or perhaps update cmake to offer the "-f" option and tell it
> >>  > to read from) contrib/cmake/CMakeLists.txt to the toplevel before
> >>  > doing anything [*1*].
> >>
> >>  FWIW, CMakeLists.txt doesn't have to be in the root of source tree in
> >>  order to work. It can perfectly work from contrib/cmake after necessary
> >>  changes in relative paths.
> >
> > Would you have an example handy, or a link to an article describing this?
>
> It's so trivial that I'm not sure what such an article would have to describe.
>
> https://github.com/annulen/cmake-example

It is trivial all right, but I had hoped for a more elegant solution along
the lines of `set_top_level_directory(../..)` or some such. I mistook your
mail for having an elegant version of this, and I was curious.

Ciao,
Johannes

> --
> Regards,
> Konstantin
>
>

^ permalink raw reply	[flat|nested] 179+ messages in thread

* [PATCH v2 00/11] CMake build system for git
  2020-04-24  4:01 [PATCH 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                   ` (8 preceding siblings ...)
  2020-04-24 18:56 ` [PATCH 0/8] CMake build system for git Junio C Hamano
@ 2020-05-12 16:50 ` Sibi Siddharthan via GitGitGadget
  2020-05-12 16:50   ` [PATCH v2 01/11] Introduce CMake support for configuring Git on Linux Sibi Siddharthan via GitGitGadget
                     ` (11 more replies)
  9 siblings, 12 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-12 16:50 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan

This is an attempt to build Git using CMake. CMake is cross-platform build
generator which works well on a variety of platforms(primarily Linux and
Windows). Using CMake we can check whether certain headers exist, certain
functions exist, the required libraries are present and configure the build
accordingly. Using CMake we can also build and test Git out of source,
resulting in a clean source tree.

Tested platforms

Ubuntu 18.04 GCC 7.4 Clang 8.0.1

Windows MinGW GCC 9.2 Clang 9 Visual Studio 2015,2017,2019

Changes:

1) The CMake script has been relocated to contrib/buildsystems 2) The CMake
script parses the Makefile for the sources. 3) Philip suggested to change
the error message if sh/bash was not found on windows. 4) CMake now tests
for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT

Sibi Siddharthan (11):
  Introduce CMake support for configuring Git on Linux
  cmake: generate the shell/perl/python scripts and templates,
    translations
  cmake: installation support for git
  cmake: support for testing git with ctest
  cmake: support for testing git when building out of the source tree
  cmake: support for building git on windows with mingw
  cmake: support for building git on windows with msvc and clang.
  cmake: added checks for struct stat and libiconv
  cmake: relocated script file contrib/buildsystems
  cmake: parse the makefile for the sources.
  ci: modification of main.yml to use cmake for vs-build job

 .github/workflows/main.yml          |  46 +-
 contrib/buildsystems/CMakeLists.txt | 945 ++++++++++++++++++++++++++++
 2 files changed, 971 insertions(+), 20 deletions(-)
 create mode 100644 contrib/buildsystems/CMakeLists.txt


base-commit: 744177e7f7fd407c26e9e4aa3b19696859010c48
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-614%2FSibiSiddharthan%2Fgit-og-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-614/SibiSiddharthan/git-og-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/614

Range-diff vs v1:

  1:  70ab1f03dd5 =  1:  70ab1f03dd5 Introduce CMake support for configuring Git on Linux
  2:  ca242cf5bda =  2:  ca242cf5bda cmake: generate the shell/perl/python scripts and templates, translations
  3:  10390063a39 !  3:  b2974432d77 cmake: installation support for git
     @@ Commit message
      
          Then run `make install`
      
     +    Changes:
     +    Removed a comment regarding the installation of gitk.
     +
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
       ## CMakeLists.txt ##
     @@ CMakeLists.txt: if(MSGFMT_EXE)
      +#install
      +install(TARGETS git git-shell
      +	RUNTIME DESTINATION bin)
     -+install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver  #${CMAKE_SOURCE_DIR}/gitk-git/gitk check
     ++install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver
      +	DESTINATION bin)
      +
      +list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)
  4:  35a3554df3e !  4:  2bd8870fb96 cmake: support for testing git with ctest
     @@ Commit message
      
          NOTE: Testing only works when building in source for now.
      
     +    Changes:
     +    Renamed the variable test_helper_sources to test-tool_SOURCES
     +    to be consistent with the naming of source variables.
     +
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
       ## CMakeLists.txt ##
     @@ CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION
      +add_executable(test-svn-fe t/helper/test-svn-fe.c)
      +target_link_libraries(test-svn-fe common-main vcs-svn)
      +
     -+set(test_helper_sources
     ++set(test-tool_SOURCES
      +	t/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c
      +	t/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c
      +	t/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c
     @@ CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION
      +	t/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c
      +	t/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)
      +
     -+add_executable(test-tool ${test_helper_sources})
     ++add_executable(test-tool ${test-tool_SOURCES})
      +target_link_libraries(test-tool common-main)
      +
      +set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
  5:  166b78f7175 =  5:  096f6311ad5 cmake: support for testing git when building out of the source tree
  6:  d6c630028bf !  6:  00cae10bbb7 cmake: support for building git on windows with mingw
     @@ Commit message
          To use CMake on Windows with MinGW do this:
          cmake `relative-path-to-srcdir` -G "MinGW Makefiles"
      
     +    Changes:
     +    Changed the error message when sh.exe is not found on Windows as
     +    suggested by Philip Oakley <philipoakley@iee.email>
     +
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
       ## CMakeLists.txt ##
     @@ CMakeLists.txt: if(Intl_FOUND)
       
       find_program(SH_EXE sh)
      +if(NOT SH_EXE)
     -+	message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")
     ++	message(FATAL_ERROR "sh: shell interpreter was not found in your path, please install one."
     ++			"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
      +endif()
      +
      +if(WIN32)
  7:  0577d7bf0a8 !  7:  af6c606881d cmake: support for building git on windows with msvc and clang.
     @@ CMakeLists.txt: find_package(ZLIB REQUIRED)
       if(NOT Intl_FOUND)
       	add_compile_definitions(NO_GETTEXT)
      @@ CMakeLists.txt: if(NOT SH_EXE)
     - 	message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")
     + 			"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
       endif()
       
      -if(WIN32)
  -:  ----------- >  8:  f496cd7d8aa cmake: added checks for struct stat and libiconv
  -:  ----------- >  9:  9c674372fb5 cmake: relocated script file contrib/buildsystems
  -:  ----------- > 10:  b0a321a714a cmake: parse the makefile for the sources.
  8:  f0294be3f11 ! 11:  fa1b8032906 ci: modification of main.yml to use cmake for vs-build job
     @@ Commit message
          FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been
          added to revert to the old behaviour.
      
     +    Edit(Explanation for the reordering of build steps):
     +    In the configuration phase CMake looks for the required libraries for
     +    building git (eg zlib,libiconv). So we extract the libraries before we
     +    configure.
     +
     +    Changes:
     +    The CMake script has been relocated to contib/buildsystems, so point
     +    to the CMakeLists.txt in the invocation commands.
     +
     +    The generation command now uses the absolute paths for the generation
     +    step.
     +
     +    To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working
     +    directory of script or path. So we copy the dlls before we configure.
     +
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
       ## .github/workflows/main.yml ##
     @@ .github/workflows/main.yml: jobs:
               Remove-Item compat.zip
           - name: add msbuild to PATH
             uses: microsoft/setup-msbuild@v1.0.0
     -+    - name: generate Visual Studio solution
     ++    - name: copy dlls to root
      +      shell: powershell
      +      run: |
     -+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
     -+          cmake . -DCMAKE_PREFIX_PATH=./compat/vcbuild/vcpkg/installed/x64-windows -DMSGFMT_EXE=./git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
     -+        "@
     ++        & compat\vcbuild\vcpkg_copy_dlls.bat release
      +        if (!$?) { exit(1) }
     ++    - name: generate Visual Studio solution
     ++      shell: bash
     ++      run: cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows -DMSGFMT_EXE=`pwd`/git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
           - name: MSBuild
             run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
           - name: bundle artifact tar
     +@@ .github/workflows/main.yml: jobs:
     +         MSVC: 1
     +         VCPKG_ROOT: ${{github.workspace}}\compat\vcbuild\vcpkg
     +       run: |
     +-        & compat\vcbuild\vcpkg_copy_dlls.bat release
     +-        if (!$?) { exit(1) }
     +         & git-sdk-64-minimal\usr\bin\bash.exe -lc @"
     +           mkdir -p artifacts &&
     +           eval \"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts 2>&1 | grep ^tar)\"
      @@ .github/workflows/main.yml: jobs:
               nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
           steps:

-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 179+ messages in thread

* [PATCH v2 01/11] Introduce CMake support for configuring Git on Linux
  2020-05-12 16:50 ` [PATCH v2 00/11] " Sibi Siddharthan via GitGitGadget
@ 2020-05-12 16:50   ` Sibi Siddharthan via GitGitGadget
  2020-05-12 20:59     ` Junio C Hamano
  2020-05-12 16:50   ` [PATCH v2 02/11] cmake: generate the shell/perl/python scripts and templates, translations Sibi Siddharthan via GitGitGadget
                     ` (10 subsequent siblings)
  11 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-12 16:50 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

At the moment, the recommended way to configure Git's builds is to
simply run `make`. If that does not work, the recommended strategy is to
look at the top of the `Makefile` to see whether any "Makefile knob" has
to be turned on/off, e.g. `make NO_OPENSSL=YesPlease`.

Alternatively, Git also has an `autoconf` setup which allows configuring
builds via `./configure [<option>...]`.

Both of these options are fine if the developer works on Unix or Linux.
But on Windows, we have to jump through hoops to configure a build
(read: we force the user to install a full Git for Windows SDK, which
occupies around two gigabytes (!) on disk and downloads about three
quarters of a gigabyte worth of Git objects).

To make this a little less awkward, the Git for Windows project offers
the `vs/master` branch which has a full Visual Studio solution generated
and committed. This branch can therefore be used to tinker with Git in
Visual Studio _without_ having to download the full Git for Windows SDK.
Unfortunatly, that branch is auto-generated from Git for Windows'
`master`. If a developer wants to tinker, say, with `pu`, they are out
of luck.

CMake was invented to make this sort of problem go away, by providing a
more standardized, cross-platform way to configure builds.

With a working support CMake, developers on Windows need only install
CMake, configure their build, load the generated Visual Studio solution
and immediately start modifying the code and build their own version of
Git. Likewise, developers on other platforms can use the convenient GUI
tools provided by CMake to configure their build.

So let's start building CMake support for Git.

This is only the first step, and to make it easier to review, it only
allows for configuring builds on the platform that is easiest to
configure for: Linux.

The CMake script checks whether the headers are present(eg. libgen.h),
whether the functions are present(eg. memmem), whether the funtions work
properly (eg. snprintf) and generate the required compile definitions
for the platform. The script also searches for the required libraries,
if it fails to find the required libraries the respective executables
won't be built.(eg. If libcurl is not found then git-remote-http won't
be built). This will help building Git easier.

With a CMake script an out of source build of git is possible resulting
in a clean source tree.

Note: earlier endeavors on the Git mailing list to introduce CMake ended
up in dead water. The primary reason for that was that reviewers
_expected_ CMake support to fall out of maintenance, unless the
contributor would promise to keep an eye on keeping CMake support up to
date. However, in the meantime, support for automated testing has been
introduced in Git's source code, and a later patch will modify the
(still experimental) GitHub workflow to continually verify that CMake
support is still complete. That will make maintenance reasonably easy.

Note: this patch asks for the minimum version v3.14 of CMake (which is
not all that old as of time of writing) because that is the first
version to offer a platform-independent way to generate hardlinks as
part of the build. This is needed to generate all those hardlinks for
the built-in commands of Git.

Instructions to run CMake:

cmake `relative-path-to-srcdir` -DCMAKE_BUILD_TYPE=Release

Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
compiler flags
Debug : -g
Release: -O3
RelWithDebInfo : -O2 -g
MinSizeRel : -Os
empty(default) :

NOTE: -DCMAKE_BUILD_TYPE is optional

This process generates a Makefile.
Then run `make` to build Git.

NOTE: By default CMake uses Makefile as the build tool on Linux, to use
another tool say `ninja` add this to the command line when configuring.
`-G Ninja`

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 CMakeLists.txt | 528 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 528 insertions(+)
 create mode 100644 CMakeLists.txt

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 00000000000..73703bd321f
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,528 @@
+#
+#	Copyright (c) 2020 Sibi Siddharthan
+#
+
+cmake_minimum_required(VERSION 3.14)
+
+#Parse GIT-VERSION-GEN to get the version
+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
+string(REPLACE "DEF_VER=v" "" git_version ${git_version})
+string(REPLACE ".GIT" ".0" git_version ${git_version})#for building from a snapshot
+
+project(git
+	VERSION ${git_version}
+	LANGUAGES C)
+
+
+include(CheckTypeSize)
+include(CheckCSourceRuns)
+include(CheckCSourceCompiles)
+include(CheckIncludeFile)
+include(CheckFunctionExists)
+include(CheckSymbolExists)
+include(CheckStructHasMember)
+
+find_package(ZLIB REQUIRED)
+find_package(CURL)
+find_package(EXPAT)
+find_package(Iconv)
+find_package(Intl)
+
+if(NOT Intl_FOUND)
+	add_compile_definitions(NO_GETTEXT)
+	if(NOT Iconv_FOUND)
+		add_compile_definitions(NO_ICONV)
+	endif()
+endif()
+
+include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
+if(CURL_FOUND)
+	include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
+endif()
+if(EXPAT_FOUND)
+	include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
+endif()
+if(Iconv_FOUND)
+	include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
+endif()
+if(Intl_FOUND)
+	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
+endif()
+
+find_program(SH_EXE sh)
+
+#default behaviour
+include_directories(${CMAKE_SOURCE_DIR})
+add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
+add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)
+add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES
+			SHA1DC_INIT_SAFE_HASH_DEFAULT=0
+			SHA1DC_CUSTOM_INCLUDE_SHA1_C="cache.h"
+			SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="git-compat-util.h" )
+list(APPEND compat_SOURCES sha1dc_git.c sha1dc/sha1.c sha1dc/ubc_check.c block-sha1/sha1.c sha256/block/sha256.c compat/qsort_s.c)
+
+
+add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
+			ETC_GITATTRIBUTES="etc/gitattributes"
+			ETC_GITCONFIG="etc/gitconfig"
+			GIT_EXEC_PATH="libexec/git-core"
+			GIT_LOCALE_PATH="share/locale"
+			GIT_MAN_PATH="share/man"
+			GIT_INFO_PATH="share/info"
+			GIT_HTML_PATH="share/doc/git-doc"
+			DEFAULT_HELP_FORMAT="html"
+			DEFAULT_GIT_TEMPLATE_DIR="share/git-core/templates"
+			GIT_VERSION="${PROJECT_VERSION}.GIT"
+			GIT_USER_AGENT="git/${PROJECT_VERSION}.GIT"
+			BINDIR="bin"
+			GIT_BUILT_FROM_COMMIT="")
+
+set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+
+add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
+list(APPEND compat_SOURCES unix-socket.c)
+
+#header checks
+check_include_file(libgen.h HAVE_LIBGEN_H)
+if(NOT HAVE_LIBGEN_H)
+	add_compile_definitions(NO_LIBGEN_H)
+	list(APPEND compat_SOURCES compat/basename.c)
+endif()
+
+check_include_file(sys/sysinfo.h HAVE_SYSINFO)
+if(HAVE_SYSINFO)
+	add_compile_definitions(HAVE_SYSINFO)
+endif()
+
+check_c_source_compiles("
+#include <alloca.h>
+int
+main ()
+{
+char *p = (char *) alloca (2 * sizeof (int));
+	if (p) return 0;
+	return 0;
+}"
+HAVE_ALLOCA_H)
+if(HAVE_ALLOCA_H)
+	add_compile_definitions(HAVE_ALLOCA_H)
+endif()
+
+check_include_file(strings.h HAVE_STRINGS_H)
+if(HAVE_STRINGS_H)
+	add_compile_definitions(HAVE_STRINGS_H)
+endif()
+
+check_include_file(sys/select.h HAVE_SYS_SELECT_H)
+if(NOT HAVE_SYS_SELECT_H)
+	add_compile_definitions(NO_SYS_SELECT_H)
+endif()
+
+check_include_file(sys/poll.h HAVE_SYS_POLL_H)
+if(NOT HAVE_SYS_POLL_H)
+	add_compile_definitions(NO_SYS_POLL_H)
+endif()
+
+check_include_file(poll.h HAVE_POLL_H)
+if(NOT HAVE_POLL_H)
+	add_compile_definitions(NO_POLL_H)
+endif()
+
+check_include_file(inttypes.h HAVE_INTTYPES_H)
+if(NOT HAVE_INTTYPES_H)
+	add_compile_definitions(NO_INTTYPES_H)
+endif()
+
+check_include_file(paths.h HAVE_PATHS_H)
+if(HAVE_PATHS_H)
+	add_compile_definitions(HAVE_PATHS_H)
+endif()
+
+#function checks
+set(function_checks
+	strcasestr memmem strlcpy strtoimax strtoumax strtoull
+	setenv  mkdtemp poll pread  memmem unsetenv hstrerror)
+
+foreach(f ${function_checks})
+	string(TOUPPER ${f} uf)
+	check_function_exists(${f} HAVE_${uf})
+	if(NOT HAVE_${uf})
+		add_compile_definitions(NO_${uf})
+	endif()
+endforeach()
+
+if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)
+	include_directories(compat/poll)
+	add_compile_definitions(NO_POLL)
+	list(APPEND compat_SOURCES compat/poll/poll.c)
+endif()
+
+if(NOT HAVE_STRCASESTR)
+	list(APPEND compat_SOURCES compat/strcasestr.c)
+endif()
+
+if(NOT HAVE_STRLCPY)
+	list(APPEND compat_SOURCES compat/strlcpy.c)
+endif()
+
+if(NOT HAVE_STRTOUMAX)
+	list(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c)
+endif()
+
+if(NOT HAVE_SETENV)
+	list(APPEND compat_SOURCES compat/setenv.c)
+endif()
+
+if(NOT HAVE_MKDTEMP)
+	list(APPEND compat_SOURCES compat/mkdtemp.c)
+endif()
+
+if(NOT HAVE_PREAD)
+	list(APPEND compat_SOURCES compat/pread.c)
+endif()
+
+if(NOT HAVE_MEMMEM)
+	list(APPEND compat_SOURCES compat/memmem.c)
+endif()
+
+if(NOT WIN32)
+	if(NOT HAVE_UNSETENV)
+		list(APPEND compat_SOURCES compat/unsetenv.c)
+	endif()
+
+	if(NOT HAVE_HSTRERROR)
+		list(APPEND compat_SOURCES compat/hstrerror.c)
+	endif()
+endif()
+
+check_function_exists(getdelim HAVE_GETDELIM)
+if(HAVE_GETDELIM)
+	add_compile_definitions(HAVE_GETDELIM)
+endif()
+
+check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
+check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC)
+if(HAVE_CLOCK_GETTIME)
+	add_compile_definitions(HAVE_CLOCK_GETTIME)
+endif()
+if(HAVE_CLOCK_MONOTONIC)
+	add_compile_definitions(HAVE_CLOCK_MONOTONIC)
+endif()
+
+
+#compile checks
+check_c_source_runs("
+#include<stdio.h>
+#include<stdarg.h>
+#include<string.h>
+#include<stdlib.h>
+int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
+{
+	int ret;
+	va_list ap;
+
+	va_start(ap, format);
+	ret = vsnprintf(str, maxsize, format, ap);
+	va_end(ap);
+	return ret;
+}
+
+int
+main ()
+{
+	char buf[6];
+	if (test_vsnprintf(buf, 3, \"%s\", \"12345\") != 5
+		|| strcmp(buf, \"12\")) return 1;
+	if (snprintf(buf, 3, \"%s\", \"12345\") != 5
+		|| strcmp(buf, \"12\")) return 1;
+
+	return 0;
+}"
+SNPRINTF_OK)
+if(NOT SNPRINTF_OK)
+	add_compile_definitions(SNPRINTF_RETURNS_BOGUS)
+	list(APPEND compat_SOURCES compat/snprintf.c)
+endif()
+
+check_c_source_runs("
+#include<stdio.h>
+int
+main ()
+{
+	FILE *f = fopen(\".\", \"r\");
+	return f != NULL;
+
+	return 0;
+}"
+FREAD_READS_DIRECTORIES_NO)
+if(NOT FREAD_READS_DIRECTORIES_NO)
+	add_compile_definitions(FREAD_READS_DIRECTORIES)
+	list(APPEND compat_SOURCES compat/fopen.c)
+endif()
+
+check_c_source_compiles("
+#include <regex.h>
+#ifndef REG_STARTEND
+#error oops we dont have it
+#endif
+int main(){return 0;}"
+HAVE_REGEX)
+if(NOT HAVE_REGEX)
+	include_directories(compat/regex )
+	list(APPEND compat_SOURCES compat/regex/regex.c )
+	add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
+endif()
+
+
+check_c_source_compiles("
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+int
+main ()
+{
+	int val, mib[2];
+	size_t len;
+
+	mib[0] = CTL_HW;
+	mib[1] = 1;
+	len = sizeof(val);
+	return sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;
+
+	return 0;
+}"
+HAVE_BSD_SYSCTL)
+if(HAVE_BSD_SYSCTL)
+	add_compile_definitions(HAVE_BSD_SYSCTL)
+endif()
+
+#programs
+set(PROGRAMS_BUILT
+	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
+	git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
+
+if(NOT CURL_FOUND)
+	list(APPEND excluded_progs git-http-fetch git-http-push)
+	add_compile_definitions(NO_CURL)
+	message(WARNING "git-http-push and git-http-fetch will not be built")
+else()
+	list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
+	if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
+		add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
+	endif()
+endif()
+
+if(NOT EXPAT_FOUND)
+	list(APPEND excluded_progs git-http-push)
+	add_compile_definitions(NO_EXPAT)
+else()
+	list(APPEND PROGRAMS_BUILT git-http-push)
+	if(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2)
+		add_compile_definitions(EXPAT_NEEDS_XMLPARSE_H)
+	endif()
+endif()
+
+list(REMOVE_DUPLICATES excluded_progs)
+list(REMOVE_DUPLICATES PROGRAMS_BUILT)
+
+
+foreach(p ${excluded_progs})
+	list(APPEND EXCLUSION_PROGS --exclude-program ${p} )
+endforeach()
+
+#for comparing null values
+list(APPEND EXCLUSION_PROGS empty)
+set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" FORCE)
+
+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
+	list(REMOVE_ITEM EXCLUSION_PROGS empty)
+	message("Generating command-list.h")
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/command-list.h)
+endif()
+
+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/config-list.h)
+	message("Generating config-list.h")
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/config-list.h)
+endif()
+
+
+#build
+set(libgit_SOURCES
+	abspath.c add-interactive.c add-patch.c advice.c alias.c
+	alloc.c apply.c archive.c archive-tar.c archive-zip.c argv-array.c
+	attr.c base85.c bisect.c blame.c blob.c bloom.c branch.c bulk-checkin.c
+	bundle.c cache-tree.c chdir-notify.c checkout.c color.c column.c
+	combine-diff.c commit.c commit-graph.c commit-reach.c compat/obstack.c
+	compat/terminal.c config.c connect.c connected.c convert.c copy.c credential.c
+	csum-file.c ctype.c date.c decorate.c delta-islands.c diffcore-break.c
+	diffcore-delta.c diffcore-order.c diffcore-pickaxe.c diffcore-rename.c
+	diff-delta.c diff-lib.c diff-no-index.c diff.c dir.c dir-iterator.c editor.c
+	entry.c environment.c ewah/bitmap.c ewah/ewah_bitmap.c ewah/ewah_io.c
+	ewah/ewah_rlw.c exec-cmd.c fetch-negotiator.c fetch-pack.c fmt-merge-msg.c fsck.c fsmonitor.c
+	gettext.c gpg-interface.c graph.c grep.c hashmap.c linear-assignment.c help.c hex.c
+	ident.c interdiff.c json-writer.c kwset.c levenshtein.c line-log.c line-range.c list-objects.c
+	list-objects-filter.c list-objects-filter-options.c ll-merge.c lockfile.c
+	log-tree.c ls-refs.c mailinfo.c mailmap.c match-trees.c mem-pool.c merge.c merge-blobs.c
+	merge-recursive.c mergesort.c midx.c name-hash.c negotiator/default.c
+	negotiator/skipping.c notes.c notes-cache.c notes-merge.c notes-utils.c object.c oidmap.c
+	oidset.c oid-array.c packfile.c pack-bitmap.c pack-bitmap-write.c pack-check.c pack-objects.c
+	pack-revindex.c pack-write.c pager.c parse-options.c parse-options-cb.c patch-delta.c
+	patch-ids.c path.c pathspec.c pkt-line.c preload-index.c pretty.c prio-queue.c progress.c
+	promisor-remote.c prompt.c protocol.c prune-packed.c quote.c range-diff.c reachable.c read-cache.c rebase.c
+	rebase-interactive.c reflog-walk.c refs.c refs/files-backend.c refs/iterator.c
+	refs/packed-backend.c refs/ref-cache.c refspec.c ref-filter.c remote.c replace-object.c
+	repo-settings.c repository.c rerere.c reset.c resolve-undo.c revision.c run-command.c
+	send-pack.c sequencer.c serve.c server-info.c setup.c sha1-lookup.c
+	sha1-file.c sha1-name.c shallow.c sideband.c sigchain.c split-index.c
+	stable-qsort.c strbuf.c streaming.c string-list.c submodule.c submodule-config.c
+	sub-process.c symlinks.c tag.c tempfile.c thread-utils.c tmp-objdir.c
+	trace.c trace2.c trace2/tr2_cfg.c trace2/tr2_cmd_name.c trace2/tr2_dst.c
+	trace2/tr2_sid.c trace2/tr2_sysenv.c trace2/tr2_tbuf.c trace2/tr2_tgt_event.c
+	trace2/tr2_tgt_normal.c trace2/tr2_tgt_perf.c trace2/tr2_tls.c trailer.c transport.c
+	transport-helper.c tree-diff.c tree.c tree-walk.c unpack-trees.c upload-pack.c url.c
+	urlmatch.c usage.c userdiff.c utf8.c varint.c version.c versioncmp.c walker.c wildmatch.c
+	worktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c
+	zlib.c)
+
+add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
+
+set(libxdiff_SOURCES
+	xdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c
+	xdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)
+add_library(xdiff STATIC ${libxdiff_SOURCES})
+
+set(libvcs-svn_SOURCES
+	vcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c
+	vcs-svn/svndiff.c vcs-svn/svndump.c)
+add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
+
+#link all required libraries to common-main
+add_library(common-main OBJECT common-main.c)
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
+if(Intl_FOUND)
+	target_link_libraries(common-main ${Intl_LIBRARIES})
+endif()
+if(Iconv_FOUND)
+	target_link_libraries(common-main ${Iconv_LIBRARIES})
+endif()
+
+
+set(git_SOURCES
+	builtin/add.c builtin/am.c builtin/annotate.c builtin/apply.c
+	builtin/archive.c builtin/bisect--helper.c builtin/blame.c
+	builtin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c
+	builtin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c
+	builtin/checkout-index.c builtin/checkout.c builtin/clean.c
+	builtin/clone.c builtin/column.c builtin/commit-tree.c
+	builtin/commit.c builtin/commit-graph.c builtin/config.c
+	builtin/count-objects.c builtin/credential.c builtin/describe.c
+	builtin/diff-files.c builtin/diff-index.c builtin/diff-tree.c
+	builtin/diff.c builtin/difftool.c builtin/env--helper.c
+	builtin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c
+	builtin/for-each-ref.c builtin/fsck.c builtin/gc.c
+	builtin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c
+	builtin/help.c builtin/index-pack.c builtin/init-db.c
+	builtin/interpret-trailers.c builtin/log.c builtin/ls-files.c
+	builtin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c
+	builtin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c
+	builtin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c
+	builtin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c
+	builtin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c
+	builtin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c
+	builtin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c
+	builtin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c
+	builtin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c
+	builtin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c
+	builtin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c
+	builtin/show-branch.c builtin/show-index.c builtin/show-ref.c
+	builtin/sparse-checkout.c builtin/stash.c builtin/stripspace.c
+	builtin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c
+	builtin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c
+	builtin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c
+	builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c
+	builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)
+
+add_executable(git git.c ${git_SOURCES})
+target_link_libraries(git common-main )
+
+add_executable(git-bugreport bugreport.c)
+target_link_libraries(git-bugreport common-main)
+
+add_executable(git-credential-store credential-store.c)
+target_link_libraries(git-credential-store common-main)
+
+add_executable(git-daemon daemon.c)
+target_link_libraries(git-daemon common-main)
+
+add_executable(git-fast-import fast-import.c)
+target_link_libraries(git-fast-import common-main)
+
+add_executable(git-http-backend http-backend.c)
+target_link_libraries(git-http-backend common-main)
+
+add_executable(git-sh-i18n--envsubst sh-i18n--envsubst.c)
+target_link_libraries(git-sh-i18n--envsubst common-main)
+
+add_executable(git-shell shell.c)
+target_link_libraries(git-shell common-main)
+
+if(CURL_FOUND)
+	add_library(http_obj OBJECT http.c)
+
+	add_executable(git-imap-send imap-send.c)
+	target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})
+
+	add_executable(git-http-fetch http-walker.c http-fetch.c)
+	target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})
+
+	add_executable(git-remote-http http-walker.c remote-curl.c)
+	target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )
+
+	if(EXPAT_FOUND)
+		add_executable(git-http-push http-push.c)
+		target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
+	endif()
+endif()
+
+add_executable(git-remote-testsvn remote-testsvn.c)
+target_link_libraries(git-remote-testsvn common-main vcs-svn)
+
+add_executable(git-credential-cache credential-cache.c)
+target_link_libraries(git-credential-cache common-main)
+
+add_executable(git-credential-cache--daemon credential-cache--daemon.c)
+target_link_libraries(git-credential-cache--daemon common-main)
+
+
+set(git_builtin_extra
+	cherry cherry-pick format-patch fsck-objects
+	init merge-subtree restore show
+	stage status switch whatchanged)
+
+#Creating hardlinks
+foreach(s ${git_SOURCES} ${git_builtin_extra})
+	string(REPLACE "builtin/" "" s ${s})
+	string(REPLACE ".c" "" s ${s})
+	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
+	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
+endforeach()
+
+if(CURL_FOUND)
+	set(remote_exes
+		git-remote-https git-remote-ftp git-remote-ftps)
+	foreach(s ${remote_exes})
+		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
+		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+	endforeach()
+endif()
+
+add_custom_command(OUTPUT ${git_links} ${git_http_links}
+		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
+		DEPENDS git git-remote-http)
+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
\ No newline at end of file
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v2 02/11] cmake: generate the shell/perl/python scripts and templates, translations
  2020-05-12 16:50 ` [PATCH v2 00/11] " Sibi Siddharthan via GitGitGadget
  2020-05-12 16:50   ` [PATCH v2 01/11] Introduce CMake support for configuring Git on Linux Sibi Siddharthan via GitGitGadget
@ 2020-05-12 16:50   ` Sibi Siddharthan via GitGitGadget
  2020-05-12 21:19     ` Junio C Hamano
  2020-05-12 16:50   ` [PATCH v2 03/11] cmake: installation support for git Sibi Siddharthan via GitGitGadget
                     ` (9 subsequent siblings)
  11 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-12 16:50 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch implements the placeholder substitution to generate, say,
`git-request-pull` from `git-request-pull.sh`.

The shell/perl/python scripts and template are generated using CMake
(very similar to what sed does).

The text translations are only build if `msgfmt` is found in your path.

NOTE: The scripts and templates are generated during configuration.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 CMakeLists.txt | 107 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 106 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 73703bd321f..788b53be873 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -51,6 +51,11 @@ endif()
 
 find_program(SH_EXE sh)
 
+find_program(MSGFMT_EXE msgfmt)
+if(NOT MSGFMT_EXE)
+	message(WARNING "Text Translations won't be build")
+endif()
+
 #default behaviour
 include_directories(${CMAKE_SOURCE_DIR})
 add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
@@ -525,4 +530,104 @@ endif()
 add_custom_command(OUTPUT ${git_links} ${git_http_links}
 		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
 		DEPENDS git git-remote-http)
-add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
\ No newline at end of file
+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
+
+
+#creating required scripts
+set(SHELL_PATH /bin/sh)
+set(PERL_PATH /usr/bin/perl)
+set(LOCALEDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
+set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
+set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)
+
+#shell scripts
+set(git_shell_scripts
+	git-bisect git-difftool--helper git-filter-branch
+	git-merge-octopus git-merge-one-file git-merge-resolve
+	git-mergetool git-quiltimport
+	git-request-pull git-submodule git-web--browse
+	git-mergetool--lib git-parse-remote git-rebase--preserve-merges
+	git-sh-setup git-sh-i18n git-instaweb)
+
+foreach(script ${git_shell_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)
+	string(REPLACE "@SHELL_PATH@" "${SHELL_PATH}" content "${content}")
+	string(REPLACE "@@DIFF@@" "diff" content "${content}")
+	string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@GITWEBDIR@" "${GITWEBDIR}" content "${content}")
+	string(REPLACE "@@NO_CURL@@" "" content "${content}")
+	string(REPLACE "@@USE_GETTEXT_SCHEME@@" "" content "${content}")
+	string(REPLACE "# @@BROKEN_PATH_FIX@@" "" content "${content}")
+	string(REPLACE "@@PERL@@" "${PERL_PATH}" content "${content}")
+	string(REPLACE "@@SANE_TEXT_GREP@@" "-a" content "${content}")
+	string(REPLACE "@@PAGER_ENV@@" "LESS=FRX LV=-c" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+endforeach()
+
+#perl scripts
+set(git_perl_scripts
+	git-add--interactive git-archimport git-cvsexportcommit
+	git-cvsimport git-cvsserver git-send-email git-svn)
+
+#create perl header
+file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
+string(REPLACE "@@PATHSEP@@" ":" perl_header "${perl_header}")
+string(REPLACE "@@INSTLIBDIR@@" "${INSTLIBDIR}" perl_header "${perl_header}")
+
+foreach(script ${git_perl_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)
+	string(REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n${perl_header}\n" content "${content}")
+	string(REPLACE "@@GIT_VERSION@@" "${PROJECT_VERSION}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+endforeach()
+
+#python script
+file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)
+string(REPLACE "#!/usr/bin/env python" "#!/usr/bin/python" content "${content}")
+file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})
+
+#perl modules
+file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
+
+foreach(pm ${perl_modules})
+	string(REPLACE "${CMAKE_SOURCE_DIR}/perl/" "" file_path ${pm})
+	file(STRINGS ${pm} content NEWLINE_CONSUME)
+	string(REPLACE "@@LOCALEDIR@@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@@NO_PERL_CPAN_FALLBACKS@@" "" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})
+#test-lib.sh requires perl/build/lib to be the build directory of perl modules
+endforeach()
+
+
+#templates
+file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
+set(hooks_templates
+	applypatch-msg.sample pre-applypatch.sample pre-push.sample
+	commit-msg.sample pre-commit.sample pre-rebase.sample
+	fsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample
+	post-update.sample prepare-commit-msg.sample update.sample)
+
+#templates have @.*@ replacement so use configure_file instead
+#hooks
+foreach(tm ${hooks_templates})
+	configure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)
+endforeach()
+
+#info
+configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)
+
+#this
+configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)
+
+
+#translations
+if(MSGFMT_EXE)
+	set(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)
+	foreach(po ${po_files})
+		file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo
+				COMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)
+		list(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)
+	endforeach()
+	add_custom_target(po-gen ALL DEPENDS ${po_gen})
+endif()
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v2 03/11] cmake: installation support for git
  2020-05-12 16:50 ` [PATCH v2 00/11] " Sibi Siddharthan via GitGitGadget
  2020-05-12 16:50   ` [PATCH v2 01/11] Introduce CMake support for configuring Git on Linux Sibi Siddharthan via GitGitGadget
  2020-05-12 16:50   ` [PATCH v2 02/11] cmake: generate the shell/perl/python scripts and templates, translations Sibi Siddharthan via GitGitGadget
@ 2020-05-12 16:50   ` Sibi Siddharthan via GitGitGadget
  2020-05-12 16:50   ` [PATCH v2 04/11] cmake: support for testing git with ctest Sibi Siddharthan via GitGitGadget
                     ` (8 subsequent siblings)
  11 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-12 16:50 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch provides the facility to install the built binaries and
scripts.

This is very similar to `make install`.
By default the destination directory(DESTDIR) is /usr/local/ on Linux
To set a custom installation path do this:
cmake `relative-path-to-srcdir`
	-DCMAKE_INSTALL_PREFIX=`preferred-install-path`

Then run `make install`

Changes:
Removed a comment regarding the installation of gitk.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 CMakeLists.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 788b53be873..1e9f2fe8ff6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,6 +13,8 @@ project(git
 	VERSION ${git_version}
 	LANGUAGES C)
 
+#TODO gitk git-gui gitweb
+#TODO Add pcre support
 
 include(CheckTypeSize)
 include(CheckCSourceRuns)
@@ -631,3 +633,50 @@ if(MSGFMT_EXE)
 	endforeach()
 	add_custom_target(po-gen ALL DEPENDS ${po_gen})
 endif()
+
+
+#to help with the install
+list(TRANSFORM git_shell_scripts PREPEND "${CMAKE_BINARY_DIR}/")
+list(TRANSFORM git_perl_scripts PREPEND "${CMAKE_BINARY_DIR}/")
+
+#install
+install(TARGETS git git-shell
+	RUNTIME DESTINATION bin)
+install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver
+	DESTINATION bin)
+
+list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)
+install(TARGETS ${PROGRAMS_BUILT}
+	RUNTIME DESTINATION libexec/git-core)
+
+set(bin_links
+	git-receive-pack git-upload-archive git-upload-pack)
+
+foreach(b ${bin_links})
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
+endforeach()
+
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
+
+foreach(b ${git_links})
+	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
+	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+endforeach()
+
+foreach(b ${git_http_links})
+	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
+	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+endforeach()
+
+install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
+	DESTINATION libexec/git-core)
+
+install(DIRECTORY mergetools DESTINATION libexec/git-core)
+install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5
+	FILES_MATCHING PATTERN "*.pm")
+install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)
+
+if(MSGFMT_EXE)
+	install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
+endif()
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v2 04/11] cmake: support for testing git with ctest
  2020-05-12 16:50 ` [PATCH v2 00/11] " Sibi Siddharthan via GitGitGadget
                     ` (2 preceding siblings ...)
  2020-05-12 16:50   ` [PATCH v2 03/11] cmake: installation support for git Sibi Siddharthan via GitGitGadget
@ 2020-05-12 16:50   ` Sibi Siddharthan via GitGitGadget
  2020-05-12 16:50   ` [PATCH v2 05/11] cmake: support for testing git when building out of the source tree Sibi Siddharthan via GitGitGadget
                     ` (7 subsequent siblings)
  11 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-12 16:50 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch provides an alternate way to test git using ctest.
CTest ships with CMake, so there is no additional dependency being
introduced.

To perform the tests with ctest do this after building:
ctest -j[number of jobs]

NOTE: -j is optional, the default number of jobs is 1

Each of the jobs does this:
cd t/ && sh t[something].sh

The reason for using CTest is that it logs the output of the tests
in a neat way, which can be helpful during diagnosis of failures.

After the tests have run ctest generates three log files located in
`build-directory`/Testing/Temporary/

These log files are:

CTestCostData.txt:
This file contains the time taken to complete each test.

LastTestsFailed.log:
This log file contains the names of the tests that have failed in the
run.

LastTest.log:
This log file contains the log of all the tests that have run.
A snippet of the file is given below.

10/901 Testing: D:/my/git-master/t/t0009-prio-queue.sh
10/901 Test: D:/my/git-master/t/t0009-prio-queue.sh
Command: "sh.exe" "D:/my/git-master/t/t0009-prio-queue.sh"
Directory: D:/my/git-master/t
"D:/my/git-master/t/t0009-prio-queue.sh"
Output:
----------------------------------------------------------
ok 1 - basic ordering
ok 2 - mixed put and get
ok 3 - notice empty queue
ok 4 - stack order
passed all 4 test(s)
1..4
<end of output>
Test time =   1.11 sec

NOTE: Testing only works when building in source for now.

Changes:
Renamed the variable test_helper_sources to test-tool_SOURCES
to be consistent with the naming of source variables.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 CMakeLists.txt | 142 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 142 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1e9f2fe8ff6..05fbb05c6ad 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,6 +23,7 @@ include(CheckIncludeFile)
 include(CheckFunctionExists)
 include(CheckSymbolExists)
 include(CheckStructHasMember)
+include(CTest)
 
 find_package(ZLIB REQUIRED)
 find_package(CURL)
@@ -680,3 +681,144 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/
 if(MSGFMT_EXE)
 	install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
 endif()
+
+
+if(BUILD_TESTING)
+
+#tests-helpers
+add_executable(test-fake-ssh t/helper/test-fake-ssh.c)
+target_link_libraries(test-fake-ssh common-main)
+
+add_executable(test-line-buffer t/helper/test-line-buffer.c)
+target_link_libraries(test-line-buffer common-main vcs-svn)
+
+add_executable(test-svn-fe t/helper/test-svn-fe.c)
+target_link_libraries(test-svn-fe common-main vcs-svn)
+
+set(test-tool_SOURCES
+	t/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c
+	t/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c
+	t/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c
+	t/helper/test-dump-fsmonitor.c t/helper/test-dump-split-index.c
+	t/helper/test-dump-untracked-cache.c t/helper/test-example-decorate.c
+	t/helper/test-genrandom.c t/helper/test-genzeros.c t/helper/test-hash.c
+	t/helper/test-hashmap.c t/helper/test-hash-speed.c t/helper/test-index-version.c
+	t/helper/test-json-writer.c t/helper/test-lazy-init-name-hash.c
+	t/helper/test-match-trees.c t/helper/test-mergesort.c t/helper/test-mktemp.c
+	t/helper/test-oidmap.c t/helper/test-online-cpus.c t/helper/test-parse-options.c
+	t/helper/test-parse-pathspec-file.c t/helper/test-path-utils.c t/helper/test-pkt-line.c
+	t/helper/test-prio-queue.c t/helper/test-progress.c t/helper/test-reach.c
+	t/helper/test-read-cache.c t/helper/test-read-graph.c t/helper/test-read-midx.c
+	t/helper/test-ref-store.c t/helper/test-regex.c t/helper/test-repository.c
+	t/helper/test-revision-walking.c t/helper/test-run-command.c t/helper/test-scrap-cache-tree.c
+	t/helper/test-serve-v2.c t/helper/test-sha1.c t/helper/test-oid-array.c t/helper/test-sha256.c
+	t/helper/test-sigchain.c t/helper/test-strcmp-offset.c t/helper/test-string-list.c
+	t/helper/test-submodule-config.c t/helper/test-submodule-nested-repo-config.c t/helper/test-subprocess.c
+	t/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c
+	t/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)
+
+add_executable(test-tool ${test-tool_SOURCES})
+target_link_libraries(test-tool common-main)
+
+set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+			PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)
+
+#wrapper scripts
+set(wrapper_scripts
+	git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)
+
+set(wrapper_test_scripts
+	test-fake-ssh test-line-buffer test-svn-fe test-tool)
+
+
+foreach(script ${wrapper_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@@PROG@@" "${script}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
+endforeach()
+
+foreach(script ${wrapper_test_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
+endforeach()
+
+file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+string(REPLACE "@@PROG@@" "git-cvsserver" content "${content}")
+file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
+
+#options for configuring test options
+option(PERL_TESTS "Perform tests that use perl" ON)
+option(PYTHON_TESTS "Perform tests that use python" ON)
+
+#GIT-BUILD-OPTIONS
+set(TEST_SHELL_PATH ${SHELL_PATH})
+set(DIFF diff)
+set(PYTHON_PATH /usr/bin/python)
+set(TAR tar)
+set(NO_CURL )
+set(NO_EXPAT )
+set(USE_LIBPCRE1 )
+set(USE_LIBPCRE2 )
+set(NO_LIBPCRE1_JIT )
+set(NO_PERL )
+set(NO_PTHREADS )
+set(NO_PYTHON )
+set(PAGER_ENV "LESS=FRX LV=-c")
+set(DC_SHA1 YesPlease)
+set(RUNTIME_PREFIX true)
+set(NO_GETTEXT )
+
+if(NOT CURL_FOUND)
+	set(NO_CURL 1)
+endif()
+
+if(NOT EXPAT_FOUND)
+	set(NO_EXPAT 1)
+endif()
+
+if(NOT Intl_FOUND)
+	set(NO_GETTEXT 1)
+endif()
+
+if(NOT PERL_TESTS)
+	set(NO_PERL 1)
+endif()
+
+if(NOT PYTHON_TESTS)
+	set(NO_PYTHON 1)
+endif()
+
+file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "SHELL_PATH='${SHELL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TEST_SHELL_PATH='${TEST_SHELL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PERL_PATH='${PERL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DIFF='${DIFF}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PYTHON_PATH='${PYTHON_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TAR='${TAR}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_CURL='${NO_CURL}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_EXPAT='${NO_EXPAT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "USE_LIBPCRE1='${USE_LIBPCRE1}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PERL='${NO_PERL}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
+
+file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
+
+#test
+foreach(tsh ${test_scipts})
+	add_test(NAME ${tsh}
+		COMMAND ${SH_EXE} ${tsh}
+		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)
+endforeach()
+
+endif()#BUILD_TESTING
\ No newline at end of file
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v2 05/11] cmake: support for testing git when building out of the source tree
  2020-05-12 16:50 ` [PATCH v2 00/11] " Sibi Siddharthan via GitGitGadget
                     ` (3 preceding siblings ...)
  2020-05-12 16:50   ` [PATCH v2 04/11] cmake: support for testing git with ctest Sibi Siddharthan via GitGitGadget
@ 2020-05-12 16:50   ` Sibi Siddharthan via GitGitGadget
  2020-05-12 16:50   ` [PATCH v2 06/11] cmake: support for building git on windows with mingw Sibi Siddharthan via GitGitGadget
                     ` (6 subsequent siblings)
  11 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-12 16:50 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch allows git to be tested when performin out of source builds.

This involves changing GIT_BUILD_DIR in t/test-lib.sh to point to the
build directory. Also some miscellaneous copies from the source directory
to the build directory.
The copies are:
t/chainlint.sed needed by a bunch of test scripts
po/is.po needed by t0204-gettext-rencode-sanity
mergetools/tkdiff needed by t7800-difftool
contrib/completion/git-prompt.sh needed by t9903-bash-prompt
contrib/completion/git-completion.bash needed by t9902-completion
contrib/svn-fe/svnrdump_sim.py needed by t9020-remote-svn

NOTE: t/test-lib.sh is only modified when tests are run not during
the build or configure.
The trash directory is still srcdir/t

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 CMakeLists.txt | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 05fbb05c6ad..47d3f3c2866 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -812,6 +812,25 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n"
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
 
+#Make the tests work when building out of the source tree
+if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
+	file(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)
+	string(REPLACE "/CMakeCache.txt" "" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})
+	#Setting the build directory in test-lib.sh before running tests
+	file(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake
+		"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \"GIT_BUILD_DIR=(.*)\")\n"
+		"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\n"
+		"string(REPLACE \"\${GIT_BUILD_DIR_REPL}\" \"GIT_BUILD_DIR=\\\"$TEST_DIRECTORY\\\"/../${BUILD_DIR_RELATIVE}\" content \"\${content}\")\n"
+		"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \${content})")
+	#misc copies
+	file(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)
+	file(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)
+	file(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/svn-fe/svnrdump_sim.py DESTINATION ${CMAKE_BINARY_DIR}/contrib/svn-fe/)
+endif()
+
 file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
 
 #test
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v2 06/11] cmake: support for building git on windows with mingw
  2020-05-12 16:50 ` [PATCH v2 00/11] " Sibi Siddharthan via GitGitGadget
                     ` (4 preceding siblings ...)
  2020-05-12 16:50   ` [PATCH v2 05/11] cmake: support for testing git when building out of the source tree Sibi Siddharthan via GitGitGadget
@ 2020-05-12 16:50   ` Sibi Siddharthan via GitGitGadget
  2020-05-14 15:25     ` Đoàn Trần Công Danh
  2020-05-12 16:50   ` [PATCH v2 07/11] cmake: support for building git on windows with msvc and clang Sibi Siddharthan via GitGitGadget
                     ` (5 subsequent siblings)
  11 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-12 16:50 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch facilitates building git on Windows with CMake using MinGW

NOTE: The funtions unsetenv and hstrerror are not checked in Windows
builds.
Reasons
NO_UNSETENV is not compatible with Windows builds.
lines 262-264 compat/mingw.h

compat/mingw.h(line 25) provides a definition of hstrerror which
conflicts with the definition provided in
git-compat-util.h(lines 733-736).

To use CMake on Windows with MinGW do this:
cmake `relative-path-to-srcdir` -G "MinGW Makefiles"

Changes:
Changed the error message when sh.exe is not found on Windows as
suggested by Philip Oakley <philipoakley@iee.email>

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 CMakeLists.txt | 121 +++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 98 insertions(+), 23 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 47d3f3c2866..9625e41886f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,9 +13,12 @@ project(git
 	VERSION ${git_version}
 	LANGUAGES C)
 
+
 #TODO gitk git-gui gitweb
+#TODO Enable NLS on windows natively
 #TODO Add pcre support
 
+
 include(CheckTypeSize)
 include(CheckCSourceRuns)
 include(CheckCSourceCompiles)
@@ -31,6 +34,7 @@ find_package(EXPAT)
 find_package(Iconv)
 find_package(Intl)
 
+
 if(NOT Intl_FOUND)
 	add_compile_definitions(NO_GETTEXT)
 	if(NOT Iconv_FOUND)
@@ -53,6 +57,17 @@ if(Intl_FOUND)
 endif()
 
 find_program(SH_EXE sh)
+if(NOT SH_EXE)
+	message(FATAL_ERROR "sh: shell interpreter was not found in your path, please install one."
+			"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
+endif()
+
+if(WIN32)
+	find_program(WINDRES_EXE windres)
+	if(NOT WINDRES_EXE)
+		message(FATAL_ERROR "Install windres on Windows for resource files")
+	endif()
+endif()
 
 find_program(MSGFMT_EXE msgfmt)
 if(NOT MSGFMT_EXE)
@@ -85,11 +100,39 @@ add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
 			BINDIR="bin"
 			GIT_BUILT_FROM_COMMIT="")
 
-set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
-add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+if(WIN32)
+	set(FALLBACK_RUNTIME_PREFIX /mingw64)
+	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+else()
+	set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+endif()
 
-add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
-list(APPEND compat_SOURCES unix-socket.c)
+
+#Platform Specific
+if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+	include_directories(compat/win32)
+	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
+				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
+				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT
+				USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
+				UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
+	list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
+		compat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c
+		compat/win32/trace2_win32_process_info.c compat/win32/dirent.c
+		compat/nedmalloc/nedmalloc.c compat/strdup.c)
+	set(NO_UNIX_SOCKETS 1)
+
+elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
+	add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
+	list(APPEND compat_SOURCES unix-socket.c)
+endif()
+
+if(WIN32)
+	set(EXE_EXTENSION .exe)
+else()
+	set(EXE_EXTENSION)
+endif()
 
 #header checks
 check_include_file(libgen.h HAVE_LIBGEN_H)
@@ -150,7 +193,12 @@ endif()
 #function checks
 set(function_checks
 	strcasestr memmem strlcpy strtoimax strtoumax strtoull
-	setenv  mkdtemp poll pread  memmem unsetenv hstrerror)
+	setenv  mkdtemp poll pread  memmem)
+
+#unsetenv,hstrerror are incompatible with windows build
+if(NOT WIN32)
+	list(APPEND function_checks unsetenv hstrerror)
+endif()
 
 foreach(f ${function_checks})
 	string(TOUPPER ${f} uf)
@@ -309,7 +357,13 @@ endif()
 #programs
 set(PROGRAMS_BUILT
 	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
-	git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
+	git-shell git-remote-testsvn)
+
+if(NO_UNIX_SOCKETS)
+	list(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)
+else()
+	list(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)
+endif()
 
 if(NOT CURL_FOUND)
 	list(APPEND excluded_progs git-http-fetch git-http-push)
@@ -410,15 +464,34 @@ set(libvcs-svn_SOURCES
 	vcs-svn/svndiff.c vcs-svn/svndump.c)
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
 
+#add git.rc for gcc
+if(WIN32)
+	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+			COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
+				-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
+				-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			VERBATIM)
+	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
+endif()
+
 #link all required libraries to common-main
 add_library(common-main OBJECT common-main.c)
-target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
+
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})
 if(Intl_FOUND)
 	target_link_libraries(common-main ${Intl_LIBRARIES})
 endif()
 if(Iconv_FOUND)
 	target_link_libraries(common-main ${Iconv_LIBRARIES})
 endif()
+if(WIN32)
+	target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
+	add_dependencies(common-main git-rc)
+	target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+elseif(UNIX)
+	target_link_libraries(common-main pthread rt)
+endif()
 
 
 set(git_SOURCES
@@ -501,11 +574,13 @@ endif()
 add_executable(git-remote-testsvn remote-testsvn.c)
 target_link_libraries(git-remote-testsvn common-main vcs-svn)
 
-add_executable(git-credential-cache credential-cache.c)
-target_link_libraries(git-credential-cache common-main)
+if(NOT NO_UNIX_SOCKETS)
+	add_executable(git-credential-cache credential-cache.c)
+	target_link_libraries(git-credential-cache common-main)
 
-add_executable(git-credential-cache--daemon credential-cache--daemon.c)
-target_link_libraries(git-credential-cache--daemon common-main)
+	add_executable(git-credential-cache--daemon credential-cache--daemon.c)
+	target_link_libraries(git-credential-cache--daemon common-main)
+endif()
 
 
 set(git_builtin_extra
@@ -517,16 +592,16 @@ set(git_builtin_extra
 foreach(s ${git_SOURCES} ${git_builtin_extra})
 	string(REPLACE "builtin/" "" s ${s})
 	string(REPLACE ".c" "" s ${s})
-	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
-	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
+	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\n")
+	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})
 endforeach()
 
 if(CURL_FOUND)
 	set(remote_exes
 		git-remote-https git-remote-ftp git-remote-ftps)
 	foreach(s ${remote_exes})
-		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
-		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http${EXE_EXTENSION} ${s}${EXE_EXTENSION})\n")
+		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s}${EXE_EXTENSION})
 	endforeach()
 endif()
 
@@ -654,20 +729,20 @@ set(bin_links
 	git-receive-pack git-upload-archive git-upload-pack)
 
 foreach(b ${bin_links})
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/bin/${b}${EXE_EXTENSION})")
 endforeach()
 
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git${EXE_EXTENSION})")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell${EXE_EXTENSION})")
 
 foreach(b ${git_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
 endforeach()
 
 foreach(b ${git_http_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
 endforeach()
 
 install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
@@ -734,14 +809,14 @@ set(wrapper_test_scripts
 foreach(script ${wrapper_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "${script}" content "${content}")
+	string(REPLACE "@@PROG@@" "${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
 foreach(script ${wrapper_test_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
+	string(REPLACE "@@PROG@@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
@@ -807,7 +882,7 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X='${EXE_EXTENSION}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v2 07/11] cmake: support for building git on windows with msvc and clang.
  2020-05-12 16:50 ` [PATCH v2 00/11] " Sibi Siddharthan via GitGitGadget
                     ` (5 preceding siblings ...)
  2020-05-12 16:50   ` [PATCH v2 06/11] cmake: support for building git on windows with mingw Sibi Siddharthan via GitGitGadget
@ 2020-05-12 16:50   ` Sibi Siddharthan via GitGitGadget
  2020-05-12 16:50   ` [PATCH v2 08/11] cmake: added checks for struct stat and libiconv Sibi Siddharthan via GitGitGadget
                     ` (4 subsequent siblings)
  11 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-12 16:50 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch adds support for Visual Studio and Clang builds

The minimum required version of CMake is upgraded to 3.15 because
this version offers proper support for Clang builds on Windows.

Libintl is not searched for when building with Visual Studio or Clang
because there is no binary compatible version available yet.

NOTE: In the link options invalidcontinue.obj has to be included.
The reason for this is because by default, Windows calls abort()'s
instead of setting errno=EINVAL when invalid arguments are passed to
standard functions.
This commit explains it in detail:
4b623d80f73528a632576990ca51e34c333d5dd6

On Windows the default generator is Visual Studio,so for Visual Studio
builds do this:

cmake `relative-path-to-srcdir`

NOTE: Visual Studio generator is a multi config generator, which means
that Debug and Release builds can be done on the same build directory.

For Clang builds do this:

On bash
CC=Clang cmake `relative-path-to-srcdir` -G Ninja
		-DCMAKE_BUILD_TYPE=[Debug or Release]

On cmd
set CC=Clang
cmake `relative-path-to-srcdir` -G Ninja
		-DCMAKE_BUILD_TYPE=[Debug or Release]

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 CMakeLists.txt | 57 ++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 46 insertions(+), 11 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9625e41886f..4353080b708 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,7 @@
 #	Copyright (c) 2020 Sibi Siddharthan
 #
 
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.15)
 
 #Parse GIT-VERSION-GEN to get the version
 file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
@@ -32,8 +32,11 @@ find_package(ZLIB REQUIRED)
 find_package(CURL)
 find_package(EXPAT)
 find_package(Iconv)
-find_package(Intl)
 
+#Don't use libintl on Windows Visual Studio and Clang builds
+if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")))
+	find_package(Intl)
+endif()
 
 if(NOT Intl_FOUND)
 	add_compile_definitions(NO_GETTEXT)
@@ -62,7 +65,7 @@ if(NOT SH_EXE)
 			"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
 endif()
 
-if(WIN32)
+if(WIN32 AND NOT MSVC)#not required for visual studio builds
 	find_program(WINDRES_EXE windres)
 	if(NOT WINDRES_EXE)
 		message(FATAL_ERROR "Install windres on Windows for resource files")
@@ -74,6 +77,13 @@ if(NOT MSGFMT_EXE)
 	message(WARNING "Text Translations won't be build")
 endif()
 
+#Force all visual studio outputs to CMAKE_BINARY_DIR
+if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
+	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
+	add_compile_options(/MP)
+endif()
+
 #default behaviour
 include_directories(${CMAKE_SOURCE_DIR})
 add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
@@ -111,6 +121,10 @@ endif()
 
 #Platform Specific
 if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+	if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+		include_directories(compat/vcbuild/include)
+		add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
+	endif()
 	include_directories(compat/win32)
 	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
 				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
@@ -464,14 +478,22 @@ set(libvcs-svn_SOURCES
 	vcs-svn/svndiff.c vcs-svn/svndump.c)
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
 
-#add git.rc for gcc
 if(WIN32)
-	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
-			COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
-				-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
-				-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
-			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-			VERBATIM)
+	if(NOT MSVC)#use windres when compiling with gcc and clang
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+				COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
+					-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
+					-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
+				WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+				VERBATIM)
+	else()#MSVC use rc
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+				COMMAND ${CMAKE_RC_COMPILER} /d MAJOR=${PROJECT_VERSION_MAJOR} /d MINOR=${PROJECT_VERSION_MINOR}
+					/d MICRO=${PROJECT_VERSION_PATCH} /d PATCHLEVEL=0 /d GIT_VERSION="${PROJECT_VERSION}.GIT"
+					/fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_SOURCE_DIR}/git.rc
+				WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+				VERBATIM)
+	endif()
 	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
 endif()
 
@@ -488,7 +510,13 @@ endif()
 if(WIN32)
 	target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
 	add_dependencies(common-main git-rc)
-	target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+	if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+		target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+	elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+		target_link_options(common-main PUBLIC -municode -Wl,-nxcompat -Wl,-dynamicbase -Wl,-entry:wmainCRTStartup -Wl,invalidcontinue.obj)
+	elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+		target_link_options(common-main PUBLIC /IGNORE:4217 /IGNORE:4049 /NOLOGO /ENTRY:wmainCRTStartup /SUBSYSTEM:CONSOLE invalidcontinue.obj)
+	endif()
 elseif(UNIX)
 	target_link_libraries(common-main pthread rt)
 endif()
@@ -798,6 +826,13 @@ target_link_libraries(test-tool common-main)
 set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
 			PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)
 
+if(MSVC)
+	set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+				PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)
+	set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+				PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)
+endif()
+
 #wrapper scripts
 set(wrapper_scripts
 	git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v2 08/11] cmake: added checks for struct stat and libiconv
  2020-05-12 16:50 ` [PATCH v2 00/11] " Sibi Siddharthan via GitGitGadget
                     ` (6 preceding siblings ...)
  2020-05-12 16:50   ` [PATCH v2 07/11] cmake: support for building git on windows with msvc and clang Sibi Siddharthan via GitGitGadget
@ 2020-05-12 16:50   ` Sibi Siddharthan via GitGitGadget
  2020-05-12 21:16     ` Junio C Hamano
  2020-05-14 15:31     ` Đoàn Trần Công Danh
  2020-05-12 16:50   ` [PATCH v2 09/11] cmake: relocated script file contrib/buildsystems Sibi Siddharthan via GitGitGadget
                     ` (3 subsequent siblings)
  11 siblings, 2 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-12 16:50 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

The CMake script now checks whether st_blocks is a member of struct stat
and set the compile definition NO_ST_BLOCKS_IN_STRUCT_STAT accordingly.

The check for whether ICONV_OMITS_BOM is also added as requested by Danh.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 CMakeLists.txt | 59 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4353080b708..975791c8b89 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,6 +22,7 @@ project(git
 include(CheckTypeSize)
 include(CheckCSourceRuns)
 include(CheckCSourceCompiles)
+include(CheckCSourceRuns)
 include(CheckIncludeFile)
 include(CheckFunctionExists)
 include(CheckSymbolExists)
@@ -128,7 +129,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
 	include_directories(compat/win32)
 	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
 				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
-				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT
+				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0
 				USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
 				UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
 	list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
@@ -280,6 +281,11 @@ if(HAVE_CLOCK_MONOTONIC)
 	add_compile_definitions(HAVE_CLOCK_MONOTONIC)
 endif()
 
+#check for st_blocks in struct stat
+check_struct_has_member("struct stat" st_blocks "sys/stat.h" STRUCT_STAT_HAS_ST_BLOCKS)
+if(NOT STRUCT_STAT_HAS_ST_BLOCKS)
+	add_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)
+endif()
 
 #compile checks
 check_c_source_runs("
@@ -344,7 +350,6 @@ if(NOT HAVE_REGEX)
 	add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
 endif()
 
-
 check_c_source_compiles("
 #include <stddef.h>
 #include <sys/types.h>
@@ -368,6 +373,56 @@ if(HAVE_BSD_SYSCTL)
 	add_compile_definitions(HAVE_BSD_SYSCTL)
 endif()
 
+set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES})
+set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS})
+
+check_c_source_compiles("
+#include <iconv.h>
+
+extern size_t iconv(iconv_t cd,
+		char **inbuf, size_t *inbytesleft,
+		char **outbuf, size_t *outbytesleft);
+
+int main(){return 0;}"
+HAVE_NEW_ICONV)
+if(HAVE_NEW_ICONV)
+	set(HAVE_OLD_ICONV 0)
+else()
+	set(HAVE_OLD_ICONV 1)
+endif()
+
+check_c_source_runs("
+#include <iconv.h>
+#if ${HAVE_OLD_ICONV}
+typedef const char *iconv_ibp;
+#else
+typedef char *iconv_ibp;
+#endif
+
+int main()
+{
+	int v;
+	iconv_t conv;
+	char in[] = \"a\"; iconv_ibp pin = in;
+	char out[20] = \"\"; char *pout = out;
+	size_t isz = sizeof in;
+	size_t osz = sizeof out;
+
+	conv = iconv_open(\"UTF-16\", \"UTF-8\");
+	iconv(conv, &pin, &isz, &pout, &osz);
+	iconv_close(conv);
+	v = (unsigned char)(out[0]) + (unsigned char)(out[1]);
+	return v != 0xfe + 0xff;
+}"
+ICONV_DOESNOT_OMIT_BOM)
+if(NOT ICONV_DOESNOT_OMIT_BOM)
+	add_compile_definitions(ICONV_OMITS_BOM)
+endif()
+
+unset(CMAKE_REQUIRED_LIBRARIES)
+unset(CMAKE_REQUIRED_INCLUDES)
+
+
 #programs
 set(PROGRAMS_BUILT
 	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v2 09/11] cmake: relocated script file contrib/buildsystems
  2020-05-12 16:50 ` [PATCH v2 00/11] " Sibi Siddharthan via GitGitGadget
                     ` (7 preceding siblings ...)
  2020-05-12 16:50   ` [PATCH v2 08/11] cmake: added checks for struct stat and libiconv Sibi Siddharthan via GitGitGadget
@ 2020-05-12 16:50   ` Sibi Siddharthan via GitGitGadget
  2020-05-12 21:09     ` Junio C Hamano
  2020-05-12 16:50   ` [PATCH v2 10/11] cmake: parse the makefile for the sources Sibi Siddharthan via GitGitGadget
                     ` (2 subsequent siblings)
  11 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-12 16:50 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

The CMake script has been relocated to contrib/buildsystems.
The changes made to the script involves pointing to correct location
of the source files.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 .../buildsystems/CMakeLists.txt               | 76 +++++++++++--------
 1 file changed, 45 insertions(+), 31 deletions(-)
 rename CMakeLists.txt => contrib/buildsystems/CMakeLists.txt (92%)

diff --git a/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
similarity index 92%
rename from CMakeLists.txt
rename to contrib/buildsystems/CMakeLists.txt
index 975791c8b89..e0ce069dc2a 100644
--- a/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -4,6 +4,9 @@
 
 cmake_minimum_required(VERSION 3.15)
 
+#set the source directory to root of git
+set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
+
 #Parse GIT-VERSION-GEN to get the version
 file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
 string(REPLACE "DEF_VER=v" "" git_version ${git_version})
@@ -123,10 +126,10 @@ endif()
 #Platform Specific
 if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
 	if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
-		include_directories(compat/vcbuild/include)
+		include_directories(${CMAKE_SOURCE_DIR}/compat/vcbuild/include)
 		add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
 	endif()
-	include_directories(compat/win32)
+	include_directories(${CMAKE_SOURCE_DIR}/compat/win32)
 	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
 				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
 				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0
@@ -224,7 +227,7 @@ foreach(f ${function_checks})
 endforeach()
 
 if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)
-	include_directories(compat/poll)
+	include_directories(${CMAKE_SOURCE_DIR}/compat/poll)
 	add_compile_definitions(NO_POLL)
 	list(APPEND compat_SOURCES compat/poll/poll.c)
 endif()
@@ -345,7 +348,7 @@ check_c_source_compiles("
 int main(){return 0;}"
 HAVE_REGEX)
 if(NOT HAVE_REGEX)
-	include_directories(compat/regex )
+	include_directories(${CMAKE_SOURCE_DIR}/compat/regex)
 	list(APPEND compat_SOURCES compat/regex/regex.c )
 	add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
 endif()
@@ -467,21 +470,23 @@ endforeach()
 list(APPEND EXCLUSION_PROGS empty)
 set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" FORCE)
 
-if(NOT EXISTS ${CMAKE_SOURCE_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
+if(NOT EXISTS ${CMAKE_BINARY_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
 	list(REMOVE_ITEM EXCLUSION_PROGS empty)
 	message("Generating command-list.h")
 	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
 			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/command-list.h)
+			OUTPUT_FILE ${CMAKE_BINARY_DIR}/command-list.h)
 endif()
 
-if(NOT EXISTS ${CMAKE_SOURCE_DIR}/config-list.h)
+if(NOT EXISTS ${CMAKE_BINARY_DIR}/config-list.h)
 	message("Generating config-list.h")
 	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
 			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/config-list.h)
+			OUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h)
 endif()
 
+include_directories(${CMAKE_BINARY_DIR})
+
 
 #build
 set(libgit_SOURCES
@@ -521,16 +526,22 @@ set(libgit_SOURCES
 	worktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c
 	zlib.c)
 
+list(TRANSFORM libgit_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+list(TRANSFORM compat_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
 
 set(libxdiff_SOURCES
 	xdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c
 	xdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)
+
+list(TRANSFORM libxdiff_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_library(xdiff STATIC ${libxdiff_SOURCES})
 
 set(libvcs-svn_SOURCES
 	vcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c
 	vcs-svn/svndiff.c vcs-svn/svndump.c)
+
+list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
 
 if(WIN32)
@@ -553,7 +564,7 @@ if(WIN32)
 endif()
 
 #link all required libraries to common-main
-add_library(common-main OBJECT common-main.c)
+add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)
 
 target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})
 if(Intl_FOUND)
@@ -612,56 +623,57 @@ set(git_SOURCES
 	builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c
 	builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)
 
-add_executable(git git.c ${git_SOURCES})
+list(TRANSFORM git_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})
 target_link_libraries(git common-main )
 
-add_executable(git-bugreport bugreport.c)
+add_executable(git-bugreport ${CMAKE_SOURCE_DIR}/bugreport.c)
 target_link_libraries(git-bugreport common-main)
 
-add_executable(git-credential-store credential-store.c)
+add_executable(git-credential-store ${CMAKE_SOURCE_DIR}/credential-store.c)
 target_link_libraries(git-credential-store common-main)
 
-add_executable(git-daemon daemon.c)
+add_executable(git-daemon ${CMAKE_SOURCE_DIR}/daemon.c)
 target_link_libraries(git-daemon common-main)
 
-add_executable(git-fast-import fast-import.c)
+add_executable(git-fast-import ${CMAKE_SOURCE_DIR}/fast-import.c)
 target_link_libraries(git-fast-import common-main)
 
-add_executable(git-http-backend http-backend.c)
+add_executable(git-http-backend ${CMAKE_SOURCE_DIR}/http-backend.c)
 target_link_libraries(git-http-backend common-main)
 
-add_executable(git-sh-i18n--envsubst sh-i18n--envsubst.c)
+add_executable(git-sh-i18n--envsubst ${CMAKE_SOURCE_DIR}/sh-i18n--envsubst.c)
 target_link_libraries(git-sh-i18n--envsubst common-main)
 
-add_executable(git-shell shell.c)
+add_executable(git-shell ${CMAKE_SOURCE_DIR}/shell.c)
 target_link_libraries(git-shell common-main)
 
 if(CURL_FOUND)
-	add_library(http_obj OBJECT http.c)
+	add_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c)
 
-	add_executable(git-imap-send imap-send.c)
+	add_executable(git-imap-send ${CMAKE_SOURCE_DIR}/imap-send.c)
 	target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})
 
-	add_executable(git-http-fetch http-walker.c http-fetch.c)
+	add_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c)
 	target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})
 
-	add_executable(git-remote-http http-walker.c remote-curl.c)
+	add_executable(git-remote-http ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/remote-curl.c)
 	target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )
 
 	if(EXPAT_FOUND)
-		add_executable(git-http-push http-push.c)
+		add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
 		target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
 	endif()
 endif()
 
-add_executable(git-remote-testsvn remote-testsvn.c)
+add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)
 target_link_libraries(git-remote-testsvn common-main vcs-svn)
 
 if(NOT NO_UNIX_SOCKETS)
-	add_executable(git-credential-cache credential-cache.c)
+	add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)
 	target_link_libraries(git-credential-cache common-main)
 
-	add_executable(git-credential-cache--daemon credential-cache--daemon.c)
+	add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)
 	target_link_libraries(git-credential-cache--daemon common-main)
 endif()
 
@@ -673,7 +685,7 @@ set(git_builtin_extra
 
 #Creating hardlinks
 foreach(s ${git_SOURCES} ${git_builtin_extra})
-	string(REPLACE "builtin/" "" s ${s})
+	string(REPLACE "${CMAKE_SOURCE_DIR}/builtin/" "" s ${s})
 	string(REPLACE ".c" "" s ${s})
 	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\n")
 	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})
@@ -831,7 +843,7 @@ endforeach()
 install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
 	DESTINATION libexec/git-core)
 
-install(DIRECTORY mergetools DESTINATION libexec/git-core)
+install(DIRECTORY ${CMAKE_SOURCE_DIR}/mergetools DESTINATION libexec/git-core)
 install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5
 	FILES_MATCHING PATTERN "*.pm")
 install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)
@@ -844,13 +856,13 @@ endif()
 if(BUILD_TESTING)
 
 #tests-helpers
-add_executable(test-fake-ssh t/helper/test-fake-ssh.c)
+add_executable(test-fake-ssh ${CMAKE_SOURCE_DIR}/t/helper/test-fake-ssh.c)
 target_link_libraries(test-fake-ssh common-main)
 
-add_executable(test-line-buffer t/helper/test-line-buffer.c)
+add_executable(test-line-buffer ${CMAKE_SOURCE_DIR}/t/helper/test-line-buffer.c)
 target_link_libraries(test-line-buffer common-main vcs-svn)
 
-add_executable(test-svn-fe t/helper/test-svn-fe.c)
+add_executable(test-svn-fe ${CMAKE_SOURCE_DIR}/t/helper/test-svn-fe.c)
 target_link_libraries(test-svn-fe common-main vcs-svn)
 
 set(test-tool_SOURCES
@@ -875,6 +887,7 @@ set(test-tool_SOURCES
 	t/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c
 	t/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)
 
+list(TRANSFORM test-tool_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_executable(test-tool ${test-tool_SOURCES})
 target_link_libraries(test-tool common-main)
 
@@ -978,7 +991,8 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PRE
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
 
 #Make the tests work when building out of the source tree
-if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
+get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE)
+if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})
 	file(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)
 	string(REPLACE "/CMakeCache.txt" "" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})
 	#Setting the build directory in test-lib.sh before running tests
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v2 10/11] cmake: parse the makefile for the sources.
  2020-05-12 16:50 ` [PATCH v2 00/11] " Sibi Siddharthan via GitGitGadget
                     ` (8 preceding siblings ...)
  2020-05-12 16:50   ` [PATCH v2 09/11] cmake: relocated script file contrib/buildsystems Sibi Siddharthan via GitGitGadget
@ 2020-05-12 16:50   ` Sibi Siddharthan via GitGitGadget
  2020-05-12 21:03     ` Junio C Hamano
  2020-05-12 16:50   ` [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job Sibi Siddharthan via GitGitGadget
  2020-05-29 13:40   ` [PATCH v3 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
  11 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-12 16:50 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

The CMake script parses the Makefile for:
SCRIPT_SH
SCRIPT_PERL
TEST_BUILTINS_OBJS
LIB_OBJS
BUILTIN_OBJS
XDIFF_OBJS
VCSSVN_OBJS

By doing this we avoid duplication of text between the Makefile and
the CMake script.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 137 ++++++----------------------
 1 file changed, 30 insertions(+), 107 deletions(-)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index e0ce069dc2a..4592ce614cf 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -21,6 +21,25 @@ project(git
 #TODO Enable NLS on windows natively
 #TODO Add pcre support
 
+#macros for parsing the Makefile for sources and scripts
+macro(parse_makefile_for_sources list_var regex)
+	file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
+	string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
+	string(REPLACE "$(COMPAT_OBJS)" "" ${list_var} ${${list_var}}) #remove "$(COMPAT_OBJS)" This is only for libgit.
+	string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
+	string(REPLACE ".o" ".c;" ${list_var} ${${list_var}}) #change .o to .c, ; is for converting the string into a list
+	list(TRANSFORM ${list_var} STRIP) #remove trailing/leading whitespaces for each element in list
+	list(REMOVE_ITEM ${list_var} "") #remove empty list elements
+endmacro()
+
+macro(parse_makefile_for_scripts list_var regex lang)
+	file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
+	string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
+	string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
+	string(REPLACE " " ";" ${list_var} ${${list_var}}) #convert string to a list
+	list(TRANSFORM ${list_var} REPLACE "${lang}" "") #do the replacement
+endmacro()
+
 
 include(CheckTypeSize)
 include(CheckCSourceRuns)
@@ -489,57 +508,18 @@ include_directories(${CMAKE_BINARY_DIR})
 
 
 #build
-set(libgit_SOURCES
-	abspath.c add-interactive.c add-patch.c advice.c alias.c
-	alloc.c apply.c archive.c archive-tar.c archive-zip.c argv-array.c
-	attr.c base85.c bisect.c blame.c blob.c bloom.c branch.c bulk-checkin.c
-	bundle.c cache-tree.c chdir-notify.c checkout.c color.c column.c
-	combine-diff.c commit.c commit-graph.c commit-reach.c compat/obstack.c
-	compat/terminal.c config.c connect.c connected.c convert.c copy.c credential.c
-	csum-file.c ctype.c date.c decorate.c delta-islands.c diffcore-break.c
-	diffcore-delta.c diffcore-order.c diffcore-pickaxe.c diffcore-rename.c
-	diff-delta.c diff-lib.c diff-no-index.c diff.c dir.c dir-iterator.c editor.c
-	entry.c environment.c ewah/bitmap.c ewah/ewah_bitmap.c ewah/ewah_io.c
-	ewah/ewah_rlw.c exec-cmd.c fetch-negotiator.c fetch-pack.c fmt-merge-msg.c fsck.c fsmonitor.c
-	gettext.c gpg-interface.c graph.c grep.c hashmap.c linear-assignment.c help.c hex.c
-	ident.c interdiff.c json-writer.c kwset.c levenshtein.c line-log.c line-range.c list-objects.c
-	list-objects-filter.c list-objects-filter-options.c ll-merge.c lockfile.c
-	log-tree.c ls-refs.c mailinfo.c mailmap.c match-trees.c mem-pool.c merge.c merge-blobs.c
-	merge-recursive.c mergesort.c midx.c name-hash.c negotiator/default.c
-	negotiator/skipping.c notes.c notes-cache.c notes-merge.c notes-utils.c object.c oidmap.c
-	oidset.c oid-array.c packfile.c pack-bitmap.c pack-bitmap-write.c pack-check.c pack-objects.c
-	pack-revindex.c pack-write.c pager.c parse-options.c parse-options-cb.c patch-delta.c
-	patch-ids.c path.c pathspec.c pkt-line.c preload-index.c pretty.c prio-queue.c progress.c
-	promisor-remote.c prompt.c protocol.c prune-packed.c quote.c range-diff.c reachable.c read-cache.c rebase.c
-	rebase-interactive.c reflog-walk.c refs.c refs/files-backend.c refs/iterator.c
-	refs/packed-backend.c refs/ref-cache.c refspec.c ref-filter.c remote.c replace-object.c
-	repo-settings.c repository.c rerere.c reset.c resolve-undo.c revision.c run-command.c
-	send-pack.c sequencer.c serve.c server-info.c setup.c sha1-lookup.c
-	sha1-file.c sha1-name.c shallow.c sideband.c sigchain.c split-index.c
-	stable-qsort.c strbuf.c streaming.c string-list.c submodule.c submodule-config.c
-	sub-process.c symlinks.c tag.c tempfile.c thread-utils.c tmp-objdir.c
-	trace.c trace2.c trace2/tr2_cfg.c trace2/tr2_cmd_name.c trace2/tr2_dst.c
-	trace2/tr2_sid.c trace2/tr2_sysenv.c trace2/tr2_tbuf.c trace2/tr2_tgt_event.c
-	trace2/tr2_tgt_normal.c trace2/tr2_tgt_perf.c trace2/tr2_tls.c trailer.c transport.c
-	transport-helper.c tree-diff.c tree.c tree-walk.c unpack-trees.c upload-pack.c url.c
-	urlmatch.c usage.c userdiff.c utf8.c varint.c version.c versioncmp.c walker.c wildmatch.c
-	worktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c
-	zlib.c)
+parse_makefile_for_sources(libgit_SOURCES "LIB_OBJS")
 
 list(TRANSFORM libgit_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 list(TRANSFORM compat_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
 
-set(libxdiff_SOURCES
-	xdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c
-	xdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)
+parse_makefile_for_sources(libxdiff_SOURCES "XDIFF_OBJS")
 
 list(TRANSFORM libxdiff_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_library(xdiff STATIC ${libxdiff_SOURCES})
 
-set(libvcs-svn_SOURCES
-	vcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c
-	vcs-svn/svndiff.c vcs-svn/svndump.c)
+parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
 
 list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
@@ -588,40 +568,7 @@ elseif(UNIX)
 endif()
 
 
-set(git_SOURCES
-	builtin/add.c builtin/am.c builtin/annotate.c builtin/apply.c
-	builtin/archive.c builtin/bisect--helper.c builtin/blame.c
-	builtin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c
-	builtin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c
-	builtin/checkout-index.c builtin/checkout.c builtin/clean.c
-	builtin/clone.c builtin/column.c builtin/commit-tree.c
-	builtin/commit.c builtin/commit-graph.c builtin/config.c
-	builtin/count-objects.c builtin/credential.c builtin/describe.c
-	builtin/diff-files.c builtin/diff-index.c builtin/diff-tree.c
-	builtin/diff.c builtin/difftool.c builtin/env--helper.c
-	builtin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c
-	builtin/for-each-ref.c builtin/fsck.c builtin/gc.c
-	builtin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c
-	builtin/help.c builtin/index-pack.c builtin/init-db.c
-	builtin/interpret-trailers.c builtin/log.c builtin/ls-files.c
-	builtin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c
-	builtin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c
-	builtin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c
-	builtin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c
-	builtin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c
-	builtin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c
-	builtin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c
-	builtin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c
-	builtin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c
-	builtin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c
-	builtin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c
-	builtin/show-branch.c builtin/show-index.c builtin/show-ref.c
-	builtin/sparse-checkout.c builtin/stash.c builtin/stripspace.c
-	builtin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c
-	builtin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c
-	builtin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c
-	builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c
-	builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)
+parse_makefile_for_sources(git_SOURCES "BUILTIN_OBJS")
 
 list(TRANSFORM git_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})
@@ -714,11 +661,9 @@ set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
 set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)
 
 #shell scripts
+parse_makefile_for_scripts(git_sh_scripts "SCRIPT_SH" ".sh")
 set(git_shell_scripts
-	git-bisect git-difftool--helper git-filter-branch
-	git-merge-octopus git-merge-one-file git-merge-resolve
-	git-mergetool git-quiltimport
-	git-request-pull git-submodule git-web--browse
+	${git_sh_scripts}
 	git-mergetool--lib git-parse-remote git-rebase--preserve-merges
 	git-sh-setup git-sh-i18n git-instaweb)
 
@@ -738,9 +683,7 @@ foreach(script ${git_shell_scripts})
 endforeach()
 
 #perl scripts
-set(git_perl_scripts
-	git-add--interactive git-archimport git-cvsexportcommit
-	git-cvsimport git-cvsserver git-send-email git-svn)
+parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" ".perl")
 
 #create perl header
 file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
@@ -865,30 +808,10 @@ target_link_libraries(test-line-buffer common-main vcs-svn)
 add_executable(test-svn-fe ${CMAKE_SOURCE_DIR}/t/helper/test-svn-fe.c)
 target_link_libraries(test-svn-fe common-main vcs-svn)
 
-set(test-tool_SOURCES
-	t/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c
-	t/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c
-	t/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c
-	t/helper/test-dump-fsmonitor.c t/helper/test-dump-split-index.c
-	t/helper/test-dump-untracked-cache.c t/helper/test-example-decorate.c
-	t/helper/test-genrandom.c t/helper/test-genzeros.c t/helper/test-hash.c
-	t/helper/test-hashmap.c t/helper/test-hash-speed.c t/helper/test-index-version.c
-	t/helper/test-json-writer.c t/helper/test-lazy-init-name-hash.c
-	t/helper/test-match-trees.c t/helper/test-mergesort.c t/helper/test-mktemp.c
-	t/helper/test-oidmap.c t/helper/test-online-cpus.c t/helper/test-parse-options.c
-	t/helper/test-parse-pathspec-file.c t/helper/test-path-utils.c t/helper/test-pkt-line.c
-	t/helper/test-prio-queue.c t/helper/test-progress.c t/helper/test-reach.c
-	t/helper/test-read-cache.c t/helper/test-read-graph.c t/helper/test-read-midx.c
-	t/helper/test-ref-store.c t/helper/test-regex.c t/helper/test-repository.c
-	t/helper/test-revision-walking.c t/helper/test-run-command.c t/helper/test-scrap-cache-tree.c
-	t/helper/test-serve-v2.c t/helper/test-sha1.c t/helper/test-oid-array.c t/helper/test-sha256.c
-	t/helper/test-sigchain.c t/helper/test-strcmp-offset.c t/helper/test-string-list.c
-	t/helper/test-submodule-config.c t/helper/test-submodule-nested-repo-config.c t/helper/test-subprocess.c
-	t/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c
-	t/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)
-
-list(TRANSFORM test-tool_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
-add_executable(test-tool ${test-tool_SOURCES})
+parse_makefile_for_sources(test-tool_SOURCES "TEST_BUILTINS_OBJS")
+
+list(TRANSFORM test-tool_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/t/helper/")
+add_executable(test-tool ${CMAKE_SOURCE_DIR}/t/helper/test-tool.c ${test-tool_SOURCES})
 target_link_libraries(test-tool common-main)
 
 set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job
  2020-05-12 16:50 ` [PATCH v2 00/11] " Sibi Siddharthan via GitGitGadget
                     ` (9 preceding siblings ...)
  2020-05-12 16:50   ` [PATCH v2 10/11] cmake: parse the makefile for the sources Sibi Siddharthan via GitGitGadget
@ 2020-05-12 16:50   ` Sibi Siddharthan via GitGitGadget
  2020-05-12 21:27     ` Junio C Hamano
  2020-05-29 13:40   ` [PATCH v3 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
  11 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-12 16:50 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch modifies .github/workflows/main.yml to use CMake for
Visual Studio builds.

Modified the vs-test step to match windows-test step. This speeds
up the vs-test. Calling git-cmd from powershell and then calling git-bash
to perform the tests slows things down(factor of about 6). So git-bash
is directly called from powershell to perform the tests using prove.

NOTE: Since GitHub keeps the same directory for each job
(with respect to path) absolute paths are used in the bin-wrapper
scripts.

GitHub has switched to CMake 3.17.1 which changed the behaviour of
FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been
added to revert to the old behaviour.

Edit(Explanation for the reordering of build steps):
In the configuration phase CMake looks for the required libraries for
building git (eg zlib,libiconv). So we extract the libraries before we
configure.

Changes:
The CMake script has been relocated to contib/buildsystems, so point
to the CMakeLists.txt in the invocation commands.

The generation command now uses the absolute paths for the generation
step.

To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working
directory of script or path. So we copy the dlls before we configure.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 .github/workflows/main.yml | 46 +++++++++++++++++++++-----------------
 1 file changed, 26 insertions(+), 20 deletions(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index fd4df939b50..7a65cc0764f 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -80,13 +80,6 @@ jobs:
     - name: download git-sdk-64-minimal
       shell: bash
       run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
-    - name: generate Visual Studio solution
-      shell: powershell
-      run: |
-        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
-          make NDEBUG=1 DEVELOPER=1 vcxproj
-        "@
-        if (!$?) { exit(1) }
     - name: download vcpkg artifacts
       shell: powershell
       run: |
@@ -98,6 +91,14 @@ jobs:
         Remove-Item compat.zip
     - name: add msbuild to PATH
       uses: microsoft/setup-msbuild@v1.0.0
+    - name: copy dlls to root
+      shell: powershell
+      run: |
+        & compat\vcbuild\vcpkg_copy_dlls.bat release
+        if (!$?) { exit(1) }
+    - name: generate Visual Studio solution
+      shell: bash
+      run: cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows -DMSGFMT_EXE=`pwd`/git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
     - name: MSBuild
       run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
     - name: bundle artifact tar
@@ -106,8 +107,6 @@ jobs:
         MSVC: 1
         VCPKG_ROOT: ${{github.workspace}}\compat\vcbuild\vcpkg
       run: |
-        & compat\vcbuild\vcpkg_copy_dlls.bat release
-        if (!$?) { exit(1) }
         & git-sdk-64-minimal\usr\bin\bash.exe -lc @"
           mkdir -p artifacts &&
           eval \"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts 2>&1 | grep ^tar)\"
@@ -125,9 +124,9 @@ jobs:
         nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
     steps:
     - uses: actions/checkout@v1
-    - name: download git-64-portable
+    - name: download git-sdk-64-minimal
       shell: bash
-      run: a=git-64-portable && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
+      run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
     - name: download build artifacts
       uses: actions/download-artifact@v1
       with:
@@ -136,23 +135,30 @@ jobs:
     - name: extract build artifacts
       shell: bash
       run: tar xf artifacts.tar.gz
-    - name: test (parallel)
+    - name: test
       shell: powershell
       env:
         MSYSTEM: MINGW64
         NO_SVN_TESTS: 1
         GIT_TEST_SKIP_REBASE_P: 1
       run: |
-        & git-64-portable\git-cmd.exe --command=usr\bin\bash.exe -lc @"
-          # Let Git ignore the SDK and the test-cache
-          printf '%s\n' /git-64-portable/ /test-cache/ >>.git/info/exclude
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
+          # Let Git ignore the SDK
+          printf '%s\n' /git-sdk-64-minimal/ >>.git/info/exclude
 
-          cd t &&
-          PATH=\"`$PWD/helper:`$PATH\" &&
-          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \
-                  `$(test-tool.exe path-utils slice-tests \
-                          ${{matrix.nr}} 10 t[0-9]*.sh)
+          ci/run-test-slice.sh ${{matrix.nr}} 10
         "@
+    - name: ci/print-test-failures.sh
+      if: failure()
+      shell: powershell
+      run: |
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc ci/print-test-failures.sh
+    - name: Upload failed tests' directories
+      if: failure() && env.FAILED_TEST_ARTIFACTS != ''
+      uses: actions/upload-artifact@v1
+      with:
+        name: failed-tests-windows
+        path: ${{env.FAILED_TEST_ARTIFACTS}}
   regular:
     strategy:
       matrix:
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 01/11] Introduce CMake support for configuring Git on Linux
  2020-05-12 16:50   ` [PATCH v2 01/11] Introduce CMake support for configuring Git on Linux Sibi Siddharthan via GitGitGadget
@ 2020-05-12 20:59     ` Junio C Hamano
  2020-05-13 20:21       ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Junio C Hamano @ 2020-05-12 20:59 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

"Sibi Siddharthan via GitGitGadget" <gitgitgadget@gmail.com> writes:

> To make this a little less awkward, the Git for Windows project offers
> the `vs/master` branch which has a full Visual Studio solution generated
> and committed. This branch can therefore be used to tinker with Git in
> Visual Studio _without_ having to download the full Git for Windows SDK.
> Unfortunatly, that branch is auto-generated from Git for Windows'
> `master`. If a developer wants to tinker, say, with `pu`, they are out
> of luck.

'pu' or 'next' are not to be built upon, so this is not a good line
of reasoning to complain that generating only for 'master' is bad.

> CMake was invented to make this sort of problem go away, by providing a
> more standardized, cross-platform way to configure builds.

I think everything above this point (including Makefile, autoconf
etc.) can be replaced with a single sentence

	The build infrastructure for Git is written around being
	able to run make, which is not supported natively on
	Windows.

without anything else.  That will flow naturally to

	Add a build script that uses CMake to help developers on
	Windows to build git.

and then you can continue the current state, like this paragraph.

> This is only the first step, and to make it easier to review, it only
> allows for configuring builds on the platform that is easiest to
> configure for: Linux.
>
> The CMake script checks whether the headers are present(eg. libgen.h),
> whether the functions are present(eg. memmem), whether the funtions work
> properly (eg. snprintf) and generate the required compile definitions
> for the platform. The script also searches for the required libraries,
> if it fails to find the required libraries the respective executables
> won't be built.(eg. If libcurl is not found then git-remote-http won't
> be built). This will help building Git easier.
>
> With a CMake script an out of source build of git is possible resulting
> in a clean source tree.


> Note: earlier endeavors on the Git mailing list to introduce CMake ended
> up in dead water. The primary reason for that was that reviewers
> _expected_ CMake support to fall out of maintenance, unless the
> contributor would promise to keep an eye on keeping CMake support up to
> date. However, in the meantime, support for automated testing has been
> introduced in Git's source code, and a later patch will modify the
> (still experimental) GitHub workflow to continually verify that CMake
> support is still complete. That will make maintenance reasonably easy.

I am not sure this belongs to the log message.

> Note: this patch asks for the minimum version v3.14 of CMake (which is
> not all that old as of time of writing) because that is the first
> version to offer a platform-independent way to generate hardlinks as
> part of the build. This is needed to generate all those hardlinks for
> the built-in commands of Git.

This does, but I do not think hardlinks are not required for our
build.  On Unix filesystems, it is not just possible but convenient
to use, and that is the only reason why we use hardlinks.

If hardlinks are possible but inconvenient to use on Windows, you
shouldn't force your target audience to use it.

> Instructions to run CMake:
>
> cmake `relative-path-to-srcdir` -DCMAKE_BUILD_TYPE=Release
>
> Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
> compiler flags
> Debug : -g
> Release: -O3
> RelWithDebInfo : -O2 -g
> MinSizeRel : -Os
> empty(default) :
>
> NOTE: -DCMAKE_BUILD_TYPE is optional
>
> This process generates a Makefile.
> Then run `make` to build Git.
>
> NOTE: By default CMake uses Makefile as the build tool on Linux, to use
> another tool say `ninja` add this to the command line when configuring.
> `-G Ninja`

I find it curious that from the instruction, the most important
platform, the primary reason why we are reviewing this patch, is
missing.  Don't Windows folks need to be told how to run CMake to
build?

In any case, all of the above "Instructions" should go at the top
part of CMakeLists.txt in a comment, and not in the log message.
"git log" output is not an easy way for your target audience to
learn how to use what the commit adds.  Think what they need to do
when they discover there is CMakeLists.txt in our tree in three
months.  Don't force them to run "git blame" to find this commit
that added the support.

> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> ---
>  CMakeLists.txt | 528 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 528 insertions(+)
>  create mode 100644 CMakeLists.txt
>
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> new file mode 100644
> index 00000000000..73703bd321f
> --- /dev/null
> +++ b/CMakeLists.txt
> @@ -0,0 +1,528 @@
> +#
> +#	Copyright (c) 2020 Sibi Siddharthan
> +#
> +
> +cmake_minimum_required(VERSION 3.14)
> +
> +#Parse GIT-VERSION-GEN to get the version
> +file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
> +string(REPLACE "DEF_VER=v" "" git_version ${git_version})
> +string(REPLACE ".GIT" ".0" git_version ${git_version})#for building from a snapshot

Hmph, I'd really prefer to see the logic in GIT-VERSION-GEN not
bypassed like this.  People know they can create a text file 'version'
and record the version name they desire in it and expect GIT-VERSION-GEN
to pick it up, for example.

Later in this file, you seem to depend on the shell to do things
like generating config-list.h file, so I'd rather see the same
technique used here a well.

> +set(libgit_SOURCES
> +	abspath.c add-interactive.c add-patch.c advice.c alias.c
> +...
> +	zlib.c)

Hmph.

> +set(git_SOURCES
> +	builtin/add.c builtin/am.c builtin/annotate.c builtin/apply.c
> +	builtin/archive.c builtin/bisect--helper.c builtin/blame.c
> +	builtin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c
> +	builtin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c
> +	builtin/checkout-index.c builtin/checkout.c builtin/clean.c
> +	builtin/clone.c builtin/column.c builtin/commit-tree.c
> +	builtin/commit.c builtin/commit-graph.c builtin/config.c
> +	builtin/count-objects.c builtin/credential.c builtin/describe.c
> +	builtin/diff-files.c builtin/diff-index.c builtin/diff-tree.c
> +	builtin/diff.c builtin/difftool.c builtin/env--helper.c
> +	builtin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c
> +	builtin/for-each-ref.c builtin/fsck.c builtin/gc.c
> +	builtin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c
> +	builtin/help.c builtin/index-pack.c builtin/init-db.c
> +	builtin/interpret-trailers.c builtin/log.c builtin/ls-files.c
> +	builtin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c
> +	builtin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c
> +	builtin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c
> +	builtin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c
> +	builtin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c
> +	builtin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c
> +	builtin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c
> +	builtin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c
> +	builtin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c
> +	builtin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c
> +	builtin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c
> +	builtin/show-branch.c builtin/show-index.c builtin/show-ref.c
> +	builtin/sparse-checkout.c builtin/stash.c builtin/stripspace.c
> +	builtin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c
> +	builtin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c
> +	builtin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c
> +	builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c
> +	builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)

Can't we do a bit better here?  

Perhaps grab this out of our Makefile?  The same command applies to
huge lists of sources we have seen.

Or do the equivalent of $(wildcard builtin/*.c) if CMake has such a
feature?

> ...
> \ No newline at end of file

Double check and make sure you have a text file without an incomplete
line at the end.

Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 10/11] cmake: parse the makefile for the sources.
  2020-05-12 16:50   ` [PATCH v2 10/11] cmake: parse the makefile for the sources Sibi Siddharthan via GitGitGadget
@ 2020-05-12 21:03     ` Junio C Hamano
  2020-05-13 19:57       ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Junio C Hamano @ 2020-05-12 21:03 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

"Sibi Siddharthan via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
>
> The CMake script parses the Makefile for:
> SCRIPT_SH
> SCRIPT_PERL
> TEST_BUILTINS_OBJS
> LIB_OBJS
> BUILTIN_OBJS
> XDIFF_OBJS
> VCSSVN_OBJS
>
> By doing this we avoid duplication of text between the Makefile and
> the CMake script.

Thanks, this makes perfect sense, but it probably should have been
done from the very beginning, without copying the huge list manually
in the step [01/11].

How robust is the "parser"?  Do we need to leave an instruction to
Makefile writers to conform to certain style to help CMake users as
an additional comment in the Makefile, or is any reasonable textual
drift still accepted?


^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 09/11] cmake: relocated script file contrib/buildsystems
  2020-05-12 16:50   ` [PATCH v2 09/11] cmake: relocated script file contrib/buildsystems Sibi Siddharthan via GitGitGadget
@ 2020-05-12 21:09     ` Junio C Hamano
  2020-05-13 20:08       ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Junio C Hamano @ 2020-05-12 21:09 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

"Sibi Siddharthan via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
>
> The CMake script has been relocated to contrib/buildsystems.
> The changes made to the script involves pointing to correct location
> of the source files.

This does match what the list agreed to do.  Why isn't this done as
part of [01/11]?  If there is no technical reason not to, I'd
strongly prefer to see it done from the very beginning.  The same
comment applies to the next step.

Thanks.

> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> ---
>  .../buildsystems/CMakeLists.txt               | 76 +++++++++++--------
>  1 file changed, 45 insertions(+), 31 deletions(-)
>  rename CMakeLists.txt => contrib/buildsystems/CMakeLists.txt (92%)

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv
  2020-05-12 16:50   ` [PATCH v2 08/11] cmake: added checks for struct stat and libiconv Sibi Siddharthan via GitGitGadget
@ 2020-05-12 21:16     ` Junio C Hamano
  2020-05-13 20:05       ` Sibi Siddharthan
  2020-05-14 15:31     ` Đoàn Trần Công Danh
  1 sibling, 1 reply; 179+ messages in thread
From: Junio C Hamano @ 2020-05-12 21:16 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

"Sibi Siddharthan via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> Subject: Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv

s/added/add/; give a command to the codebase to "be like so", or a
command to whoever is typing changes to the editor to "make this
happen".

> The CMake script now checks whether st_blocks is a member of struct stat
> and set the compile definition NO_ST_BLOCKS_IN_STRUCT_STAT accordingly.

	Teach the CMake script to check ...

> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 4353080b708..975791c8b89 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -22,6 +22,7 @@ project(git
>  include(CheckTypeSize)
>  include(CheckCSourceRuns)
>  include(CheckCSourceCompiles)
> +include(CheckCSourceRuns)
> ...
> +#check for st_blocks in struct stat
> +check_struct_has_member("struct stat" st_blocks "sys/stat.h" STRUCT_STAT_HAS_ST_BLOCKS)
> +if(NOT STRUCT_STAT_HAS_ST_BLOCKS)
> +	add_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)
> +endif()

All of these compatibility stuff makes sense, but how do we decide
where to draw the line between the checks we saw added in [01/11]
and the checks added here?  It feels pretty arbitrary to me and if
that is the case, perhaps we want to move all the "add checks" to a
commit separate from [01/11] (whose primary purpose is to add the
basic rules without these build tweaks in the file at the final
place)?


^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 02/11] cmake: generate the shell/perl/python scripts and templates, translations
  2020-05-12 16:50   ` [PATCH v2 02/11] cmake: generate the shell/perl/python scripts and templates, translations Sibi Siddharthan via GitGitGadget
@ 2020-05-12 21:19     ` Junio C Hamano
  2020-05-13 20:07       ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Junio C Hamano @ 2020-05-12 21:19 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

"Sibi Siddharthan via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
>
> This patch implements the placeholder substitution to generate, say,
> `git-request-pull` from `git-request-pull.sh`.
>
> The shell/perl/python scripts and template are generated using CMake
> (very similar to what sed does).

We do not say "This patch does X" or "I do Y in this patch".
perhaps.

	Implement the placeholder substitution to generate scripted
	Porcelain commands, e.g. git-request-pull out of
	git-request-pull.sh

	Generate scripts and templates using CMake, instead of using
	sed like the build procedure in the Makefile does.


^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job
  2020-05-12 16:50   ` [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job Sibi Siddharthan via GitGitGadget
@ 2020-05-12 21:27     ` Junio C Hamano
  2020-05-13 19:45       ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Junio C Hamano @ 2020-05-12 21:27 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

"Sibi Siddharthan via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> Subject: Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job

Yay!

> This patch modifies .github/workflows/main.yml to use CMake for
> Visual Studio builds.
> Modified the vs-test step to match windows-test step. This speeds

	Teach .github/workflows/main.yml to use Cmake for VS builds.
	Modify vs-test step to match windows-test step to speed up
	the vs-test.

> Changes:
> The CMake script has been relocated to contib/buildsystems, so point
> to the CMakeLists.txt in the invocation commands.

This does not belong to the log message for this (or any for that
matter) commit, no?  Up to this point, nothing in main.yml used
CMake script from anywhere, and "has been relocated" is irrelevant.

And if we add CMake script to contrib/buildsystems/ from the
beginning in [01/11], there won't be any "relocation" the readers of
the log message of this step need to know about.

> The generation command now uses the absolute paths for the generation
> step.

"now uses"?  Is that something the readers of the log message of
this step need to know about, or is it "in contrast to an earlier
attempt to add CMake script"?  If the latter, it only confuses the
readers of our history, as most of them will not even know about an
earlier attempt.

Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job
  2020-05-12 21:27     ` Junio C Hamano
@ 2020-05-13 19:45       ` Sibi Siddharthan
  2020-05-25 19:16         ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-13 19:45 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Sibi Siddharthan via GitGitGadget, git

On Wed, May 13, 2020 at 2:57 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Sibi Siddharthan via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> > Subject: Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job
>
> Yay!
>
> > This patch modifies .github/workflows/main.yml to use CMake for
> > Visual Studio builds.
> > Modified the vs-test step to match windows-test step. This speeds
>
>         Teach .github/workflows/main.yml to use Cmake for VS builds.
>         Modify vs-test step to match windows-test step to speed up
>         the vs-test.
>
> > Changes:
> > The CMake script has been relocated to contib/buildsystems, so point
> > to the CMakeLists.txt in the invocation commands.
>
> This does not belong to the log message for this (or any for that
> matter) commit, no?  Up to this point, nothing in main.yml used
> CMake script from anywhere, and "has been relocated" is irrelevant.
>

Will remove this.

> And if we add CMake script to contrib/buildsystems/ from the
> beginning in [01/11], there won't be any "relocation" the readers of
> the log message of this step need to know about.
>
> > The generation command now uses the absolute paths for the generation
> > step.
>
> "now uses"?  Is that something the readers of the log message of
> this step need to know about, or is it "in contrast to an earlier
> attempt to add CMake script"?  If the latter, it only confuses the
> readers of our history, as most of them will not even know about an
> earlier attempt.

Will also remove this.

>
> Thanks.

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 10/11] cmake: parse the makefile for the sources.
  2020-05-12 21:03     ` Junio C Hamano
@ 2020-05-13 19:57       ` Sibi Siddharthan
  2020-05-13 20:23         ` Junio C Hamano
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-13 19:57 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Sibi Siddharthan via GitGitGadget, git

On Wed, May 13, 2020 at 2:33 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Sibi Siddharthan via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >
> > The CMake script parses the Makefile for:
> > SCRIPT_SH
> > SCRIPT_PERL
> > TEST_BUILTINS_OBJS
> > LIB_OBJS
> > BUILTIN_OBJS
> > XDIFF_OBJS
> > VCSSVN_OBJS
> >
> > By doing this we avoid duplication of text between the Makefile and
> > the CMake script.
>
> Thanks, this makes perfect sense, but it probably should have been
> done from the very beginning, without copying the huge list manually
> in the step [01/11].
>
> How robust is the "parser"?  Do we need to leave an instruction to
> Makefile writers to conform to certain style to help CMake users as
> an additional comment in the Makefile, or is any reasonable textual
> drift still accepted?
>

The parser just uses a regex capture like this "SCRIPT_SH += (.*)".
If the current source/script definition in the Makefile is continued
things will be fine.

On a side note, why are we using SCRIPT_SH and SCRIPT_LIB separately?
Can't we combine them into one? If we can then I can also add it to
the list above.

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv
  2020-05-12 21:16     ` Junio C Hamano
@ 2020-05-13 20:05       ` Sibi Siddharthan
  2020-05-14  2:00         ` Junio C Hamano
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-13 20:05 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Sibi Siddharthan via GitGitGadget, git

On Wed, May 13, 2020 at 2:46 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Sibi Siddharthan via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> > Subject: Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv
>
> s/added/add/; give a command to the codebase to "be like so", or a
> command to whoever is typing changes to the editor to "make this
> happen".
>
> > The CMake script now checks whether st_blocks is a member of struct stat
> > and set the compile definition NO_ST_BLOCKS_IN_STRUCT_STAT accordingly.
>
>         Teach the CMake script to check ...
>
> > diff --git a/CMakeLists.txt b/CMakeLists.txt
> > index 4353080b708..975791c8b89 100644
> > --- a/CMakeLists.txt
> > +++ b/CMakeLists.txt
> > @@ -22,6 +22,7 @@ project(git
> >  include(CheckTypeSize)
> >  include(CheckCSourceRuns)
> >  include(CheckCSourceCompiles)
> > +include(CheckCSourceRuns)
> > ...
> > +#check for st_blocks in struct stat
> > +check_struct_has_member("struct stat" st_blocks "sys/stat.h" STRUCT_STAT_HAS_ST_BLOCKS)
> > +if(NOT STRUCT_STAT_HAS_ST_BLOCKS)
> > +     add_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)
> > +endif()
>
> All of these compatibility stuff makes sense, but how do we decide
> where to draw the line between the checks we saw added in [01/11]
> and the checks added here?  It feels pretty arbitrary to me and if
> that is the case, perhaps we want to move all the "add checks" to a
> commit separate from [01/11] (whose primary purpose is to add the
> basic rules without these build tweaks in the file at the final
> place)?
>

The checks are added on a "demand" based the target platform.
In the future, if apple support is needed, we need to add ST_TIMESPEC checks.

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 02/11] cmake: generate the shell/perl/python scripts and templates, translations
  2020-05-12 21:19     ` Junio C Hamano
@ 2020-05-13 20:07       ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-13 20:07 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Sibi Siddharthan via GitGitGadget, git

On Wed, May 13, 2020 at 2:49 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Sibi Siddharthan via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >
> > This patch implements the placeholder substitution to generate, say,
> > `git-request-pull` from `git-request-pull.sh`.
> >
> > The shell/perl/python scripts and template are generated using CMake
> > (very similar to what sed does).
>
> We do not say "This patch does X" or "I do Y in this patch".
> perhaps.
>
>         Implement the placeholder substitution to generate scripted
>         Porcelain commands, e.g. git-request-pull out of
>         git-request-pull.sh
>
>         Generate scripts and templates using CMake, instead of using
>         sed like the build procedure in the Makefile does.
>

Will reword.

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 09/11] cmake: relocated script file contrib/buildsystems
  2020-05-12 21:09     ` Junio C Hamano
@ 2020-05-13 20:08       ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-13 20:08 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Sibi Siddharthan via GitGitGadget, git

On Wed, May 13, 2020 at 2:40 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Sibi Siddharthan via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >
> > The CMake script has been relocated to contrib/buildsystems.
> > The changes made to the script involves pointing to correct location
> > of the source files.
>
> This does match what the list agreed to do.  Why isn't this done as
> part of [01/11]?  If there is no technical reason not to, I'd
> strongly prefer to see it done from the very beginning.  The same
> comment applies to the next step.

Okay

>
> Thanks.
>
> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> > ---
> >  .../buildsystems/CMakeLists.txt               | 76 +++++++++++--------
> >  1 file changed, 45 insertions(+), 31 deletions(-)
> >  rename CMakeLists.txt => contrib/buildsystems/CMakeLists.txt (92%)

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 01/11] Introduce CMake support for configuring Git on Linux
  2020-05-12 20:59     ` Junio C Hamano
@ 2020-05-13 20:21       ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-13 20:21 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Sibi Siddharthan via GitGitGadget, git

On Wed, May 13, 2020 at 2:29 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Sibi Siddharthan via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > To make this a little less awkward, the Git for Windows project offers
> > the `vs/master` branch which has a full Visual Studio solution generated
> > and committed. This branch can therefore be used to tinker with Git in
> > Visual Studio _without_ having to download the full Git for Windows SDK.
> > Unfortunatly, that branch is auto-generated from Git for Windows'
> > `master`. If a developer wants to tinker, say, with `pu`, they are out
> > of luck.
>
> 'pu' or 'next' are not to be built upon, so this is not a good line
> of reasoning to complain that generating only for 'master' is bad.
>
> > CMake was invented to make this sort of problem go away, by providing a
> > more standardized, cross-platform way to configure builds.
>
> I think everything above this point (including Makefile, autoconf
> etc.) can be replaced with a single sentence
>
>         The build infrastructure for Git is written around being
>         able to run make, which is not supported natively on
>         Windows.
>
> without anything else.  That will flow naturally to
>
>         Add a build script that uses CMake to help developers on
>         Windows to build git.
>
> and then you can continue the current state, like this paragraph.
>
> > This is only the first step, and to make it easier to review, it only
> > allows for configuring builds on the platform that is easiest to
> > configure for: Linux.
> >
> > The CMake script checks whether the headers are present(eg. libgen.h),
> > whether the functions are present(eg. memmem), whether the funtions work
> > properly (eg. snprintf) and generate the required compile definitions
> > for the platform. The script also searches for the required libraries,
> > if it fails to find the required libraries the respective executables
> > won't be built.(eg. If libcurl is not found then git-remote-http won't
> > be built). This will help building Git easier.
> >
> > With a CMake script an out of source build of git is possible resulting
> > in a clean source tree.
>
>
> > Note: earlier endeavors on the Git mailing list to introduce CMake ended
> > up in dead water. The primary reason for that was that reviewers
> > _expected_ CMake support to fall out of maintenance, unless the
> > contributor would promise to keep an eye on keeping CMake support up to
> > date. However, in the meantime, support for automated testing has been
> > introduced in Git's source code, and a later patch will modify the
> > (still experimental) GitHub workflow to continually verify that CMake
> > support is still complete. That will make maintenance reasonably easy.
>
> I am not sure this belongs to the log message.
>

Will remove it.

> > Note: this patch asks for the minimum version v3.14 of CMake (which is
> > not all that old as of time of writing) because that is the first
> > version to offer a platform-independent way to generate hardlinks as
> > part of the build. This is needed to generate all those hardlinks for
> > the built-in commands of Git.
>
> This does, but I do not think hardlinks are not required for our
> build.  On Unix filesystems, it is not just possible but convenient
> to use, and that is the only reason why we use hardlinks.
>
> If hardlinks are possible but inconvenient to use on Windows, you
> shouldn't force your target audience to use it.

Another alternative is to use verbatim copies, but this increases the
size of the generated build artifacts considerably.
Hardlinks are not inconvenient on Windows, CMake 3.14 gives a cross
platform way of generating them.

>
> > Instructions to run CMake:
> >
> > cmake `relative-path-to-srcdir` -DCMAKE_BUILD_TYPE=Release
> >
> > Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
> > compiler flags
> > Debug : -g
> > Release: -O3
> > RelWithDebInfo : -O2 -g
> > MinSizeRel : -Os
> > empty(default) :
> >
> > NOTE: -DCMAKE_BUILD_TYPE is optional
> >
> > This process generates a Makefile.
> > Then run `make` to build Git.
> >
> > NOTE: By default CMake uses Makefile as the build tool on Linux, to use
> > another tool say `ninja` add this to the command line when configuring.
> > `-G Ninja`
>
> I find it curious that from the instruction, the most important
> platform, the primary reason why we are reviewing this patch, is
> missing.  Don't Windows folks need to be told how to run CMake to
> build?

The instructions are the same for any platform. Just like ./configure.

>
> In any case, all of the above "Instructions" should go at the top
> part of CMakeLists.txt in a comment, and not in the log message.
> "git log" output is not an easy way for your target audience to
> learn how to use what the commit adds.  Think what they need to do
> when they discover there is CMakeLists.txt in our tree in three
> months.  Don't force them to run "git blame" to find this commit
> that added the support.

Okay, will add some instructions on top of the script.

>
> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> > ---
> >  CMakeLists.txt | 528 +++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 528 insertions(+)
> >  create mode 100644 CMakeLists.txt
> >
> > diff --git a/CMakeLists.txt b/CMakeLists.txt
> > new file mode 100644
> > index 00000000000..73703bd321f
> > --- /dev/null
> > +++ b/CMakeLists.txt
> > @@ -0,0 +1,528 @@
> > +#
> > +#    Copyright (c) 2020 Sibi Siddharthan
> > +#
> > +
> > +cmake_minimum_required(VERSION 3.14)
> > +
> > +#Parse GIT-VERSION-GEN to get the version
> > +file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
> > +string(REPLACE "DEF_VER=v" "" git_version ${git_version})
> > +string(REPLACE ".GIT" ".0" git_version ${git_version})#for building from a snapshot
>
> Hmph, I'd really prefer to see the logic in GIT-VERSION-GEN not
> bypassed like this.  People know they can create a text file 'version'
> and record the version name they desire in it and expect GIT-VERSION-GEN
> to pick it up, for example.
>
> Later in this file, you seem to depend on the shell to do things
> like generating config-list.h file, so I'd rather see the same
> technique used here a well.
>
> > +set(libgit_SOURCES
> > +     abspath.c add-interactive.c add-patch.c advice.c alias.c
> > +...
> > +     zlib.c)
>
> Hmph.
>
> > +set(git_SOURCES
> > +     builtin/add.c builtin/am.c builtin/annotate.c builtin/apply.c
> > +     builtin/archive.c builtin/bisect--helper.c builtin/blame.c
> > +     builtin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c
> > +     builtin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c
> > +     builtin/checkout-index.c builtin/checkout.c builtin/clean.c
> > +     builtin/clone.c builtin/column.c builtin/commit-tree.c
> > +     builtin/commit.c builtin/commit-graph.c builtin/config.c
> > +     builtin/count-objects.c builtin/credential.c builtin/describe.c
> > +     builtin/diff-files.c builtin/diff-index.c builtin/diff-tree.c
> > +     builtin/diff.c builtin/difftool.c builtin/env--helper.c
> > +     builtin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c
> > +     builtin/for-each-ref.c builtin/fsck.c builtin/gc.c
> > +     builtin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c
> > +     builtin/help.c builtin/index-pack.c builtin/init-db.c
> > +     builtin/interpret-trailers.c builtin/log.c builtin/ls-files.c
> > +     builtin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c
> > +     builtin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c
> > +     builtin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c
> > +     builtin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c
> > +     builtin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c
> > +     builtin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c
> > +     builtin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c
> > +     builtin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c
> > +     builtin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c
> > +     builtin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c
> > +     builtin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c
> > +     builtin/show-branch.c builtin/show-index.c builtin/show-ref.c
> > +     builtin/sparse-checkout.c builtin/stash.c builtin/stripspace.c
> > +     builtin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c
> > +     builtin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c
> > +     builtin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c
> > +     builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c
> > +     builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)
>
> Can't we do a bit better here?
>
> Perhaps grab this out of our Makefile?  The same command applies to
> huge lists of sources we have seen.
>
> Or do the equivalent of $(wildcard builtin/*.c) if CMake has such a
> feature?
>

We do have that.

> > ...
> > \ No newline at end of file
>
> Double check and make sure you have a text file without an incomplete
> line at the end.
>
> Thanks.

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 10/11] cmake: parse the makefile for the sources.
  2020-05-13 19:57       ` Sibi Siddharthan
@ 2020-05-13 20:23         ` Junio C Hamano
  0 siblings, 0 replies; 179+ messages in thread
From: Junio C Hamano @ 2020-05-13 20:23 UTC (permalink / raw)
  To: Sibi Siddharthan; +Cc: Sibi Siddharthan via GitGitGadget, git

Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:

> On a side note, why are we using SCRIPT_SH and SCRIPT_LIB separately?

I think _SH are commands to be installed as executable, while _LIB
are to be dot-included and installed as non-executable.  

There may be other differences; they (i.e. what the Makefile uses
these lists for, how the elements on these lists are treated, etc.)
are something you need to know before you can reimplement the logic
of building and installing used by the current system in a different
build system.

Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv
  2020-05-13 20:05       ` Sibi Siddharthan
@ 2020-05-14  2:00         ` Junio C Hamano
  0 siblings, 0 replies; 179+ messages in thread
From: Junio C Hamano @ 2020-05-14  2:00 UTC (permalink / raw)
  To: Sibi Siddharthan; +Cc: Sibi Siddharthan via GitGitGadget, git

Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:

>> All of these compatibility stuff makes sense, but how do we decide
>> where to draw the line between the checks we saw added in [01/11]
>> and the checks added here?  It feels pretty arbitrary to me and if
>> that is the case, perhaps we want to move all the "add checks" to a
>> commit separate from [01/11] (whose primary purpose is to add the
>> basic rules without these build tweaks in the file at the final
>> place)?
>>
>
> The checks are added on a "demand" based the target platform.
> In the future, if apple support is needed, we need to add ST_TIMESPEC checks.

Well, let's ask a related question then.

Given that the primary reason why the project may be interested in
adding cmake-based build system is because of its support for
Windows build, how much smaller would this 11-patch series can
become if we discard support for any platforms other than Windows?
Let's say we add support for other platforms only after the series
proves capable to build on/for Windows by going through the usual
"queued in 'pu', merged to 'next' and then down to 'master'" route
and appears in a tagged release.  Would it reduce the time we need
to spend before seeing a cmake-based build for Windows by doing so?

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 06/11] cmake: support for building git on windows with mingw
  2020-05-12 16:50   ` [PATCH v2 06/11] cmake: support for building git on windows with mingw Sibi Siddharthan via GitGitGadget
@ 2020-05-14 15:25     ` Đoàn Trần Công Danh
  2020-05-14 18:27       ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Đoàn Trần Công Danh @ 2020-05-14 15:25 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

Hi Sibi,

On 2020-05-12 16:50:49+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 47d3f3c2866..9625e41886f 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -13,9 +13,12 @@ project(git
>  	VERSION ${git_version}
>  	LANGUAGES C)
>  
> +

This newline maybe left from debugging. (and other new newline below).

> +#Platform Specific
> +if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")

Please drop ${} around CMAKE_SYSTEM_NAME, here (and other if)
Or user may accidental messed up.
------------8<----------------
$ cat CMakeLists.txt
project(test)
message("This is ${CMAKE_SYSTEM_NAME}")
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
	message("Yes, STREQUAL Windows")
endif()
$ cmake . -DLinux=Windows
This is Linux
Yes, STREQUAL Windows
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp
---------------->8--------------


-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv
  2020-05-12 16:50   ` [PATCH v2 08/11] cmake: added checks for struct stat and libiconv Sibi Siddharthan via GitGitGadget
  2020-05-12 21:16     ` Junio C Hamano
@ 2020-05-14 15:31     ` Đoàn Trần Công Danh
  2020-05-14 18:31       ` Sibi Siddharthan
  1 sibling, 1 reply; 179+ messages in thread
From: Đoàn Trần Công Danh @ 2020-05-14 15:31 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

On 2020-05-12 16:50:51+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> 
> The CMake script now checks whether st_blocks is a member of struct stat
> and set the compile definition NO_ST_BLOCKS_IN_STRUCT_STAT accordingly.
> 
> The check for whether ICONV_OMITS_BOM is also added as requested by Danh.

Please don't write my name in the commit message like this.
This maybe rephased to:
	
	While we're as it, add the check for ICONV_OMITS_BOM.

> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> ---
>  CMakeLists.txt | 59 ++++++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 57 insertions(+), 2 deletions(-)
> 
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 4353080b708..975791c8b89 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -22,6 +22,7 @@ project(git
>  include(CheckTypeSize)
>  include(CheckCSourceRuns)
>  include(CheckCSourceCompiles)
> +include(CheckCSourceRuns)
>  include(CheckIncludeFile)
>  include(CheckFunctionExists)
>  include(CheckSymbolExists)
> @@ -128,7 +129,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
>  	include_directories(compat/win32)
>  	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
>  				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
> -				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT
> +				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0
>  				USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
>  				UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
>  	list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
> @@ -280,6 +281,11 @@ if(HAVE_CLOCK_MONOTONIC)
>  	add_compile_definitions(HAVE_CLOCK_MONOTONIC)
>  endif()
>  
> +#check for st_blocks in struct stat
> +check_struct_has_member("struct stat" st_blocks "sys/stat.h" STRUCT_STAT_HAS_ST_BLOCKS)
> +if(NOT STRUCT_STAT_HAS_ST_BLOCKS)
> +	add_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)
> +endif()
>  
>  #compile checks
>  check_c_source_runs("
> @@ -344,7 +350,6 @@ if(NOT HAVE_REGEX)
>  	add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
>  endif()
>  
> -
>  check_c_source_compiles("
>  #include <stddef.h>
>  #include <sys/types.h>
> @@ -368,6 +373,56 @@ if(HAVE_BSD_SYSCTL)
>  	add_compile_definitions(HAVE_BSD_SYSCTL)
>  endif()
>  
> +set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES})
> +set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS})
> +
> +check_c_source_compiles("
> +#include <iconv.h>
> +
> +extern size_t iconv(iconv_t cd,
> +		char **inbuf, size_t *inbytesleft,
> +		char **outbuf, size_t *outbytesleft);
> +
> +int main(){return 0;}"
> +HAVE_NEW_ICONV)
> +if(HAVE_NEW_ICONV)
> +	set(HAVE_OLD_ICONV 0)
> +else()
> +	set(HAVE_OLD_ICONV 1)
> +endif()
> +
> +check_c_source_runs("
> +#include <iconv.h>
> +#if ${HAVE_OLD_ICONV}
> +typedef const char *iconv_ibp;
> +#else
> +typedef char *iconv_ibp;
> +#endif
> +
> +int main()
> +{
> +	int v;
> +	iconv_t conv;
> +	char in[] = \"a\"; iconv_ibp pin = in;
> +	char out[20] = \"\"; char *pout = out;
> +	size_t isz = sizeof in;
> +	size_t osz = sizeof out;
> +
> +	conv = iconv_open(\"UTF-16\", \"UTF-8\");
> +	iconv(conv, &pin, &isz, &pout, &osz);
> +	iconv_close(conv);
> +	v = (unsigned char)(out[0]) + (unsigned char)(out[1]);
> +	return v != 0xfe + 0xff;
> +}"

I think the closing double-quote should be placed in a newline,
in order to make sure the source file ended with newline,
old C standard requires final newline.


-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 06/11] cmake: support for building git on windows with mingw
  2020-05-14 15:25     ` Đoàn Trần Công Danh
@ 2020-05-14 18:27       ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-14 18:27 UTC (permalink / raw)
  To: Đoàn Trần Công Danh
  Cc: Sibi Siddharthan via GitGitGadget, git

On Thu, May 14, 2020 at 8:56 PM Đoàn Trần Công Danh
<congdanhqx@gmail.com> wrote:
>
> Hi Sibi,
>
> On 2020-05-12 16:50:49+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> > diff --git a/CMakeLists.txt b/CMakeLists.txt
> > index 47d3f3c2866..9625e41886f 100644
> > --- a/CMakeLists.txt
> > +++ b/CMakeLists.txt
> > @@ -13,9 +13,12 @@ project(git
> >       VERSION ${git_version}
> >       LANGUAGES C)
> >
> > +
>
> This newline maybe left from debugging. (and other new newline below).
>
> > +#Platform Specific
> > +if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
>
> Please drop ${} around CMAKE_SYSTEM_NAME, here (and other if)
> Or user may accidental messed up.
> ------------8<----------------
> $ cat CMakeLists.txt
> project(test)
> message("This is ${CMAKE_SYSTEM_NAME}")
> if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
>         message("Yes, STREQUAL Windows")
> endif()
> $ cmake . -DLinux=Windows
> This is Linux
> Yes, STREQUAL Windows
> -- Configuring done
> -- Generating done
> -- Build files have been written to: /tmp
> ---------------->8--------------
>

Thanks for pointing it out, will fix it ASAP.

Thank You,
Sibi Siddharthan


>
> --
> Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 08/11] cmake: added checks for struct stat and libiconv
  2020-05-14 15:31     ` Đoàn Trần Công Danh
@ 2020-05-14 18:31       ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-14 18:31 UTC (permalink / raw)
  To: Đoàn Trần Công Danh
  Cc: Sibi Siddharthan via GitGitGadget, git

On Thu, May 14, 2020 at 9:01 PM Đoàn Trần Công Danh
<congdanhqx@gmail.com> wrote:
>
> On 2020-05-12 16:50:51+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >
> > The CMake script now checks whether st_blocks is a member of struct stat
> > and set the compile definition NO_ST_BLOCKS_IN_STRUCT_STAT accordingly.
> >
> > The check for whether ICONV_OMITS_BOM is also added as requested by Danh.
>
> Please don't write my name in the commit message like this.
> This maybe rephased to:
>
>         While we're as it, add the check for ICONV_OMITS_BOM.

Sure, will remove your name from the message.
I added it because gitgitgadget PR bot suggested it as a good practice.

>
> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> > ---
> >  CMakeLists.txt | 59 ++++++++++++++++++++++++++++++++++++++++++++++++--
> >  1 file changed, 57 insertions(+), 2 deletions(-)
> >
> > diff --git a/CMakeLists.txt b/CMakeLists.txt
> > index 4353080b708..975791c8b89 100644
> > --- a/CMakeLists.txt
> > +++ b/CMakeLists.txt
> > @@ -22,6 +22,7 @@ project(git
> >  include(CheckTypeSize)
> >  include(CheckCSourceRuns)
> >  include(CheckCSourceCompiles)
> > +include(CheckCSourceRuns)
> >  include(CheckIncludeFile)
> >  include(CheckFunctionExists)
> >  include(CheckSymbolExists)
> > @@ -128,7 +129,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
> >       include_directories(compat/win32)
> >       add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
> >                               _CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
> > -                             NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT
> > +                             NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0
> >                               USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
> >                               UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
> >       list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
> > @@ -280,6 +281,11 @@ if(HAVE_CLOCK_MONOTONIC)
> >       add_compile_definitions(HAVE_CLOCK_MONOTONIC)
> >  endif()
> >
> > +#check for st_blocks in struct stat
> > +check_struct_has_member("struct stat" st_blocks "sys/stat.h" STRUCT_STAT_HAS_ST_BLOCKS)
> > +if(NOT STRUCT_STAT_HAS_ST_BLOCKS)
> > +     add_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)
> > +endif()
> >
> >  #compile checks
> >  check_c_source_runs("
> > @@ -344,7 +350,6 @@ if(NOT HAVE_REGEX)
> >       add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
> >  endif()
> >
> > -
> >  check_c_source_compiles("
> >  #include <stddef.h>
> >  #include <sys/types.h>
> > @@ -368,6 +373,56 @@ if(HAVE_BSD_SYSCTL)
> >       add_compile_definitions(HAVE_BSD_SYSCTL)
> >  endif()
> >
> > +set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES})
> > +set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS})
> > +
> > +check_c_source_compiles("
> > +#include <iconv.h>
> > +
> > +extern size_t iconv(iconv_t cd,
> > +             char **inbuf, size_t *inbytesleft,
> > +             char **outbuf, size_t *outbytesleft);
> > +
> > +int main(){return 0;}"
> > +HAVE_NEW_ICONV)
> > +if(HAVE_NEW_ICONV)
> > +     set(HAVE_OLD_ICONV 0)
> > +else()
> > +     set(HAVE_OLD_ICONV 1)
> > +endif()
> > +
> > +check_c_source_runs("
> > +#include <iconv.h>
> > +#if ${HAVE_OLD_ICONV}
> > +typedef const char *iconv_ibp;
> > +#else
> > +typedef char *iconv_ibp;
> > +#endif
> > +
> > +int main()
> > +{
> > +     int v;
> > +     iconv_t conv;
> > +     char in[] = \"a\"; iconv_ibp pin = in;
> > +     char out[20] = \"\"; char *pout = out;
> > +     size_t isz = sizeof in;
> > +     size_t osz = sizeof out;
> > +
> > +     conv = iconv_open(\"UTF-16\", \"UTF-8\");
> > +     iconv(conv, &pin, &isz, &pout, &osz);
> > +     iconv_close(conv);
> > +     v = (unsigned char)(out[0]) + (unsigned char)(out[1]);
> > +     return v != 0xfe + 0xff;
> > +}"
>
> I think the closing double-quote should be placed in a newline,
> in order to make sure the source file ended with newline,
> old C standard requires final newline.
>

Okay

Thank You,
Sibi Siddharthan

>
> --
> Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job
  2020-05-13 19:45       ` Sibi Siddharthan
@ 2020-05-25 19:16         ` Sibi Siddharthan
  2020-05-25 20:03           ` Junio C Hamano
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-25 19:16 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Sibi Siddharthan via GitGitGadget, git

Hi Junio,

I have finished the changes you have asked for.
1) Relocating the CMake script to contrib/buildsystems from patch 01/xx.
2) Parse the Makefile for sources from patch 01/xx.
3) Reworded the commit messages you pointed out.
4) Rebased the ST_BLOCKS_IN_STRUCT_STAT and ICONV_OMITS_BOM to patch
01/xx to make the review process easier.

No new features will be introduced in the script, to make the review
process easier.

I have looked at the GIT-VERSION-GEN script and the logic it uses to
determine the version of git.
The logic is a bit complicated to be implemented in a  CMake script,
so I am skipping it for now.

Any other changes I should make before I submit PATCH v3?

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job
  2020-05-25 19:16         ` Sibi Siddharthan
@ 2020-05-25 20:03           ` Junio C Hamano
  2020-05-25 20:56             ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Junio C Hamano @ 2020-05-25 20:03 UTC (permalink / raw)
  To: Sibi Siddharthan; +Cc: Sibi Siddharthan via GitGitGadget, git

Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:

> 1) Relocating the CMake script to contrib/buildsystems from patch 01/xx.
> 2) Parse the Makefile for sources from patch 01/xx.
> 3) Reworded the commit messages you pointed out.
> 4) Rebased the ST_BLOCKS_IN_STRUCT_STAT and ICONV_OMITS_BOM to patch
> 01/xx to make the review process easier.
> ...
> No new features will be introduced in the script, to make the review
> process easier.

You did not answer <xmqqd077qnqc.fsf@gitster.c.googlers.com>,
so I have to guess.

I am guessing that your answer would be that if we keep this series
concentrate only on Windows support from the beginning and do not
add support for any other platform at all, the scope and necessary
effort to bring the patches in reviewable shape would be reduced
dramatically.  And if that is the case, that would be great.

In other words, I'd prefer not just "no new features", but "with
much less features, now we do not even add support for Linux or
macOS to the initial patch series".

But because I haven't heard the question answered, I cannot tell if
that level of simplification is possible and if that is already what
you did in (silent) response to my questions.

> I have looked at the GIT-VERSION-GEN script and the logic it uses to
> determine the version of git.
> The logic is a bit complicated to be implemented in a  CMake script,
> so I am skipping it for now.

Regarding the generation of GIT-VERSION-FILE, I asked you why you
need to hand-parse, instead of running the script itself, which is
the way you generate the config-list.h file in the same patch, which
is done with execute_process() to run generate-cmdlist.sh.

You did not answer the question, either, so I have to guess.

I am guessing that it was an oversight that you did not update the
procedure to handle GIT-VERSION-FILE because you wrote the "let's
string-find in the GIT-VERSION-GEN script" approach way before you
wrote the other parts of the CMake thing, and with the experience
and hindsight of having written command-list-h support, you now
realize that running the script to ensure that you get the result
consistent with folks who use Makefile would be much better.  After
all, the logic being more complex than your CMake support can
express shouldn't be an issue, if you just let the logic execute
itself, no?

But that is also merely my guess, so...

> Any other changes I should make before I submit PATCH v3?

... at this point, it is too early for me to answer that question.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job
  2020-05-25 20:03           ` Junio C Hamano
@ 2020-05-25 20:56             ` Sibi Siddharthan
  2020-05-25 21:40               ` Johannes Schindelin
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-25 20:56 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Sibi Siddharthan via GitGitGadget, git

On Tue, May 26, 2020 at 1:33 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:
>
> > 1) Relocating the CMake script to contrib/buildsystems from patch 01/xx.
> > 2) Parse the Makefile for sources from patch 01/xx.
> > 3) Reworded the commit messages you pointed out.
> > 4) Rebased the ST_BLOCKS_IN_STRUCT_STAT and ICONV_OMITS_BOM to patch
> > 01/xx to make the review process easier.
> > ...
> > No new features will be introduced in the script, to make the review
> > process easier.
>
> You did not answer <xmqqd077qnqc.fsf@gitster.c.googlers.com>,
> so I have to guess.

Sorry, was going to reply to that, but forgot about it along the way.

As for my reply to that for windows only support we do not need
a few of the checks namely:
1) HAVE_BSD_SYSCTL
2) ICONV_OMITS_BOM (because we are using GNU libiconv 1.16)

The functions checks (check_function_exists) is needed.
A few of the header checks are unnecessary(paths.h sys/sysinfo.h).

The difference in build between Linux platforms and Windows would
be 8-15 lines of code atmost . I see no point in the extra Linux stuff to be
a burden for the reviewers.

There is another way of just copying the configurations in config.mak.uname,
but this hurts the purpose of configuring in the first place.

>
> I am guessing that your answer would be that if we keep this series
> concentrate only on Windows support from the beginning and do not
> add support for any other platform at all, the scope and necessary
> effort to bring the patches in reviewable shape would be reduced
> dramatically.  And if that is the case, that would be great.
>
> In other words, I'd prefer not just "no new features", but "with
> much less features, now we do not even add support for Linux or
> macOS to the initial patch series".

macOS support is ways off, needs quite a bit of work.

In terms of Linux support apart from the function, header checks there
is nothing special
implemented here.

>
> But because I haven't heard the question answered, I cannot tell if
> that level of simplification is possible and if that is already what
> you did in (silent) response to my questions.
>
> > I have looked at the GIT-VERSION-GEN script and the logic it uses to
> > determine the version of git.
> > The logic is a bit complicated to be implemented in a  CMake script,
> > so I am skipping it for now.
>
> Regarding the generation of GIT-VERSION-FILE, I asked you why you
> need to hand-parse, instead of running the script itself, which is
> the way you generate the config-list.h file in the same patch, which
> is done with execute_process() to run generate-cmdlist.sh.
>
> You did not answer the question, either, so I have to guess.
>
> I am guessing that it was an oversight that you did not update the
> procedure to handle GIT-VERSION-FILE because you wrote the "let's
> string-find in the GIT-VERSION-GEN script" approach way before you
> wrote the other parts of the CMake thing, and with the experience
> and hindsight of having written command-list-h support, you now
> realize that running the script to ensure that you get the result
> consistent with folks who use Makefile would be much better.  After
> all, the logic being more complex than your CMake support can
> express shouldn't be an issue, if you just let the logic execute
> itself, no?
>

Yes, fair point.

Have executed GIT-VERSION-GEN, then parsed the GIT-VERSION-FILE for
version info.
Added it to the list of changes.

> But that is also merely my guess, so...
>
> > Any other changes I should make before I submit PATCH v3?
>
> ... at this point, it is too early for me to answer that question.

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job
  2020-05-25 20:56             ` Sibi Siddharthan
@ 2020-05-25 21:40               ` Johannes Schindelin
  0 siblings, 0 replies; 179+ messages in thread
From: Johannes Schindelin @ 2020-05-25 21:40 UTC (permalink / raw)
  To: Sibi Siddharthan; +Cc: Junio C Hamano, Sibi Siddharthan via GitGitGadget, git

Hi Sibi,

On Tue, 26 May 2020, Sibi Siddharthan wrote:

> The difference in build between Linux platforms and Windows would be
> 8-15 lines of code atmost . I see no point in the extra Linux stuff to
> be a burden for the reviewers.

I agree that this does not constitute a big burden.

Linux support in the CMake system _might_ come in real handy in certain
circumstances. For example, if I understand correctly cppcheck uses the
CMake configuration to figure out which source files to analyze, and with
which #define's.

So there might be some previously-underappreciated benefit to having a
CMake configuration that works on Linux, even if it is not the recommended
way to build Git on Linux.

Thank you for your incredible work on the CMake front,
Dscho

^ permalink raw reply	[flat|nested] 179+ messages in thread

* [PATCH v3 0/8] CMake build system for git
  2020-05-12 16:50 ` [PATCH v2 00/11] " Sibi Siddharthan via GitGitGadget
                     ` (10 preceding siblings ...)
  2020-05-12 16:50   ` [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job Sibi Siddharthan via GitGitGadget
@ 2020-05-29 13:40   ` Sibi Siddharthan via GitGitGadget
  2020-05-29 13:40     ` [PATCH v3 1/8] Introduce CMake support for configuring Git Sibi Siddharthan via GitGitGadget
                       ` (8 more replies)
  11 siblings, 9 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-29 13:40 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan

This is an attempt to build Git using CMake. CMake is cross-platform build
generator which works well on a variety of platforms(primarily Linux and
Windows). Using CMake we can check whether certain headers exist, certain
functions exist, the required libraries are present and configure the build
accordingly. Using CMake we can also build and test Git out of source,
resulting in a clean source tree.

Tested platforms

Ubuntu 18.04 GCC 7.4 Clang 8.0.1

Windows MinGW GCC 9.2 Clang 9 Visual Studio 2015,2017,2019

Changes:

1) The CMake script has been relocated to contrib/buildsystems 2) The CMake
script parses the Makefile for the sources. 3) Philip suggested to change
the error message if sh/bash was not found on windows. 4) CMake now tests
for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT

Changes v2: Changes 1,2,4 have been rebased to PATCH 01/xx CMake uses
GIT-VERSION-GEN to get the version of Git

Sibi Siddharthan (8):
  Introduce CMake support for configuring Git
  cmake: generate the shell/perl/python scripts and templates,
    translations
  cmake: installation support for git
  cmake: support for testing git with ctest
  cmake: support for testing git when building out of the source tree
  cmake: support for building git on windows with mingw
  cmake: support for building git on windows with msvc and clang.
  ci: modification of main.yml to use cmake for vs-build job

 .github/workflows/main.yml          |  38 +-
 contrib/buildsystems/CMakeLists.txt | 987 ++++++++++++++++++++++++++++
 2 files changed, 1009 insertions(+), 16 deletions(-)
 create mode 100644 contrib/buildsystems/CMakeLists.txt


base-commit: 90737beb8258c0a99181b6308eef898d77979c71
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-614%2FSibiSiddharthan%2Fgit-og-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-614/SibiSiddharthan/git-og-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/614

Range-diff vs v2:

  1:  70ab1f03dd5 !  1:  09c972de52b Introduce CMake support for configuring Git on Linux
     @@ Metadata
      Author: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
       ## Commit message ##
     -    Introduce CMake support for configuring Git on Linux
     +    Introduce CMake support for configuring Git
      
          At the moment, the recommended way to configure Git's builds is to
          simply run `make`. If that does not work, the recommended strategy is to
     @@ Commit message
          occupies around two gigabytes (!) on disk and downloads about three
          quarters of a gigabyte worth of Git objects).
      
     -    To make this a little less awkward, the Git for Windows project offers
     -    the `vs/master` branch which has a full Visual Studio solution generated
     -    and committed. This branch can therefore be used to tinker with Git in
     -    Visual Studio _without_ having to download the full Git for Windows SDK.
     -    Unfortunatly, that branch is auto-generated from Git for Windows'
     -    `master`. If a developer wants to tinker, say, with `pu`, they are out
     -    of luck.
     -
     -    CMake was invented to make this sort of problem go away, by providing a
     -    more standardized, cross-platform way to configure builds.
     +    The build infrastructure for Git is written around being able to run
     +    make, which is not supported natively on Windows.
     +    To help Windows developers a CMake build script is introduced here.
      
          With a working support CMake, developers on Windows need only install
          CMake, configure their build, load the generated Visual Studio solution
     @@ Commit message
          With a CMake script an out of source build of git is possible resulting
          in a clean source tree.
      
     -    Note: earlier endeavors on the Git mailing list to introduce CMake ended
     -    up in dead water. The primary reason for that was that reviewers
     -    _expected_ CMake support to fall out of maintenance, unless the
     -    contributor would promise to keep an eye on keeping CMake support up to
     -    date. However, in the meantime, support for automated testing has been
     -    introduced in Git's source code, and a later patch will modify the
     -    (still experimental) GitHub workflow to continually verify that CMake
     -    support is still complete. That will make maintenance reasonably easy.
     -
          Note: this patch asks for the minimum version v3.14 of CMake (which is
          not all that old as of time of writing) because that is the first
          version to offer a platform-independent way to generate hardlinks as
          part of the build. This is needed to generate all those hardlinks for
          the built-in commands of Git.
      
     -    Instructions to run CMake:
     -
     -    cmake `relative-path-to-srcdir` -DCMAKE_BUILD_TYPE=Release
     +    Changes
     +    The CMake script parses the Makefile for:
     +    LIB_OBJS
     +    BUILTIN_OBJS
     +    XDIFF_OBJS
     +    VCSSVN_OBJS
     +    TEST_BUILTINS_OBJS
      
     -    Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
     -    compiler flags
     -    Debug : -g
     -    Release: -O3
     -    RelWithDebInfo : -O2 -g
     -    MinSizeRel : -Os
     -    empty(default) :
     +    By doing this we avoid duplication of text between the Makefile and
     +    the CMake script.
      
     -    NOTE: -DCMAKE_BUILD_TYPE is optional
     +    The CMake script has been relocated to contrib/buildsystems.
      
     -    This process generates a Makefile.
     -    Then run `make` to build Git.
     -
     -    NOTE: By default CMake uses Makefile as the build tool on Linux, to use
     -    another tool say `ninja` add this to the command line when configuring.
     -    `-G Ninja`
     +    The CMake script uses GIT-VERSION-GEN to determine the version of Git
     +    being built.
      
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
     - ## CMakeLists.txt (new) ##
     + ## contrib/buildsystems/CMakeLists.txt (new) ##
      @@
      +#
      +#	Copyright (c) 2020 Sibi Siddharthan
      +#
      +
     ++#[[
     ++
     ++Instructions to run CMake:
     ++
     ++cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release
     ++
     ++Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
     ++compiler flags
     ++Debug : -g
     ++Release: -O3
     ++RelWithDebInfo : -O2 -g
     ++MinSizeRel : -Os
     ++empty(default) :
     ++
     ++NOTE: -DCMAKE_BUILD_TYPE is optional. For multi-config generators like Visual Studio
     ++this option is ignored
     ++
     ++This process generates a Makefile(Linux) , Visual Studio solution(Windows) by default.
     ++Run `make` to build Git on Linux.
     ++Open git.sln on Windows and build Git.
     ++
     ++NOTE: By default CMake uses Makefile as the build tool on Linux and Visual Studio in Windows,
     ++to use another tool say `ninja` add this to the command line when configuring.
     ++`-G Ninja`
     ++
     ++]]
      +cmake_minimum_required(VERSION 3.14)
      +
     -+#Parse GIT-VERSION-GEN to get the version
     -+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
     -+string(REPLACE "DEF_VER=v" "" git_version ${git_version})
     -+string(REPLACE ".GIT" ".0" git_version ${git_version})#for building from a snapshot
     ++#set the source directory to root of git
     ++set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
     ++
     ++find_program(SH_EXE sh)
     ++
     ++#Create GIT-VERSION-FILE using GIT-VERSION-GEN
     ++if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)
     ++	message("Generating GIT-VERSION-FILE")
     ++	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN
     ++		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
     ++endif()
     ++
     ++#Parse GIT-VERSION-FILE to get the version
     ++file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE git_version REGEX "GIT_VERSION = (.*)")
     ++string(REPLACE "GIT_VERSION = " "" git_version ${git_version})
     ++string(FIND ${git_version} "GIT" location)
     ++if(location EQUAL -1)
     ++	string(REGEX MATCH "[0-9]*\\.[0-9]*\\.[0-9]*" git_version ${git_version})
     ++else()
     ++	string(REGEX MATCH "[0-9]*\\.[0-9]*" git_version ${git_version})
     ++	string(APPEND git_version ".0") #for building from a snapshot
     ++endif()
      +
      +project(git
      +	VERSION ${git_version}
      +	LANGUAGES C)
      +
      +
     ++#macros for parsing the Makefile for sources
     ++macro(parse_makefile_for_sources list_var regex)
     ++	file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
     ++	string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
     ++	string(REPLACE "$(COMPAT_OBJS)" "" ${list_var} ${${list_var}}) #remove "$(COMPAT_OBJS)" This is only for libgit.
     ++	string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
     ++	string(REPLACE ".o" ".c;" ${list_var} ${${list_var}}) #change .o to .c, ; is for converting the string into a list
     ++	list(TRANSFORM ${list_var} STRIP) #remove trailing/leading whitespaces for each element in list
     ++	list(REMOVE_ITEM ${list_var} "") #remove empty list elements
     ++endmacro()
     ++
      +include(CheckTypeSize)
      +include(CheckCSourceRuns)
      +include(CheckCSourceCompiles)
     @@ CMakeLists.txt (new)
      +	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
      +endif()
      +
     -+find_program(SH_EXE sh)
     -+
      +#default behaviour
      +include_directories(${CMAKE_SOURCE_DIR})
      +add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
     @@ CMakeLists.txt (new)
      +#function checks
      +set(function_checks
      +	strcasestr memmem strlcpy strtoimax strtoumax strtoull
     -+	setenv  mkdtemp poll pread  memmem unsetenv hstrerror)
     ++	setenv mkdtemp poll pread memmem unsetenv hstrerror)
      +
      +foreach(f ${function_checks})
      +	string(TOUPPER ${f} uf)
     @@ CMakeLists.txt (new)
      +endforeach()
      +
      +if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)
     -+	include_directories(compat/poll)
     ++	include_directories(${CMAKE_SOURCE_DIR}/compat/poll)
      +	add_compile_definitions(NO_POLL)
      +	list(APPEND compat_SOURCES compat/poll/poll.c)
      +endif()
     @@ CMakeLists.txt (new)
      +	add_compile_definitions(HAVE_CLOCK_MONOTONIC)
      +endif()
      +
     ++#check for st_blocks in struct stat
     ++check_struct_has_member("struct stat" st_blocks "sys/stat.h" STRUCT_STAT_HAS_ST_BLOCKS)
     ++if(NOT STRUCT_STAT_HAS_ST_BLOCKS)
     ++	add_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)
     ++endif()
      +
      +#compile checks
      +check_c_source_runs("
     @@ CMakeLists.txt (new)
      +int main(){return 0;}"
      +HAVE_REGEX)
      +if(NOT HAVE_REGEX)
     -+	include_directories(compat/regex )
     ++	include_directories(${CMAKE_SOURCE_DIR}/compat/regex)
      +	list(APPEND compat_SOURCES compat/regex/regex.c )
      +	add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
      +endif()
     @@ CMakeLists.txt (new)
      +	add_compile_definitions(HAVE_BSD_SYSCTL)
      +endif()
      +
     ++set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES})
     ++set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS})
     ++
     ++check_c_source_compiles("
     ++#include <iconv.h>
     ++
     ++extern size_t iconv(iconv_t cd,
     ++		char **inbuf, size_t *inbytesleft,
     ++		char **outbuf, size_t *outbytesleft);
     ++
     ++int main(){return 0;}"
     ++HAVE_NEW_ICONV)
     ++if(HAVE_NEW_ICONV)
     ++	set(HAVE_OLD_ICONV 0)
     ++else()
     ++	set(HAVE_OLD_ICONV 1)
     ++endif()
     ++
     ++check_c_source_runs("
     ++#include <iconv.h>
     ++#if ${HAVE_OLD_ICONV}
     ++typedef const char *iconv_ibp;
     ++#else
     ++typedef char *iconv_ibp;
     ++#endif
     ++
     ++int main()
     ++{
     ++	int v;
     ++	iconv_t conv;
     ++	char in[] = \"a\"; iconv_ibp pin = in;
     ++	char out[20] = \"\"; char *pout = out;
     ++	size_t isz = sizeof in;
     ++	size_t osz = sizeof out;
     ++
     ++	conv = iconv_open(\"UTF-16\", \"UTF-8\");
     ++	iconv(conv, &pin, &isz, &pout, &osz);
     ++	iconv_close(conv);
     ++	v = (unsigned char)(out[0]) + (unsigned char)(out[1]);
     ++	return v != 0xfe + 0xff;
     ++}"
     ++ICONV_DOESNOT_OMIT_BOM)
     ++if(NOT ICONV_DOESNOT_OMIT_BOM)
     ++	add_compile_definitions(ICONV_OMITS_BOM)
     ++endif()
     ++
     ++unset(CMAKE_REQUIRED_LIBRARIES)
     ++unset(CMAKE_REQUIRED_INCLUDES)
     ++
     ++
      +#programs
      +set(PROGRAMS_BUILT
      +	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
     @@ CMakeLists.txt (new)
      +list(APPEND EXCLUSION_PROGS empty)
      +set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" FORCE)
      +
     -+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
     ++if(NOT EXISTS ${CMAKE_BINARY_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
      +	list(REMOVE_ITEM EXCLUSION_PROGS empty)
      +	message("Generating command-list.h")
      +	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
      +			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
     -+			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/command-list.h)
     ++			OUTPUT_FILE ${CMAKE_BINARY_DIR}/command-list.h)
      +endif()
      +
     -+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/config-list.h)
     ++if(NOT EXISTS ${CMAKE_BINARY_DIR}/config-list.h)
      +	message("Generating config-list.h")
      +	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
      +			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
     -+			OUTPUT_FILE ${CMAKE_SOURCE_DIR}/config-list.h)
     ++			OUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h)
      +endif()
      +
     ++include_directories(${CMAKE_BINARY_DIR})
      +
      +#build
     -+set(libgit_SOURCES
     -+	abspath.c add-interactive.c add-patch.c advice.c alias.c
     -+	alloc.c apply.c archive.c archive-tar.c archive-zip.c argv-array.c
     -+	attr.c base85.c bisect.c blame.c blob.c bloom.c branch.c bulk-checkin.c
     -+	bundle.c cache-tree.c chdir-notify.c checkout.c color.c column.c
     -+	combine-diff.c commit.c commit-graph.c commit-reach.c compat/obstack.c
     -+	compat/terminal.c config.c connect.c connected.c convert.c copy.c credential.c
     -+	csum-file.c ctype.c date.c decorate.c delta-islands.c diffcore-break.c
     -+	diffcore-delta.c diffcore-order.c diffcore-pickaxe.c diffcore-rename.c
     -+	diff-delta.c diff-lib.c diff-no-index.c diff.c dir.c dir-iterator.c editor.c
     -+	entry.c environment.c ewah/bitmap.c ewah/ewah_bitmap.c ewah/ewah_io.c
     -+	ewah/ewah_rlw.c exec-cmd.c fetch-negotiator.c fetch-pack.c fmt-merge-msg.c fsck.c fsmonitor.c
     -+	gettext.c gpg-interface.c graph.c grep.c hashmap.c linear-assignment.c help.c hex.c
     -+	ident.c interdiff.c json-writer.c kwset.c levenshtein.c line-log.c line-range.c list-objects.c
     -+	list-objects-filter.c list-objects-filter-options.c ll-merge.c lockfile.c
     -+	log-tree.c ls-refs.c mailinfo.c mailmap.c match-trees.c mem-pool.c merge.c merge-blobs.c
     -+	merge-recursive.c mergesort.c midx.c name-hash.c negotiator/default.c
     -+	negotiator/skipping.c notes.c notes-cache.c notes-merge.c notes-utils.c object.c oidmap.c
     -+	oidset.c oid-array.c packfile.c pack-bitmap.c pack-bitmap-write.c pack-check.c pack-objects.c
     -+	pack-revindex.c pack-write.c pager.c parse-options.c parse-options-cb.c patch-delta.c
     -+	patch-ids.c path.c pathspec.c pkt-line.c preload-index.c pretty.c prio-queue.c progress.c
     -+	promisor-remote.c prompt.c protocol.c prune-packed.c quote.c range-diff.c reachable.c read-cache.c rebase.c
     -+	rebase-interactive.c reflog-walk.c refs.c refs/files-backend.c refs/iterator.c
     -+	refs/packed-backend.c refs/ref-cache.c refspec.c ref-filter.c remote.c replace-object.c
     -+	repo-settings.c repository.c rerere.c reset.c resolve-undo.c revision.c run-command.c
     -+	send-pack.c sequencer.c serve.c server-info.c setup.c sha1-lookup.c
     -+	sha1-file.c sha1-name.c shallow.c sideband.c sigchain.c split-index.c
     -+	stable-qsort.c strbuf.c streaming.c string-list.c submodule.c submodule-config.c
     -+	sub-process.c symlinks.c tag.c tempfile.c thread-utils.c tmp-objdir.c
     -+	trace.c trace2.c trace2/tr2_cfg.c trace2/tr2_cmd_name.c trace2/tr2_dst.c
     -+	trace2/tr2_sid.c trace2/tr2_sysenv.c trace2/tr2_tbuf.c trace2/tr2_tgt_event.c
     -+	trace2/tr2_tgt_normal.c trace2/tr2_tgt_perf.c trace2/tr2_tls.c trailer.c transport.c
     -+	transport-helper.c tree-diff.c tree.c tree-walk.c unpack-trees.c upload-pack.c url.c
     -+	urlmatch.c usage.c userdiff.c utf8.c varint.c version.c versioncmp.c walker.c wildmatch.c
     -+	worktree.c wrapper.c write-or-die.c ws.c wt-status.c xdiff-interface.c
     -+	zlib.c)
     ++#libgit
     ++parse_makefile_for_sources(libgit_SOURCES "LIB_OBJS")
      +
     ++list(TRANSFORM libgit_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
     ++list(TRANSFORM compat_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
      +add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
      +
     -+set(libxdiff_SOURCES
     -+	xdiff/xdiffi.c xdiff/xprepare.c xdiff/xutils.c xdiff/xemit.c
     -+	xdiff/xmerge.c xdiff/xpatience.c xdiff/xhistogram.c)
     ++#libxdiff
     ++parse_makefile_for_sources(libxdiff_SOURCES "XDIFF_OBJS")
     ++
     ++list(TRANSFORM libxdiff_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
      +add_library(xdiff STATIC ${libxdiff_SOURCES})
      +
     -+set(libvcs-svn_SOURCES
     -+	vcs-svn/line_buffer.c vcs-svn/sliding_window.c vcs-svn/fast_export.c
     -+	vcs-svn/svndiff.c vcs-svn/svndump.c)
     ++#libvcs-svn
     ++parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
     ++
     ++list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
      +add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
      +
      +#link all required libraries to common-main
     -+add_library(common-main OBJECT common-main.c)
     ++add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)
      +target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
      +if(Intl_FOUND)
      +	target_link_libraries(common-main ${Intl_LIBRARIES})
     @@ CMakeLists.txt (new)
      +	target_link_libraries(common-main ${Iconv_LIBRARIES})
      +endif()
      +
     ++#git
     ++parse_makefile_for_sources(git_SOURCES "BUILTIN_OBJS")
     ++
     ++list(TRANSFORM git_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
     ++add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})
     ++target_link_libraries(git common-main)
      +
     -+set(git_SOURCES
     -+	builtin/add.c builtin/am.c builtin/annotate.c builtin/apply.c
     -+	builtin/archive.c builtin/bisect--helper.c builtin/blame.c
     -+	builtin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c
     -+	builtin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c
     -+	builtin/checkout-index.c builtin/checkout.c builtin/clean.c
     -+	builtin/clone.c builtin/column.c builtin/commit-tree.c
     -+	builtin/commit.c builtin/commit-graph.c builtin/config.c
     -+	builtin/count-objects.c builtin/credential.c builtin/describe.c
     -+	builtin/diff-files.c builtin/diff-index.c builtin/diff-tree.c
     -+	builtin/diff.c builtin/difftool.c builtin/env--helper.c
     -+	builtin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c
     -+	builtin/for-each-ref.c builtin/fsck.c builtin/gc.c
     -+	builtin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c
     -+	builtin/help.c builtin/index-pack.c builtin/init-db.c
     -+	builtin/interpret-trailers.c builtin/log.c builtin/ls-files.c
     -+	builtin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c
     -+	builtin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c
     -+	builtin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c
     -+	builtin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c
     -+	builtin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c
     -+	builtin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c
     -+	builtin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c
     -+	builtin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c
     -+	builtin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c
     -+	builtin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c
     -+	builtin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c
     -+	builtin/show-branch.c builtin/show-index.c builtin/show-ref.c
     -+	builtin/sparse-checkout.c builtin/stash.c builtin/stripspace.c
     -+	builtin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c
     -+	builtin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c
     -+	builtin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c
     -+	builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c
     -+	builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)
     -+
     -+add_executable(git git.c ${git_SOURCES})
     -+target_link_libraries(git common-main )
     -+
     -+add_executable(git-bugreport bugreport.c)
     ++add_executable(git-bugreport ${CMAKE_SOURCE_DIR}/bugreport.c)
      +target_link_libraries(git-bugreport common-main)
      +
     -+add_executable(git-credential-store credential-store.c)
     ++add_executable(git-credential-store ${CMAKE_SOURCE_DIR}/credential-store.c)
      +target_link_libraries(git-credential-store common-main)
      +
     -+add_executable(git-daemon daemon.c)
     ++add_executable(git-daemon ${CMAKE_SOURCE_DIR}/daemon.c)
      +target_link_libraries(git-daemon common-main)
      +
     -+add_executable(git-fast-import fast-import.c)
     ++add_executable(git-fast-import ${CMAKE_SOURCE_DIR}/fast-import.c)
      +target_link_libraries(git-fast-import common-main)
      +
     -+add_executable(git-http-backend http-backend.c)
     ++add_executable(git-http-backend ${CMAKE_SOURCE_DIR}/http-backend.c)
      +target_link_libraries(git-http-backend common-main)
      +
     -+add_executable(git-sh-i18n--envsubst sh-i18n--envsubst.c)
     ++add_executable(git-sh-i18n--envsubst ${CMAKE_SOURCE_DIR}/sh-i18n--envsubst.c)
      +target_link_libraries(git-sh-i18n--envsubst common-main)
      +
     -+add_executable(git-shell shell.c)
     ++add_executable(git-shell ${CMAKE_SOURCE_DIR}/shell.c)
      +target_link_libraries(git-shell common-main)
      +
      +if(CURL_FOUND)
     -+	add_library(http_obj OBJECT http.c)
     ++	add_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c)
      +
     -+	add_executable(git-imap-send imap-send.c)
     ++	add_executable(git-imap-send ${CMAKE_SOURCE_DIR}/imap-send.c)
      +	target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})
      +
     -+	add_executable(git-http-fetch http-walker.c http-fetch.c)
     ++	add_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c)
      +	target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})
      +
     -+	add_executable(git-remote-http http-walker.c remote-curl.c)
     ++	add_executable(git-remote-http ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/remote-curl.c)
      +	target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )
      +
      +	if(EXPAT_FOUND)
     -+		add_executable(git-http-push http-push.c)
     ++		add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
      +		target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
      +	endif()
      +endif()
      +
     -+add_executable(git-remote-testsvn remote-testsvn.c)
     ++add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)
      +target_link_libraries(git-remote-testsvn common-main vcs-svn)
      +
     -+add_executable(git-credential-cache credential-cache.c)
     ++add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)
      +target_link_libraries(git-credential-cache common-main)
      +
     -+add_executable(git-credential-cache--daemon credential-cache--daemon.c)
     ++add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)
      +target_link_libraries(git-credential-cache--daemon common-main)
      +
      +
     @@ CMakeLists.txt (new)
      +
      +#Creating hardlinks
      +foreach(s ${git_SOURCES} ${git_builtin_extra})
     -+	string(REPLACE "builtin/" "" s ${s})
     ++	string(REPLACE "${CMAKE_SOURCE_DIR}/builtin/" "" s ${s})
      +	string(REPLACE ".c" "" s ${s})
      +	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
      +	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
     @@ CMakeLists.txt (new)
      +		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
      +		DEPENDS git git-remote-http)
      +add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
     - \ No newline at end of file
  2:  ca242cf5bda !  2:  f19794fdbc0 cmake: generate the shell/perl/python scripts and templates, translations
     @@ Metadata
       ## Commit message ##
          cmake: generate the shell/perl/python scripts and templates, translations
      
     -    This patch implements the placeholder substitution to generate, say,
     -    `git-request-pull` from `git-request-pull.sh`.
     +    Implement the placeholder substitution to generate scripted
     +    Porcelain commands, e.g. git-request-pull out of
     +    git-request-pull.sh
      
     -    The shell/perl/python scripts and template are generated using CMake
     -    (very similar to what sed does).
     +    Generate shell/perl/python scripts and template using CMake instead of
     +    using sed like the build procedure in the Makefile does.
      
          The text translations are only build if `msgfmt` is found in your path.
      
          NOTE: The scripts and templates are generated during configuration.
      
     +    Changes
     +    The CMake script parses the Makefile for:
     +    SCRIPT_SH
     +    SCRIPT_PERL
     +
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
     - ## CMakeLists.txt ##
     -@@ CMakeLists.txt: endif()
     + ## contrib/buildsystems/CMakeLists.txt ##
     +@@ contrib/buildsystems/CMakeLists.txt: project(git
     + 	LANGUAGES C)
     + 
     + 
     +-#macros for parsing the Makefile for sources
     ++#macros for parsing the Makefile for sources and scripts
     + macro(parse_makefile_for_sources list_var regex)
     + 	file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
     + 	string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
     +@@ contrib/buildsystems/CMakeLists.txt: macro(parse_makefile_for_sources list_var regex)
     + 	list(REMOVE_ITEM ${list_var} "") #remove empty list elements
     + endmacro()
       
     - find_program(SH_EXE sh)
     ++macro(parse_makefile_for_scripts list_var regex lang)
     ++	file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
     ++	string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
     ++	string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
     ++	string(REPLACE " " ";" ${list_var} ${${list_var}}) #convert string to a list
     ++	list(TRANSFORM ${list_var} REPLACE "${lang}" "") #do the replacement
     ++endmacro()
     ++
     + include(CheckTypeSize)
     + include(CheckCSourceRuns)
     + include(CheckCSourceCompiles)
     +@@ contrib/buildsystems/CMakeLists.txt: if(Intl_FOUND)
     + 	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
     + endif()
       
      +find_program(MSGFMT_EXE msgfmt)
      +if(NOT MSGFMT_EXE)
     @@ CMakeLists.txt: endif()
       #default behaviour
       include_directories(${CMAKE_SOURCE_DIR})
       add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
     -@@ CMakeLists.txt: endif()
     - add_custom_command(OUTPUT ${git_links} ${git_http_links}
     +@@ contrib/buildsystems/CMakeLists.txt: add_custom_command(OUTPUT ${git_links} ${git_http_links}
       		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
       		DEPENDS git git-remote-http)
     --add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
     - \ No newline at end of file
     -+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
     + add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
      +
      +
      +#creating required scripts
     @@ CMakeLists.txt: endif()
      +set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)
      +
      +#shell scripts
     ++parse_makefile_for_scripts(git_sh_scripts "SCRIPT_SH" ".sh")
      +set(git_shell_scripts
     -+	git-bisect git-difftool--helper git-filter-branch
     -+	git-merge-octopus git-merge-one-file git-merge-resolve
     -+	git-mergetool git-quiltimport
     -+	git-request-pull git-submodule git-web--browse
     ++	${git_sh_scripts}
      +	git-mergetool--lib git-parse-remote git-rebase--preserve-merges
      +	git-sh-setup git-sh-i18n git-instaweb)
      +
     @@ CMakeLists.txt: endif()
      +endforeach()
      +
      +#perl scripts
     -+set(git_perl_scripts
     -+	git-add--interactive git-archimport git-cvsexportcommit
     -+	git-cvsimport git-cvsserver git-send-email git-svn)
     ++parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" ".perl")
      +
      +#create perl header
      +file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
  3:  b2974432d77 !  3:  6ec73d3e967 cmake: installation support for git
     @@ Metadata
       ## Commit message ##
          cmake: installation support for git
      
     -    This patch provides the facility to install the built binaries and
     -    scripts.
     +    Install the built binaries and scripts using CMake
      
          This is very similar to `make install`.
          By default the destination directory(DESTDIR) is /usr/local/ on Linux
     @@ Commit message
      
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
     - ## CMakeLists.txt ##
     -@@ CMakeLists.txt: project(git
     + ## contrib/buildsystems/CMakeLists.txt ##
     +@@ contrib/buildsystems/CMakeLists.txt: project(git
       	VERSION ${git_version}
       	LANGUAGES C)
       
      +#TODO gitk git-gui gitweb
      +#TODO Add pcre support
       
     - include(CheckTypeSize)
     - include(CheckCSourceRuns)
     -@@ CMakeLists.txt: if(MSGFMT_EXE)
     + #macros for parsing the Makefile for sources and scripts
     + macro(parse_makefile_for_sources list_var regex)
     +@@ contrib/buildsystems/CMakeLists.txt: if(MSGFMT_EXE)
       	endforeach()
       	add_custom_target(po-gen ALL DEPENDS ${po_gen})
       endif()
     @@ CMakeLists.txt: if(MSGFMT_EXE)
      +install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
      +	DESTINATION libexec/git-core)
      +
     -+install(DIRECTORY mergetools DESTINATION libexec/git-core)
     ++install(DIRECTORY ${CMAKE_SOURCE_DIR}/mergetools DESTINATION libexec/git-core)
      +install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5
      +	FILES_MATCHING PATTERN "*.pm")
      +install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)
  4:  2bd8870fb96 !  4:  cdc53172b3f cmake: support for testing git with ctest
     @@ Commit message
      
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
     - ## CMakeLists.txt ##
     -@@ CMakeLists.txt: include(CheckIncludeFile)
     + ## contrib/buildsystems/CMakeLists.txt ##
     +@@ contrib/buildsystems/CMakeLists.txt: include(CheckIncludeFile)
       include(CheckFunctionExists)
       include(CheckSymbolExists)
       include(CheckStructHasMember)
     @@ CMakeLists.txt: include(CheckIncludeFile)
       
       find_package(ZLIB REQUIRED)
       find_package(CURL)
     -@@ CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/
     +@@ contrib/buildsystems/CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/
       if(MSGFMT_EXE)
       	install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
       endif()
     @@ CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION
      +if(BUILD_TESTING)
      +
      +#tests-helpers
     -+add_executable(test-fake-ssh t/helper/test-fake-ssh.c)
     ++add_executable(test-fake-ssh ${CMAKE_SOURCE_DIR}/t/helper/test-fake-ssh.c)
      +target_link_libraries(test-fake-ssh common-main)
      +
     -+add_executable(test-line-buffer t/helper/test-line-buffer.c)
     ++add_executable(test-line-buffer ${CMAKE_SOURCE_DIR}/t/helper/test-line-buffer.c)
      +target_link_libraries(test-line-buffer common-main vcs-svn)
      +
     -+add_executable(test-svn-fe t/helper/test-svn-fe.c)
     ++add_executable(test-svn-fe ${CMAKE_SOURCE_DIR}/t/helper/test-svn-fe.c)
      +target_link_libraries(test-svn-fe common-main vcs-svn)
      +
     -+set(test-tool_SOURCES
     -+	t/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c
     -+	t/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c
     -+	t/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c
     -+	t/helper/test-dump-fsmonitor.c t/helper/test-dump-split-index.c
     -+	t/helper/test-dump-untracked-cache.c t/helper/test-example-decorate.c
     -+	t/helper/test-genrandom.c t/helper/test-genzeros.c t/helper/test-hash.c
     -+	t/helper/test-hashmap.c t/helper/test-hash-speed.c t/helper/test-index-version.c
     -+	t/helper/test-json-writer.c t/helper/test-lazy-init-name-hash.c
     -+	t/helper/test-match-trees.c t/helper/test-mergesort.c t/helper/test-mktemp.c
     -+	t/helper/test-oidmap.c t/helper/test-online-cpus.c t/helper/test-parse-options.c
     -+	t/helper/test-parse-pathspec-file.c t/helper/test-path-utils.c t/helper/test-pkt-line.c
     -+	t/helper/test-prio-queue.c t/helper/test-progress.c t/helper/test-reach.c
     -+	t/helper/test-read-cache.c t/helper/test-read-graph.c t/helper/test-read-midx.c
     -+	t/helper/test-ref-store.c t/helper/test-regex.c t/helper/test-repository.c
     -+	t/helper/test-revision-walking.c t/helper/test-run-command.c t/helper/test-scrap-cache-tree.c
     -+	t/helper/test-serve-v2.c t/helper/test-sha1.c t/helper/test-oid-array.c t/helper/test-sha256.c
     -+	t/helper/test-sigchain.c t/helper/test-strcmp-offset.c t/helper/test-string-list.c
     -+	t/helper/test-submodule-config.c t/helper/test-submodule-nested-repo-config.c t/helper/test-subprocess.c
     -+	t/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c
     -+	t/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)
     -+
     -+add_executable(test-tool ${test-tool_SOURCES})
     ++#test-tool
     ++parse_makefile_for_sources(test-tool_SOURCES "TEST_BUILTINS_OBJS")
     ++
     ++list(TRANSFORM test-tool_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/t/helper/")
     ++add_executable(test-tool ${CMAKE_SOURCE_DIR}/t/helper/test-tool.c ${test-tool_SOURCES})
      +target_link_libraries(test-tool common-main)
      +
      +set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
     @@ CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION
      +endforeach()
      +
      +endif()#BUILD_TESTING
     - \ No newline at end of file
  5:  096f6311ad5 !  5:  cdc68f102cb cmake: support for testing git when building out of the source tree
     @@ Commit message
      
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
     - ## CMakeLists.txt ##
     -@@ CMakeLists.txt: file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n"
     + ## contrib/buildsystems/CMakeLists.txt ##
     +@@ contrib/buildsystems/CMakeLists.txt: file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n"
       file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
       file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
       
      +#Make the tests work when building out of the source tree
     -+if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
     ++get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE)
     ++if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})
      +	file(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)
      +	string(REPLACE "/CMakeCache.txt" "" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})
      +	#Setting the build directory in test-lib.sh before running tests
  6:  00cae10bbb7 !  6:  f41cbd43081 cmake: support for building git on windows with mingw
     @@ Commit message
          Changed the error message when sh.exe is not found on Windows as
          suggested by Philip Oakley <philipoakley@iee.email>
      
     +    v2:
     +    Fixed a bug where a Windows user can pose as Linux user and vice versa.
     +
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
     - ## CMakeLists.txt ##
     -@@ CMakeLists.txt: project(git
     + ## contrib/buildsystems/CMakeLists.txt ##
     +@@ contrib/buildsystems/CMakeLists.txt: cmake_minimum_required(VERSION 3.14)
     + set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
     + 
     + find_program(SH_EXE sh)
     ++if(NOT SH_EXE)
     ++	message(FATAL_ERROR "sh: shell interpreter was not found in your path, please install one."
     ++			"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
     ++endif()
     + 
     + #Create GIT-VERSION-FILE using GIT-VERSION-GEN
     + if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)
     +@@ contrib/buildsystems/CMakeLists.txt: project(git
       	VERSION ${git_version}
       	LANGUAGES C)
       
     @@ CMakeLists.txt: project(git
      +#TODO Enable NLS on windows natively
       #TODO Add pcre support
       
     -+
     - include(CheckTypeSize)
     - include(CheckCSourceRuns)
     - include(CheckCSourceCompiles)
     -@@ CMakeLists.txt: find_package(EXPAT)
     + #macros for parsing the Makefile for sources and scripts
     +@@ contrib/buildsystems/CMakeLists.txt: find_package(EXPAT)
       find_package(Iconv)
       find_package(Intl)
       
     @@ CMakeLists.txt: find_package(EXPAT)
       if(NOT Intl_FOUND)
       	add_compile_definitions(NO_GETTEXT)
       	if(NOT Iconv_FOUND)
     -@@ CMakeLists.txt: if(Intl_FOUND)
     +@@ contrib/buildsystems/CMakeLists.txt: if(Intl_FOUND)
     + 	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
       endif()
       
     - find_program(SH_EXE sh)
     -+if(NOT SH_EXE)
     -+	message(FATAL_ERROR "sh: shell interpreter was not found in your path, please install one."
     -+			"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
     -+endif()
      +
      +if(WIN32)
      +	find_program(WINDRES_EXE windres)
     @@ CMakeLists.txt: if(Intl_FOUND)
      +		message(FATAL_ERROR "Install windres on Windows for resource files")
      +	endif()
      +endif()
     - 
     ++
       find_program(MSGFMT_EXE msgfmt)
       if(NOT MSGFMT_EXE)
     -@@ CMakeLists.txt: add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
     + 	message(WARNING "Text Translations won't be build")
     +@@ contrib/buildsystems/CMakeLists.txt: add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
       			BINDIR="bin"
       			GIT_BUILT_FROM_COMMIT="")
       
     @@ CMakeLists.txt: add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
      -list(APPEND compat_SOURCES unix-socket.c)
      +
      +#Platform Specific
     -+if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
     -+	include_directories(compat/win32)
     ++if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
     ++	include_directories(${CMAKE_SOURCE_DIR}/compat/win32)
      +	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
      +				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
     -+				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0 NO_ST_BLOCKS_IN_STRUCT_STAT
     ++				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0
      +				USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
      +				UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
      +	list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
     @@ CMakeLists.txt: add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
      +		compat/nedmalloc/nedmalloc.c compat/strdup.c)
      +	set(NO_UNIX_SOCKETS 1)
      +
     -+elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
     ++elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
      +	add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
      +	list(APPEND compat_SOURCES unix-socket.c)
      +endif()
     @@ CMakeLists.txt: add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
       
       #header checks
       check_include_file(libgen.h HAVE_LIBGEN_H)
     -@@ CMakeLists.txt: endif()
     +@@ contrib/buildsystems/CMakeLists.txt: endif()
       #function checks
       set(function_checks
       	strcasestr memmem strlcpy strtoimax strtoumax strtoull
     --	setenv  mkdtemp poll pread  memmem unsetenv hstrerror)
     -+	setenv  mkdtemp poll pread  memmem)
     +-	setenv mkdtemp poll pread memmem unsetenv hstrerror)
     ++	setenv mkdtemp poll pread memmem)
      +
      +#unsetenv,hstrerror are incompatible with windows build
      +if(NOT WIN32)
     @@ CMakeLists.txt: endif()
       
       foreach(f ${function_checks})
       	string(TOUPPER ${f} uf)
     -@@ CMakeLists.txt: endif()
     +@@ contrib/buildsystems/CMakeLists.txt: unset(CMAKE_REQUIRED_INCLUDES)
       #programs
       set(PROGRAMS_BUILT
       	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
     @@ CMakeLists.txt: endif()
       
       if(NOT CURL_FOUND)
       	list(APPEND excluded_progs git-http-fetch git-http-push)
     -@@ CMakeLists.txt: set(libvcs-svn_SOURCES
     - 	vcs-svn/svndiff.c vcs-svn/svndump.c)
     +@@ contrib/buildsystems/CMakeLists.txt: parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
     + list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
       add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
       
      +#add git.rc for gcc
     @@ CMakeLists.txt: set(libvcs-svn_SOURCES
      +endif()
      +
       #link all required libraries to common-main
     - add_library(common-main OBJECT common-main.c)
     + add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)
      -target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
      +
      +target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})
     @@ CMakeLists.txt: set(libvcs-svn_SOURCES
      +	target_link_libraries(common-main pthread rt)
      +endif()
       
     - 
     - set(git_SOURCES
     -@@ CMakeLists.txt: endif()
     - add_executable(git-remote-testsvn remote-testsvn.c)
     + #git
     + parse_makefile_for_sources(git_SOURCES "BUILTIN_OBJS")
     +@@ contrib/buildsystems/CMakeLists.txt: endif()
     + add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)
       target_link_libraries(git-remote-testsvn common-main vcs-svn)
       
     --add_executable(git-credential-cache credential-cache.c)
     +-add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)
      -target_link_libraries(git-credential-cache common-main)
      +if(NOT NO_UNIX_SOCKETS)
     -+	add_executable(git-credential-cache credential-cache.c)
     ++	add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)
      +	target_link_libraries(git-credential-cache common-main)
       
     --add_executable(git-credential-cache--daemon credential-cache--daemon.c)
     +-add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)
      -target_link_libraries(git-credential-cache--daemon common-main)
     -+	add_executable(git-credential-cache--daemon credential-cache--daemon.c)
     ++	add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)
      +	target_link_libraries(git-credential-cache--daemon common-main)
      +endif()
       
       
       set(git_builtin_extra
     -@@ CMakeLists.txt: set(git_builtin_extra
     +@@ contrib/buildsystems/CMakeLists.txt: set(git_builtin_extra
       foreach(s ${git_SOURCES} ${git_builtin_extra})
     - 	string(REPLACE "builtin/" "" s ${s})
     + 	string(REPLACE "${CMAKE_SOURCE_DIR}/builtin/" "" s ${s})
       	string(REPLACE ".c" "" s ${s})
      -	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
      -	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
     @@ CMakeLists.txt: set(git_builtin_extra
       	endforeach()
       endif()
       
     -@@ CMakeLists.txt: set(bin_links
     +@@ contrib/buildsystems/CMakeLists.txt: set(bin_links
       	git-receive-pack git-upload-archive git-upload-pack)
       
       foreach(b ${bin_links})
     @@ CMakeLists.txt: set(bin_links
       endforeach()
       
       install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
     -@@ CMakeLists.txt: set(wrapper_test_scripts
     +@@ contrib/buildsystems/CMakeLists.txt: set(wrapper_test_scripts
       foreach(script ${wrapper_scripts})
       	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
       	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
     @@ CMakeLists.txt: set(wrapper_test_scripts
       	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
       endforeach()
       
     -@@ CMakeLists.txt: file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\
     +@@ contrib/buildsystems/CMakeLists.txt: file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\
       file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
       file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
       file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
  7:  af6c606881d !  7:  8f36e30cd22 cmake: support for building git on windows with msvc and clang.
     @@ Commit message
      
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
     - ## CMakeLists.txt ##
     -@@
     - #	Copyright (c) 2020 Sibi Siddharthan
     - #
     - 
     --cmake_minimum_required(VERSION 3.14)
     -+cmake_minimum_required(VERSION 3.15)
     - 
     - #Parse GIT-VERSION-GEN to get the version
     - file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
     -@@ CMakeLists.txt: find_package(ZLIB REQUIRED)
     + ## contrib/buildsystems/CMakeLists.txt ##
     +@@ contrib/buildsystems/CMakeLists.txt: find_package(ZLIB REQUIRED)
       find_package(CURL)
       find_package(EXPAT)
       find_package(Iconv)
     @@ CMakeLists.txt: find_package(ZLIB REQUIRED)
       
       if(NOT Intl_FOUND)
       	add_compile_definitions(NO_GETTEXT)
     -@@ CMakeLists.txt: if(NOT SH_EXE)
     - 			"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
     +@@ contrib/buildsystems/CMakeLists.txt: if(Intl_FOUND)
       endif()
       
     + 
      -if(WIN32)
      +if(WIN32 AND NOT MSVC)#not required for visual studio builds
       	find_program(WINDRES_EXE windres)
       	if(NOT WINDRES_EXE)
       		message(FATAL_ERROR "Install windres on Windows for resource files")
     -@@ CMakeLists.txt: if(NOT MSGFMT_EXE)
     +@@ contrib/buildsystems/CMakeLists.txt: if(NOT MSGFMT_EXE)
       	message(WARNING "Text Translations won't be build")
       endif()
       
     @@ CMakeLists.txt: if(NOT MSGFMT_EXE)
       #default behaviour
       include_directories(${CMAKE_SOURCE_DIR})
       add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
     -@@ CMakeLists.txt: endif()
     +@@ contrib/buildsystems/CMakeLists.txt: endif()
       
       #Platform Specific
     - if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
     + if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
      +	if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
     -+		include_directories(compat/vcbuild/include)
     ++		include_directories(${CMAKE_SOURCE_DIR}/compat/vcbuild/include)
      +		add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
      +	endif()
     - 	include_directories(compat/win32)
     + 	include_directories(${CMAKE_SOURCE_DIR}/compat/win32)
       	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
       				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
     -@@ CMakeLists.txt: set(libvcs-svn_SOURCES
     - 	vcs-svn/svndiff.c vcs-svn/svndump.c)
     +@@ contrib/buildsystems/CMakeLists.txt: parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
     + list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
       add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
       
      -#add git.rc for gcc
     @@ CMakeLists.txt: set(libvcs-svn_SOURCES
       	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
       endif()
       
     -@@ CMakeLists.txt: endif()
     +@@ contrib/buildsystems/CMakeLists.txt: endif()
       if(WIN32)
       	target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
       	add_dependencies(common-main git-rc)
     @@ CMakeLists.txt: endif()
       elseif(UNIX)
       	target_link_libraries(common-main pthread rt)
       endif()
     -@@ CMakeLists.txt: target_link_libraries(test-tool common-main)
     +@@ contrib/buildsystems/CMakeLists.txt: target_link_libraries(test-tool common-main)
       set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
       			PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)
       
  8:  f496cd7d8aa <  -:  ----------- cmake: added checks for struct stat and libiconv
  9:  9c674372fb5 <  -:  ----------- cmake: relocated script file contrib/buildsystems
 10:  b0a321a714a <  -:  ----------- cmake: parse the makefile for the sources.
 11:  fa1b8032906 !  8:  bb329d16ce0 ci: modification of main.yml to use cmake for vs-build job
     @@
       ## Metadata ##
     -Author: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
     +Author: Sibi Siddharthan <sibisiv.siddharthan@gmail.com>
      
       ## Commit message ##
          ci: modification of main.yml to use cmake for vs-build job
      
     -    This patch modifies .github/workflows/main.yml to use CMake for
     -    Visual Studio builds.
     +    Teach .github/workflows/main.yml to use CMake for VS builds.
      
          Modified the vs-test step to match windows-test step. This speeds
          up the vs-test. Calling git-cmd from powershell and then calling git-bash
     @@ Commit message
          building git (eg zlib,libiconv). So we extract the libraries before we
          configure.
      
     -    Changes:
     -    The CMake script has been relocated to contib/buildsystems, so point
     -    to the CMakeLists.txt in the invocation commands.
     -
     -    The generation command now uses the absolute paths for the generation
     -    step.
     -
          To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working
          directory of script or path. So we copy the dlls before we configure.
      
     -    Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
     +    Signed-off-by: Sibi Siddharthan <sibisiv.siddharthan@gmail.com>
      
       ## .github/workflows/main.yml ##
      @@ .github/workflows/main.yml: jobs:
     -     - name: download git-sdk-64-minimal
     -       shell: bash
     -       run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
     +         ## Unzip and remove the artifact
     +         unzip artifacts.zip
     +         rm artifacts.zip
      -    - name: generate Visual Studio solution
      -      shell: powershell
      -      run: |
     @@ .github/workflows/main.yml: jobs:
               & git-sdk-64-minimal\usr\bin\bash.exe -lc @"
                 mkdir -p artifacts &&
                 eval \"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts 2>&1 | grep ^tar)\"
     -@@ .github/workflows/main.yml: jobs:
     -         nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
     -     steps:
     -     - uses: actions/checkout@v1
     --    - name: download git-64-portable
     -+    - name: download git-sdk-64-minimal
     -       shell: bash
     --      run: a=git-64-portable && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
     -+      run: a=git-sdk-64-minimal && mkdir -p $a && curl -# https://wingit.blob.core.windows.net/ci-artifacts/$a.tar.xz | tar -C $a -xJf -
     -     - name: download build artifacts
     -       uses: actions/download-artifact@v1
     -       with:
      @@ .github/workflows/main.yml: jobs:
           - name: extract build artifacts
             shell: bash
     @@ .github/workflows/main.yml: jobs:
             shell: powershell
             env:
               MSYSTEM: MINGW64
     -         NO_SVN_TESTS: 1
     -         GIT_TEST_SKIP_REBASE_P: 1
     -       run: |
     --        & git-64-portable\git-cmd.exe --command=usr\bin\bash.exe -lc @"
     --          # Let Git ignore the SDK and the test-cache
     --          printf '%s\n' /git-64-portable/ /test-cache/ >>.git/info/exclude
     -+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
     -+          # Let Git ignore the SDK
     -+          printf '%s\n' /git-sdk-64-minimal/ >>.git/info/exclude
     +@@ .github/workflows/main.yml: jobs:
     +           # Let Git ignore the SDK and the test-cache
     +           printf '%s\n' /git-sdk-64-minimal/ /test-cache/ >>.git/info/exclude
       
      -          cd t &&
      -          PATH=\"`$PWD/helper:`$PATH\" &&
     @@ .github/workflows/main.yml: jobs:
      +        name: failed-tests-windows
      +        path: ${{env.FAILED_TEST_ARTIFACTS}}
         regular:
     -     strategy:
     -       matrix:
     +     needs: ci-config
     +     if: needs.ci-config.outputs.enabled == 'yes'
     +@@ .github/workflows/main.yml: jobs:
     +     steps:
     +     - uses: actions/checkout@v1
     +     - run: ci/install-dependencies.sh
     +-    - run: ci/test-documentation.sh
     ++    - run: ci/test-documentation.sh
     + \ No newline at end of file

-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 179+ messages in thread

* [PATCH v3 1/8] Introduce CMake support for configuring Git
  2020-05-29 13:40   ` [PATCH v3 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
@ 2020-05-29 13:40     ` Sibi Siddharthan via GitGitGadget
  2020-05-29 19:27       ` Junio C Hamano
  2020-05-30 13:17       ` Đoàn Trần Công Danh
  2020-05-29 13:40     ` [PATCH v3 2/8] cmake: generate the shell/perl/python scripts and templates, translations Sibi Siddharthan via GitGitGadget
                       ` (7 subsequent siblings)
  8 siblings, 2 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-29 13:40 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

At the moment, the recommended way to configure Git's builds is to
simply run `make`. If that does not work, the recommended strategy is to
look at the top of the `Makefile` to see whether any "Makefile knob" has
to be turned on/off, e.g. `make NO_OPENSSL=YesPlease`.

Alternatively, Git also has an `autoconf` setup which allows configuring
builds via `./configure [<option>...]`.

Both of these options are fine if the developer works on Unix or Linux.
But on Windows, we have to jump through hoops to configure a build
(read: we force the user to install a full Git for Windows SDK, which
occupies around two gigabytes (!) on disk and downloads about three
quarters of a gigabyte worth of Git objects).

The build infrastructure for Git is written around being able to run
make, which is not supported natively on Windows.
To help Windows developers a CMake build script is introduced here.

With a working support CMake, developers on Windows need only install
CMake, configure their build, load the generated Visual Studio solution
and immediately start modifying the code and build their own version of
Git. Likewise, developers on other platforms can use the convenient GUI
tools provided by CMake to configure their build.

So let's start building CMake support for Git.

This is only the first step, and to make it easier to review, it only
allows for configuring builds on the platform that is easiest to
configure for: Linux.

The CMake script checks whether the headers are present(eg. libgen.h),
whether the functions are present(eg. memmem), whether the funtions work
properly (eg. snprintf) and generate the required compile definitions
for the platform. The script also searches for the required libraries,
if it fails to find the required libraries the respective executables
won't be built.(eg. If libcurl is not found then git-remote-http won't
be built). This will help building Git easier.

With a CMake script an out of source build of git is possible resulting
in a clean source tree.

Note: this patch asks for the minimum version v3.14 of CMake (which is
not all that old as of time of writing) because that is the first
version to offer a platform-independent way to generate hardlinks as
part of the build. This is needed to generate all those hardlinks for
the built-in commands of Git.

Changes
The CMake script parses the Makefile for:
LIB_OBJS
BUILTIN_OBJS
XDIFF_OBJS
VCSSVN_OBJS
TEST_BUILTINS_OBJS

By doing this we avoid duplication of text between the Makefile and
the CMake script.

The CMake script has been relocated to contrib/buildsystems.

The CMake script uses GIT-VERSION-GEN to determine the version of Git
being built.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 575 ++++++++++++++++++++++++++++
 1 file changed, 575 insertions(+)
 create mode 100644 contrib/buildsystems/CMakeLists.txt

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
new file mode 100644
index 00000000000..8e2b27f44a6
--- /dev/null
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -0,0 +1,575 @@
+#
+#	Copyright (c) 2020 Sibi Siddharthan
+#
+
+#[[
+
+Instructions to run CMake:
+
+cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release
+
+Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
+compiler flags
+Debug : -g
+Release: -O3
+RelWithDebInfo : -O2 -g
+MinSizeRel : -Os
+empty(default) :
+
+NOTE: -DCMAKE_BUILD_TYPE is optional. For multi-config generators like Visual Studio
+this option is ignored
+
+This process generates a Makefile(Linux) , Visual Studio solution(Windows) by default.
+Run `make` to build Git on Linux.
+Open git.sln on Windows and build Git.
+
+NOTE: By default CMake uses Makefile as the build tool on Linux and Visual Studio in Windows,
+to use another tool say `ninja` add this to the command line when configuring.
+`-G Ninja`
+
+]]
+cmake_minimum_required(VERSION 3.14)
+
+#set the source directory to root of git
+set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
+
+find_program(SH_EXE sh)
+
+#Create GIT-VERSION-FILE using GIT-VERSION-GEN
+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)
+	message("Generating GIT-VERSION-FILE")
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN
+		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+endif()
+
+#Parse GIT-VERSION-FILE to get the version
+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE git_version REGEX "GIT_VERSION = (.*)")
+string(REPLACE "GIT_VERSION = " "" git_version ${git_version})
+string(FIND ${git_version} "GIT" location)
+if(location EQUAL -1)
+	string(REGEX MATCH "[0-9]*\\.[0-9]*\\.[0-9]*" git_version ${git_version})
+else()
+	string(REGEX MATCH "[0-9]*\\.[0-9]*" git_version ${git_version})
+	string(APPEND git_version ".0") #for building from a snapshot
+endif()
+
+project(git
+	VERSION ${git_version}
+	LANGUAGES C)
+
+
+#macros for parsing the Makefile for sources
+macro(parse_makefile_for_sources list_var regex)
+	file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
+	string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
+	string(REPLACE "$(COMPAT_OBJS)" "" ${list_var} ${${list_var}}) #remove "$(COMPAT_OBJS)" This is only for libgit.
+	string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
+	string(REPLACE ".o" ".c;" ${list_var} ${${list_var}}) #change .o to .c, ; is for converting the string into a list
+	list(TRANSFORM ${list_var} STRIP) #remove trailing/leading whitespaces for each element in list
+	list(REMOVE_ITEM ${list_var} "") #remove empty list elements
+endmacro()
+
+include(CheckTypeSize)
+include(CheckCSourceRuns)
+include(CheckCSourceCompiles)
+include(CheckIncludeFile)
+include(CheckFunctionExists)
+include(CheckSymbolExists)
+include(CheckStructHasMember)
+
+find_package(ZLIB REQUIRED)
+find_package(CURL)
+find_package(EXPAT)
+find_package(Iconv)
+find_package(Intl)
+
+if(NOT Intl_FOUND)
+	add_compile_definitions(NO_GETTEXT)
+	if(NOT Iconv_FOUND)
+		add_compile_definitions(NO_ICONV)
+	endif()
+endif()
+
+include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
+if(CURL_FOUND)
+	include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
+endif()
+if(EXPAT_FOUND)
+	include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
+endif()
+if(Iconv_FOUND)
+	include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
+endif()
+if(Intl_FOUND)
+	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
+endif()
+
+#default behaviour
+include_directories(${CMAKE_SOURCE_DIR})
+add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
+add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)
+add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES
+			SHA1DC_INIT_SAFE_HASH_DEFAULT=0
+			SHA1DC_CUSTOM_INCLUDE_SHA1_C="cache.h"
+			SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="git-compat-util.h" )
+list(APPEND compat_SOURCES sha1dc_git.c sha1dc/sha1.c sha1dc/ubc_check.c block-sha1/sha1.c sha256/block/sha256.c compat/qsort_s.c)
+
+
+add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
+			ETC_GITATTRIBUTES="etc/gitattributes"
+			ETC_GITCONFIG="etc/gitconfig"
+			GIT_EXEC_PATH="libexec/git-core"
+			GIT_LOCALE_PATH="share/locale"
+			GIT_MAN_PATH="share/man"
+			GIT_INFO_PATH="share/info"
+			GIT_HTML_PATH="share/doc/git-doc"
+			DEFAULT_HELP_FORMAT="html"
+			DEFAULT_GIT_TEMPLATE_DIR="share/git-core/templates"
+			GIT_VERSION="${PROJECT_VERSION}.GIT"
+			GIT_USER_AGENT="git/${PROJECT_VERSION}.GIT"
+			BINDIR="bin"
+			GIT_BUILT_FROM_COMMIT="")
+
+set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+
+add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
+list(APPEND compat_SOURCES unix-socket.c)
+
+#header checks
+check_include_file(libgen.h HAVE_LIBGEN_H)
+if(NOT HAVE_LIBGEN_H)
+	add_compile_definitions(NO_LIBGEN_H)
+	list(APPEND compat_SOURCES compat/basename.c)
+endif()
+
+check_include_file(sys/sysinfo.h HAVE_SYSINFO)
+if(HAVE_SYSINFO)
+	add_compile_definitions(HAVE_SYSINFO)
+endif()
+
+check_c_source_compiles("
+#include <alloca.h>
+int
+main ()
+{
+char *p = (char *) alloca (2 * sizeof (int));
+	if (p) return 0;
+	return 0;
+}"
+HAVE_ALLOCA_H)
+if(HAVE_ALLOCA_H)
+	add_compile_definitions(HAVE_ALLOCA_H)
+endif()
+
+check_include_file(strings.h HAVE_STRINGS_H)
+if(HAVE_STRINGS_H)
+	add_compile_definitions(HAVE_STRINGS_H)
+endif()
+
+check_include_file(sys/select.h HAVE_SYS_SELECT_H)
+if(NOT HAVE_SYS_SELECT_H)
+	add_compile_definitions(NO_SYS_SELECT_H)
+endif()
+
+check_include_file(sys/poll.h HAVE_SYS_POLL_H)
+if(NOT HAVE_SYS_POLL_H)
+	add_compile_definitions(NO_SYS_POLL_H)
+endif()
+
+check_include_file(poll.h HAVE_POLL_H)
+if(NOT HAVE_POLL_H)
+	add_compile_definitions(NO_POLL_H)
+endif()
+
+check_include_file(inttypes.h HAVE_INTTYPES_H)
+if(NOT HAVE_INTTYPES_H)
+	add_compile_definitions(NO_INTTYPES_H)
+endif()
+
+check_include_file(paths.h HAVE_PATHS_H)
+if(HAVE_PATHS_H)
+	add_compile_definitions(HAVE_PATHS_H)
+endif()
+
+#function checks
+set(function_checks
+	strcasestr memmem strlcpy strtoimax strtoumax strtoull
+	setenv mkdtemp poll pread memmem unsetenv hstrerror)
+
+foreach(f ${function_checks})
+	string(TOUPPER ${f} uf)
+	check_function_exists(${f} HAVE_${uf})
+	if(NOT HAVE_${uf})
+		add_compile_definitions(NO_${uf})
+	endif()
+endforeach()
+
+if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)
+	include_directories(${CMAKE_SOURCE_DIR}/compat/poll)
+	add_compile_definitions(NO_POLL)
+	list(APPEND compat_SOURCES compat/poll/poll.c)
+endif()
+
+if(NOT HAVE_STRCASESTR)
+	list(APPEND compat_SOURCES compat/strcasestr.c)
+endif()
+
+if(NOT HAVE_STRLCPY)
+	list(APPEND compat_SOURCES compat/strlcpy.c)
+endif()
+
+if(NOT HAVE_STRTOUMAX)
+	list(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c)
+endif()
+
+if(NOT HAVE_SETENV)
+	list(APPEND compat_SOURCES compat/setenv.c)
+endif()
+
+if(NOT HAVE_MKDTEMP)
+	list(APPEND compat_SOURCES compat/mkdtemp.c)
+endif()
+
+if(NOT HAVE_PREAD)
+	list(APPEND compat_SOURCES compat/pread.c)
+endif()
+
+if(NOT HAVE_MEMMEM)
+	list(APPEND compat_SOURCES compat/memmem.c)
+endif()
+
+if(NOT WIN32)
+	if(NOT HAVE_UNSETENV)
+		list(APPEND compat_SOURCES compat/unsetenv.c)
+	endif()
+
+	if(NOT HAVE_HSTRERROR)
+		list(APPEND compat_SOURCES compat/hstrerror.c)
+	endif()
+endif()
+
+check_function_exists(getdelim HAVE_GETDELIM)
+if(HAVE_GETDELIM)
+	add_compile_definitions(HAVE_GETDELIM)
+endif()
+
+check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
+check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC)
+if(HAVE_CLOCK_GETTIME)
+	add_compile_definitions(HAVE_CLOCK_GETTIME)
+endif()
+if(HAVE_CLOCK_MONOTONIC)
+	add_compile_definitions(HAVE_CLOCK_MONOTONIC)
+endif()
+
+#check for st_blocks in struct stat
+check_struct_has_member("struct stat" st_blocks "sys/stat.h" STRUCT_STAT_HAS_ST_BLOCKS)
+if(NOT STRUCT_STAT_HAS_ST_BLOCKS)
+	add_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)
+endif()
+
+#compile checks
+check_c_source_runs("
+#include<stdio.h>
+#include<stdarg.h>
+#include<string.h>
+#include<stdlib.h>
+int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
+{
+	int ret;
+	va_list ap;
+
+	va_start(ap, format);
+	ret = vsnprintf(str, maxsize, format, ap);
+	va_end(ap);
+	return ret;
+}
+
+int
+main ()
+{
+	char buf[6];
+	if (test_vsnprintf(buf, 3, \"%s\", \"12345\") != 5
+		|| strcmp(buf, \"12\")) return 1;
+	if (snprintf(buf, 3, \"%s\", \"12345\") != 5
+		|| strcmp(buf, \"12\")) return 1;
+
+	return 0;
+}"
+SNPRINTF_OK)
+if(NOT SNPRINTF_OK)
+	add_compile_definitions(SNPRINTF_RETURNS_BOGUS)
+	list(APPEND compat_SOURCES compat/snprintf.c)
+endif()
+
+check_c_source_runs("
+#include<stdio.h>
+int
+main ()
+{
+	FILE *f = fopen(\".\", \"r\");
+	return f != NULL;
+
+	return 0;
+}"
+FREAD_READS_DIRECTORIES_NO)
+if(NOT FREAD_READS_DIRECTORIES_NO)
+	add_compile_definitions(FREAD_READS_DIRECTORIES)
+	list(APPEND compat_SOURCES compat/fopen.c)
+endif()
+
+check_c_source_compiles("
+#include <regex.h>
+#ifndef REG_STARTEND
+#error oops we dont have it
+#endif
+int main(){return 0;}"
+HAVE_REGEX)
+if(NOT HAVE_REGEX)
+	include_directories(${CMAKE_SOURCE_DIR}/compat/regex)
+	list(APPEND compat_SOURCES compat/regex/regex.c )
+	add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
+endif()
+
+
+check_c_source_compiles("
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+int
+main ()
+{
+	int val, mib[2];
+	size_t len;
+
+	mib[0] = CTL_HW;
+	mib[1] = 1;
+	len = sizeof(val);
+	return sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;
+
+	return 0;
+}"
+HAVE_BSD_SYSCTL)
+if(HAVE_BSD_SYSCTL)
+	add_compile_definitions(HAVE_BSD_SYSCTL)
+endif()
+
+set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES})
+set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS})
+
+check_c_source_compiles("
+#include <iconv.h>
+
+extern size_t iconv(iconv_t cd,
+		char **inbuf, size_t *inbytesleft,
+		char **outbuf, size_t *outbytesleft);
+
+int main(){return 0;}"
+HAVE_NEW_ICONV)
+if(HAVE_NEW_ICONV)
+	set(HAVE_OLD_ICONV 0)
+else()
+	set(HAVE_OLD_ICONV 1)
+endif()
+
+check_c_source_runs("
+#include <iconv.h>
+#if ${HAVE_OLD_ICONV}
+typedef const char *iconv_ibp;
+#else
+typedef char *iconv_ibp;
+#endif
+
+int main()
+{
+	int v;
+	iconv_t conv;
+	char in[] = \"a\"; iconv_ibp pin = in;
+	char out[20] = \"\"; char *pout = out;
+	size_t isz = sizeof in;
+	size_t osz = sizeof out;
+
+	conv = iconv_open(\"UTF-16\", \"UTF-8\");
+	iconv(conv, &pin, &isz, &pout, &osz);
+	iconv_close(conv);
+	v = (unsigned char)(out[0]) + (unsigned char)(out[1]);
+	return v != 0xfe + 0xff;
+}"
+ICONV_DOESNOT_OMIT_BOM)
+if(NOT ICONV_DOESNOT_OMIT_BOM)
+	add_compile_definitions(ICONV_OMITS_BOM)
+endif()
+
+unset(CMAKE_REQUIRED_LIBRARIES)
+unset(CMAKE_REQUIRED_INCLUDES)
+
+
+#programs
+set(PROGRAMS_BUILT
+	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
+	git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
+
+if(NOT CURL_FOUND)
+	list(APPEND excluded_progs git-http-fetch git-http-push)
+	add_compile_definitions(NO_CURL)
+	message(WARNING "git-http-push and git-http-fetch will not be built")
+else()
+	list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
+	if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
+		add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
+	endif()
+endif()
+
+if(NOT EXPAT_FOUND)
+	list(APPEND excluded_progs git-http-push)
+	add_compile_definitions(NO_EXPAT)
+else()
+	list(APPEND PROGRAMS_BUILT git-http-push)
+	if(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2)
+		add_compile_definitions(EXPAT_NEEDS_XMLPARSE_H)
+	endif()
+endif()
+
+list(REMOVE_DUPLICATES excluded_progs)
+list(REMOVE_DUPLICATES PROGRAMS_BUILT)
+
+
+foreach(p ${excluded_progs})
+	list(APPEND EXCLUSION_PROGS --exclude-program ${p} )
+endforeach()
+
+#for comparing null values
+list(APPEND EXCLUSION_PROGS empty)
+set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" FORCE)
+
+if(NOT EXISTS ${CMAKE_BINARY_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
+	list(REMOVE_ITEM EXCLUSION_PROGS empty)
+	message("Generating command-list.h")
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			OUTPUT_FILE ${CMAKE_BINARY_DIR}/command-list.h)
+endif()
+
+if(NOT EXISTS ${CMAKE_BINARY_DIR}/config-list.h)
+	message("Generating config-list.h")
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			OUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h)
+endif()
+
+include_directories(${CMAKE_BINARY_DIR})
+
+#build
+#libgit
+parse_makefile_for_sources(libgit_SOURCES "LIB_OBJS")
+
+list(TRANSFORM libgit_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+list(TRANSFORM compat_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
+
+#libxdiff
+parse_makefile_for_sources(libxdiff_SOURCES "XDIFF_OBJS")
+
+list(TRANSFORM libxdiff_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+add_library(xdiff STATIC ${libxdiff_SOURCES})
+
+#libvcs-svn
+parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
+
+list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
+
+#link all required libraries to common-main
+add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
+if(Intl_FOUND)
+	target_link_libraries(common-main ${Intl_LIBRARIES})
+endif()
+if(Iconv_FOUND)
+	target_link_libraries(common-main ${Iconv_LIBRARIES})
+endif()
+
+#git
+parse_makefile_for_sources(git_SOURCES "BUILTIN_OBJS")
+
+list(TRANSFORM git_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})
+target_link_libraries(git common-main)
+
+add_executable(git-bugreport ${CMAKE_SOURCE_DIR}/bugreport.c)
+target_link_libraries(git-bugreport common-main)
+
+add_executable(git-credential-store ${CMAKE_SOURCE_DIR}/credential-store.c)
+target_link_libraries(git-credential-store common-main)
+
+add_executable(git-daemon ${CMAKE_SOURCE_DIR}/daemon.c)
+target_link_libraries(git-daemon common-main)
+
+add_executable(git-fast-import ${CMAKE_SOURCE_DIR}/fast-import.c)
+target_link_libraries(git-fast-import common-main)
+
+add_executable(git-http-backend ${CMAKE_SOURCE_DIR}/http-backend.c)
+target_link_libraries(git-http-backend common-main)
+
+add_executable(git-sh-i18n--envsubst ${CMAKE_SOURCE_DIR}/sh-i18n--envsubst.c)
+target_link_libraries(git-sh-i18n--envsubst common-main)
+
+add_executable(git-shell ${CMAKE_SOURCE_DIR}/shell.c)
+target_link_libraries(git-shell common-main)
+
+if(CURL_FOUND)
+	add_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c)
+
+	add_executable(git-imap-send ${CMAKE_SOURCE_DIR}/imap-send.c)
+	target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})
+
+	add_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c)
+	target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})
+
+	add_executable(git-remote-http ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/remote-curl.c)
+	target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )
+
+	if(EXPAT_FOUND)
+		add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
+		target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
+	endif()
+endif()
+
+add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)
+target_link_libraries(git-remote-testsvn common-main vcs-svn)
+
+add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)
+target_link_libraries(git-credential-cache common-main)
+
+add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)
+target_link_libraries(git-credential-cache--daemon common-main)
+
+
+set(git_builtin_extra
+	cherry cherry-pick format-patch fsck-objects
+	init merge-subtree restore show
+	stage status switch whatchanged)
+
+#Creating hardlinks
+foreach(s ${git_SOURCES} ${git_builtin_extra})
+	string(REPLACE "${CMAKE_SOURCE_DIR}/builtin/" "" s ${s})
+	string(REPLACE ".c" "" s ${s})
+	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
+	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
+endforeach()
+
+if(CURL_FOUND)
+	set(remote_exes
+		git-remote-https git-remote-ftp git-remote-ftps)
+	foreach(s ${remote_exes})
+		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
+		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+	endforeach()
+endif()
+
+add_custom_command(OUTPUT ${git_links} ${git_http_links}
+		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
+		DEPENDS git git-remote-http)
+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v3 2/8] cmake: generate the shell/perl/python scripts and templates, translations
  2020-05-29 13:40   ` [PATCH v3 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
  2020-05-29 13:40     ` [PATCH v3 1/8] Introduce CMake support for configuring Git Sibi Siddharthan via GitGitGadget
@ 2020-05-29 13:40     ` Sibi Siddharthan via GitGitGadget
  2020-05-29 19:27       ` Junio C Hamano
  2020-05-29 13:40     ` [PATCH v3 3/8] cmake: installation support for git Sibi Siddharthan via GitGitGadget
                       ` (6 subsequent siblings)
  8 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-29 13:40 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

Implement the placeholder substitution to generate scripted
Porcelain commands, e.g. git-request-pull out of
git-request-pull.sh

Generate shell/perl/python scripts and template using CMake instead of
using sed like the build procedure in the Makefile does.

The text translations are only build if `msgfmt` is found in your path.

NOTE: The scripts and templates are generated during configuration.

Changes
The CMake script parses the Makefile for:
SCRIPT_SH
SCRIPT_PERL

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 111 +++++++++++++++++++++++++++-
 1 file changed, 110 insertions(+), 1 deletion(-)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 8e2b27f44a6..11c909d23e3 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -58,7 +58,7 @@ project(git
 	LANGUAGES C)
 
 
-#macros for parsing the Makefile for sources
+#macros for parsing the Makefile for sources and scripts
 macro(parse_makefile_for_sources list_var regex)
 	file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
 	string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
@@ -69,6 +69,14 @@ macro(parse_makefile_for_sources list_var regex)
 	list(REMOVE_ITEM ${list_var} "") #remove empty list elements
 endmacro()
 
+macro(parse_makefile_for_scripts list_var regex lang)
+	file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
+	string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
+	string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
+	string(REPLACE " " ";" ${list_var} ${${list_var}}) #convert string to a list
+	list(TRANSFORM ${list_var} REPLACE "${lang}" "") #do the replacement
+endmacro()
+
 include(CheckTypeSize)
 include(CheckCSourceRuns)
 include(CheckCSourceCompiles)
@@ -104,6 +112,11 @@ if(Intl_FOUND)
 	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
 endif()
 
+find_program(MSGFMT_EXE msgfmt)
+if(NOT MSGFMT_EXE)
+	message(WARNING "Text Translations won't be build")
+endif()
+
 #default behaviour
 include_directories(${CMAKE_SOURCE_DIR})
 add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
@@ -573,3 +586,99 @@ add_custom_command(OUTPUT ${git_links} ${git_http_links}
 		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
 		DEPENDS git git-remote-http)
 add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
+
+
+#creating required scripts
+set(SHELL_PATH /bin/sh)
+set(PERL_PATH /usr/bin/perl)
+set(LOCALEDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
+set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
+set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)
+
+#shell scripts
+parse_makefile_for_scripts(git_sh_scripts "SCRIPT_SH" ".sh")
+set(git_shell_scripts
+	${git_sh_scripts}
+	git-mergetool--lib git-parse-remote git-rebase--preserve-merges
+	git-sh-setup git-sh-i18n git-instaweb)
+
+foreach(script ${git_shell_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)
+	string(REPLACE "@SHELL_PATH@" "${SHELL_PATH}" content "${content}")
+	string(REPLACE "@@DIFF@@" "diff" content "${content}")
+	string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@GITWEBDIR@" "${GITWEBDIR}" content "${content}")
+	string(REPLACE "@@NO_CURL@@" "" content "${content}")
+	string(REPLACE "@@USE_GETTEXT_SCHEME@@" "" content "${content}")
+	string(REPLACE "# @@BROKEN_PATH_FIX@@" "" content "${content}")
+	string(REPLACE "@@PERL@@" "${PERL_PATH}" content "${content}")
+	string(REPLACE "@@SANE_TEXT_GREP@@" "-a" content "${content}")
+	string(REPLACE "@@PAGER_ENV@@" "LESS=FRX LV=-c" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+endforeach()
+
+#perl scripts
+parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" ".perl")
+
+#create perl header
+file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
+string(REPLACE "@@PATHSEP@@" ":" perl_header "${perl_header}")
+string(REPLACE "@@INSTLIBDIR@@" "${INSTLIBDIR}" perl_header "${perl_header}")
+
+foreach(script ${git_perl_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)
+	string(REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n${perl_header}\n" content "${content}")
+	string(REPLACE "@@GIT_VERSION@@" "${PROJECT_VERSION}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+endforeach()
+
+#python script
+file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)
+string(REPLACE "#!/usr/bin/env python" "#!/usr/bin/python" content "${content}")
+file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})
+
+#perl modules
+file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
+
+foreach(pm ${perl_modules})
+	string(REPLACE "${CMAKE_SOURCE_DIR}/perl/" "" file_path ${pm})
+	file(STRINGS ${pm} content NEWLINE_CONSUME)
+	string(REPLACE "@@LOCALEDIR@@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@@NO_PERL_CPAN_FALLBACKS@@" "" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})
+#test-lib.sh requires perl/build/lib to be the build directory of perl modules
+endforeach()
+
+
+#templates
+file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
+set(hooks_templates
+	applypatch-msg.sample pre-applypatch.sample pre-push.sample
+	commit-msg.sample pre-commit.sample pre-rebase.sample
+	fsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample
+	post-update.sample prepare-commit-msg.sample update.sample)
+
+#templates have @.*@ replacement so use configure_file instead
+#hooks
+foreach(tm ${hooks_templates})
+	configure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)
+endforeach()
+
+#info
+configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)
+
+#this
+configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)
+
+
+#translations
+if(MSGFMT_EXE)
+	set(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)
+	foreach(po ${po_files})
+		file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo
+				COMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)
+		list(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)
+	endforeach()
+	add_custom_target(po-gen ALL DEPENDS ${po_gen})
+endif()
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v3 3/8] cmake: installation support for git
  2020-05-29 13:40   ` [PATCH v3 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
  2020-05-29 13:40     ` [PATCH v3 1/8] Introduce CMake support for configuring Git Sibi Siddharthan via GitGitGadget
  2020-05-29 13:40     ` [PATCH v3 2/8] cmake: generate the shell/perl/python scripts and templates, translations Sibi Siddharthan via GitGitGadget
@ 2020-05-29 13:40     ` Sibi Siddharthan via GitGitGadget
  2020-05-29 13:40     ` [PATCH v3 4/8] cmake: support for testing git with ctest Sibi Siddharthan via GitGitGadget
                       ` (5 subsequent siblings)
  8 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-29 13:40 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

Install the built binaries and scripts using CMake

This is very similar to `make install`.
By default the destination directory(DESTDIR) is /usr/local/ on Linux
To set a custom installation path do this:
cmake `relative-path-to-srcdir`
	-DCMAKE_INSTALL_PREFIX=`preferred-install-path`

Then run `make install`

Changes:
Removed a comment regarding the installation of gitk.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 49 +++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 11c909d23e3..0cde1a02cbc 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -57,6 +57,8 @@ project(git
 	VERSION ${git_version}
 	LANGUAGES C)
 
+#TODO gitk git-gui gitweb
+#TODO Add pcre support
 
 #macros for parsing the Makefile for sources and scripts
 macro(parse_makefile_for_sources list_var regex)
@@ -682,3 +684,50 @@ if(MSGFMT_EXE)
 	endforeach()
 	add_custom_target(po-gen ALL DEPENDS ${po_gen})
 endif()
+
+
+#to help with the install
+list(TRANSFORM git_shell_scripts PREPEND "${CMAKE_BINARY_DIR}/")
+list(TRANSFORM git_perl_scripts PREPEND "${CMAKE_BINARY_DIR}/")
+
+#install
+install(TARGETS git git-shell
+	RUNTIME DESTINATION bin)
+install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver
+	DESTINATION bin)
+
+list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)
+install(TARGETS ${PROGRAMS_BUILT}
+	RUNTIME DESTINATION libexec/git-core)
+
+set(bin_links
+	git-receive-pack git-upload-archive git-upload-pack)
+
+foreach(b ${bin_links})
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
+endforeach()
+
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
+
+foreach(b ${git_links})
+	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
+	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+endforeach()
+
+foreach(b ${git_http_links})
+	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
+	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+endforeach()
+
+install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
+	DESTINATION libexec/git-core)
+
+install(DIRECTORY ${CMAKE_SOURCE_DIR}/mergetools DESTINATION libexec/git-core)
+install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5
+	FILES_MATCHING PATTERN "*.pm")
+install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)
+
+if(MSGFMT_EXE)
+	install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
+endif()
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v3 4/8] cmake: support for testing git with ctest
  2020-05-29 13:40   ` [PATCH v3 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                       ` (2 preceding siblings ...)
  2020-05-29 13:40     ` [PATCH v3 3/8] cmake: installation support for git Sibi Siddharthan via GitGitGadget
@ 2020-05-29 13:40     ` Sibi Siddharthan via GitGitGadget
  2020-05-30 13:49       ` Đoàn Trần Công Danh
  2020-05-29 13:40     ` [PATCH v3 5/8] cmake: support for testing git when building out of the source tree Sibi Siddharthan via GitGitGadget
                       ` (4 subsequent siblings)
  8 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-29 13:40 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch provides an alternate way to test git using ctest.
CTest ships with CMake, so there is no additional dependency being
introduced.

To perform the tests with ctest do this after building:
ctest -j[number of jobs]

NOTE: -j is optional, the default number of jobs is 1

Each of the jobs does this:
cd t/ && sh t[something].sh

The reason for using CTest is that it logs the output of the tests
in a neat way, which can be helpful during diagnosis of failures.

After the tests have run ctest generates three log files located in
`build-directory`/Testing/Temporary/

These log files are:

CTestCostData.txt:
This file contains the time taken to complete each test.

LastTestsFailed.log:
This log file contains the names of the tests that have failed in the
run.

LastTest.log:
This log file contains the log of all the tests that have run.
A snippet of the file is given below.

10/901 Testing: D:/my/git-master/t/t0009-prio-queue.sh
10/901 Test: D:/my/git-master/t/t0009-prio-queue.sh
Command: "sh.exe" "D:/my/git-master/t/t0009-prio-queue.sh"
Directory: D:/my/git-master/t
"D:/my/git-master/t/t0009-prio-queue.sh"
Output:
----------------------------------------------------------
ok 1 - basic ordering
ok 2 - mixed put and get
ok 3 - notice empty queue
ok 4 - stack order
passed all 4 test(s)
1..4
<end of output>
Test time =   1.11 sec

NOTE: Testing only works when building in source for now.

Changes:
Renamed the variable test_helper_sources to test-tool_SOURCES
to be consistent with the naming of source variables.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 124 ++++++++++++++++++++++++++++
 1 file changed, 124 insertions(+)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 0cde1a02cbc..33a3559eb8c 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -86,6 +86,7 @@ include(CheckIncludeFile)
 include(CheckFunctionExists)
 include(CheckSymbolExists)
 include(CheckStructHasMember)
+include(CTest)
 
 find_package(ZLIB REQUIRED)
 find_package(CURL)
@@ -731,3 +732,126 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/
 if(MSGFMT_EXE)
 	install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
 endif()
+
+
+if(BUILD_TESTING)
+
+#tests-helpers
+add_executable(test-fake-ssh ${CMAKE_SOURCE_DIR}/t/helper/test-fake-ssh.c)
+target_link_libraries(test-fake-ssh common-main)
+
+add_executable(test-line-buffer ${CMAKE_SOURCE_DIR}/t/helper/test-line-buffer.c)
+target_link_libraries(test-line-buffer common-main vcs-svn)
+
+add_executable(test-svn-fe ${CMAKE_SOURCE_DIR}/t/helper/test-svn-fe.c)
+target_link_libraries(test-svn-fe common-main vcs-svn)
+
+#test-tool
+parse_makefile_for_sources(test-tool_SOURCES "TEST_BUILTINS_OBJS")
+
+list(TRANSFORM test-tool_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/t/helper/")
+add_executable(test-tool ${CMAKE_SOURCE_DIR}/t/helper/test-tool.c ${test-tool_SOURCES})
+target_link_libraries(test-tool common-main)
+
+set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+			PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)
+
+#wrapper scripts
+set(wrapper_scripts
+	git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)
+
+set(wrapper_test_scripts
+	test-fake-ssh test-line-buffer test-svn-fe test-tool)
+
+
+foreach(script ${wrapper_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@@PROG@@" "${script}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
+endforeach()
+
+foreach(script ${wrapper_test_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
+endforeach()
+
+file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+string(REPLACE "@@PROG@@" "git-cvsserver" content "${content}")
+file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
+
+#options for configuring test options
+option(PERL_TESTS "Perform tests that use perl" ON)
+option(PYTHON_TESTS "Perform tests that use python" ON)
+
+#GIT-BUILD-OPTIONS
+set(TEST_SHELL_PATH ${SHELL_PATH})
+set(DIFF diff)
+set(PYTHON_PATH /usr/bin/python)
+set(TAR tar)
+set(NO_CURL )
+set(NO_EXPAT )
+set(USE_LIBPCRE1 )
+set(USE_LIBPCRE2 )
+set(NO_LIBPCRE1_JIT )
+set(NO_PERL )
+set(NO_PTHREADS )
+set(NO_PYTHON )
+set(PAGER_ENV "LESS=FRX LV=-c")
+set(DC_SHA1 YesPlease)
+set(RUNTIME_PREFIX true)
+set(NO_GETTEXT )
+
+if(NOT CURL_FOUND)
+	set(NO_CURL 1)
+endif()
+
+if(NOT EXPAT_FOUND)
+	set(NO_EXPAT 1)
+endif()
+
+if(NOT Intl_FOUND)
+	set(NO_GETTEXT 1)
+endif()
+
+if(NOT PERL_TESTS)
+	set(NO_PERL 1)
+endif()
+
+if(NOT PYTHON_TESTS)
+	set(NO_PYTHON 1)
+endif()
+
+file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "SHELL_PATH='${SHELL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TEST_SHELL_PATH='${TEST_SHELL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PERL_PATH='${PERL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DIFF='${DIFF}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PYTHON_PATH='${PYTHON_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TAR='${TAR}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_CURL='${NO_CURL}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_EXPAT='${NO_EXPAT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "USE_LIBPCRE1='${USE_LIBPCRE1}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PERL='${NO_PERL}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
+
+file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
+
+#test
+foreach(tsh ${test_scipts})
+	add_test(NAME ${tsh}
+		COMMAND ${SH_EXE} ${tsh}
+		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)
+endforeach()
+
+endif()#BUILD_TESTING
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v3 5/8] cmake: support for testing git when building out of the source tree
  2020-05-29 13:40   ` [PATCH v3 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                       ` (3 preceding siblings ...)
  2020-05-29 13:40     ` [PATCH v3 4/8] cmake: support for testing git with ctest Sibi Siddharthan via GitGitGadget
@ 2020-05-29 13:40     ` Sibi Siddharthan via GitGitGadget
  2020-05-29 13:40     ` [PATCH v3 6/8] cmake: support for building git on windows with mingw Sibi Siddharthan via GitGitGadget
                       ` (3 subsequent siblings)
  8 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-29 13:40 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch allows git to be tested when performin out of source builds.

This involves changing GIT_BUILD_DIR in t/test-lib.sh to point to the
build directory. Also some miscellaneous copies from the source directory
to the build directory.
The copies are:
t/chainlint.sed needed by a bunch of test scripts
po/is.po needed by t0204-gettext-rencode-sanity
mergetools/tkdiff needed by t7800-difftool
contrib/completion/git-prompt.sh needed by t9903-bash-prompt
contrib/completion/git-completion.bash needed by t9902-completion
contrib/svn-fe/svnrdump_sim.py needed by t9020-remote-svn

NOTE: t/test-lib.sh is only modified when tests are run not during
the build or configure.
The trash directory is still srcdir/t

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 33a3559eb8c..ea26f4612d3 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -845,6 +845,26 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n"
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
 
+#Make the tests work when building out of the source tree
+get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE)
+if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})
+	file(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)
+	string(REPLACE "/CMakeCache.txt" "" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})
+	#Setting the build directory in test-lib.sh before running tests
+	file(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake
+		"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \"GIT_BUILD_DIR=(.*)\")\n"
+		"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\n"
+		"string(REPLACE \"\${GIT_BUILD_DIR_REPL}\" \"GIT_BUILD_DIR=\\\"$TEST_DIRECTORY\\\"/../${BUILD_DIR_RELATIVE}\" content \"\${content}\")\n"
+		"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \${content})")
+	#misc copies
+	file(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)
+	file(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)
+	file(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/svn-fe/svnrdump_sim.py DESTINATION ${CMAKE_BINARY_DIR}/contrib/svn-fe/)
+endif()
+
 file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
 
 #test
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v3 6/8] cmake: support for building git on windows with mingw
  2020-05-29 13:40   ` [PATCH v3 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                       ` (4 preceding siblings ...)
  2020-05-29 13:40     ` [PATCH v3 5/8] cmake: support for testing git when building out of the source tree Sibi Siddharthan via GitGitGadget
@ 2020-05-29 13:40     ` Sibi Siddharthan via GitGitGadget
  2020-05-29 13:40     ` [PATCH v3 7/8] cmake: support for building git on windows with msvc and clang Sibi Siddharthan via GitGitGadget
                       ` (2 subsequent siblings)
  8 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-29 13:40 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch facilitates building git on Windows with CMake using MinGW

NOTE: The funtions unsetenv and hstrerror are not checked in Windows
builds.
Reasons
NO_UNSETENV is not compatible with Windows builds.
lines 262-264 compat/mingw.h

compat/mingw.h(line 25) provides a definition of hstrerror which
conflicts with the definition provided in
git-compat-util.h(lines 733-736).

To use CMake on Windows with MinGW do this:
cmake `relative-path-to-srcdir` -G "MinGW Makefiles"

Changes:
Changed the error message when sh.exe is not found on Windows as
suggested by Philip Oakley <philipoakley@iee.email>

v2:
Fixed a bug where a Windows user can pose as Linux user and vice versa.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 121 ++++++++++++++++++++++------
 1 file changed, 98 insertions(+), 23 deletions(-)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index ea26f4612d3..46197d0b806 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -34,6 +34,10 @@ cmake_minimum_required(VERSION 3.14)
 set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
 
 find_program(SH_EXE sh)
+if(NOT SH_EXE)
+	message(FATAL_ERROR "sh: shell interpreter was not found in your path, please install one."
+			"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
+endif()
 
 #Create GIT-VERSION-FILE using GIT-VERSION-GEN
 if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)
@@ -57,7 +61,9 @@ project(git
 	VERSION ${git_version}
 	LANGUAGES C)
 
+
 #TODO gitk git-gui gitweb
+#TODO Enable NLS on windows natively
 #TODO Add pcre support
 
 #macros for parsing the Makefile for sources and scripts
@@ -94,6 +100,7 @@ find_package(EXPAT)
 find_package(Iconv)
 find_package(Intl)
 
+
 if(NOT Intl_FOUND)
 	add_compile_definitions(NO_GETTEXT)
 	if(NOT Iconv_FOUND)
@@ -115,6 +122,14 @@ if(Intl_FOUND)
 	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
 endif()
 
+
+if(WIN32)
+	find_program(WINDRES_EXE windres)
+	if(NOT WINDRES_EXE)
+		message(FATAL_ERROR "Install windres on Windows for resource files")
+	endif()
+endif()
+
 find_program(MSGFMT_EXE msgfmt)
 if(NOT MSGFMT_EXE)
 	message(WARNING "Text Translations won't be build")
@@ -146,11 +161,39 @@ add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
 			BINDIR="bin"
 			GIT_BUILT_FROM_COMMIT="")
 
-set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
-add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+if(WIN32)
+	set(FALLBACK_RUNTIME_PREFIX /mingw64)
+	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+else()
+	set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+endif()
 
-add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
-list(APPEND compat_SOURCES unix-socket.c)
+
+#Platform Specific
+if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+	include_directories(${CMAKE_SOURCE_DIR}/compat/win32)
+	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
+				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
+				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0
+				USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
+				UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
+	list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
+		compat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c
+		compat/win32/trace2_win32_process_info.c compat/win32/dirent.c
+		compat/nedmalloc/nedmalloc.c compat/strdup.c)
+	set(NO_UNIX_SOCKETS 1)
+
+elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+	add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
+	list(APPEND compat_SOURCES unix-socket.c)
+endif()
+
+if(WIN32)
+	set(EXE_EXTENSION .exe)
+else()
+	set(EXE_EXTENSION)
+endif()
 
 #header checks
 check_include_file(libgen.h HAVE_LIBGEN_H)
@@ -211,7 +254,12 @@ endif()
 #function checks
 set(function_checks
 	strcasestr memmem strlcpy strtoimax strtoumax strtoull
-	setenv mkdtemp poll pread memmem unsetenv hstrerror)
+	setenv mkdtemp poll pread memmem)
+
+#unsetenv,hstrerror are incompatible with windows build
+if(NOT WIN32)
+	list(APPEND function_checks unsetenv hstrerror)
+endif()
 
 foreach(f ${function_checks})
 	string(TOUPPER ${f} uf)
@@ -425,7 +473,13 @@ unset(CMAKE_REQUIRED_INCLUDES)
 #programs
 set(PROGRAMS_BUILT
 	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
-	git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
+	git-shell git-remote-testsvn)
+
+if(NO_UNIX_SOCKETS)
+	list(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)
+else()
+	list(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)
+endif()
 
 if(NOT CURL_FOUND)
 	list(APPEND excluded_progs git-http-fetch git-http-push)
@@ -497,15 +551,34 @@ parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
 list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
 
+#add git.rc for gcc
+if(WIN32)
+	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+			COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
+				-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
+				-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			VERBATIM)
+	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
+endif()
+
 #link all required libraries to common-main
 add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)
-target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
+
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})
 if(Intl_FOUND)
 	target_link_libraries(common-main ${Intl_LIBRARIES})
 endif()
 if(Iconv_FOUND)
 	target_link_libraries(common-main ${Iconv_LIBRARIES})
 endif()
+if(WIN32)
+	target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
+	add_dependencies(common-main git-rc)
+	target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+elseif(UNIX)
+	target_link_libraries(common-main pthread rt)
+endif()
 
 #git
 parse_makefile_for_sources(git_SOURCES "BUILTIN_OBJS")
@@ -556,11 +629,13 @@ endif()
 add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)
 target_link_libraries(git-remote-testsvn common-main vcs-svn)
 
-add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)
-target_link_libraries(git-credential-cache common-main)
+if(NOT NO_UNIX_SOCKETS)
+	add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)
+	target_link_libraries(git-credential-cache common-main)
 
-add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)
-target_link_libraries(git-credential-cache--daemon common-main)
+	add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)
+	target_link_libraries(git-credential-cache--daemon common-main)
+endif()
 
 
 set(git_builtin_extra
@@ -572,16 +647,16 @@ set(git_builtin_extra
 foreach(s ${git_SOURCES} ${git_builtin_extra})
 	string(REPLACE "${CMAKE_SOURCE_DIR}/builtin/" "" s ${s})
 	string(REPLACE ".c" "" s ${s})
-	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
-	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
+	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\n")
+	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})
 endforeach()
 
 if(CURL_FOUND)
 	set(remote_exes
 		git-remote-https git-remote-ftp git-remote-ftps)
 	foreach(s ${remote_exes})
-		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
-		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http${EXE_EXTENSION} ${s}${EXE_EXTENSION})\n")
+		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s}${EXE_EXTENSION})
 	endforeach()
 endif()
 
@@ -705,20 +780,20 @@ set(bin_links
 	git-receive-pack git-upload-archive git-upload-pack)
 
 foreach(b ${bin_links})
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/bin/${b}${EXE_EXTENSION})")
 endforeach()
 
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git${EXE_EXTENSION})")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell${EXE_EXTENSION})")
 
 foreach(b ${git_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
 endforeach()
 
 foreach(b ${git_http_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
 endforeach()
 
 install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
@@ -767,14 +842,14 @@ set(wrapper_test_scripts
 foreach(script ${wrapper_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "${script}" content "${content}")
+	string(REPLACE "@@PROG@@" "${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
 foreach(script ${wrapper_test_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
+	string(REPLACE "@@PROG@@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
@@ -840,7 +915,7 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X='${EXE_EXTENSION}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v3 7/8] cmake: support for building git on windows with msvc and clang.
  2020-05-29 13:40   ` [PATCH v3 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                       ` (5 preceding siblings ...)
  2020-05-29 13:40     ` [PATCH v3 6/8] cmake: support for building git on windows with mingw Sibi Siddharthan via GitGitGadget
@ 2020-05-29 13:40     ` Sibi Siddharthan via GitGitGadget
  2020-05-30 14:08       ` Đoàn Trần Công Danh
  2020-05-29 13:40     ` [PATCH v3 8/8] ci: modification of main.yml to use cmake for vs-build job Sibi Siddharthan via GitGitGadget
  2020-06-12 18:29     ` [PATCH v4 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
  8 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-29 13:40 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch adds support for Visual Studio and Clang builds

The minimum required version of CMake is upgraded to 3.15 because
this version offers proper support for Clang builds on Windows.

Libintl is not searched for when building with Visual Studio or Clang
because there is no binary compatible version available yet.

NOTE: In the link options invalidcontinue.obj has to be included.
The reason for this is because by default, Windows calls abort()'s
instead of setting errno=EINVAL when invalid arguments are passed to
standard functions.
This commit explains it in detail:
4b623d80f73528a632576990ca51e34c333d5dd6

On Windows the default generator is Visual Studio,so for Visual Studio
builds do this:

cmake `relative-path-to-srcdir`

NOTE: Visual Studio generator is a multi config generator, which means
that Debug and Release builds can be done on the same build directory.

For Clang builds do this:

On bash
CC=Clang cmake `relative-path-to-srcdir` -G Ninja
		-DCMAKE_BUILD_TYPE=[Debug or Release]

On cmd
set CC=Clang
cmake `relative-path-to-srcdir` -G Ninja
		-DCMAKE_BUILD_TYPE=[Debug or Release]

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 55 +++++++++++++++++++++++------
 1 file changed, 45 insertions(+), 10 deletions(-)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 46197d0b806..0a3f711db88 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -98,8 +98,11 @@ find_package(ZLIB REQUIRED)
 find_package(CURL)
 find_package(EXPAT)
 find_package(Iconv)
-find_package(Intl)
 
+#Don't use libintl on Windows Visual Studio and Clang builds
+if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")))
+	find_package(Intl)
+endif()
 
 if(NOT Intl_FOUND)
 	add_compile_definitions(NO_GETTEXT)
@@ -123,7 +126,7 @@ if(Intl_FOUND)
 endif()
 
 
-if(WIN32)
+if(WIN32 AND NOT MSVC)#not required for visual studio builds
 	find_program(WINDRES_EXE windres)
 	if(NOT WINDRES_EXE)
 		message(FATAL_ERROR "Install windres on Windows for resource files")
@@ -135,6 +138,13 @@ if(NOT MSGFMT_EXE)
 	message(WARNING "Text Translations won't be build")
 endif()
 
+#Force all visual studio outputs to CMAKE_BINARY_DIR
+if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
+	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
+	add_compile_options(/MP)
+endif()
+
 #default behaviour
 include_directories(${CMAKE_SOURCE_DIR})
 add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
@@ -172,6 +182,10 @@ endif()
 
 #Platform Specific
 if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+	if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+		include_directories(${CMAKE_SOURCE_DIR}/compat/vcbuild/include)
+		add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
+	endif()
 	include_directories(${CMAKE_SOURCE_DIR}/compat/win32)
 	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
 				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
@@ -551,14 +565,22 @@ parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
 list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
 
-#add git.rc for gcc
 if(WIN32)
-	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
-			COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
-				-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
-				-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
-			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-			VERBATIM)
+	if(NOT MSVC)#use windres when compiling with gcc and clang
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+				COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
+					-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
+					-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
+				WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+				VERBATIM)
+	else()#MSVC use rc
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+				COMMAND ${CMAKE_RC_COMPILER} /d MAJOR=${PROJECT_VERSION_MAJOR} /d MINOR=${PROJECT_VERSION_MINOR}
+					/d MICRO=${PROJECT_VERSION_PATCH} /d PATCHLEVEL=0 /d GIT_VERSION="${PROJECT_VERSION}.GIT"
+					/fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_SOURCE_DIR}/git.rc
+				WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+				VERBATIM)
+	endif()
 	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
 endif()
 
@@ -575,7 +597,13 @@ endif()
 if(WIN32)
 	target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
 	add_dependencies(common-main git-rc)
-	target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+	if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+		target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+	elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+		target_link_options(common-main PUBLIC -municode -Wl,-nxcompat -Wl,-dynamicbase -Wl,-entry:wmainCRTStartup -Wl,invalidcontinue.obj)
+	elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+		target_link_options(common-main PUBLIC /IGNORE:4217 /IGNORE:4049 /NOLOGO /ENTRY:wmainCRTStartup /SUBSYSTEM:CONSOLE invalidcontinue.obj)
+	endif()
 elseif(UNIX)
 	target_link_libraries(common-main pthread rt)
 endif()
@@ -831,6 +859,13 @@ target_link_libraries(test-tool common-main)
 set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
 			PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)
 
+if(MSVC)
+	set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+				PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)
+	set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+				PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)
+endif()
+
 #wrapper scripts
 set(wrapper_scripts
 	git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v3 8/8] ci: modification of main.yml to use cmake for vs-build job
  2020-05-29 13:40   ` [PATCH v3 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                       ` (6 preceding siblings ...)
  2020-05-29 13:40     ` [PATCH v3 7/8] cmake: support for building git on windows with msvc and clang Sibi Siddharthan via GitGitGadget
@ 2020-05-29 13:40     ` Sibi Siddharthan via GitGitGadget
  2020-05-30 14:14       ` Đoàn Trần Công Danh
  2020-06-12 18:29     ` [PATCH v4 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
  8 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-05-29 13:40 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiv.siddharthan@gmail.com>

Teach .github/workflows/main.yml to use CMake for VS builds.

Modified the vs-test step to match windows-test step. This speeds
up the vs-test. Calling git-cmd from powershell and then calling git-bash
to perform the tests slows things down(factor of about 6). So git-bash
is directly called from powershell to perform the tests using prove.

NOTE: Since GitHub keeps the same directory for each job
(with respect to path) absolute paths are used in the bin-wrapper
scripts.

GitHub has switched to CMake 3.17.1 which changed the behaviour of
FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been
added to revert to the old behaviour.

Edit(Explanation for the reordering of build steps):
In the configuration phase CMake looks for the required libraries for
building git (eg zlib,libiconv). So we extract the libraries before we
configure.

To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working
directory of script or path. So we copy the dlls before we configure.

Signed-off-by: Sibi Siddharthan <sibisiv.siddharthan@gmail.com>
---
 .github/workflows/main.yml | 38 ++++++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 84a5dcff7a0..f0f0af720e4 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -145,13 +145,6 @@ jobs:
         ## Unzip and remove the artifact
         unzip artifacts.zip
         rm artifacts.zip
-    - name: generate Visual Studio solution
-      shell: powershell
-      run: |
-        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
-          make NDEBUG=1 DEVELOPER=1 vcxproj
-        "@
-        if (!$?) { exit(1) }
     - name: download vcpkg artifacts
       shell: powershell
       run: |
@@ -163,6 +156,14 @@ jobs:
         Remove-Item compat.zip
     - name: add msbuild to PATH
       uses: microsoft/setup-msbuild@v1.0.0
+    - name: copy dlls to root
+      shell: powershell
+      run: |
+        & compat\vcbuild\vcpkg_copy_dlls.bat release
+        if (!$?) { exit(1) }
+    - name: generate Visual Studio solution
+      shell: bash
+      run: cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows -DMSGFMT_EXE=`pwd`/git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
     - name: MSBuild
       run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
     - name: bundle artifact tar
@@ -171,8 +172,6 @@ jobs:
         MSVC: 1
         VCPKG_ROOT: ${{github.workspace}}\compat\vcbuild\vcpkg
       run: |
-        & compat\vcbuild\vcpkg_copy_dlls.bat release
-        if (!$?) { exit(1) }
         & git-sdk-64-minimal\usr\bin\bash.exe -lc @"
           mkdir -p artifacts &&
           eval \"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts 2>&1 | grep ^tar)\"
@@ -203,7 +202,7 @@ jobs:
     - name: extract build artifacts
       shell: bash
       run: tar xf artifacts.tar.gz
-    - name: test (parallel)
+    - name: test
       shell: powershell
       env:
         MSYSTEM: MINGW64
@@ -214,12 +213,19 @@ jobs:
           # Let Git ignore the SDK and the test-cache
           printf '%s\n' /git-sdk-64-minimal/ /test-cache/ >>.git/info/exclude
 
-          cd t &&
-          PATH=\"`$PWD/helper:`$PATH\" &&
-          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \
-                  `$(test-tool.exe path-utils slice-tests \
-                          ${{matrix.nr}} 10 t[0-9]*.sh)
+          ci/run-test-slice.sh ${{matrix.nr}} 10
         "@
+    - name: ci/print-test-failures.sh
+      if: failure()
+      shell: powershell
+      run: |
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc ci/print-test-failures.sh
+    - name: Upload failed tests' directories
+      if: failure() && env.FAILED_TEST_ARTIFACTS != ''
+      uses: actions/upload-artifact@v1
+      with:
+        name: failed-tests-windows
+        path: ${{env.FAILED_TEST_ARTIFACTS}}
   regular:
     needs: ci-config
     if: needs.ci-config.outputs.enabled == 'yes'
@@ -302,4 +308,4 @@ jobs:
     steps:
     - uses: actions/checkout@v1
     - run: ci/install-dependencies.sh
-    - run: ci/test-documentation.sh
+    - run: ci/test-documentation.sh
\ No newline at end of file
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 179+ messages in thread

* Re: [PATCH v3 1/8] Introduce CMake support for configuring Git
  2020-05-29 13:40     ` [PATCH v3 1/8] Introduce CMake support for configuring Git Sibi Siddharthan via GitGitGadget
@ 2020-05-29 19:27       ` Junio C Hamano
  2020-05-30 18:50         ` Sibi Siddharthan
  2020-05-30 13:17       ` Đoàn Trần Công Danh
  1 sibling, 1 reply; 179+ messages in thread
From: Junio C Hamano @ 2020-05-29 19:27 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

"Sibi Siddharthan via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
>
> At the moment, the recommended way to configure Git's builds is to
> ...
> Note: this patch asks for the minimum version v3.14 of CMake (which is
> not all that old as of time of writing) because that is the first
> version to offer a platform-independent way to generate hardlinks as
> part of the build. This is needed to generate all those hardlinks for
> the built-in commands of Git.

All of the above reads reasonable.

> Changes
> The CMake script parses the Makefile for:
> LIB_OBJS
> BUILTIN_OBJS
> XDIFF_OBJS
> VCSSVN_OBJS
> TEST_BUILTINS_OBJS
>
> By doing this we avoid duplication of text between the Makefile and
> the CMake script.
>
> The CMake script has been relocated to contrib/buildsystems.
>
> The CMake script uses GIT-VERSION-GEN to determine the version of Git
> being built.

Everything after the "Changes" line does not belong to the commit
log, as it is no use for those who read "git log" output and
encounter the "first" attempt to add CMake support there.  There is
no need to tell them that you did things differently from this
version in the past, as they simply do not know what you did in the
previous iterations, nor particularly care about them.

These *do* help reviewers who saw previous iterations, and the space
after the three-dash line below is the right/recommended place for
them.

The above applies to other patches in this series.

> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> ---
>  contrib/buildsystems/CMakeLists.txt | 575 ++++++++++++++++++++++++++++
>  1 file changed, 575 insertions(+)
>  create mode 100644 contrib/buildsystems/CMakeLists.txt
>
> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
> new file mode 100644
> index 00000000000..8e2b27f44a6
> --- /dev/null
> +++ b/contrib/buildsystems/CMakeLists.txt
> @@ -0,0 +1,575 @@
> +#
> +#	Copyright (c) 2020 Sibi Siddharthan
> +#
> +
> +#[[
> +
> +Instructions to run CMake:
> +
> +cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release

The readers can infer from `relative-path-to-CMakeLists` that they
can run this command from anywhere, e.g.

	$ cd $HOME
	$ tar xf /var/tmp/git-2.7.0.tar
	$ cd /tmp
	$ cmake $HOME/git/contrib/buildsystems/CMakeLists.txt

but when given the freedom/flexibility to use it from "anywhere",
they are faced by an extra choice to make.  It may be helpful to
readers to elaborate a bit more to help them decide where in the
directory hierarchy they would want to run this command.  In the
above example sequence, I chose /tmp, but if I used /var/tmp as the
starting place instead, what becomes different?  The answer might
be "resulting 'git' binary is stored in the directory you run the
'cmake' command in", and by spelling it out, it helps readers to
make an informed decision.

> +Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
> +compiler flags
> +Debug : -g
> +Release: -O3
> +RelWithDebInfo : -O2 -g
> +MinSizeRel : -Os
> +empty(default) :
> +
> +NOTE: -DCMAKE_BUILD_TYPE is optional. For multi-config generators like Visual Studio
> +this option is ignored

Quite helpful.

> +This process generates a Makefile(Linux) , Visual Studio solution(Windows) by default.
> +Run `make` to build Git on Linux.
> +Open git.sln on Windows and build Git.
> +
> +NOTE: By default CMake uses Makefile as the build tool on Linux and Visual Studio in Windows,

The above makes it sound as if Linux and VS are the only two systems
we care about, but is it really Linux, or UNIX-flavoured systems in
general?  In other words, are we excluding friends on BSD and macOS
with the above?

The above is not a complaint about "exclusion", but is a complaint
about unclarity.

> +to use another tool say `ninja` add this to the command line when configuring.
> +`-G Ninja`
> +
> +]]
> +cmake_minimum_required(VERSION 3.14)
> ...
> +check_c_source_compiles("

The "source" given to check_c_source_{compiles,runs} may be allowed
to be anything, but I'd prefer to see it follow some consistent
style, preferrably our CodingGuidelines (except for git specific
bits like "do not include standard system file but instead just use
git-compat-util.h", which of course should not apply).  This is a
comment not only about the two instances below I use as examples,
but all C-source snippets in this patch.

> +#include <alloca.h>
> +int
> +main ()
> +{

	int main(void)
	{

is how we start this function.

> +char *p = (char *) alloca (2 * sizeof (int));

And the decl of function local variable here would be indented by a
HT like the remainder of the function.  No SP between function name
and the parentheses around its arguments.  NP SP after sizeof,
either.

> +	if (p) return 0;
> +	return 0;
> +}"
> +HAVE_ALLOCA_H)
> ...
> +check_c_source_runs("
> +#include<stdio.h>
> +#include<stdarg.h>
> +#include<string.h>
> +#include<stdlib.h>
> +int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
> +{
> +	int ret;
> +	va_list ap;
> +
> +	va_start(ap, format);
> +	ret = vsnprintf(str, maxsize, format, ap);
> +	va_end(ap);
> +	return ret;
> +}
> +
> +int
> +main ()
> +{

Likewise.

> +	char buf[6];
> +	if (test_vsnprintf(buf, 3, \"%s\", \"12345\") != 5
> +		|| strcmp(buf, \"12\")) return 1;
> +	if (snprintf(buf, 3, \"%s\", \"12345\") != 5
> +		|| strcmp(buf, \"12\")) return 1;
> +
> +	return 0;
> +}"

Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v3 2/8] cmake: generate the shell/perl/python scripts and templates, translations
  2020-05-29 13:40     ` [PATCH v3 2/8] cmake: generate the shell/perl/python scripts and templates, translations Sibi Siddharthan via GitGitGadget
@ 2020-05-29 19:27       ` Junio C Hamano
  2020-05-30 18:56         ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Junio C Hamano @ 2020-05-29 19:27 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

"Sibi Siddharthan via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
>
> Implement the placeholder substitution to generate scripted
> Porcelain commands, e.g. git-request-pull out of
> git-request-pull.sh
>
> Generate shell/perl/python scripts and template using CMake instead of
> using sed like the build procedure in the Makefile does.
>
> The text translations are only build if `msgfmt` is found in your path.
>
> NOTE: The scripts and templates are generated during configuration.

OK.

> Changes
> The CMake script parses the Makefile for:
> SCRIPT_SH
> SCRIPT_PERL

Below the three-dash line.

> +#shell scripts
> +parse_makefile_for_scripts(git_sh_scripts "SCRIPT_SH" ".sh")

OK.

> +set(git_shell_scripts
> +	${git_sh_scripts}
> +	git-mergetool--lib git-parse-remote git-rebase--preserve-merges
> +	git-sh-setup git-sh-i18n git-instaweb)

Do we need to have enumeration here, which can drift out of sync
with the reality?  Wouldn't we want to avoid it with something like

 parse_makefile_for_scripts(git_sh_lib "SCRIPT_LIB" "")

too?

> +#perl modules
> +file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
> +
> +foreach(pm ${perl_modules})
> +	string(REPLACE "${CMAKE_SOURCE_DIR}/perl/" "" file_path ${pm})
> +	file(STRINGS ${pm} content NEWLINE_CONSUME)
> +	string(REPLACE "@@LOCALEDIR@@" "${LOCALEDIR}" content "${content}")
> +	string(REPLACE "@@NO_PERL_CPAN_FALLBACKS@@" "" content "${content}")
> +	file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})
> +#test-lib.sh requires perl/build/lib to be the build directory of perl modules
> +endforeach()
> +
> +
> +#templates
> +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
> +set(hooks_templates
> +	applypatch-msg.sample pre-applypatch.sample pre-push.sample
> +	commit-msg.sample pre-commit.sample pre-rebase.sample
> +	fsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample
> +	post-update.sample prepare-commit-msg.sample update.sample)

Do we need to have enumeration here, which can drift out of sync
with the reality?  Wouldn't we want to avoid it with file(GLOB) or
something?

> +#templates have @.*@ replacement so use configure_file instead
> +#hooks
> +foreach(tm ${hooks_templates})
> +	configure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)
> +endforeach()
> +
> +#info
> +configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)
> +
> +#this
> +configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)

I was hoping that we could drive any build system without having to
have separate rules like the above.  The idea behind all files with
funny double-dash in its name under templates/ directory is:

 - double-dash denotes directory boundary

 - when a template input ends with double-dash, it tells us to
   create a directory

 - leading "this--" denotes "not in a subdirectory but at the top
   level of the generated template directory"

so that each of them knows what the name of the file and directory
hierarchy of the final destination is, and the result of transforming
can be created and deposited at the final place mechanically with a
single rule.

> +#translations
> +if(MSGFMT_EXE)
> +	set(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)

Do we need to have enumeration here, which can drift out of sync
with the reality?  Wouldn't globbing for *.po be sufficient?

> +	foreach(po ${po_files})
> +		file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)
> +		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo
> +				COMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)
> +		list(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)
> +	endforeach()
> +	add_custom_target(po-gen ALL DEPENDS ${po_gen})
> +endif()

Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v3 1/8] Introduce CMake support for configuring Git
  2020-05-31 16:17           ` Junio C Hamano
@ 2020-05-30  8:00             ` Johannes Schindelin
  0 siblings, 0 replies; 179+ messages in thread
From: Johannes Schindelin @ 2020-05-30  8:00 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Sibi Siddharthan, Sibi Siddharthan via GitGitGadget, git

Hi,

On Sun, 31 May 2020, Junio C Hamano wrote:

> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:
>
> > On Sat, May 30, 2020 at 12:57 AM Junio C Hamano <gitster@pobox.com> wrote:
> >> ...
> >> Everything after the "Changes" line does not belong to the commit
> >> log, as it is no use for those who read "git log" output and
> >> encounter the "first" attempt to add CMake support there.  There is
> >> no need to tell them that you did things differently from this
> >> version in the past, as they simply do not know what you did in the
> >> previous iterations, nor particularly care about them.
> >>
> >> These *do* help reviewers who saw previous iterations, and the space
> >> after the three-dash line below is the right/recommended place for
> >> them.
> >>
> >> The above applies to other patches in this series.
> >
> > Do you mean this line '---' below?
>
> Yes.
>
> > If so how do I place the changelog below them?
> > I just do `/submit` at gigitgadet/git.
>
> Sorry, I don't use GGG, so the question needs to be redirected to
> those who do and enhance (Dscho cc'ed).

There is currently no support for that in GitGitGadget.

The idea was to put such commentary into the cover letter, usually by
editing the first PR comment and appending the additional information
before `/submit`ing.

IIRC some support was added to `format-patch` to potentially pick up
comments via notes to be added after the `---` line. So it should not be
all too hard, I simply cannot afford the time for that right now (but I'd
of course be glad to review/accept PRs at
https://github.com/gitgitgadget/gitgitgadget).

Ciao,
Dscho

> >> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >> > ---
>
> Here is what I meant, but another place that is suitable to describe
> differences from previous rounds is the cover letter.  If the split
> of tasks between steps in a multi-patch series hasn't changed from
> the previous round, it makes it easier to review if the changes
> since the last round for each individual step is described in the
> message itself, like you did.  It just needs to be done outside the
> log message.
>
> Thanks.
>

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v3 1/8] Introduce CMake support for configuring Git
  2020-05-29 13:40     ` [PATCH v3 1/8] Introduce CMake support for configuring Git Sibi Siddharthan via GitGitGadget
  2020-05-29 19:27       ` Junio C Hamano
@ 2020-05-30 13:17       ` Đoàn Trần Công Danh
  1 sibling, 0 replies; 179+ messages in thread
From: Đoàn Trần Công Danh @ 2020-05-30 13:17 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

Hi Sibi,

On 2020-05-29 13:40:17+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> +file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE git_version REGEX "GIT_VERSION = (.*)")
> +string(REPLACE "GIT_VERSION = " "" git_version ${git_version})
> +string(FIND ${git_version} "GIT" location)
> +if(location EQUAL -1)
> +	string(REGEX MATCH "[0-9]*\\.[0-9]*\\.[0-9]*" git_version ${git_version})

This will strip everything begins with first non-number.

With the same Git repo,
The git binary generated via Makefile reports version:

	git version 2.27.0.rc2.274.g860c8aebb9.dirty

The git binary generated via CMake reports:

	git version 2.27.0.GIT

Anyway, I pretty much defer this step to build step. Since this will
report the version when *cmake* is run. And *cmake* will be unlikely
run again if nothing related to CMake is being changed.

-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v3 4/8] cmake: support for testing git with ctest
  2020-05-29 13:40     ` [PATCH v3 4/8] cmake: support for testing git with ctest Sibi Siddharthan via GitGitGadget
@ 2020-05-30 13:49       ` Đoàn Trần Công Danh
  2020-05-30 19:04         ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Đoàn Trần Công Danh @ 2020-05-30 13:49 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

On 2020-05-29 13:40:20+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> 
> This patch provides an alternate way to test git using ctest.
> CTest ships with CMake, so there is no additional dependency being
> introduced.
> 
> To perform the tests with ctest do this after building:
> ctest -j[number of jobs]

Or we can just run: make test
CMake will run: ctest itself.

Ah, OK, that's not equivalence. make -j9 test doesn't work :/

Anyway, there're test is failing in Linux with this CMake.

	$git_repo/t/../build/bin-wrappers/git is not executable; using GIT_EXEC_PATH

It looks like CMake Generator forgets "chmod +x bin-wrappers/git"

> Test time =   1.11 sec
> 
> NOTE: Testing only works when building in source for now.

OK, so this maybe the pain point, let me build in source again.
Hm, no, I still see the same problems.
Worse, CMake overrides my current Makefile.
Luckily, I don't have any changes in Makefile.

> +endif()#BUILD_TESTING

We can use:

	endif(BUILD_TESTING)

-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v3 7/8] cmake: support for building git on windows with msvc and clang.
  2020-05-29 13:40     ` [PATCH v3 7/8] cmake: support for building git on windows with msvc and clang Sibi Siddharthan via GitGitGadget
@ 2020-05-30 14:08       ` Đoàn Trần Công Danh
  2020-05-30 19:08         ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Đoàn Trần Công Danh @ 2020-05-30 14:08 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

On 2020-05-29 13:40:23+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> 
> This patch adds support for Visual Studio and Clang builds
> 
> The minimum required version of CMake is upgraded to 3.15 because
> this version offers proper support for Clang builds on Windows.
> 
> Libintl is not searched for when building with Visual Studio or Clang
> because there is no binary compatible version available yet.
> 
> NOTE: In the link options invalidcontinue.obj has to be included.
> The reason for this is because by default, Windows calls abort()'s
> instead of setting errno=EINVAL when invalid arguments are passed to
> standard functions.
> This commit explains it in detail:
> 4b623d80f73528a632576990ca51e34c333d5dd6

I think it's better to say:

	See 4b623d80f7 (MSVC: link in invalidcontinue.obj for better
	POSIX compatibility, 2014-03-29) for detail.


(I haven't read the referenced commit, FWIW)

> On Windows the default generator is Visual Studio,so for Visual Studio
> builds do this:
> 
> cmake `relative-path-to-srcdir`
> 
> NOTE: Visual Studio generator is a multi config generator, which means
> that Debug and Release builds can be done on the same build directory.
> 
> For Clang builds do this:
> 
> On bash
> CC=Clang cmake `relative-path-to-srcdir` -G Ninja

I think you meant CC=clang, note the lowercase c,
that will cmake this note applicable for case-sensitive filesystem.

... reading this patch ...

So, this is applicable for Windows only, it's fine as is, then.
It's still better to lowercase it, though.

> 		-DCMAKE_BUILD_TYPE=[Debug or Release]
> 
> On cmd
> set CC=Clang
> cmake `relative-path-to-srcdir` -G Ninja
> 		-DCMAKE_BUILD_TYPE=[Debug or Release]
> 
> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> ---
>  contrib/buildsystems/CMakeLists.txt | 55 +++++++++++++++++++++++------
>  1 file changed, 45 insertions(+), 10 deletions(-)
> 
> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
> index 46197d0b806..0a3f711db88 100644
> --- a/contrib/buildsystems/CMakeLists.txt
> +++ b/contrib/buildsystems/CMakeLists.txt
> @@ -98,8 +98,11 @@ find_package(ZLIB REQUIRED)
>  find_package(CURL)
>  find_package(EXPAT)
>  find_package(Iconv)
> -find_package(Intl)
>  
> +#Don't use libintl on Windows Visual Studio and Clang builds
> +if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")))

Personally, I find this is a bit ugly.
Does it work to move the if(WIN32) down there, here.
Then make sub-condition for MSVC and Clang?

> +	find_package(Intl)
> +endif()
>  
>  if(NOT Intl_FOUND)
>  	add_compile_definitions(NO_GETTEXT)
> @@ -123,7 +126,7 @@ if(Intl_FOUND)
>  endif()
>  
>  
> -if(WIN32)
> +if(WIN32 AND NOT MSVC)#not required for visual studio builds

for the down there, I meant here.
Using "NOT MSVC" here and `CMAKE_C_COMPILER_ID STREQUAL "MSVC"` above
may puzzle people interest in this patch.

>  	find_program(WINDRES_EXE windres)
>  	if(NOT WINDRES_EXE)
>  		message(FATAL_ERROR "Install windres on Windows for resource files")
> @@ -135,6 +138,13 @@ if(NOT MSGFMT_EXE)
>  	message(WARNING "Text Translations won't be build")
>  endif()
>  
> +#Force all visual studio outputs to CMAKE_BINARY_DIR
> +if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
> +	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
> +	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
> +	add_compile_options(/MP)
> +endif()
> +
>  #default behaviour
>  include_directories(${CMAKE_SOURCE_DIR})
>  add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
> @@ -172,6 +182,10 @@ endif()
>  
>  #Platform Specific
>  if(CMAKE_SYSTEM_NAME STREQUAL "Windows")

I missed this line from previous patch
(and my comment in previous round, which suggested remove ${})
Does `if(WIN32)` and `if(CMAKE_SYSTEM_NAME STREQUAL "Windows")` have
different meanings?
I don't know much about CMake on Windows to really sure about this.

-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v3 8/8] ci: modification of main.yml to use cmake for vs-build job
  2020-05-29 13:40     ` [PATCH v3 8/8] ci: modification of main.yml to use cmake for vs-build job Sibi Siddharthan via GitGitGadget
@ 2020-05-30 14:14       ` Đoàn Trần Công Danh
  2020-05-30 19:13         ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Đoàn Trần Công Danh @ 2020-05-30 14:14 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan, Sibi Siddharthan

On 2020-05-29 13:40:24+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working
> directory of script or path. So we copy the dlls before we configure.

If ICONV_OMITS_BOM is such a troublemaker for CMake,
I'm fine with not supporting it at all.

It seems like noone except me have interest in ICONV_OMITS_BOM.

> @@ -302,4 +308,4 @@ jobs:
>      steps:
>      - uses: actions/checkout@v1
>      - run: ci/install-dependencies.sh
> -    - run: ci/test-documentation.sh
> +    - run: ci/test-documentation.sh
> \ No newline at end of file

Please fix your editor ;)

-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v3 1/8] Introduce CMake support for configuring Git
  2020-05-29 19:27       ` Junio C Hamano
@ 2020-05-30 18:50         ` Sibi Siddharthan
  2020-05-31 16:17           ` Junio C Hamano
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-30 18:50 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Sibi Siddharthan via GitGitGadget, git

On Sat, May 30, 2020 at 12:57 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Sibi Siddharthan via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >
> > At the moment, the recommended way to configure Git's builds is to
> > ...
> > Note: this patch asks for the minimum version v3.14 of CMake (which is
> > not all that old as of time of writing) because that is the first
> > version to offer a platform-independent way to generate hardlinks as
> > part of the build. This is needed to generate all those hardlinks for
> > the built-in commands of Git.
>
> All of the above reads reasonable.
>
> > Changes
> > The CMake script parses the Makefile for:
> > LIB_OBJS
> > BUILTIN_OBJS
> > XDIFF_OBJS
> > VCSSVN_OBJS
> > TEST_BUILTINS_OBJS
> >
> > By doing this we avoid duplication of text between the Makefile and
> > the CMake script.
> >
> > The CMake script has been relocated to contrib/buildsystems.
> >
> > The CMake script uses GIT-VERSION-GEN to determine the version of Git
> > being built.
>
> Everything after the "Changes" line does not belong to the commit
> log, as it is no use for those who read "git log" output and
> encounter the "first" attempt to add CMake support there.  There is
> no need to tell them that you did things differently from this
> version in the past, as they simply do not know what you did in the
> previous iterations, nor particularly care about them.
>
> These *do* help reviewers who saw previous iterations, and the space
> after the three-dash line below is the right/recommended place for
> them.
>
> The above applies to other patches in this series.

Do you mean this line '---' below?
If so how do I place the changelog below them?
I just do `/submit` at gigitgadet/git.

>
> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> > ---
> >  contrib/buildsystems/CMakeLists.txt | 575 ++++++++++++++++++++++++++++
> >  1 file changed, 575 insertions(+)
> >  create mode 100644 contrib/buildsystems/CMakeLists.txt
> >
> > diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
> > new file mode 100644
> > index 00000000000..8e2b27f44a6
> > --- /dev/null
> > +++ b/contrib/buildsystems/CMakeLists.txt
> > @@ -0,0 +1,575 @@
> > +#
> > +#    Copyright (c) 2020 Sibi Siddharthan
> > +#
> > +
> > +#[[
> > +
> > +Instructions to run CMake:
> > +
> > +cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release
>
> The readers can infer from `relative-path-to-CMakeLists` that they
> can run this command from anywhere, e.g.
>
>         $ cd $HOME
>         $ tar xf /var/tmp/git-2.7.0.tar
>         $ cd /tmp
>         $ cmake $HOME/git/contrib/buildsystems/CMakeLists.txt
>
> but when given the freedom/flexibility to use it from "anywhere",
> they are faced by an extra choice to make.  It may be helpful to
> readers to elaborate a bit more to help them decide where in the
> directory hierarchy they would want to run this command.  In the
> above example sequence, I chose /tmp, but if I used /var/tmp as the
> starting place instead, what becomes different?  The answer might
> be "resulting 'git' binary is stored in the directory you run the
> 'cmake' command in", and by spelling it out, it helps readers to
> make an informed decision.
>

Okay

> > +Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
> > +compiler flags
> > +Debug : -g
> > +Release: -O3
> > +RelWithDebInfo : -O2 -g
> > +MinSizeRel : -Os
> > +empty(default) :
> > +
> > +NOTE: -DCMAKE_BUILD_TYPE is optional. For multi-config generators like Visual Studio
> > +this option is ignored
>
> Quite helpful.
>
> > +This process generates a Makefile(Linux) , Visual Studio solution(Windows) by default.
> > +Run `make` to build Git on Linux.
> > +Open git.sln on Windows and build Git.
> > +
> > +NOTE: By default CMake uses Makefile as the build tool on Linux and Visual Studio in Windows,
>
> The above makes it sound as if Linux and VS are the only two systems
> we care about, but is it really Linux, or UNIX-flavoured systems in
> general?  In other words, are we excluding friends on BSD and macOS
> with the above?
>
> The above is not a complaint about "exclusion", but is a complaint
> about unclarity.
>

Will specify for other systems as well.

> > +to use another tool say `ninja` add this to the command line when configuring.
> > +`-G Ninja`
> > +
> > +]]
> > +cmake_minimum_required(VERSION 3.14)
> > ...
> > +check_c_source_compiles("
>
> The "source" given to check_c_source_{compiles,runs} may be allowed
> to be anything, but I'd prefer to see it follow some consistent
> style, preferrably our CodingGuidelines (except for git specific
> bits like "do not include standard system file but instead just use
> git-compat-util.h", which of course should not apply).  This is a
> comment not only about the two instances below I use as examples,
> but all C-source snippets in this patch.
>
> > +#include <alloca.h>
> > +int
> > +main ()
> > +{
>
>         int main(void)
>         {
>
> is how we start this function.
>
> > +char *p = (char *) alloca (2 * sizeof (int));
>
> And the decl of function local variable here would be indented by a
> HT like the remainder of the function.  No SP between function name
> and the parentheses around its arguments.  NP SP after sizeof,
> either.
>
> > +     if (p) return 0;
> > +     return 0;
> > +}"
> > +HAVE_ALLOCA_H)
> > ...
> > +check_c_source_runs("
> > +#include<stdio.h>
> > +#include<stdarg.h>
> > +#include<string.h>
> > +#include<stdlib.h>
> > +int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
> > +{
> > +     int ret;
> > +     va_list ap;
> > +
> > +     va_start(ap, format);
> > +     ret = vsnprintf(str, maxsize, format, ap);
> > +     va_end(ap);
> > +     return ret;
> > +}
> > +
> > +int
> > +main ()
> > +{
>
> Likewise.
>
> > +     char buf[6];
> > +     if (test_vsnprintf(buf, 3, \"%s\", \"12345\") != 5
> > +             || strcmp(buf, \"12\")) return 1;
> > +     if (snprintf(buf, 3, \"%s\", \"12345\") != 5
> > +             || strcmp(buf, \"12\")) return 1;
> > +
> > +     return 0;
> > +}"
>

Will format the checks.

Thank You,
Sibi Siddharthan

> Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v3 2/8] cmake: generate the shell/perl/python scripts and templates, translations
  2020-05-29 19:27       ` Junio C Hamano
@ 2020-05-30 18:56         ` Sibi Siddharthan
  2020-06-08 20:07           ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-30 18:56 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Sibi Siddharthan via GitGitGadget, git

On Sat, May 30, 2020 at 12:58 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Sibi Siddharthan via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >
> > Implement the placeholder substitution to generate scripted
> > Porcelain commands, e.g. git-request-pull out of
> > git-request-pull.sh
> >
> > Generate shell/perl/python scripts and template using CMake instead of
> > using sed like the build procedure in the Makefile does.
> >
> > The text translations are only build if `msgfmt` is found in your path.
> >
> > NOTE: The scripts and templates are generated during configuration.
>
> OK.
>
> > Changes
> > The CMake script parses the Makefile for:
> > SCRIPT_SH
> > SCRIPT_PERL
>
> Below the three-dash line.
>
> > +#shell scripts
> > +parse_makefile_for_scripts(git_sh_scripts "SCRIPT_SH" ".sh")
>
> OK.
>
> > +set(git_shell_scripts
> > +     ${git_sh_scripts}
> > +     git-mergetool--lib git-parse-remote git-rebase--preserve-merges
> > +     git-sh-setup git-sh-i18n git-instaweb)
>
> Do we need to have enumeration here, which can drift out of sync
> with the reality?  Wouldn't we want to avoid it with something like
>
>  parse_makefile_for_scripts(git_sh_lib "SCRIPT_LIB" "")
>
> too?
>

Will do.

> > +#perl modules
> > +file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
> > +
> > +foreach(pm ${perl_modules})
> > +     string(REPLACE "${CMAKE_SOURCE_DIR}/perl/" "" file_path ${pm})
> > +     file(STRINGS ${pm} content NEWLINE_CONSUME)
> > +     string(REPLACE "@@LOCALEDIR@@" "${LOCALEDIR}" content "${content}")
> > +     string(REPLACE "@@NO_PERL_CPAN_FALLBACKS@@" "" content "${content}")
> > +     file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})
> > +#test-lib.sh requires perl/build/lib to be the build directory of perl modules
> > +endforeach()
> > +
> > +
> > +#templates
> > +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
> > +set(hooks_templates
> > +     applypatch-msg.sample pre-applypatch.sample pre-push.sample
> > +     commit-msg.sample pre-commit.sample pre-rebase.sample
> > +     fsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample
> > +     post-update.sample prepare-commit-msg.sample update.sample)
>
> Do we need to have enumeration here, which can drift out of sync
> with the reality?  Wouldn't we want to avoid it with file(GLOB) or
> something?
>

Will glob the above, and the po files as well.

> > +#templates have @.*@ replacement so use configure_file instead
> > +#hooks
> > +foreach(tm ${hooks_templates})
> > +     configure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)
> > +endforeach()
> > +
> > +#info
> > +configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)
> > +
> > +#this
> > +configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)
>
> I was hoping that we could drive any build system without having to
> have separate rules like the above.  The idea behind all files with
> funny double-dash in its name under templates/ directory is:
>

So, I have to write the logic for determining the directories?
If so will do.

>  - double-dash denotes directory boundary
>
>  - when a template input ends with double-dash, it tells us to
>    create a directory
>
>  - leading "this--" denotes "not in a subdirectory but at the top
>    level of the generated template directory"
>
> so that each of them knows what the name of the file and directory
> hierarchy of the final destination is, and the result of transforming
> can be created and deposited at the final place mechanically with a
> single rule.
>
> > +#translations
> > +if(MSGFMT_EXE)
> > +     set(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)
>
> Do we need to have enumeration here, which can drift out of sync
> with the reality?  Wouldn't globbing for *.po be sufficient?
>
> > +     foreach(po ${po_files})
> > +             file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)
> > +             add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo
> > +                             COMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)
> > +             list(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)
> > +     endforeach()
> > +     add_custom_target(po-gen ALL DEPENDS ${po_gen})
> > +endif()
>
> Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v3 4/8] cmake: support for testing git with ctest
  2020-05-30 13:49       ` Đoàn Trần Công Danh
@ 2020-05-30 19:04         ` Sibi Siddharthan
  2020-05-31  1:28           ` Đoàn Trần Công Danh
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-30 19:04 UTC (permalink / raw)
  To: Đoàn Trần Công Danh
  Cc: Sibi Siddharthan via GitGitGadget, git

On Sat, May 30, 2020 at 7:19 PM Đoàn Trần Công Danh
<congdanhqx@gmail.com> wrote:
>
> On 2020-05-29 13:40:20+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >
> > This patch provides an alternate way to test git using ctest.
> > CTest ships with CMake, so there is no additional dependency being
> > introduced.
> >
> > To perform the tests with ctest do this after building:
> > ctest -j[number of jobs]
>
> Or we can just run: make test
> CMake will run: ctest itself.
>
> Ah, OK, that's not equivalence. make -j9 test doesn't work :/
>

No, it does not.
make test -> ctest --force-new-ctest-process.

> Anyway, there're test is failing in Linux with this CMake.
>
>         $git_repo/t/../build/bin-wrappers/git is not executable; using GIT_EXEC_PATH
>
> It looks like CMake Generator forgets "chmod +x bin-wrappers/git"
>

CMake does not support changing permissions of files easily.
You have to juggle them around to a temporary location and
change the permissions when you do `file(COPY ...)`.

Will look into this.

> > Test time =   1.11 sec
> >
> > NOTE: Testing only works when building in source for now.
>
> OK, so this maybe the pain point, let me build in source again.
> Hm, no, I still see the same problems.
> Worse, CMake overrides my current Makefile.
> Luckily, I don't have any changes in Makefile.
>

Please read the next PATCH, it supports out of source building and testing.

> > +endif()#BUILD_TESTING
>
> We can use:
>
>         endif(BUILD_TESTING)
>

The docs suggest that this way of endif() is for backwards compat only.
Not sure if I should change this, as CMake might remove this in the
future(very unlikely though).

Thank You,
Sibi Siddharthan

> --
> Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v3 7/8] cmake: support for building git on windows with msvc and clang.
  2020-05-30 14:08       ` Đoàn Trần Công Danh
@ 2020-05-30 19:08         ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-30 19:08 UTC (permalink / raw)
  To: Đoàn Trần Công Danh
  Cc: Sibi Siddharthan via GitGitGadget, git

On Sat, May 30, 2020 at 7:38 PM Đoàn Trần Công Danh
<congdanhqx@gmail.com> wrote:
>
> On 2020-05-29 13:40:23+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >
> > This patch adds support for Visual Studio and Clang builds
> >
> > The minimum required version of CMake is upgraded to 3.15 because
> > this version offers proper support for Clang builds on Windows.
> >
> > Libintl is not searched for when building with Visual Studio or Clang
> > because there is no binary compatible version available yet.
> >
> > NOTE: In the link options invalidcontinue.obj has to be included.
> > The reason for this is because by default, Windows calls abort()'s
> > instead of setting errno=EINVAL when invalid arguments are passed to
> > standard functions.
> > This commit explains it in detail:
> > 4b623d80f73528a632576990ca51e34c333d5dd6
>
> I think it's better to say:
>
>         See 4b623d80f7 (MSVC: link in invalidcontinue.obj for better
>         POSIX compatibility, 2014-03-29) for detail.
>
>
> (I haven't read the referenced commit, FWIW)
>
> > On Windows the default generator is Visual Studio,so for Visual Studio
> > builds do this:
> >
> > cmake `relative-path-to-srcdir`
> >
> > NOTE: Visual Studio generator is a multi config generator, which means
> > that Debug and Release builds can be done on the same build directory.
> >
> > For Clang builds do this:
> >
> > On bash
> > CC=Clang cmake `relative-path-to-srcdir` -G Ninja
>
> I think you meant CC=clang, note the lowercase c,
> that will cmake this note applicable for case-sensitive filesystem.
>
> ... reading this patch ...
>
> So, this is applicable for Windows only, it's fine as is, then.
> It's still better to lowercase it, though.

will change it,(typo)

>
> >               -DCMAKE_BUILD_TYPE=[Debug or Release]
> >
> > On cmd
> > set CC=Clang
> > cmake `relative-path-to-srcdir` -G Ninja
> >               -DCMAKE_BUILD_TYPE=[Debug or Release]
> >
> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> > ---
> >  contrib/buildsystems/CMakeLists.txt | 55 +++++++++++++++++++++++------
> >  1 file changed, 45 insertions(+), 10 deletions(-)
> >
> > diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
> > index 46197d0b806..0a3f711db88 100644
> > --- a/contrib/buildsystems/CMakeLists.txt
> > +++ b/contrib/buildsystems/CMakeLists.txt
> > @@ -98,8 +98,11 @@ find_package(ZLIB REQUIRED)
> >  find_package(CURL)
> >  find_package(EXPAT)
> >  find_package(Iconv)
> > -find_package(Intl)
> >
> > +#Don't use libintl on Windows Visual Studio and Clang builds
> > +if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")))
>
> Personally, I find this is a bit ugly.
> Does it work to move the if(WIN32) down there, here.
> Then make sub-condition for MSVC and Clang?
>
> > +     find_package(Intl)
> > +endif()
> >
> >  if(NOT Intl_FOUND)
> >       add_compile_definitions(NO_GETTEXT)
> > @@ -123,7 +126,7 @@ if(Intl_FOUND)
> >  endif()
> >
> >
> > -if(WIN32)
> > +if(WIN32 AND NOT MSVC)#not required for visual studio builds
>

Can do that.

> for the down there, I meant here.
> Using "NOT MSVC" here and `CMAKE_C_COMPILER_ID STREQUAL "MSVC"` above
> may puzzle people interest in this patch.
>
> >       find_program(WINDRES_EXE windres)
> >       if(NOT WINDRES_EXE)
> >               message(FATAL_ERROR "Install windres on Windows for resource files")
> > @@ -135,6 +138,13 @@ if(NOT MSGFMT_EXE)
> >       message(WARNING "Text Translations won't be build")
> >  endif()
> >
> > +#Force all visual studio outputs to CMAKE_BINARY_DIR
> > +if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
> > +     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
> > +     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
> > +     add_compile_options(/MP)
> > +endif()
> > +
> >  #default behaviour
> >  include_directories(${CMAKE_SOURCE_DIR})
> >  add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
> > @@ -172,6 +182,10 @@ endif()
> >
> >  #Platform Specific
> >  if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
>
> I missed this line from previous patch
> (and my comment in previous round, which suggested remove ${})
> Does `if(WIN32)` and `if(CMAKE_SYSTEM_NAME STREQUAL "Windows")` have
> different meanings?
> I don't know much about CMake on Windows to really sure about this.
>

They are the same.
The reason for using CMAKE_SYSTEM_NAME instead of (WIN32,UNIX,APPLE...) is that
if you specify `if(UNIX)` it means both Linux and Darwin, whereas if you specify
if(CMAKE_SYSTEM_NAME STREQUAL "Linux") it means Linux only.

Thank You,
Sibi Siddharthan

> --
> Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v3 8/8] ci: modification of main.yml to use cmake for vs-build job
  2020-05-30 14:14       ` Đoàn Trần Công Danh
@ 2020-05-30 19:13         ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-05-30 19:13 UTC (permalink / raw)
  To: Đoàn Trần Công Danh
  Cc: Sibi Siddharthan via GitGitGadget, git, Sibi Siddharthan

On Sat, May 30, 2020 at 7:44 PM Đoàn Trần Công Danh
<congdanhqx@gmail.com> wrote:
>
> On 2020-05-29 13:40:24+0000, Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com> wrote:
> > To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working
> > directory of script or path. So we copy the dlls before we configure.
>
> If ICONV_OMITS_BOM is such a troublemaker for CMake,
> I'm fine with not supporting it at all.
>
> It seems like noone except me have interest in ICONV_OMITS_BOM.
>

It is not a problem supporting this check. This check has to be
implemented sometime down the road.(as it is specified in the
Makefile)
The issue currently is that this check is a bit big (~50 loc)
including setup and cleanup. This might be a burden
for the reviewers as the only reason for considering CMake support is
to support windows developers.

> > @@ -302,4 +308,4 @@ jobs:
> >      steps:
> >      - uses: actions/checkout@v1
> >      - run: ci/install-dependencies.sh
> > -    - run: ci/test-documentation.sh
> > +    - run: ci/test-documentation.sh
> > \ No newline at end of file
>
> Please fix your editor ;)
>
> --
> Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v3 4/8] cmake: support for testing git with ctest
  2020-05-30 19:04         ` Sibi Siddharthan
@ 2020-05-31  1:28           ` Đoàn Trần Công Danh
  0 siblings, 0 replies; 179+ messages in thread
From: Đoàn Trần Công Danh @ 2020-05-31  1:28 UTC (permalink / raw)
  To: Sibi Siddharthan; +Cc: Sibi Siddharthan via GitGitGadget, git

On 2020-05-31 00:34:52+0530, Sibi Siddharthan <sibisiddharthan.github@gmail.com> wrote:
> > Anyway, there're test is failing in Linux with this CMake.
> >
> >         $git_repo/t/../build/bin-wrappers/git is not executable; using GIT_EXEC_PATH
> >
> > It looks like CMake Generator forgets "chmod +x bin-wrappers/git"
> >
> 
> CMake does not support changing permissions of files easily.
> You have to juggle them around to a temporary location and
> change the permissions when you do `file(COPY ...)`.

Does it work better to use `configure_file` and `file(COPY)`

> > OK, so this maybe the pain point, let me build in source again.
> > Hm, no, I still see the same problems.
> > Worse, CMake overrides my current Makefile.
> > Luckily, I don't have any changes in Makefile.
> >
> 
> Please read the next PATCH, it supports out of source building and testing.

It's the remind to NOT mess with Git's Makefile ;)

> > > +endif()#BUILD_TESTING
> >
> > We can use:
> >
> >         endif(BUILD_TESTING)
> >
> 
> The docs suggest that this way of endif() is for backwards compat only.
> Not sure if I should change this, as CMake might remove this in the
> future(very unlikely though).

I don't have strong opinion for this syntax.

-- 
Danh

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v3 1/8] Introduce CMake support for configuring Git
  2020-05-30 18:50         ` Sibi Siddharthan
@ 2020-05-31 16:17           ` Junio C Hamano
  2020-05-30  8:00             ` Johannes Schindelin
  0 siblings, 1 reply; 179+ messages in thread
From: Junio C Hamano @ 2020-05-31 16:17 UTC (permalink / raw)
  To: Sibi Siddharthan
  Cc: Sibi Siddharthan via GitGitGadget, git, Johannes Schindelin

Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:

> On Sat, May 30, 2020 at 12:57 AM Junio C Hamano <gitster@pobox.com> wrote:
>> ...
>> Everything after the "Changes" line does not belong to the commit
>> log, as it is no use for those who read "git log" output and
>> encounter the "first" attempt to add CMake support there.  There is
>> no need to tell them that you did things differently from this
>> version in the past, as they simply do not know what you did in the
>> previous iterations, nor particularly care about them.
>>
>> These *do* help reviewers who saw previous iterations, and the space
>> after the three-dash line below is the right/recommended place for
>> them.
>>
>> The above applies to other patches in this series.
>
> Do you mean this line '---' below?

Yes.

> If so how do I place the changelog below them?
> I just do `/submit` at gigitgadet/git.

Sorry, I don't use GGG, so the question needs to be redirected to
those who do and enhance (Dscho cc'ed).

>> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
>> > ---

Here is what I meant, but another place that is suitable to describe
differences from previous rounds is the cover letter.  If the split
of tasks between steps in a multi-patch series hasn't changed from
the previous round, it makes it easier to review if the changes
since the last round for each individual step is described in the
message itself, like you did.  It just needs to be done outside the
log message.

Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v3 2/8] cmake: generate the shell/perl/python scripts and templates, translations
  2020-05-30 18:56         ` Sibi Siddharthan
@ 2020-06-08 20:07           ` Sibi Siddharthan
  2020-06-08 22:10             ` Junio C Hamano
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-06-08 20:07 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Sibi Siddharthan via GitGitGadget, git

Hi Junio,

I have done the suggested changes namely:
1) Format code inside check_c_source_compiles/runs
2) Moved the changelog of the patch series from the commit messages to
the cover letter
3) parse for SCRIPT_LIB
4) glob templates and po files
5) add logic as to where the template file should be built.

Any other changes I should do before I a new version of the patch series?

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v3 2/8] cmake: generate the shell/perl/python scripts and templates, translations
  2020-06-08 20:07           ` Sibi Siddharthan
@ 2020-06-08 22:10             ` Junio C Hamano
  0 siblings, 0 replies; 179+ messages in thread
From: Junio C Hamano @ 2020-06-08 22:10 UTC (permalink / raw)
  To: Sibi Siddharthan; +Cc: Sibi Siddharthan via GitGitGadget, git

Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:

> Hi Junio,
>
> I have done the suggested changes namely:
> 1) Format code inside check_c_source_compiles/runs
> 2) Moved the changelog of the patch series from the commit messages to
> the cover letter
> 3) parse for SCRIPT_LIB
> 4) glob templates and po files
> 5) add logic as to where the template file should be built.
>
> Any other changes I should do before I a new version of the patch series?
>
> Thank You,
> Sibi Siddharthan

Sorry, but I read too many patch series that I do not remember
glitches I pointed out in the previous round of individual topics.

So asking that question is waste of both of our times.  Just use the
time necessary to compose that message to instead proofread one more
time, scan the review thread of previous round and make sure you
took everybody's input into consideration (you do not have to follow
everything other people said---you just need to be able to solidly
stand behind the decision you made to follow or not follow them in
your latest version).

Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* [PATCH v4 0/8] CMake build system for git
  2020-05-29 13:40   ` [PATCH v3 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                       ` (7 preceding siblings ...)
  2020-05-29 13:40     ` [PATCH v3 8/8] ci: modification of main.yml to use cmake for vs-build job Sibi Siddharthan via GitGitGadget
@ 2020-06-12 18:29     ` Sibi Siddharthan via GitGitGadget
  2020-06-12 18:29       ` [PATCH v4 1/8] Introduce CMake support for configuring Git Sibi Siddharthan via GitGitGadget
                         ` (8 more replies)
  8 siblings, 9 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-06-12 18:29 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan

This is an attempt to build Git using CMake. CMake is cross-platform build
generator which works well on a variety of platforms(primarily Linux and
Windows). Using CMake we can check whether certain headers exist, certain
functions exist, the required libraries are present and configure the build
accordingly. Using CMake we can also build and test Git out of source,
resulting in a clean source tree.

Tested platforms

Ubuntu 18.04 GCC 7.4 Clang 8.0.1

Windows MinGW GCC 9.2 Clang 9 Visual Studio 2015,2017,2019

Changes:

1) The CMake script has been relocated to contrib/buildsystems 2) The CMake
script parses the Makefile for the sources. LIB_OBJS BUILTIN_OBJS XDIFF_OBJS
VCSSVN_OBJS TEST_BUILTINS_OBJS SCRIPT_SH SCRIPT_PERL 3) Philip suggested to
change the error message if sh/bash was not found on windows. 4) CMake now
tests for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT 5) Renamed the
variable test_helper_sources to test-tool_SOURCES [PATCH 4/8] to be
consistent with the naming of source variables.

Changes v2: Changes 1,2,4 have been rebased to PATCH 01/xx CMake uses
GIT-VERSION-GEN to get the version of Git Fixed a bug where a Windows user
can pose as Linux user and vice versa. [PATCH 6/8]

Changes v3: Patch changes are moved from the commit messages and are placed
here. Code inside check_c_source_(compiles/runs) have been formatted
according to git coding guidelines. [PATCH 1/8] The CMake script parses the
Makefile for SCRIPT_LIB also. [PATCH 2/8] The CMake script globs templates,
po files. Logic has been added to place the template files in their
respective directories instead of hard-coding them. [PATCH 2/8]

Sibi Siddharthan (8):
  Introduce CMake support for configuring Git
  cmake: generate the shell/perl/python scripts and templates,
    translations
  cmake: installation support for git
  cmake: support for testing git with ctest
  cmake: support for testing git when building out of the source tree
  cmake: support for building git on windows with mingw
  cmake: support for building git on windows with msvc and clang.
  ci: modification of main.yml to use cmake for vs-build job

 .github/workflows/main.yml          |   36 +-
 contrib/buildsystems/CMakeLists.txt | 1003 +++++++++++++++++++++++++++
 2 files changed, 1024 insertions(+), 15 deletions(-)
 create mode 100644 contrib/buildsystems/CMakeLists.txt


base-commit: c72c7da667dba3465fb566ecb23457950e28893c
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-614%2FSibiSiddharthan%2Fgit-og-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-614/SibiSiddharthan/git-og-v4
Pull-Request: https://github.com/gitgitgadget/git/pull/614

Range-diff vs v3:

 1:  09c972de52b ! 1:  c4e1ba74464 Introduce CMake support for configuring Git
     @@ Commit message
          part of the build. This is needed to generate all those hardlinks for
          the built-in commands of Git.
      
     -    Changes
     -    The CMake script parses the Makefile for:
     -    LIB_OBJS
     -    BUILTIN_OBJS
     -    XDIFF_OBJS
     -    VCSSVN_OBJS
     -    TEST_BUILTINS_OBJS
     -
     -    By doing this we avoid duplication of text between the Makefile and
     -    the CMake script.
     -
     -    The CMake script has been relocated to contrib/buildsystems.
     -
     -    The CMake script uses GIT-VERSION-GEN to determine the version of Git
     -    being built.
     -
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
       ## contrib/buildsystems/CMakeLists.txt (new) ##
     @@ contrib/buildsystems/CMakeLists.txt (new)
      +Instructions to run CMake:
      +
      +cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release
     ++Eg.
     ++From the root of git source tree
     ++	`cmake contrib/buildsystems/ `
     ++This will build the git binaries at the root
     ++
     ++For out of source builds, say build in 'git/git-build/'
     ++	`mkdir git-build;cd git-build; cmake ../contrib/buildsystems/`
     ++This will build the git binaries in git-build directory
      +
      +Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
      +compiler flags
     @@ contrib/buildsystems/CMakeLists.txt (new)
      +NOTE: -DCMAKE_BUILD_TYPE is optional. For multi-config generators like Visual Studio
      +this option is ignored
      +
     -+This process generates a Makefile(Linux) , Visual Studio solution(Windows) by default.
     -+Run `make` to build Git on Linux.
     ++This process generates a Makefile(Linux/*BSD/MacOS) , Visual Studio solution(Windows) by default.
     ++Run `make` to build Git on Linux/*BSD/MacOS.
      +Open git.sln on Windows and build Git.
      +
      +NOTE: By default CMake uses Makefile as the build tool on Linux and Visual Studio in Windows,
     @@ contrib/buildsystems/CMakeLists.txt (new)
      +
      +check_c_source_compiles("
      +#include <alloca.h>
     -+int
     -+main ()
     ++
     ++int main(void)
      +{
     -+char *p = (char *) alloca (2 * sizeof (int));
     -+	if (p) return 0;
     ++	char *p = (char *) alloca(2 * sizeof(int));
     ++
     ++	if (p)
     ++		return 0;
      +	return 0;
      +}"
      +HAVE_ALLOCA_H)
     @@ contrib/buildsystems/CMakeLists.txt (new)
      +#include<stdarg.h>
      +#include<string.h>
      +#include<stdlib.h>
     ++
      +int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
      +{
      +	int ret;
     @@ contrib/buildsystems/CMakeLists.txt (new)
      +	return ret;
      +}
      +
     -+int
     -+main ()
     ++int main(void)
      +{
      +	char buf[6];
     ++
      +	if (test_vsnprintf(buf, 3, \"%s\", \"12345\") != 5
     -+		|| strcmp(buf, \"12\")) return 1;
     ++		|| strcmp(buf, \"12\"))
     ++			return 1;
      +	if (snprintf(buf, 3, \"%s\", \"12345\") != 5
     -+		|| strcmp(buf, \"12\")) return 1;
     -+
     ++		|| strcmp(buf, \"12\"))
     ++			return 1;
      +	return 0;
      +}"
      +SNPRINTF_OK)
     @@ contrib/buildsystems/CMakeLists.txt (new)
      +
      +check_c_source_runs("
      +#include<stdio.h>
     -+int
     -+main ()
     ++
     ++int main(void)
      +{
      +	FILE *f = fopen(\".\", \"r\");
     -+	return f != NULL;
      +
     -+	return 0;
     ++	return f != NULL;
      +}"
      +FREAD_READS_DIRECTORIES_NO)
      +if(NOT FREAD_READS_DIRECTORIES_NO)
     @@ contrib/buildsystems/CMakeLists.txt (new)
      +#ifndef REG_STARTEND
      +#error oops we dont have it
      +#endif
     -+int main(){return 0;}"
     ++
     ++int main(void)
     ++{
     ++	return 0;
     ++}"
      +HAVE_REGEX)
      +if(NOT HAVE_REGEX)
      +	include_directories(${CMAKE_SOURCE_DIR}/compat/regex)
     @@ contrib/buildsystems/CMakeLists.txt (new)
      +#include <sys/types.h>
      +#include <sys/sysctl.h>
      +
     -+int
     -+main ()
     ++int main(void)
      +{
      +	int val, mib[2];
      +	size_t len;
     @@ contrib/buildsystems/CMakeLists.txt (new)
      +	mib[1] = 1;
      +	len = sizeof(val);
      +	return sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;
     -+
     -+	return 0;
      +}"
      +HAVE_BSD_SYSCTL)
      +if(HAVE_BSD_SYSCTL)
     @@ contrib/buildsystems/CMakeLists.txt (new)
      +		char **inbuf, size_t *inbytesleft,
      +		char **outbuf, size_t *outbytesleft);
      +
     -+int main(){return 0;}"
     ++int main(void)
     ++{
     ++	return 0;
     ++}"
      +HAVE_NEW_ICONV)
      +if(HAVE_NEW_ICONV)
      +	set(HAVE_OLD_ICONV 0)
     @@ contrib/buildsystems/CMakeLists.txt (new)
      +typedef char *iconv_ibp;
      +#endif
      +
     -+int main()
     ++int main(void)
      +{
      +	int v;
      +	iconv_t conv;
     -+	char in[] = \"a\"; iconv_ibp pin = in;
     -+	char out[20] = \"\"; char *pout = out;
     -+	size_t isz = sizeof in;
     -+	size_t osz = sizeof out;
     ++	char in[] = \"a\";
     ++	iconv_ibp pin = in;
     ++	char out[20] = \"\";
     ++	char *pout = out;
     ++	size_t isz = sizeof(in);
     ++	size_t osz = sizeof(out);
      +
      +	conv = iconv_open(\"UTF-16\", \"UTF-8\");
      +	iconv(conv, &pin, &isz, &pout, &osz);
 2:  f19794fdbc0 ! 2:  abb9e6e1d58 cmake: generate the shell/perl/python scripts and templates, translations
     @@ Commit message
      
          NOTE: The scripts and templates are generated during configuration.
      
     -    Changes
     -    The CMake script parses the Makefile for:
     -    SCRIPT_SH
     -    SCRIPT_PERL
     -
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
       ## contrib/buildsystems/CMakeLists.txt ##
     @@ contrib/buildsystems/CMakeLists.txt: macro(parse_makefile_for_sources list_var r
      +	string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
      +	string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
      +	string(REPLACE " " ";" ${list_var} ${${list_var}}) #convert string to a list
     -+	list(TRANSFORM ${list_var} REPLACE "${lang}" "") #do the replacement
     ++	if(NOT ${lang}) #exclude for SCRIPT_LIB
     ++		list(TRANSFORM ${list_var} REPLACE "${lang}" "") #do the replacement
     ++	endif()
      +endmacro()
      +
       include(CheckTypeSize)
     @@ contrib/buildsystems/CMakeLists.txt: add_custom_command(OUTPUT ${git_links} ${gi
      +
      +#shell scripts
      +parse_makefile_for_scripts(git_sh_scripts "SCRIPT_SH" ".sh")
     ++parse_makefile_for_scripts(git_shlib_scripts "SCRIPT_LIB" "")
      +set(git_shell_scripts
     -+	${git_sh_scripts}
     -+	git-mergetool--lib git-parse-remote git-rebase--preserve-merges
     -+	git-sh-setup git-sh-i18n git-instaweb)
     ++	${git_sh_scripts} ${git_shlib_scripts} git-instaweb)
      +
      +foreach(script ${git_shell_scripts})
      +	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)
     @@ contrib/buildsystems/CMakeLists.txt: add_custom_command(OUTPUT ${git_links} ${gi
      +
      +
      +#templates
     ++file(GLOB templates "${CMAKE_SOURCE_DIR}/templates/*")
     ++list(TRANSFORM templates REPLACE "${CMAKE_SOURCE_DIR}/templates/" "")
     ++list(REMOVE_ITEM templates ".gitignore")
     ++list(REMOVE_ITEM templates "Makefile")
     ++
     ++list(REMOVE_ITEM templates "branches--")
      +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
     -+set(hooks_templates
     -+	applypatch-msg.sample pre-applypatch.sample pre-push.sample
     -+	commit-msg.sample pre-commit.sample pre-rebase.sample
     -+	fsmonitor-watchman.sample pre-merge-commit.sample pre-receive.sample
     -+	post-update.sample prepare-commit-msg.sample update.sample)
      +
      +#templates have @.*@ replacement so use configure_file instead
     -+#hooks
     -+foreach(tm ${hooks_templates})
     -+	configure_file(${CMAKE_SOURCE_DIR}/templates/hooks--${tm} ${CMAKE_BINARY_DIR}/templates/blt/hooks/${tm} @ONLY)
     ++foreach(tm ${templates})
     ++	string(REPLACE "--" "/" blt_tm ${tm})
     ++	string(REPLACE "this" "" blt_tm ${blt_tm})# for this--
     ++	configure_file(${CMAKE_SOURCE_DIR}/templates/${tm} ${CMAKE_BINARY_DIR}/templates/blt/${blt_tm} @ONLY)
      +endforeach()
      +
     -+#info
     -+configure_file(${CMAKE_SOURCE_DIR}/templates/info--exclude ${CMAKE_BINARY_DIR}/templates/blt/info/exclude @ONLY)
     -+
     -+#this
     -+configure_file(${CMAKE_SOURCE_DIR}/templates/this--description ${CMAKE_BINARY_DIR}/templates/blt/description @ONLY)
     -+
      +
      +#translations
      +if(MSGFMT_EXE)
     -+	set(po_files bg  ca  de  el  es  fr  is  it  ko  pt_PT  ru  sv  tr  vi  zh_CN  zh_TW)
     ++	file(GLOB po_files "${CMAKE_SOURCE_DIR}/po/*.po")
     ++	list(TRANSFORM po_files REPLACE "${CMAKE_SOURCE_DIR}/po/" "")
     ++	list(TRANSFORM po_files REPLACE ".po" "")
      +	foreach(po ${po_files})
      +		file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)
      +		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo
 3:  6ec73d3e967 ! 3:  4a0dd23cbbf cmake: installation support for git
     @@ Commit message
      
          Then run `make install`
      
     -    Changes:
     -    Removed a comment regarding the installation of gitk.
     -
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
       ## contrib/buildsystems/CMakeLists.txt ##
 4:  cdc53172b3f ! 4:  db05180e98a cmake: support for testing git with ctest
     @@ Commit message
      
          NOTE: Testing only works when building in source for now.
      
     -    Changes:
     -    Renamed the variable test_helper_sources to test-tool_SOURCES
     -    to be consistent with the naming of source variables.
     -
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
       ## contrib/buildsystems/CMakeLists.txt ##
 5:  cdc68f102cb = 5:  17e7f3e9de6 cmake: support for testing git when building out of the source tree
 6:  f41cbd43081 ! 6:  549f0cd5fff cmake: support for building git on windows with mingw
     @@ Commit message
          To use CMake on Windows with MinGW do this:
          cmake `relative-path-to-srcdir` -G "MinGW Makefiles"
      
     -    Changes:
     -    Changed the error message when sh.exe is not found on Windows as
     -    suggested by Philip Oakley <philipoakley@iee.email>
     -
     -    v2:
     -    Fixed a bug where a Windows user can pose as Linux user and vice versa.
     -
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
       ## contrib/buildsystems/CMakeLists.txt ##
 7:  8f36e30cd22 ! 7:  f85ea0ac0ca cmake: support for building git on windows with msvc and clang.
     @@ Commit message
          For Clang builds do this:
      
          On bash
     -    CC=Clang cmake `relative-path-to-srcdir` -G Ninja
     +    CC=clang cmake `relative-path-to-srcdir` -G Ninja
                          -DCMAKE_BUILD_TYPE=[Debug or Release]
      
          On cmd
 8:  bb329d16ce0 ! 8:  2f7cf41e08f ci: modification of main.yml to use cmake for vs-build job
     @@ Commit message
          FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been
          added to revert to the old behaviour.
      
     -    Edit(Explanation for the reordering of build steps):
          In the configuration phase CMake looks for the required libraries for
          building git (eg zlib,libiconv). So we extract the libraries before we
          configure.
     @@ Commit message
          To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working
          directory of script or path. So we copy the dlls before we configure.
      
     -    Signed-off-by: Sibi Siddharthan <sibisiv.siddharthan@gmail.com>
     +    Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
       ## .github/workflows/main.yml ##
      @@ .github/workflows/main.yml: jobs:
     @@ .github/workflows/main.yml: jobs:
         regular:
           needs: ci-config
           if: needs.ci-config.outputs.enabled == 'yes'
     -@@ .github/workflows/main.yml: jobs:
     -     steps:
     -     - uses: actions/checkout@v1
     -     - run: ci/install-dependencies.sh
     --    - run: ci/test-documentation.sh
     -+    - run: ci/test-documentation.sh
     - \ No newline at end of file

-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 179+ messages in thread

* [PATCH v4 1/8] Introduce CMake support for configuring Git
  2020-06-12 18:29     ` [PATCH v4 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
@ 2020-06-12 18:29       ` Sibi Siddharthan via GitGitGadget
  2020-06-15 14:00         ` Øystein Walle
  2020-06-12 18:29       ` [PATCH v4 2/8] cmake: generate the shell/perl/python scripts and templates, translations Sibi Siddharthan via GitGitGadget
                         ` (7 subsequent siblings)
  8 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-06-12 18:29 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

At the moment, the recommended way to configure Git's builds is to
simply run `make`. If that does not work, the recommended strategy is to
look at the top of the `Makefile` to see whether any "Makefile knob" has
to be turned on/off, e.g. `make NO_OPENSSL=YesPlease`.

Alternatively, Git also has an `autoconf` setup which allows configuring
builds via `./configure [<option>...]`.

Both of these options are fine if the developer works on Unix or Linux.
But on Windows, we have to jump through hoops to configure a build
(read: we force the user to install a full Git for Windows SDK, which
occupies around two gigabytes (!) on disk and downloads about three
quarters of a gigabyte worth of Git objects).

The build infrastructure for Git is written around being able to run
make, which is not supported natively on Windows.
To help Windows developers a CMake build script is introduced here.

With a working support CMake, developers on Windows need only install
CMake, configure their build, load the generated Visual Studio solution
and immediately start modifying the code and build their own version of
Git. Likewise, developers on other platforms can use the convenient GUI
tools provided by CMake to configure their build.

So let's start building CMake support for Git.

This is only the first step, and to make it easier to review, it only
allows for configuring builds on the platform that is easiest to
configure for: Linux.

The CMake script checks whether the headers are present(eg. libgen.h),
whether the functions are present(eg. memmem), whether the funtions work
properly (eg. snprintf) and generate the required compile definitions
for the platform. The script also searches for the required libraries,
if it fails to find the required libraries the respective executables
won't be built.(eg. If libcurl is not found then git-remote-http won't
be built). This will help building Git easier.

With a CMake script an out of source build of git is possible resulting
in a clean source tree.

Note: this patch asks for the minimum version v3.14 of CMake (which is
not all that old as of time of writing) because that is the first
version to offer a platform-independent way to generate hardlinks as
part of the build. This is needed to generate all those hardlinks for
the built-in commands of Git.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 592 ++++++++++++++++++++++++++++
 1 file changed, 592 insertions(+)
 create mode 100644 contrib/buildsystems/CMakeLists.txt

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
new file mode 100644
index 00000000000..1e910d9df85
--- /dev/null
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -0,0 +1,592 @@
+#
+#	Copyright (c) 2020 Sibi Siddharthan
+#
+
+#[[
+
+Instructions to run CMake:
+
+cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release
+Eg.
+From the root of git source tree
+	`cmake contrib/buildsystems/ `
+This will build the git binaries at the root
+
+For out of source builds, say build in 'git/git-build/'
+	`mkdir git-build;cd git-build; cmake ../contrib/buildsystems/`
+This will build the git binaries in git-build directory
+
+Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
+compiler flags
+Debug : -g
+Release: -O3
+RelWithDebInfo : -O2 -g
+MinSizeRel : -Os
+empty(default) :
+
+NOTE: -DCMAKE_BUILD_TYPE is optional. For multi-config generators like Visual Studio
+this option is ignored
+
+This process generates a Makefile(Linux/*BSD/MacOS) , Visual Studio solution(Windows) by default.
+Run `make` to build Git on Linux/*BSD/MacOS.
+Open git.sln on Windows and build Git.
+
+NOTE: By default CMake uses Makefile as the build tool on Linux and Visual Studio in Windows,
+to use another tool say `ninja` add this to the command line when configuring.
+`-G Ninja`
+
+]]
+cmake_minimum_required(VERSION 3.14)
+
+#set the source directory to root of git
+set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
+
+find_program(SH_EXE sh)
+
+#Create GIT-VERSION-FILE using GIT-VERSION-GEN
+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)
+	message("Generating GIT-VERSION-FILE")
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN
+		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+endif()
+
+#Parse GIT-VERSION-FILE to get the version
+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE git_version REGEX "GIT_VERSION = (.*)")
+string(REPLACE "GIT_VERSION = " "" git_version ${git_version})
+string(FIND ${git_version} "GIT" location)
+if(location EQUAL -1)
+	string(REGEX MATCH "[0-9]*\\.[0-9]*\\.[0-9]*" git_version ${git_version})
+else()
+	string(REGEX MATCH "[0-9]*\\.[0-9]*" git_version ${git_version})
+	string(APPEND git_version ".0") #for building from a snapshot
+endif()
+
+project(git
+	VERSION ${git_version}
+	LANGUAGES C)
+
+
+#macros for parsing the Makefile for sources
+macro(parse_makefile_for_sources list_var regex)
+	file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
+	string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
+	string(REPLACE "$(COMPAT_OBJS)" "" ${list_var} ${${list_var}}) #remove "$(COMPAT_OBJS)" This is only for libgit.
+	string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
+	string(REPLACE ".o" ".c;" ${list_var} ${${list_var}}) #change .o to .c, ; is for converting the string into a list
+	list(TRANSFORM ${list_var} STRIP) #remove trailing/leading whitespaces for each element in list
+	list(REMOVE_ITEM ${list_var} "") #remove empty list elements
+endmacro()
+
+include(CheckTypeSize)
+include(CheckCSourceRuns)
+include(CheckCSourceCompiles)
+include(CheckIncludeFile)
+include(CheckFunctionExists)
+include(CheckSymbolExists)
+include(CheckStructHasMember)
+
+find_package(ZLIB REQUIRED)
+find_package(CURL)
+find_package(EXPAT)
+find_package(Iconv)
+find_package(Intl)
+
+if(NOT Intl_FOUND)
+	add_compile_definitions(NO_GETTEXT)
+	if(NOT Iconv_FOUND)
+		add_compile_definitions(NO_ICONV)
+	endif()
+endif()
+
+include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
+if(CURL_FOUND)
+	include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
+endif()
+if(EXPAT_FOUND)
+	include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
+endif()
+if(Iconv_FOUND)
+	include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
+endif()
+if(Intl_FOUND)
+	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
+endif()
+
+#default behaviour
+include_directories(${CMAKE_SOURCE_DIR})
+add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
+add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)
+add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES
+			SHA1DC_INIT_SAFE_HASH_DEFAULT=0
+			SHA1DC_CUSTOM_INCLUDE_SHA1_C="cache.h"
+			SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="git-compat-util.h" )
+list(APPEND compat_SOURCES sha1dc_git.c sha1dc/sha1.c sha1dc/ubc_check.c block-sha1/sha1.c sha256/block/sha256.c compat/qsort_s.c)
+
+
+add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
+			ETC_GITATTRIBUTES="etc/gitattributes"
+			ETC_GITCONFIG="etc/gitconfig"
+			GIT_EXEC_PATH="libexec/git-core"
+			GIT_LOCALE_PATH="share/locale"
+			GIT_MAN_PATH="share/man"
+			GIT_INFO_PATH="share/info"
+			GIT_HTML_PATH="share/doc/git-doc"
+			DEFAULT_HELP_FORMAT="html"
+			DEFAULT_GIT_TEMPLATE_DIR="share/git-core/templates"
+			GIT_VERSION="${PROJECT_VERSION}.GIT"
+			GIT_USER_AGENT="git/${PROJECT_VERSION}.GIT"
+			BINDIR="bin"
+			GIT_BUILT_FROM_COMMIT="")
+
+set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+
+add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
+list(APPEND compat_SOURCES unix-socket.c)
+
+#header checks
+check_include_file(libgen.h HAVE_LIBGEN_H)
+if(NOT HAVE_LIBGEN_H)
+	add_compile_definitions(NO_LIBGEN_H)
+	list(APPEND compat_SOURCES compat/basename.c)
+endif()
+
+check_include_file(sys/sysinfo.h HAVE_SYSINFO)
+if(HAVE_SYSINFO)
+	add_compile_definitions(HAVE_SYSINFO)
+endif()
+
+check_c_source_compiles("
+#include <alloca.h>
+
+int main(void)
+{
+	char *p = (char *) alloca(2 * sizeof(int));
+
+	if (p)
+		return 0;
+	return 0;
+}"
+HAVE_ALLOCA_H)
+if(HAVE_ALLOCA_H)
+	add_compile_definitions(HAVE_ALLOCA_H)
+endif()
+
+check_include_file(strings.h HAVE_STRINGS_H)
+if(HAVE_STRINGS_H)
+	add_compile_definitions(HAVE_STRINGS_H)
+endif()
+
+check_include_file(sys/select.h HAVE_SYS_SELECT_H)
+if(NOT HAVE_SYS_SELECT_H)
+	add_compile_definitions(NO_SYS_SELECT_H)
+endif()
+
+check_include_file(sys/poll.h HAVE_SYS_POLL_H)
+if(NOT HAVE_SYS_POLL_H)
+	add_compile_definitions(NO_SYS_POLL_H)
+endif()
+
+check_include_file(poll.h HAVE_POLL_H)
+if(NOT HAVE_POLL_H)
+	add_compile_definitions(NO_POLL_H)
+endif()
+
+check_include_file(inttypes.h HAVE_INTTYPES_H)
+if(NOT HAVE_INTTYPES_H)
+	add_compile_definitions(NO_INTTYPES_H)
+endif()
+
+check_include_file(paths.h HAVE_PATHS_H)
+if(HAVE_PATHS_H)
+	add_compile_definitions(HAVE_PATHS_H)
+endif()
+
+#function checks
+set(function_checks
+	strcasestr memmem strlcpy strtoimax strtoumax strtoull
+	setenv mkdtemp poll pread memmem unsetenv hstrerror)
+
+foreach(f ${function_checks})
+	string(TOUPPER ${f} uf)
+	check_function_exists(${f} HAVE_${uf})
+	if(NOT HAVE_${uf})
+		add_compile_definitions(NO_${uf})
+	endif()
+endforeach()
+
+if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)
+	include_directories(${CMAKE_SOURCE_DIR}/compat/poll)
+	add_compile_definitions(NO_POLL)
+	list(APPEND compat_SOURCES compat/poll/poll.c)
+endif()
+
+if(NOT HAVE_STRCASESTR)
+	list(APPEND compat_SOURCES compat/strcasestr.c)
+endif()
+
+if(NOT HAVE_STRLCPY)
+	list(APPEND compat_SOURCES compat/strlcpy.c)
+endif()
+
+if(NOT HAVE_STRTOUMAX)
+	list(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c)
+endif()
+
+if(NOT HAVE_SETENV)
+	list(APPEND compat_SOURCES compat/setenv.c)
+endif()
+
+if(NOT HAVE_MKDTEMP)
+	list(APPEND compat_SOURCES compat/mkdtemp.c)
+endif()
+
+if(NOT HAVE_PREAD)
+	list(APPEND compat_SOURCES compat/pread.c)
+endif()
+
+if(NOT HAVE_MEMMEM)
+	list(APPEND compat_SOURCES compat/memmem.c)
+endif()
+
+if(NOT WIN32)
+	if(NOT HAVE_UNSETENV)
+		list(APPEND compat_SOURCES compat/unsetenv.c)
+	endif()
+
+	if(NOT HAVE_HSTRERROR)
+		list(APPEND compat_SOURCES compat/hstrerror.c)
+	endif()
+endif()
+
+check_function_exists(getdelim HAVE_GETDELIM)
+if(HAVE_GETDELIM)
+	add_compile_definitions(HAVE_GETDELIM)
+endif()
+
+check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
+check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC)
+if(HAVE_CLOCK_GETTIME)
+	add_compile_definitions(HAVE_CLOCK_GETTIME)
+endif()
+if(HAVE_CLOCK_MONOTONIC)
+	add_compile_definitions(HAVE_CLOCK_MONOTONIC)
+endif()
+
+#check for st_blocks in struct stat
+check_struct_has_member("struct stat" st_blocks "sys/stat.h" STRUCT_STAT_HAS_ST_BLOCKS)
+if(NOT STRUCT_STAT_HAS_ST_BLOCKS)
+	add_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)
+endif()
+
+#compile checks
+check_c_source_runs("
+#include<stdio.h>
+#include<stdarg.h>
+#include<string.h>
+#include<stdlib.h>
+
+int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
+{
+	int ret;
+	va_list ap;
+
+	va_start(ap, format);
+	ret = vsnprintf(str, maxsize, format, ap);
+	va_end(ap);
+	return ret;
+}
+
+int main(void)
+{
+	char buf[6];
+
+	if (test_vsnprintf(buf, 3, \"%s\", \"12345\") != 5
+		|| strcmp(buf, \"12\"))
+			return 1;
+	if (snprintf(buf, 3, \"%s\", \"12345\") != 5
+		|| strcmp(buf, \"12\"))
+			return 1;
+	return 0;
+}"
+SNPRINTF_OK)
+if(NOT SNPRINTF_OK)
+	add_compile_definitions(SNPRINTF_RETURNS_BOGUS)
+	list(APPEND compat_SOURCES compat/snprintf.c)
+endif()
+
+check_c_source_runs("
+#include<stdio.h>
+
+int main(void)
+{
+	FILE *f = fopen(\".\", \"r\");
+
+	return f != NULL;
+}"
+FREAD_READS_DIRECTORIES_NO)
+if(NOT FREAD_READS_DIRECTORIES_NO)
+	add_compile_definitions(FREAD_READS_DIRECTORIES)
+	list(APPEND compat_SOURCES compat/fopen.c)
+endif()
+
+check_c_source_compiles("
+#include <regex.h>
+#ifndef REG_STARTEND
+#error oops we dont have it
+#endif
+
+int main(void)
+{
+	return 0;
+}"
+HAVE_REGEX)
+if(NOT HAVE_REGEX)
+	include_directories(${CMAKE_SOURCE_DIR}/compat/regex)
+	list(APPEND compat_SOURCES compat/regex/regex.c )
+	add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
+endif()
+
+
+check_c_source_compiles("
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+int main(void)
+{
+	int val, mib[2];
+	size_t len;
+
+	mib[0] = CTL_HW;
+	mib[1] = 1;
+	len = sizeof(val);
+	return sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;
+}"
+HAVE_BSD_SYSCTL)
+if(HAVE_BSD_SYSCTL)
+	add_compile_definitions(HAVE_BSD_SYSCTL)
+endif()
+
+set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES})
+set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS})
+
+check_c_source_compiles("
+#include <iconv.h>
+
+extern size_t iconv(iconv_t cd,
+		char **inbuf, size_t *inbytesleft,
+		char **outbuf, size_t *outbytesleft);
+
+int main(void)
+{
+	return 0;
+}"
+HAVE_NEW_ICONV)
+if(HAVE_NEW_ICONV)
+	set(HAVE_OLD_ICONV 0)
+else()
+	set(HAVE_OLD_ICONV 1)
+endif()
+
+check_c_source_runs("
+#include <iconv.h>
+#if ${HAVE_OLD_ICONV}
+typedef const char *iconv_ibp;
+#else
+typedef char *iconv_ibp;
+#endif
+
+int main(void)
+{
+	int v;
+	iconv_t conv;
+	char in[] = \"a\";
+	iconv_ibp pin = in;
+	char out[20] = \"\";
+	char *pout = out;
+	size_t isz = sizeof(in);
+	size_t osz = sizeof(out);
+
+	conv = iconv_open(\"UTF-16\", \"UTF-8\");
+	iconv(conv, &pin, &isz, &pout, &osz);
+	iconv_close(conv);
+	v = (unsigned char)(out[0]) + (unsigned char)(out[1]);
+	return v != 0xfe + 0xff;
+}"
+ICONV_DOESNOT_OMIT_BOM)
+if(NOT ICONV_DOESNOT_OMIT_BOM)
+	add_compile_definitions(ICONV_OMITS_BOM)
+endif()
+
+unset(CMAKE_REQUIRED_LIBRARIES)
+unset(CMAKE_REQUIRED_INCLUDES)
+
+
+#programs
+set(PROGRAMS_BUILT
+	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
+	git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
+
+if(NOT CURL_FOUND)
+	list(APPEND excluded_progs git-http-fetch git-http-push)
+	add_compile_definitions(NO_CURL)
+	message(WARNING "git-http-push and git-http-fetch will not be built")
+else()
+	list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
+	if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
+		add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
+	endif()
+endif()
+
+if(NOT EXPAT_FOUND)
+	list(APPEND excluded_progs git-http-push)
+	add_compile_definitions(NO_EXPAT)
+else()
+	list(APPEND PROGRAMS_BUILT git-http-push)
+	if(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2)
+		add_compile_definitions(EXPAT_NEEDS_XMLPARSE_H)
+	endif()
+endif()
+
+list(REMOVE_DUPLICATES excluded_progs)
+list(REMOVE_DUPLICATES PROGRAMS_BUILT)
+
+
+foreach(p ${excluded_progs})
+	list(APPEND EXCLUSION_PROGS --exclude-program ${p} )
+endforeach()
+
+#for comparing null values
+list(APPEND EXCLUSION_PROGS empty)
+set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" FORCE)
+
+if(NOT EXISTS ${CMAKE_BINARY_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
+	list(REMOVE_ITEM EXCLUSION_PROGS empty)
+	message("Generating command-list.h")
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			OUTPUT_FILE ${CMAKE_BINARY_DIR}/command-list.h)
+endif()
+
+if(NOT EXISTS ${CMAKE_BINARY_DIR}/config-list.h)
+	message("Generating config-list.h")
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			OUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h)
+endif()
+
+include_directories(${CMAKE_BINARY_DIR})
+
+#build
+#libgit
+parse_makefile_for_sources(libgit_SOURCES "LIB_OBJS")
+
+list(TRANSFORM libgit_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+list(TRANSFORM compat_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
+
+#libxdiff
+parse_makefile_for_sources(libxdiff_SOURCES "XDIFF_OBJS")
+
+list(TRANSFORM libxdiff_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+add_library(xdiff STATIC ${libxdiff_SOURCES})
+
+#libvcs-svn
+parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
+
+list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
+
+#link all required libraries to common-main
+add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
+if(Intl_FOUND)
+	target_link_libraries(common-main ${Intl_LIBRARIES})
+endif()
+if(Iconv_FOUND)
+	target_link_libraries(common-main ${Iconv_LIBRARIES})
+endif()
+
+#git
+parse_makefile_for_sources(git_SOURCES "BUILTIN_OBJS")
+
+list(TRANSFORM git_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})
+target_link_libraries(git common-main)
+
+add_executable(git-bugreport ${CMAKE_SOURCE_DIR}/bugreport.c)
+target_link_libraries(git-bugreport common-main)
+
+add_executable(git-credential-store ${CMAKE_SOURCE_DIR}/credential-store.c)
+target_link_libraries(git-credential-store common-main)
+
+add_executable(git-daemon ${CMAKE_SOURCE_DIR}/daemon.c)
+target_link_libraries(git-daemon common-main)
+
+add_executable(git-fast-import ${CMAKE_SOURCE_DIR}/fast-import.c)
+target_link_libraries(git-fast-import common-main)
+
+add_executable(git-http-backend ${CMAKE_SOURCE_DIR}/http-backend.c)
+target_link_libraries(git-http-backend common-main)
+
+add_executable(git-sh-i18n--envsubst ${CMAKE_SOURCE_DIR}/sh-i18n--envsubst.c)
+target_link_libraries(git-sh-i18n--envsubst common-main)
+
+add_executable(git-shell ${CMAKE_SOURCE_DIR}/shell.c)
+target_link_libraries(git-shell common-main)
+
+if(CURL_FOUND)
+	add_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c)
+
+	add_executable(git-imap-send ${CMAKE_SOURCE_DIR}/imap-send.c)
+	target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})
+
+	add_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c)
+	target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})
+
+	add_executable(git-remote-http ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/remote-curl.c)
+	target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )
+
+	if(EXPAT_FOUND)
+		add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
+		target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
+	endif()
+endif()
+
+add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)
+target_link_libraries(git-remote-testsvn common-main vcs-svn)
+
+add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)
+target_link_libraries(git-credential-cache common-main)
+
+add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)
+target_link_libraries(git-credential-cache--daemon common-main)
+
+
+set(git_builtin_extra
+	cherry cherry-pick format-patch fsck-objects
+	init merge-subtree restore show
+	stage status switch whatchanged)
+
+#Creating hardlinks
+foreach(s ${git_SOURCES} ${git_builtin_extra})
+	string(REPLACE "${CMAKE_SOURCE_DIR}/builtin/" "" s ${s})
+	string(REPLACE ".c" "" s ${s})
+	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
+	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
+endforeach()
+
+if(CURL_FOUND)
+	set(remote_exes
+		git-remote-https git-remote-ftp git-remote-ftps)
+	foreach(s ${remote_exes})
+		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
+		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+	endforeach()
+endif()
+
+add_custom_command(OUTPUT ${git_links} ${git_http_links}
+		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
+		DEPENDS git git-remote-http)
+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v4 2/8] cmake: generate the shell/perl/python scripts and templates, translations
  2020-06-12 18:29     ` [PATCH v4 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
  2020-06-12 18:29       ` [PATCH v4 1/8] Introduce CMake support for configuring Git Sibi Siddharthan via GitGitGadget
@ 2020-06-12 18:29       ` Sibi Siddharthan via GitGitGadget
  2020-06-12 18:29       ` [PATCH v4 3/8] cmake: installation support for git Sibi Siddharthan via GitGitGadget
                         ` (6 subsequent siblings)
  8 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-06-12 18:29 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

Implement the placeholder substitution to generate scripted
Porcelain commands, e.g. git-request-pull out of
git-request-pull.sh

Generate shell/perl/python scripts and template using CMake instead of
using sed like the build procedure in the Makefile does.

The text translations are only build if `msgfmt` is found in your path.

NOTE: The scripts and templates are generated during configuration.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 110 +++++++++++++++++++++++++++-
 1 file changed, 109 insertions(+), 1 deletion(-)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 1e910d9df85..b3863bffee6 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -66,7 +66,7 @@ project(git
 	LANGUAGES C)
 
 
-#macros for parsing the Makefile for sources
+#macros for parsing the Makefile for sources and scripts
 macro(parse_makefile_for_sources list_var regex)
 	file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
 	string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
@@ -77,6 +77,16 @@ macro(parse_makefile_for_sources list_var regex)
 	list(REMOVE_ITEM ${list_var} "") #remove empty list elements
 endmacro()
 
+macro(parse_makefile_for_scripts list_var regex lang)
+	file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
+	string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
+	string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
+	string(REPLACE " " ";" ${list_var} ${${list_var}}) #convert string to a list
+	if(NOT ${lang}) #exclude for SCRIPT_LIB
+		list(TRANSFORM ${list_var} REPLACE "${lang}" "") #do the replacement
+	endif()
+endmacro()
+
 include(CheckTypeSize)
 include(CheckCSourceRuns)
 include(CheckCSourceCompiles)
@@ -112,6 +122,11 @@ if(Intl_FOUND)
 	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
 endif()
 
+find_program(MSGFMT_EXE msgfmt)
+if(NOT MSGFMT_EXE)
+	message(WARNING "Text Translations won't be build")
+endif()
+
 #default behaviour
 include_directories(${CMAKE_SOURCE_DIR})
 add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
@@ -590,3 +605,96 @@ add_custom_command(OUTPUT ${git_links} ${git_http_links}
 		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
 		DEPENDS git git-remote-http)
 add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
+
+
+#creating required scripts
+set(SHELL_PATH /bin/sh)
+set(PERL_PATH /usr/bin/perl)
+set(LOCALEDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
+set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
+set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)
+
+#shell scripts
+parse_makefile_for_scripts(git_sh_scripts "SCRIPT_SH" ".sh")
+parse_makefile_for_scripts(git_shlib_scripts "SCRIPT_LIB" "")
+set(git_shell_scripts
+	${git_sh_scripts} ${git_shlib_scripts} git-instaweb)
+
+foreach(script ${git_shell_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)
+	string(REPLACE "@SHELL_PATH@" "${SHELL_PATH}" content "${content}")
+	string(REPLACE "@@DIFF@@" "diff" content "${content}")
+	string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@GITWEBDIR@" "${GITWEBDIR}" content "${content}")
+	string(REPLACE "@@NO_CURL@@" "" content "${content}")
+	string(REPLACE "@@USE_GETTEXT_SCHEME@@" "" content "${content}")
+	string(REPLACE "# @@BROKEN_PATH_FIX@@" "" content "${content}")
+	string(REPLACE "@@PERL@@" "${PERL_PATH}" content "${content}")
+	string(REPLACE "@@SANE_TEXT_GREP@@" "-a" content "${content}")
+	string(REPLACE "@@PAGER_ENV@@" "LESS=FRX LV=-c" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+endforeach()
+
+#perl scripts
+parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" ".perl")
+
+#create perl header
+file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
+string(REPLACE "@@PATHSEP@@" ":" perl_header "${perl_header}")
+string(REPLACE "@@INSTLIBDIR@@" "${INSTLIBDIR}" perl_header "${perl_header}")
+
+foreach(script ${git_perl_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)
+	string(REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n${perl_header}\n" content "${content}")
+	string(REPLACE "@@GIT_VERSION@@" "${PROJECT_VERSION}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+endforeach()
+
+#python script
+file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)
+string(REPLACE "#!/usr/bin/env python" "#!/usr/bin/python" content "${content}")
+file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})
+
+#perl modules
+file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
+
+foreach(pm ${perl_modules})
+	string(REPLACE "${CMAKE_SOURCE_DIR}/perl/" "" file_path ${pm})
+	file(STRINGS ${pm} content NEWLINE_CONSUME)
+	string(REPLACE "@@LOCALEDIR@@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@@NO_PERL_CPAN_FALLBACKS@@" "" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})
+#test-lib.sh requires perl/build/lib to be the build directory of perl modules
+endforeach()
+
+
+#templates
+file(GLOB templates "${CMAKE_SOURCE_DIR}/templates/*")
+list(TRANSFORM templates REPLACE "${CMAKE_SOURCE_DIR}/templates/" "")
+list(REMOVE_ITEM templates ".gitignore")
+list(REMOVE_ITEM templates "Makefile")
+
+list(REMOVE_ITEM templates "branches--")
+file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
+
+#templates have @.*@ replacement so use configure_file instead
+foreach(tm ${templates})
+	string(REPLACE "--" "/" blt_tm ${tm})
+	string(REPLACE "this" "" blt_tm ${blt_tm})# for this--
+	configure_file(${CMAKE_SOURCE_DIR}/templates/${tm} ${CMAKE_BINARY_DIR}/templates/blt/${blt_tm} @ONLY)
+endforeach()
+
+
+#translations
+if(MSGFMT_EXE)
+	file(GLOB po_files "${CMAKE_SOURCE_DIR}/po/*.po")
+	list(TRANSFORM po_files REPLACE "${CMAKE_SOURCE_DIR}/po/" "")
+	list(TRANSFORM po_files REPLACE ".po" "")
+	foreach(po ${po_files})
+		file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo
+				COMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)
+		list(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)
+	endforeach()
+	add_custom_target(po-gen ALL DEPENDS ${po_gen})
+endif()
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v4 3/8] cmake: installation support for git
  2020-06-12 18:29     ` [PATCH v4 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
  2020-06-12 18:29       ` [PATCH v4 1/8] Introduce CMake support for configuring Git Sibi Siddharthan via GitGitGadget
  2020-06-12 18:29       ` [PATCH v4 2/8] cmake: generate the shell/perl/python scripts and templates, translations Sibi Siddharthan via GitGitGadget
@ 2020-06-12 18:29       ` Sibi Siddharthan via GitGitGadget
  2020-06-12 18:29       ` [PATCH v4 4/8] cmake: support for testing git with ctest Sibi Siddharthan via GitGitGadget
                         ` (5 subsequent siblings)
  8 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-06-12 18:29 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

Install the built binaries and scripts using CMake

This is very similar to `make install`.
By default the destination directory(DESTDIR) is /usr/local/ on Linux
To set a custom installation path do this:
cmake `relative-path-to-srcdir`
	-DCMAKE_INSTALL_PREFIX=`preferred-install-path`

Then run `make install`

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 49 +++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index b3863bffee6..e8ed2439e46 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -65,6 +65,8 @@ project(git
 	VERSION ${git_version}
 	LANGUAGES C)
 
+#TODO gitk git-gui gitweb
+#TODO Add pcre support
 
 #macros for parsing the Makefile for sources and scripts
 macro(parse_makefile_for_sources list_var regex)
@@ -698,3 +700,50 @@ if(MSGFMT_EXE)
 	endforeach()
 	add_custom_target(po-gen ALL DEPENDS ${po_gen})
 endif()
+
+
+#to help with the install
+list(TRANSFORM git_shell_scripts PREPEND "${CMAKE_BINARY_DIR}/")
+list(TRANSFORM git_perl_scripts PREPEND "${CMAKE_BINARY_DIR}/")
+
+#install
+install(TARGETS git git-shell
+	RUNTIME DESTINATION bin)
+install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver
+	DESTINATION bin)
+
+list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)
+install(TARGETS ${PROGRAMS_BUILT}
+	RUNTIME DESTINATION libexec/git-core)
+
+set(bin_links
+	git-receive-pack git-upload-archive git-upload-pack)
+
+foreach(b ${bin_links})
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
+endforeach()
+
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
+
+foreach(b ${git_links})
+	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
+	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+endforeach()
+
+foreach(b ${git_http_links})
+	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
+	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+endforeach()
+
+install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
+	DESTINATION libexec/git-core)
+
+install(DIRECTORY ${CMAKE_SOURCE_DIR}/mergetools DESTINATION libexec/git-core)
+install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5
+	FILES_MATCHING PATTERN "*.pm")
+install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)
+
+if(MSGFMT_EXE)
+	install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
+endif()
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v4 4/8] cmake: support for testing git with ctest
  2020-06-12 18:29     ` [PATCH v4 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                         ` (2 preceding siblings ...)
  2020-06-12 18:29       ` [PATCH v4 3/8] cmake: installation support for git Sibi Siddharthan via GitGitGadget
@ 2020-06-12 18:29       ` Sibi Siddharthan via GitGitGadget
  2020-06-15 14:02         ` Øystein Walle
  2020-06-12 18:29       ` [PATCH v4 5/8] cmake: support for testing git when building out of the source tree Sibi Siddharthan via GitGitGadget
                         ` (4 subsequent siblings)
  8 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-06-12 18:29 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch provides an alternate way to test git using ctest.
CTest ships with CMake, so there is no additional dependency being
introduced.

To perform the tests with ctest do this after building:
ctest -j[number of jobs]

NOTE: -j is optional, the default number of jobs is 1

Each of the jobs does this:
cd t/ && sh t[something].sh

The reason for using CTest is that it logs the output of the tests
in a neat way, which can be helpful during diagnosis of failures.

After the tests have run ctest generates three log files located in
`build-directory`/Testing/Temporary/

These log files are:

CTestCostData.txt:
This file contains the time taken to complete each test.

LastTestsFailed.log:
This log file contains the names of the tests that have failed in the
run.

LastTest.log:
This log file contains the log of all the tests that have run.
A snippet of the file is given below.

10/901 Testing: D:/my/git-master/t/t0009-prio-queue.sh
10/901 Test: D:/my/git-master/t/t0009-prio-queue.sh
Command: "sh.exe" "D:/my/git-master/t/t0009-prio-queue.sh"
Directory: D:/my/git-master/t
"D:/my/git-master/t/t0009-prio-queue.sh"
Output:
----------------------------------------------------------
ok 1 - basic ordering
ok 2 - mixed put and get
ok 3 - notice empty queue
ok 4 - stack order
passed all 4 test(s)
1..4
<end of output>
Test time =   1.11 sec

NOTE: Testing only works when building in source for now.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 124 ++++++++++++++++++++++++++++
 1 file changed, 124 insertions(+)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index e8ed2439e46..1d57ac86772 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -96,6 +96,7 @@ include(CheckIncludeFile)
 include(CheckFunctionExists)
 include(CheckSymbolExists)
 include(CheckStructHasMember)
+include(CTest)
 
 find_package(ZLIB REQUIRED)
 find_package(CURL)
@@ -747,3 +748,126 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/
 if(MSGFMT_EXE)
 	install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
 endif()
+
+
+if(BUILD_TESTING)
+
+#tests-helpers
+add_executable(test-fake-ssh ${CMAKE_SOURCE_DIR}/t/helper/test-fake-ssh.c)
+target_link_libraries(test-fake-ssh common-main)
+
+add_executable(test-line-buffer ${CMAKE_SOURCE_DIR}/t/helper/test-line-buffer.c)
+target_link_libraries(test-line-buffer common-main vcs-svn)
+
+add_executable(test-svn-fe ${CMAKE_SOURCE_DIR}/t/helper/test-svn-fe.c)
+target_link_libraries(test-svn-fe common-main vcs-svn)
+
+#test-tool
+parse_makefile_for_sources(test-tool_SOURCES "TEST_BUILTINS_OBJS")
+
+list(TRANSFORM test-tool_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/t/helper/")
+add_executable(test-tool ${CMAKE_SOURCE_DIR}/t/helper/test-tool.c ${test-tool_SOURCES})
+target_link_libraries(test-tool common-main)
+
+set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+			PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)
+
+#wrapper scripts
+set(wrapper_scripts
+	git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)
+
+set(wrapper_test_scripts
+	test-fake-ssh test-line-buffer test-svn-fe test-tool)
+
+
+foreach(script ${wrapper_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@@PROG@@" "${script}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
+endforeach()
+
+foreach(script ${wrapper_test_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
+endforeach()
+
+file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+string(REPLACE "@@PROG@@" "git-cvsserver" content "${content}")
+file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
+
+#options for configuring test options
+option(PERL_TESTS "Perform tests that use perl" ON)
+option(PYTHON_TESTS "Perform tests that use python" ON)
+
+#GIT-BUILD-OPTIONS
+set(TEST_SHELL_PATH ${SHELL_PATH})
+set(DIFF diff)
+set(PYTHON_PATH /usr/bin/python)
+set(TAR tar)
+set(NO_CURL )
+set(NO_EXPAT )
+set(USE_LIBPCRE1 )
+set(USE_LIBPCRE2 )
+set(NO_LIBPCRE1_JIT )
+set(NO_PERL )
+set(NO_PTHREADS )
+set(NO_PYTHON )
+set(PAGER_ENV "LESS=FRX LV=-c")
+set(DC_SHA1 YesPlease)
+set(RUNTIME_PREFIX true)
+set(NO_GETTEXT )
+
+if(NOT CURL_FOUND)
+	set(NO_CURL 1)
+endif()
+
+if(NOT EXPAT_FOUND)
+	set(NO_EXPAT 1)
+endif()
+
+if(NOT Intl_FOUND)
+	set(NO_GETTEXT 1)
+endif()
+
+if(NOT PERL_TESTS)
+	set(NO_PERL 1)
+endif()
+
+if(NOT PYTHON_TESTS)
+	set(NO_PYTHON 1)
+endif()
+
+file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "SHELL_PATH='${SHELL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TEST_SHELL_PATH='${TEST_SHELL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PERL_PATH='${PERL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DIFF='${DIFF}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PYTHON_PATH='${PYTHON_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TAR='${TAR}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_CURL='${NO_CURL}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_EXPAT='${NO_EXPAT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "USE_LIBPCRE1='${USE_LIBPCRE1}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PERL='${NO_PERL}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
+
+file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
+
+#test
+foreach(tsh ${test_scipts})
+	add_test(NAME ${tsh}
+		COMMAND ${SH_EXE} ${tsh}
+		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)
+endforeach()
+
+endif()#BUILD_TESTING
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v4 5/8] cmake: support for testing git when building out of the source tree
  2020-06-12 18:29     ` [PATCH v4 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                         ` (3 preceding siblings ...)
  2020-06-12 18:29       ` [PATCH v4 4/8] cmake: support for testing git with ctest Sibi Siddharthan via GitGitGadget
@ 2020-06-12 18:29       ` Sibi Siddharthan via GitGitGadget
  2020-06-12 18:29       ` [PATCH v4 6/8] cmake: support for building git on windows with mingw Sibi Siddharthan via GitGitGadget
                         ` (3 subsequent siblings)
  8 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-06-12 18:29 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch allows git to be tested when performin out of source builds.

This involves changing GIT_BUILD_DIR in t/test-lib.sh to point to the
build directory. Also some miscellaneous copies from the source directory
to the build directory.
The copies are:
t/chainlint.sed needed by a bunch of test scripts
po/is.po needed by t0204-gettext-rencode-sanity
mergetools/tkdiff needed by t7800-difftool
contrib/completion/git-prompt.sh needed by t9903-bash-prompt
contrib/completion/git-completion.bash needed by t9902-completion
contrib/svn-fe/svnrdump_sim.py needed by t9020-remote-svn

NOTE: t/test-lib.sh is only modified when tests are run not during
the build or configure.
The trash directory is still srcdir/t

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 1d57ac86772..f9976378d2d 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -861,6 +861,26 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n"
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
 
+#Make the tests work when building out of the source tree
+get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE)
+if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})
+	file(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)
+	string(REPLACE "/CMakeCache.txt" "" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})
+	#Setting the build directory in test-lib.sh before running tests
+	file(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake
+		"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \"GIT_BUILD_DIR=(.*)\")\n"
+		"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\n"
+		"string(REPLACE \"\${GIT_BUILD_DIR_REPL}\" \"GIT_BUILD_DIR=\\\"$TEST_DIRECTORY\\\"/../${BUILD_DIR_RELATIVE}\" content \"\${content}\")\n"
+		"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \${content})")
+	#misc copies
+	file(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)
+	file(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)
+	file(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/svn-fe/svnrdump_sim.py DESTINATION ${CMAKE_BINARY_DIR}/contrib/svn-fe/)
+endif()
+
 file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
 
 #test
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v4 6/8] cmake: support for building git on windows with mingw
  2020-06-12 18:29     ` [PATCH v4 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                         ` (4 preceding siblings ...)
  2020-06-12 18:29       ` [PATCH v4 5/8] cmake: support for testing git when building out of the source tree Sibi Siddharthan via GitGitGadget
@ 2020-06-12 18:29       ` Sibi Siddharthan via GitGitGadget
  2020-06-15 14:03         ` Øystein Walle
  2020-06-12 18:29       ` [PATCH v4 7/8] cmake: support for building git on windows with msvc and clang Sibi Siddharthan via GitGitGadget
                         ` (2 subsequent siblings)
  8 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-06-12 18:29 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch facilitates building git on Windows with CMake using MinGW

NOTE: The funtions unsetenv and hstrerror are not checked in Windows
builds.
Reasons
NO_UNSETENV is not compatible with Windows builds.
lines 262-264 compat/mingw.h

compat/mingw.h(line 25) provides a definition of hstrerror which
conflicts with the definition provided in
git-compat-util.h(lines 733-736).

To use CMake on Windows with MinGW do this:
cmake `relative-path-to-srcdir` -G "MinGW Makefiles"

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 121 ++++++++++++++++++++++------
 1 file changed, 98 insertions(+), 23 deletions(-)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index f9976378d2d..9aff2b9f4f9 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -42,6 +42,10 @@ cmake_minimum_required(VERSION 3.14)
 set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
 
 find_program(SH_EXE sh)
+if(NOT SH_EXE)
+	message(FATAL_ERROR "sh: shell interpreter was not found in your path, please install one."
+			"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
+endif()
 
 #Create GIT-VERSION-FILE using GIT-VERSION-GEN
 if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)
@@ -65,7 +69,9 @@ project(git
 	VERSION ${git_version}
 	LANGUAGES C)
 
+
 #TODO gitk git-gui gitweb
+#TODO Enable NLS on windows natively
 #TODO Add pcre support
 
 #macros for parsing the Makefile for sources and scripts
@@ -104,6 +110,7 @@ find_package(EXPAT)
 find_package(Iconv)
 find_package(Intl)
 
+
 if(NOT Intl_FOUND)
 	add_compile_definitions(NO_GETTEXT)
 	if(NOT Iconv_FOUND)
@@ -125,6 +132,14 @@ if(Intl_FOUND)
 	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
 endif()
 
+
+if(WIN32)
+	find_program(WINDRES_EXE windres)
+	if(NOT WINDRES_EXE)
+		message(FATAL_ERROR "Install windres on Windows for resource files")
+	endif()
+endif()
+
 find_program(MSGFMT_EXE msgfmt)
 if(NOT MSGFMT_EXE)
 	message(WARNING "Text Translations won't be build")
@@ -156,11 +171,39 @@ add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
 			BINDIR="bin"
 			GIT_BUILT_FROM_COMMIT="")
 
-set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
-add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+if(WIN32)
+	set(FALLBACK_RUNTIME_PREFIX /mingw64)
+	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+else()
+	set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+endif()
 
-add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
-list(APPEND compat_SOURCES unix-socket.c)
+
+#Platform Specific
+if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+	include_directories(${CMAKE_SOURCE_DIR}/compat/win32)
+	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
+				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
+				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0
+				USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
+				UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
+	list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
+		compat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c
+		compat/win32/trace2_win32_process_info.c compat/win32/dirent.c
+		compat/nedmalloc/nedmalloc.c compat/strdup.c)
+	set(NO_UNIX_SOCKETS 1)
+
+elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+	add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
+	list(APPEND compat_SOURCES unix-socket.c)
+endif()
+
+if(WIN32)
+	set(EXE_EXTENSION .exe)
+else()
+	set(EXE_EXTENSION)
+endif()
 
 #header checks
 check_include_file(libgen.h HAVE_LIBGEN_H)
@@ -223,7 +266,12 @@ endif()
 #function checks
 set(function_checks
 	strcasestr memmem strlcpy strtoimax strtoumax strtoull
-	setenv mkdtemp poll pread memmem unsetenv hstrerror)
+	setenv mkdtemp poll pread memmem)
+
+#unsetenv,hstrerror are incompatible with windows build
+if(NOT WIN32)
+	list(APPEND function_checks unsetenv hstrerror)
+endif()
 
 foreach(f ${function_checks})
 	string(TOUPPER ${f} uf)
@@ -444,7 +492,13 @@ unset(CMAKE_REQUIRED_INCLUDES)
 #programs
 set(PROGRAMS_BUILT
 	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
-	git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
+	git-shell git-remote-testsvn)
+
+if(NO_UNIX_SOCKETS)
+	list(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)
+else()
+	list(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)
+endif()
 
 if(NOT CURL_FOUND)
 	list(APPEND excluded_progs git-http-fetch git-http-push)
@@ -516,15 +570,34 @@ parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
 list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
 
+#add git.rc for gcc
+if(WIN32)
+	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+			COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
+				-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
+				-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			VERBATIM)
+	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
+endif()
+
 #link all required libraries to common-main
 add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)
-target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
+
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})
 if(Intl_FOUND)
 	target_link_libraries(common-main ${Intl_LIBRARIES})
 endif()
 if(Iconv_FOUND)
 	target_link_libraries(common-main ${Iconv_LIBRARIES})
 endif()
+if(WIN32)
+	target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
+	add_dependencies(common-main git-rc)
+	target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+elseif(UNIX)
+	target_link_libraries(common-main pthread rt)
+endif()
 
 #git
 parse_makefile_for_sources(git_SOURCES "BUILTIN_OBJS")
@@ -575,11 +648,13 @@ endif()
 add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)
 target_link_libraries(git-remote-testsvn common-main vcs-svn)
 
-add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)
-target_link_libraries(git-credential-cache common-main)
+if(NOT NO_UNIX_SOCKETS)
+	add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)
+	target_link_libraries(git-credential-cache common-main)
 
-add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)
-target_link_libraries(git-credential-cache--daemon common-main)
+	add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)
+	target_link_libraries(git-credential-cache--daemon common-main)
+endif()
 
 
 set(git_builtin_extra
@@ -591,16 +666,16 @@ set(git_builtin_extra
 foreach(s ${git_SOURCES} ${git_builtin_extra})
 	string(REPLACE "${CMAKE_SOURCE_DIR}/builtin/" "" s ${s})
 	string(REPLACE ".c" "" s ${s})
-	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
-	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
+	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\n")
+	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})
 endforeach()
 
 if(CURL_FOUND)
 	set(remote_exes
 		git-remote-https git-remote-ftp git-remote-ftps)
 	foreach(s ${remote_exes})
-		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
-		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http${EXE_EXTENSION} ${s}${EXE_EXTENSION})\n")
+		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s}${EXE_EXTENSION})
 	endforeach()
 endif()
 
@@ -721,20 +796,20 @@ set(bin_links
 	git-receive-pack git-upload-archive git-upload-pack)
 
 foreach(b ${bin_links})
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/bin/${b}${EXE_EXTENSION})")
 endforeach()
 
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git${EXE_EXTENSION})")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell${EXE_EXTENSION})")
 
 foreach(b ${git_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
 endforeach()
 
 foreach(b ${git_http_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
 endforeach()
 
 install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
@@ -783,14 +858,14 @@ set(wrapper_test_scripts
 foreach(script ${wrapper_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "${script}" content "${content}")
+	string(REPLACE "@@PROG@@" "${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
 foreach(script ${wrapper_test_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
+	string(REPLACE "@@PROG@@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
@@ -856,7 +931,7 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X='${EXE_EXTENSION}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v4 7/8] cmake: support for building git on windows with msvc and clang.
  2020-06-12 18:29     ` [PATCH v4 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                         ` (5 preceding siblings ...)
  2020-06-12 18:29       ` [PATCH v4 6/8] cmake: support for building git on windows with mingw Sibi Siddharthan via GitGitGadget
@ 2020-06-12 18:29       ` Sibi Siddharthan via GitGitGadget
  2020-06-15 14:04         ` Øystein Walle
  2020-06-12 18:29       ` [PATCH v4 8/8] ci: modification of main.yml to use cmake for vs-build job Sibi Siddharthan via GitGitGadget
  2020-06-26 16:11       ` [PATCH v5 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
  8 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-06-12 18:29 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch adds support for Visual Studio and Clang builds

The minimum required version of CMake is upgraded to 3.15 because
this version offers proper support for Clang builds on Windows.

Libintl is not searched for when building with Visual Studio or Clang
because there is no binary compatible version available yet.

NOTE: In the link options invalidcontinue.obj has to be included.
The reason for this is because by default, Windows calls abort()'s
instead of setting errno=EINVAL when invalid arguments are passed to
standard functions.
This commit explains it in detail:
4b623d80f73528a632576990ca51e34c333d5dd6

On Windows the default generator is Visual Studio,so for Visual Studio
builds do this:

cmake `relative-path-to-srcdir`

NOTE: Visual Studio generator is a multi config generator, which means
that Debug and Release builds can be done on the same build directory.

For Clang builds do this:

On bash
CC=clang cmake `relative-path-to-srcdir` -G Ninja
		-DCMAKE_BUILD_TYPE=[Debug or Release]

On cmd
set CC=Clang
cmake `relative-path-to-srcdir` -G Ninja
		-DCMAKE_BUILD_TYPE=[Debug or Release]

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 55 +++++++++++++++++++++++------
 1 file changed, 45 insertions(+), 10 deletions(-)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 9aff2b9f4f9..8367b73e947 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -108,8 +108,11 @@ find_package(ZLIB REQUIRED)
 find_package(CURL)
 find_package(EXPAT)
 find_package(Iconv)
-find_package(Intl)
 
+#Don't use libintl on Windows Visual Studio and Clang builds
+if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")))
+	find_package(Intl)
+endif()
 
 if(NOT Intl_FOUND)
 	add_compile_definitions(NO_GETTEXT)
@@ -133,7 +136,7 @@ if(Intl_FOUND)
 endif()
 
 
-if(WIN32)
+if(WIN32 AND NOT MSVC)#not required for visual studio builds
 	find_program(WINDRES_EXE windres)
 	if(NOT WINDRES_EXE)
 		message(FATAL_ERROR "Install windres on Windows for resource files")
@@ -145,6 +148,13 @@ if(NOT MSGFMT_EXE)
 	message(WARNING "Text Translations won't be build")
 endif()
 
+#Force all visual studio outputs to CMAKE_BINARY_DIR
+if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
+	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
+	add_compile_options(/MP)
+endif()
+
 #default behaviour
 include_directories(${CMAKE_SOURCE_DIR})
 add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
@@ -182,6 +192,10 @@ endif()
 
 #Platform Specific
 if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+	if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+		include_directories(${CMAKE_SOURCE_DIR}/compat/vcbuild/include)
+		add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
+	endif()
 	include_directories(${CMAKE_SOURCE_DIR}/compat/win32)
 	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
 				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
@@ -570,14 +584,22 @@ parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
 list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
 
-#add git.rc for gcc
 if(WIN32)
-	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
-			COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
-				-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
-				-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
-			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-			VERBATIM)
+	if(NOT MSVC)#use windres when compiling with gcc and clang
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+				COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
+					-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
+					-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
+				WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+				VERBATIM)
+	else()#MSVC use rc
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+				COMMAND ${CMAKE_RC_COMPILER} /d MAJOR=${PROJECT_VERSION_MAJOR} /d MINOR=${PROJECT_VERSION_MINOR}
+					/d MICRO=${PROJECT_VERSION_PATCH} /d PATCHLEVEL=0 /d GIT_VERSION="${PROJECT_VERSION}.GIT"
+					/fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_SOURCE_DIR}/git.rc
+				WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+				VERBATIM)
+	endif()
 	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
 endif()
 
@@ -594,7 +616,13 @@ endif()
 if(WIN32)
 	target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
 	add_dependencies(common-main git-rc)
-	target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+	if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+		target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+	elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+		target_link_options(common-main PUBLIC -municode -Wl,-nxcompat -Wl,-dynamicbase -Wl,-entry:wmainCRTStartup -Wl,invalidcontinue.obj)
+	elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+		target_link_options(common-main PUBLIC /IGNORE:4217 /IGNORE:4049 /NOLOGO /ENTRY:wmainCRTStartup /SUBSYSTEM:CONSOLE invalidcontinue.obj)
+	endif()
 elseif(UNIX)
 	target_link_libraries(common-main pthread rt)
 endif()
@@ -847,6 +875,13 @@ target_link_libraries(test-tool common-main)
 set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
 			PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)
 
+if(MSVC)
+	set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+				PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)
+	set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+				PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)
+endif()
+
 #wrapper scripts
 set(wrapper_scripts
 	git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v4 8/8] ci: modification of main.yml to use cmake for vs-build job
  2020-06-12 18:29     ` [PATCH v4 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                         ` (6 preceding siblings ...)
  2020-06-12 18:29       ` [PATCH v4 7/8] cmake: support for building git on windows with msvc and clang Sibi Siddharthan via GitGitGadget
@ 2020-06-12 18:29       ` Sibi Siddharthan via GitGitGadget
  2020-06-26 16:11       ` [PATCH v5 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
  8 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-06-12 18:29 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiv.siddharthan@gmail.com>

Teach .github/workflows/main.yml to use CMake for VS builds.

Modified the vs-test step to match windows-test step. This speeds
up the vs-test. Calling git-cmd from powershell and then calling git-bash
to perform the tests slows things down(factor of about 6). So git-bash
is directly called from powershell to perform the tests using prove.

NOTE: Since GitHub keeps the same directory for each job
(with respect to path) absolute paths are used in the bin-wrapper
scripts.

GitHub has switched to CMake 3.17.1 which changed the behaviour of
FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been
added to revert to the old behaviour.

In the configuration phase CMake looks for the required libraries for
building git (eg zlib,libiconv). So we extract the libraries before we
configure.

To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working
directory of script or path. So we copy the dlls before we configure.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 .github/workflows/main.yml | 36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 84a5dcff7a0..77fbb08fd31 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -145,13 +145,6 @@ jobs:
         ## Unzip and remove the artifact
         unzip artifacts.zip
         rm artifacts.zip
-    - name: generate Visual Studio solution
-      shell: powershell
-      run: |
-        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
-          make NDEBUG=1 DEVELOPER=1 vcxproj
-        "@
-        if (!$?) { exit(1) }
     - name: download vcpkg artifacts
       shell: powershell
       run: |
@@ -163,6 +156,14 @@ jobs:
         Remove-Item compat.zip
     - name: add msbuild to PATH
       uses: microsoft/setup-msbuild@v1.0.0
+    - name: copy dlls to root
+      shell: powershell
+      run: |
+        & compat\vcbuild\vcpkg_copy_dlls.bat release
+        if (!$?) { exit(1) }
+    - name: generate Visual Studio solution
+      shell: bash
+      run: cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows -DMSGFMT_EXE=`pwd`/git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
     - name: MSBuild
       run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
     - name: bundle artifact tar
@@ -171,8 +172,6 @@ jobs:
         MSVC: 1
         VCPKG_ROOT: ${{github.workspace}}\compat\vcbuild\vcpkg
       run: |
-        & compat\vcbuild\vcpkg_copy_dlls.bat release
-        if (!$?) { exit(1) }
         & git-sdk-64-minimal\usr\bin\bash.exe -lc @"
           mkdir -p artifacts &&
           eval \"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts 2>&1 | grep ^tar)\"
@@ -203,7 +202,7 @@ jobs:
     - name: extract build artifacts
       shell: bash
       run: tar xf artifacts.tar.gz
-    - name: test (parallel)
+    - name: test
       shell: powershell
       env:
         MSYSTEM: MINGW64
@@ -214,12 +213,19 @@ jobs:
           # Let Git ignore the SDK and the test-cache
           printf '%s\n' /git-sdk-64-minimal/ /test-cache/ >>.git/info/exclude
 
-          cd t &&
-          PATH=\"`$PWD/helper:`$PATH\" &&
-          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \
-                  `$(test-tool.exe path-utils slice-tests \
-                          ${{matrix.nr}} 10 t[0-9]*.sh)
+          ci/run-test-slice.sh ${{matrix.nr}} 10
         "@
+    - name: ci/print-test-failures.sh
+      if: failure()
+      shell: powershell
+      run: |
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc ci/print-test-failures.sh
+    - name: Upload failed tests' directories
+      if: failure() && env.FAILED_TEST_ARTIFACTS != ''
+      uses: actions/upload-artifact@v1
+      with:
+        name: failed-tests-windows
+        path: ${{env.FAILED_TEST_ARTIFACTS}}
   regular:
     needs: ci-config
     if: needs.ci-config.outputs.enabled == 'yes'
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 179+ messages in thread

* Re: [PATCH v4 1/8] Introduce CMake support for configuring Git
  2020-06-12 18:29       ` [PATCH v4 1/8] Introduce CMake support for configuring Git Sibi Siddharthan via GitGitGadget
@ 2020-06-15 14:00         ` Øystein Walle
  2020-06-15 20:04           ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Øystein Walle @ 2020-06-15 14:00 UTC (permalink / raw)
  To: gitgitgadget; +Cc: git, sibisiddharthan.github, Øystein Walle

Hi,

I haven't been able to pay much attention lately. I see this is v4 of this
patch series and thought I took a quick look and didn't find anything, it's
possible some of this has been addressed already. If so I apologize.

> So let's start building CMake support for Git.

Yay!

> +
> +Instructions to run CMake:
> +
> +cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release
> +Eg.
> +From the root of git source tree
> +	`cmake contrib/buildsystems/ `
> +This will build the git binaries at the root
> +
> +For out of source builds, say build in 'git/git-build/'
> +	`mkdir git-build;cd git-build; cmake ../contrib/buildsystems/`
> +This will build the git binaries in git-build directory
> +

Since the mininum required version is sufficiently high I suggest you
recommend the following as well:

    cmake -B build-dir -S contrib/buildsystems

This might be easier for scripted tasks (packaging and whatnot) since cd
and mkdir aren't necessary.

> +#set the source directory to root of git
> +set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)

See if you can avoid this. This this will break if another project includes Git
as part of itself with add_subdirectory() or the ExternalProject module. If all
you use it for is paths to other files then you might as well do this:

    set(repo_root "${CMAKE_CURRENT_LIST_DIR}/../..")

and use ${repo_root} the places you use ${CMAKE_SOURCE_DIR} now.

AFAIK the places CMake accepts relative paths it's usually relative to
CMAKE_CURRENT_SOURCE_DIR and not CMAKE_SOURCE_DIR, anyway. I don't think it's
automagically updated when CMAKE_SOURCE_DIR is changed.

> +include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
> +if(CURL_FOUND)
> +	include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
> +endif()

This is better handled like this these days:

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 8367b73e94..ca1f90e58c 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -121,10 +121,6 @@ if(NOT Intl_FOUND)
 	endif()
 endif()
 
-include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
-if(CURL_FOUND)
-	include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
-endif()
 if(EXPAT_FOUND)
 	include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
 endif()
@@ -606,7 +602,7 @@ endif()
 #link all required libraries to common-main
 add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)
 
-target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})
+target_link_libraries(common-main libgit xdiff ZLIB::ZLIB)
 if(Intl_FOUND)
 	target_link_libraries(common-main ${Intl_LIBRARIES})
 endif()
@@ -659,17 +655,17 @@ if(CURL_FOUND)
 	add_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c)
 
 	add_executable(git-imap-send ${CMAKE_SOURCE_DIR}/imap-send.c)
-	target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})
+	target_link_libraries(git-imap-send http_obj common-main CURL::libcurl)
 
 	add_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c)
-	target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})
+	target_link_libraries(git-http-fetch http_obj common-main CURL::libcurl)
 
 	add_executable(git-remote-http ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/remote-curl.c)
-	target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )
+	target_link_libraries(git-remote-http http_obj common-main CURL::libcurl)
 
 	if(EXPAT_FOUND)
 		add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
-		target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
+		target_link_libraries(git-http-push http_obj common-main CURL::libcurl ${EXPAT_LIBRARIES})
 	endif()
 endif()
 
With this change we're feeding proper CMake targets to target_link_libraries()
instead of just a bunch of strings. CMake can know a lot about a target, such
as it's dependencies, required macros and so on[1]. This means some boilerplate
code can be removed: Notice that the manual handling of Zlib's include path is
gone. The same can perhaps be done for the other libraries as well but I
haven't checked that.

> +include_directories(${CMAKE_SOURCE_DIR})
> +(...)
> +include_directories(${CMAKE_BINARY_DIR})

See if CMAKE_INCLUDE_CURRENT_DIR[2] makes this unneeded. It might not since you
overwrite CMAKE_SOURCE_DIR manually.

Øsse

[1]: https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#properties-on-targets
[2]: https://cmake.org/cmake/help/latest/variable/CMAKE_INCLUDE_CURRENT_DIR.html

^ permalink raw reply related	[flat|nested] 179+ messages in thread

* Re: [PATCH v4 4/8] cmake: support for testing git with ctest
  2020-06-12 18:29       ` [PATCH v4 4/8] cmake: support for testing git with ctest Sibi Siddharthan via GitGitGadget
@ 2020-06-15 14:02         ` Øystein Walle
  2020-06-15 19:45           ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Øystein Walle @ 2020-06-15 14:02 UTC (permalink / raw)
  To: gitgitgadget; +Cc: git, sibisiddharthan.github, Øystein Walle

> +
> +if(BUILD_TESTING)
> +

This variable should perhaps be declared as an option using option()[1] since
it's a knob the user is supposed to be able to switch. This makes it listed by
`cmake -L`, and shown in ccmake and cmake-gui. In short, it's made more
disoverable.

> file(APPEND ...)
> file(APPEND ...)
> file(APPEND ...)
> (...)

Maybe make this one multiline string and have one file(APPEND ...) at the end?
It looks a bit... big.

Øsse

[1]: ttps://cmake.org/cmake/help/v3.18/command/option.html

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v4 6/8] cmake: support for building git on windows with mingw
  2020-06-12 18:29       ` [PATCH v4 6/8] cmake: support for building git on windows with mingw Sibi Siddharthan via GitGitGadget
@ 2020-06-15 14:03         ` Øystein Walle
  2020-06-15 19:47           ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Øystein Walle @ 2020-06-15 14:03 UTC (permalink / raw)
  To: gitgitgadget; +Cc: git, sibisiddharthan.github, Øystein Walle

> +if(WIN32)
> +	set(EXE_EXTENSION .exe)
> +else()
> +	set(EXE_EXTENSION)
> +endif()

You can probably use CMAKE_EXECUTABLE_SUFFIX here. See:
https://cmake.org/cmake/help/latest/variable/CMAKE_EXECUTABLE_SUFFIX.html

Øsse


^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v4 7/8] cmake: support for building git on windows with msvc and clang
  2020-06-12 18:29       ` [PATCH v4 7/8] cmake: support for building git on windows with msvc and clang Sibi Siddharthan via GitGitGadget
@ 2020-06-15 14:04         ` Øystein Walle
  2020-06-15 19:56           ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Øystein Walle @ 2020-06-15 14:04 UTC (permalink / raw)
  To: gitgitgadget; +Cc: git, sibisiddharthan.github, Øystein Walle

> +#Force all visual studio outputs to CMAKE_BINARY_DIR

What is the reasoning for this? AFAIK this makes it impossible to customize it
from the outside by doing `cmake -DFOO=bar ...`.  

>  if(WIN32)
> -	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
> -			COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
> -				-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
> -				-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
> -			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
> -			VERBATIM)
> +	if(NOT MSVC)#use windres when compiling with gcc and clang
> +		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
> +				COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
> +					-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
> +					-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
> +				WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
> +				VERBATIM)
> +	else()#MSVC use rc
> +		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
> +				COMMAND ${CMAKE_RC_COMPILER} /d MAJOR=${PROJECT_VERSION_MAJOR} /d MINOR=${PROJECT_VERSION_MINOR}
> +					/d MICRO=${PROJECT_VERSION_PATCH} /d PATCHLEVEL=0 /d GIT_VERSION="${PROJECT_VERSION}.GIT"
> +					/fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_SOURCE_DIR}/git.rc
> +				WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
> +				VERBATIM)
> +	endif()
>  	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
>  endif()

If you list a .rc in the call to add_executable() then CMake knows how to
handle it and will invoke the resource compiler on it. I am not 100% sure how
to provide additional arguments right now, but I believe it will lead to
simpler code than using add_custom_command() and add_custom_target().

Øsse


^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v4 4/8] cmake: support for testing git with ctest
  2020-06-15 14:02         ` Øystein Walle
@ 2020-06-15 19:45           ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-06-15 19:45 UTC (permalink / raw)
  To: Øystein Walle; +Cc: Sibi Siddharthan via GitGitGadget, git

On Mon, Jun 15, 2020 at 7:32 PM Øystein Walle <oystwa@gmail.com> wrote:
>
> > +
> > +if(BUILD_TESTING)
> > +
>
> This variable should perhaps be declared as an option using option()[1] since
> it's a knob the user is supposed to be able to switch. This makes it listed by
> `cmake -L`, and shown in ccmake and cmake-gui. In short, it's made more
> disoverable.
>

When you `include(CTest)` the option BUILD_TESTING is automatically added.

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v4 6/8] cmake: support for building git on windows with mingw
  2020-06-15 14:03         ` Øystein Walle
@ 2020-06-15 19:47           ` Sibi Siddharthan
  2020-06-18  4:43             ` Junio C Hamano
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-06-15 19:47 UTC (permalink / raw)
  To: Øystein Walle; +Cc: Sibi Siddharthan via GitGitGadget, git

On Mon, Jun 15, 2020 at 7:33 PM Øystein Walle <oystwa@gmail.com> wrote:
>
> > +if(WIN32)
> > +     set(EXE_EXTENSION .exe)
> > +else()
> > +     set(EXE_EXTENSION)
> > +endif()
>
> You can probably use CMAKE_EXECUTABLE_SUFFIX here. See:
> https://cmake.org/cmake/help/latest/variable/CMAKE_EXECUTABLE_SUFFIX.html
>

Could have done it that way, will try to change it once the patch
series gets merged with next or master.

> Øsse
>

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v4 7/8] cmake: support for building git on windows with msvc and clang
  2020-06-15 14:04         ` Øystein Walle
@ 2020-06-15 19:56           ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-06-15 19:56 UTC (permalink / raw)
  To: Øystein Walle; +Cc: Sibi Siddharthan via GitGitGadget, git

On Mon, Jun 15, 2020 at 7:34 PM Øystein Walle <oystwa@gmail.com> wrote:
>
> > +#Force all visual studio outputs to CMAKE_BINARY_DIR
>
> What is the reasoning for this? AFAIK this makes it impossible to customize it
> from the outside by doing `cmake -DFOO=bar ...`.
>

When you test git, the test system expects the binaries to be in a
particular directory relative to a bunch of miscellaneous
scripts(wrappers,etc).
Since Visual Studio is multi config generator the binaries go into
CMAKE_BINARY_DIR/(Debug|Release|RelWithDebInfo...). By doing it this
way it is a bit easier to handle, along with the other generators like
Makefile or Ninja.


> >  if(WIN32)
> > -     add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
> > -                     COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
> > -                             -DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
> > -                             -i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
> > -                     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
> > -                     VERBATIM)
> > +     if(NOT MSVC)#use windres when compiling with gcc and clang
> > +             add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
> > +                             COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
> > +                                     -DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
> > +                                     -i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
> > +                             WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
> > +                             VERBATIM)
> > +     else()#MSVC use rc
> > +             add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
> > +                             COMMAND ${CMAKE_RC_COMPILER} /d MAJOR=${PROJECT_VERSION_MAJOR} /d MINOR=${PROJECT_VERSION_MINOR}
> > +                                     /d MICRO=${PROJECT_VERSION_PATCH} /d PATCHLEVEL=0 /d GIT_VERSION="${PROJECT_VERSION}.GIT"
> > +                                     /fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_SOURCE_DIR}/git.rc
> > +                             WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
> > +                             VERBATIM)
> > +     endif()
> >       add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
> >  endif()
>
> If you list a .rc in the call to add_executable() then CMake knows how to
> handle it and will invoke the resource compiler on it. I am not 100% sure how
> to provide additional arguments right now, but I believe it will lead to
> simpler code than using add_custom_command() and add_custom_target().
>
> Øsse
>

CMake does know how to handle rc commands including defines.
The issue here is the conflicting redefinition of GIT_VERSION which is
used in the source files.
And CMake uses llvm-rc(completely broken as of llvm 9.0) for the rc compiler.
Hence the above monstrocity.

Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v4 1/8] Introduce CMake support for configuring Git
  2020-06-15 14:00         ` Øystein Walle
@ 2020-06-15 20:04           ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-06-15 20:04 UTC (permalink / raw)
  To: Øystein Walle; +Cc: Sibi Siddharthan via GitGitGadget, git

On Mon, Jun 15, 2020 at 7:31 PM Øystein Walle <oystwa@gmail.com> wrote:
>
> Hi,
>
> I haven't been able to pay much attention lately. I see this is v4 of this
> patch series and thought I took a quick look and didn't find anything, it's
> possible some of this has been addressed already. If so I apologize.
>
> > So let's start building CMake support for Git.
>
> Yay!
>
> > +
> > +Instructions to run CMake:
> > +
> > +cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release
> > +Eg.
> > +From the root of git source tree
> > +     `cmake contrib/buildsystems/ `
> > +This will build the git binaries at the root
> > +
> > +For out of source builds, say build in 'git/git-build/'
> > +     `mkdir git-build;cd git-build; cmake ../contrib/buildsystems/`
> > +This will build the git binaries in git-build directory
> > +
>
> Since the mininum required version is sufficiently high I suggest you
> recommend the following as well:
>
>     cmake -B build-dir -S contrib/buildsystems
>
> This might be easier for scripted tasks (packaging and whatnot) since cd
> and mkdir aren't necessary.
>

We could do that.

> > +#set the source directory to root of git
> > +set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
>
> See if you can avoid this. This this will break if another project includes Git
> as part of itself with add_subdirectory() or the ExternalProject module. If all
> you use it for is paths to other files then you might as well do this:
>
>     set(repo_root "${CMAKE_CURRENT_LIST_DIR}/../..")
>
> and use ${repo_root} the places you use ${CMAKE_SOURCE_DIR} now.
>
> AFAIK the places CMake accepts relative paths it's usually relative to
> CMAKE_CURRENT_SOURCE_DIR and not CMAKE_SOURCE_DIR, anyway. I don't think it's
> automagically updated when CMAKE_SOURCE_DIR is changed.
>

Since we are using a single list file, it is fine.
I understand your concern that git is included as part of another
project things might break, but that is really rare.
I will try to fix these issues after adding support for BSD and APPLE systems.
The main priority for this patch series is to help git-for-windows
developers for now.

> > +include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
> > +if(CURL_FOUND)
> > +     include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
> > +endif()
>
> This is better handled like this these days:
>
> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
> index 8367b73e94..ca1f90e58c 100644
> --- a/contrib/buildsystems/CMakeLists.txt
> +++ b/contrib/buildsystems/CMakeLists.txt
> @@ -121,10 +121,6 @@ if(NOT Intl_FOUND)
>         endif()
>  endif()
>
> -include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
> -if(CURL_FOUND)
> -       include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
> -endif()
>  if(EXPAT_FOUND)
>         include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
>  endif()
> @@ -606,7 +602,7 @@ endif()
>  #link all required libraries to common-main
>  add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)
>
> -target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})
> +target_link_libraries(common-main libgit xdiff ZLIB::ZLIB)
>  if(Intl_FOUND)
>         target_link_libraries(common-main ${Intl_LIBRARIES})
>  endif()
> @@ -659,17 +655,17 @@ if(CURL_FOUND)
>         add_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c)
>
>         add_executable(git-imap-send ${CMAKE_SOURCE_DIR}/imap-send.c)
> -       target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})
> +       target_link_libraries(git-imap-send http_obj common-main CURL::libcurl)
>
>         add_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c)
> -       target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})
> +       target_link_libraries(git-http-fetch http_obj common-main CURL::libcurl)
>
>         add_executable(git-remote-http ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/remote-curl.c)
> -       target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )
> +       target_link_libraries(git-remote-http http_obj common-main CURL::libcurl)
>
>         if(EXPAT_FOUND)
>                 add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
> -               target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
> +               target_link_libraries(git-http-push http_obj common-main CURL::libcurl ${EXPAT_LIBRARIES})
>         endif()
>  endif()
>
> With this change we're feeding proper CMake targets to target_link_libraries()
> instead of just a bunch of strings. CMake can know a lot about a target, such
> as it's dependencies, required macros and so on[1]. This means some boilerplate
> code can be removed: Notice that the manual handling of Zlib's include path is
> gone. The same can perhaps be done for the other libraries as well but I
> haven't checked that.
>

It depends on the implementation of the CMake modules. We can do as
you suggested for Zlib and curl.
Iconv added exported targets recently.
Intl still does not have this syntax yet.
Using ${*_LIBRARIES} works all across the board.

Thank You
Sibi Siddharthan

> > +include_directories(${CMAKE_SOURCE_DIR})
> > +(...)
> > +include_directories(${CMAKE_BINARY_DIR})
>
> See if CMAKE_INCLUDE_CURRENT_DIR[2] makes this unneeded. It might not since you
> overwrite CMAKE_SOURCE_DIR manually.
>
> Øsse
>
> [1]: https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#properties-on-targets
> [2]: https://cmake.org/cmake/help/latest/variable/CMAKE_INCLUDE_CURRENT_DIR.html

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v4 6/8] cmake: support for building git on windows with mingw
  2020-06-15 19:47           ` Sibi Siddharthan
@ 2020-06-18  4:43             ` Junio C Hamano
  2020-06-18 19:55               ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Junio C Hamano @ 2020-06-18  4:43 UTC (permalink / raw)
  To: Sibi Siddharthan
  Cc: Øystein Walle, Sibi Siddharthan via GitGitGadget, git

Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:

> On Mon, Jun 15, 2020 at 7:33 PM Øystein Walle <oystwa@gmail.com> wrote:
>>
>> > +if(WIN32)
>> > +     set(EXE_EXTENSION .exe)
>> > +else()
>> > +     set(EXE_EXTENSION)
>> > +endif()
>>
>> You can probably use CMAKE_EXECUTABLE_SUFFIX here. See:
>> https://cmake.org/cmake/help/latest/variable/CMAKE_EXECUTABLE_SUFFIX.html
>>
>
> Could have done it that way, will try to change it once the patch
> series gets merged with next or master.

If it is something that makes the result even simpler than the above
quoted 5 lines, I do not see a reason to postpone it and use that
simpler way from the beginning.

Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v4 6/8] cmake: support for building git on windows with mingw
  2020-06-18  4:43             ` Junio C Hamano
@ 2020-06-18 19:55               ` Sibi Siddharthan
  2020-06-18 20:08                 ` Junio C Hamano
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-06-18 19:55 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Øystein Walle, Sibi Siddharthan via GitGitGadget, git

On Thu, Jun 18, 2020 at 10:13 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:
>
> > On Mon, Jun 15, 2020 at 7:33 PM Øystein Walle <oystwa@gmail.com> wrote:
> >>
> >> > +if(WIN32)
> >> > +     set(EXE_EXTENSION .exe)
> >> > +else()
> >> > +     set(EXE_EXTENSION)
> >> > +endif()
> >>
> >> You can probably use CMAKE_EXECUTABLE_SUFFIX here. See:
> >> https://cmake.org/cmake/help/latest/variable/CMAKE_EXECUTABLE_SUFFIX.html
> >>
> >
> > Could have done it that way, will try to change it once the patch
> > series gets merged with next or master.
>
> If it is something that makes the result even simpler than the above
> quoted 5 lines, I do not see a reason to postpone it and use that
> simpler way from the beginning.
>

Since this patch series has been merged with pu, I didn't know whether
I should wait till the patch gets merged into 'next' or do the change
immediately.
If I do this change should I fixup the commit that introduced
EXE_EXTENSION or commit on top of HEAD? Please tell. I will do the
changes immediately and submit another PATCH series.

One more thing, there is an issue with the scripts' permissions when
run in Linux. They don't have execute permissions.
Since the main focus of the CMake build is to help windows devs,
should I defer this modification until a later time, or should I do
them immediately.
The changes will involve adding a line of code to each of the script
varieties(sh,perl,python) so 3 more lines of extra code.

Thank You,
Sibi Siddharthan

> Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v4 6/8] cmake: support for building git on windows with mingw
  2020-06-18 19:55               ` Sibi Siddharthan
@ 2020-06-18 20:08                 ` Junio C Hamano
  2020-06-18 20:40                   ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Junio C Hamano @ 2020-06-18 20:08 UTC (permalink / raw)
  To: Sibi Siddharthan
  Cc: Øystein Walle, Sibi Siddharthan via GitGitGadget, git

Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:

> Since this patch series has been merged with pu, I didn't know whether
> I should wait till the patch gets merged into 'next' or do the change
> immediately.

Ah, OK.  Being in 'pu' does not mean no more than that the patch was
sent to the list and I happened to have seen it.  If it were ready
to be merged to 'next', I may have marked it as such in the "What's
cooking" report, but otherwise, the default is to be polished until
it gets ready.

> One more thing, there is an issue with the scripts' permissions when
> run in Linux. They don't have execute permissions.

What script?  Your scripts you add in the patch series?  What is the
reason why they lack execute permissions?  Forgot to "chmod +x"?

It sounds like, in addition to issues pointed out during the review
cycle, you have identified more issues that can be solved to make
the series more complete yourself, which is a very good thing.  It
is hard for anyone to review one's own patches and find issues, and
you seem to be getting the hang of it.  These are all good thing to
address before the topic becomes ready for 'next'.

And there is no need to hurry.  If you do not want to waste time in
repeated rewrite and review cycle, the best way may be to go slowly
and carefully to avoid "this was known to be suboptimal even when I
wrote it, but I didn't bother fixing it before sending it out, but
it was noticed during the review so I have to update it and send a
new round".

Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v4 6/8] cmake: support for building git on windows with mingw
  2020-06-18 20:08                 ` Junio C Hamano
@ 2020-06-18 20:40                   ` Sibi Siddharthan
  2020-06-18 21:00                     ` Junio C Hamano
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-06-18 20:40 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Øystein Walle, Sibi Siddharthan via GitGitGadget, git

On Fri, Jun 19, 2020 at 1:38 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:
>
> > Since this patch series has been merged with pu, I didn't know whether
> > I should wait till the patch gets merged into 'next' or do the change
> > immediately.
>
> Ah, OK.  Being in 'pu' does not mean no more than that the patch was
> sent to the list and I happened to have seen it.  If it were ready
> to be merged to 'next', I may have marked it as such in the "What's
> cooking" report, but otherwise, the default is to be polished until
> it gets ready.
>
> > One more thing, there is an issue with the scripts' permissions when
> > run in Linux. They don't have execute permissions.
>
> What script?  Your scripts you add in the patch series?  What is the
> reason why they lack execute permissions?  Forgot to "chmod +x"?
>
> It sounds like, in addition to issues pointed out during the review
> cycle, you have identified more issues that can be solved to make
> the series more complete yourself, which is a very good thing.  It
> is hard for anyone to review one's own patches and find issues, and
> you seem to be getting the hang of it.  These are all good thing to
> address before the topic becomes ready for 'next'.
>

Danh was the one who pointed this out, credit goes to him.
The reason I deferred modifying in PATCH v4 was because there was no
easy way(cross platform)
to change file permissions. The workaround is to juggle the files to a
temporary directory, and then copy them
to where they are intended to be with the required permissions. This
added quite a bit of code.
Since Windows platform was the priority, I did not address this issue.

I know that this issue needs to be addressed to make the script more
complete, so will have a UNIX conditional block for addressing this
issue.

Thank You,
Sibi Siddharthan

> And there is no need to hurry.  If you do not want to waste time in
> repeated rewrite and review cycle, the best way may be to go slowly
> and carefully to avoid "this was known to be suboptimal even when I
> wrote it, but I didn't bother fixing it before sending it out, but
> it was noticed during the review so I have to update it and send a
> new round".
>
> Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v4 6/8] cmake: support for building git on windows with mingw
  2020-06-18 20:40                   ` Sibi Siddharthan
@ 2020-06-18 21:00                     ` Junio C Hamano
  2020-06-19 17:15                       ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Junio C Hamano @ 2020-06-18 21:00 UTC (permalink / raw)
  To: Sibi Siddharthan
  Cc: Øystein Walle, Sibi Siddharthan via GitGitGadget, git

Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:

> The reason I deferred modifying in PATCH v4 was because there was no
> easy way(cross platform)
> to change file permissions. The workaround is to juggle the files to a
> temporary directory, and then copy them
> to where they are intended to be with the required permissions. This
> added quite a bit of code.
> Since Windows platform was the priority, I did not address this issue.

I recall asking you, in a very early iteration, if you just
concentrate on Windows and do not even pretend you support Linux or
any other systems, the series can be kept smaller and review
simpler, and your answer was "no, it can be done with just a little
extra code".  But I think you are saying it needs "workaround" and
what needs to happen in the workaround sounds quite ugly to me.

Let's not worry about cross-platform and instead stick to Windows
and nothing else for now to expedite the process.  As long as it is
advertised as such, nobody would complain that it does not work on
Linux or macOS.

Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v4 6/8] cmake: support for building git on windows with mingw
  2020-06-18 21:00                     ` Junio C Hamano
@ 2020-06-19 17:15                       ` Sibi Siddharthan
  2020-06-19 17:29                         ` Junio C Hamano
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-06-19 17:15 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Øystein Walle, Sibi Siddharthan via GitGitGadget, git

On Fri, Jun 19, 2020 at 2:30 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:
>
> > The reason I deferred modifying in PATCH v4 was because there was no
> > easy way(cross platform)
> > to change file permissions. The workaround is to juggle the files to a
> > temporary directory, and then copy them
> > to where they are intended to be with the required permissions. This
> > added quite a bit of code.
> > Since Windows platform was the priority, I did not address this issue.
>
> I recall asking you, in a very early iteration, if you just
> concentrate on Windows and do not even pretend you support Linux or
> any other systems, the series can be kept smaller and review
> simpler, and your answer was "no, it can be done with just a little
> extra code".  But I think you are saying it needs "workaround" and
> what needs to happen in the workaround sounds quite ugly to me.
>

I know what I said. This is the worst edge case of this scenario.

> Let's not worry about cross-platform and instead stick to Windows
> and nothing else for now to expedite the process.  As long as it is
> advertised as such, nobody would complain that it does not work on
> Linux or macOS.
>

Okay.

Just for your information.
This is the exact diff that needs to be added to address the issue.
------------------------------------------
@@ -761,6 +761,14 @@
 file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)
 string(REPLACE "#!/usr/bin/env python" "#!/usr/bin/python" content
"${content}")
 file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})

+#Give the scripts execute permissions. This does not apply on Windows
+if(UNIX)
+       foreach(script ${git_sh_scripts} git-instaweb
${git_perl_scripts} git-p4)
+               add_custom_target(${script}_executable ALL
+                               chmod +x ${CMAKE_BINARY_DIR}/${script})
+       endforeach()
+endif()
+
 #perl modules
 file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")

@@ -790,6 +799,12 @@
foreach(tm ${templates})
        configure_file(${CMAKE_SOURCE_DIR}/templates/${tm}
${CMAKE_BINARY_DIR}/templates/blt/${blt_tm} @ONLY)
 endforeach()

+#Give the templates read & execute permissions. This does not apply on Windows
+if(UNIX)
+       add_custom_target(templates_executable ALL
+                       chmod -R +rx ${CMAKE_BINARY_DIR}/templates/blt/)
+endif()
+

 #translations
 if(MSGFMT_EXE)
---------------------------------------------------------
If this is simple enough, I will add it in the next patch series. If
not, when in the future should I implement this?


Thank You,
Sibi Siddharthan

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v4 6/8] cmake: support for building git on windows with mingw
  2020-06-19 17:15                       ` Sibi Siddharthan
@ 2020-06-19 17:29                         ` Junio C Hamano
  0 siblings, 0 replies; 179+ messages in thread
From: Junio C Hamano @ 2020-06-19 17:29 UTC (permalink / raw)
  To: Sibi Siddharthan
  Cc: Øystein Walle, Sibi Siddharthan via GitGitGadget, git

Sibi Siddharthan <sibisiddharthan.github@gmail.com> writes:

>> Let's not worry about cross-platform and instead stick to Windows
>> and nothing else for now to expedite the process.  As long as it is
>> advertised as such, nobody would complain that it does not work on
>> Linux or macOS.
>>
>
> Okay.
>
> Just for your information.
> This is the exact diff that needs to be added to address the issue.

I do not care how small the diff is.  This won't be the last such
case that needs a workaround, and I do not want to see us die from
thousands of little cuts.

If anything, a diff that removes things that are needed only because
we try to work on non-Windows systems would be more interesting to
see.  If it removes a single ifdef(), that would be worth applying.

Thanks.

^ permalink raw reply	[flat|nested] 179+ messages in thread

* [PATCH v5 0/8] CMake build system for git
  2020-06-12 18:29     ` [PATCH v4 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                         ` (7 preceding siblings ...)
  2020-06-12 18:29       ` [PATCH v4 8/8] ci: modification of main.yml to use cmake for vs-build job Sibi Siddharthan via GitGitGadget
@ 2020-06-26 16:11       ` Sibi Siddharthan via GitGitGadget
  2020-06-26 16:11         ` [PATCH v5 1/8] Introduce CMake support for configuring Git Sibi Siddharthan via GitGitGadget
                           ` (7 more replies)
  8 siblings, 8 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-06-26 16:11 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan

This is an attempt to build Git using CMake. CMake is cross-platform build
generator which works well on a variety of platforms(primarily Linux and
Windows). Using CMake we can check whether certain headers exist, certain
functions exist, the required libraries are present and configure the build
accordingly. Using CMake we can also build and test Git out of source,
resulting in a clean source tree.

Tested platforms

Ubuntu 18.04 GCC 7.4 Clang 8.0.1

Windows MinGW GCC 9.2 Clang 9 Visual Studio 2015,2017,2019

Changes:

1) The CMake script has been relocated to contrib/buildsystems 2) The CMake
script parses the Makefile for the sources. LIB_OBJS BUILTIN_OBJS XDIFF_OBJS
VCSSVN_OBJS TEST_BUILTINS_OBJS SCRIPT_SH SCRIPT_PERL 3) Philip suggested to
change the error message if sh/bash was not found on windows. 4) CMake now
tests for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT 5) Renamed the
variable test_helper_sources to test-tool_SOURCES [PATCH 4/8] to be
consistent with the naming of source variables.

Changes v2: Changes 1,2,4 have been rebased to PATCH 01/xx CMake uses
GIT-VERSION-GEN to get the version of Git Fixed a bug where a Windows user
can pose as Linux user and vice versa. [PATCH 6/8]

Changes v3: Patch changes are moved from the commit messages and are placed
here. Code inside check_c_source_(compiles/runs) have been formatted
according to git coding guidelines. [PATCH 1/8] The CMake script parses the
Makefile for SCRIPT_LIB also. [PATCH 2/8] The CMake script globs templates,
po files. Logic has been added to place the template files in their
respective directories instead of hard-coding them. [PATCH 2/8]

Changes v4: Removed EXE_EXTENSION conditional stuff using
CMAKE_EXECUTABLE_SUFFIX [PATCH 4/8] There was an issue in build pipelines
where CMake was not able to find the correct iconv library (caused by an
update that installed PostgreSQL), so we need to manually set the location
of the iconv library and its includes. This issue is extremely rare and is
specific to the implementation of FindIconv.cmake. Other libraries are
unaffected. [PATCH 8/8]

Sibi Siddharthan (8):
  Introduce CMake support for configuring Git
  cmake: generate the shell/perl/python scripts and templates,
    translations
  cmake: installation support for git
  cmake: support for testing git with ctest
  cmake: support for testing git when building out of the source tree
  cmake: support for building git on windows with mingw
  cmake: support for building git on windows with msvc and clang.
  ci: modification of main.yml to use cmake for vs-build job

 .github/workflows/main.yml          |   39 +-
 contrib/buildsystems/CMakeLists.txt | 1000 +++++++++++++++++++++++++++
 2 files changed, 1024 insertions(+), 15 deletions(-)
 create mode 100644 contrib/buildsystems/CMakeLists.txt


base-commit: e8ba1cc988e122f1a74cda161ba3ec1bf22fe88f
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-614%2FSibiSiddharthan%2Fgit-og-v5
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-614/SibiSiddharthan/git-og-v5
Pull-Request: https://github.com/gitgitgadget/git/pull/614

Range-diff vs v4:

 1:  c4e1ba7446 = 1:  07ae9f0a49 Introduce CMake support for configuring Git
 2:  abb9e6e1d5 ! 2:  74358b389d cmake: generate the shell/perl/python scripts and templates, translations
     @@ contrib/buildsystems/CMakeLists.txt: add_custom_command(OUTPUT ${git_links} ${gi
      +list(TRANSFORM templates REPLACE "${CMAKE_SOURCE_DIR}/templates/" "")
      +list(REMOVE_ITEM templates ".gitignore")
      +list(REMOVE_ITEM templates "Makefile")
     ++list(REMOVE_ITEM templates "blt")# Prevents an error when reconfiguring for in source builds
      +
      +list(REMOVE_ITEM templates "branches--")
      +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
 3:  4a0dd23cbb = 3:  a60e7472d3 cmake: installation support for git
 4:  db05180e98 = 4:  fedda55fc2 cmake: support for testing git with ctest
 5:  17e7f3e9de = 5:  398a578558 cmake: support for testing git when building out of the source tree
 6:  549f0cd5ff ! 6:  10acdbf5e4 cmake: support for building git on windows with mingw
     @@ contrib/buildsystems/CMakeLists.txt: add_compile_definitions(PAGER_ENV="LESS=FRX
      +	set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
      +	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
      +endif()
     - 
     --add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
     --list(APPEND compat_SOURCES unix-socket.c)
     ++
      +
      +#Platform Specific
      +if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
     @@ contrib/buildsystems/CMakeLists.txt: add_compile_definitions(PAGER_ENV="LESS=FRX
      +	add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
      +	list(APPEND compat_SOURCES unix-socket.c)
      +endif()
     -+
     -+if(WIN32)
     -+	set(EXE_EXTENSION .exe)
     -+else()
     -+	set(EXE_EXTENSION)
     -+endif()
     + 
     +-add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
     +-list(APPEND compat_SOURCES unix-socket.c)
     ++set(EXE_EXTENSION ${CMAKE_EXECUTABLE_SUFFIX})
       
       #header checks
       check_include_file(libgen.h HAVE_LIBGEN_H)
 7:  f85ea0ac0c = 7:  0b921545d2 cmake: support for building git on windows with msvc and clang.
 8:  2f7cf41e08 ! 8:  3cdefab43a ci: modification of main.yml to use cmake for vs-build job
     @@ .github/workflows/main.yml: jobs:
      +        if (!$?) { exit(1) }
      +    - name: generate Visual Studio solution
      +      shell: bash
     -+      run: cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows -DMSGFMT_EXE=`pwd`/git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
     ++      run: |
     ++        cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows \
     ++        -DIconv_LIBRARY=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows/lib/libiconv.lib -DIconv_INCLUDE_DIR=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows/include \
     ++        -DMSGFMT_EXE=`pwd`/git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
           - name: MSBuild
             run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
           - name: bundle artifact tar

-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 179+ messages in thread

* [PATCH v5 1/8] Introduce CMake support for configuring Git
  2020-06-26 16:11       ` [PATCH v5 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
@ 2020-06-26 16:11         ` Sibi Siddharthan via GitGitGadget
  2020-06-26 16:11         ` [PATCH v5 2/8] cmake: generate the shell/perl/python scripts and templates, translations Sibi Siddharthan via GitGitGadget
                           ` (6 subsequent siblings)
  7 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-06-26 16:11 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

At the moment, the recommended way to configure Git's builds is to
simply run `make`. If that does not work, the recommended strategy is to
look at the top of the `Makefile` to see whether any "Makefile knob" has
to be turned on/off, e.g. `make NO_OPENSSL=YesPlease`.

Alternatively, Git also has an `autoconf` setup which allows configuring
builds via `./configure [<option>...]`.

Both of these options are fine if the developer works on Unix or Linux.
But on Windows, we have to jump through hoops to configure a build
(read: we force the user to install a full Git for Windows SDK, which
occupies around two gigabytes (!) on disk and downloads about three
quarters of a gigabyte worth of Git objects).

The build infrastructure for Git is written around being able to run
make, which is not supported natively on Windows.
To help Windows developers a CMake build script is introduced here.

With a working support CMake, developers on Windows need only install
CMake, configure their build, load the generated Visual Studio solution
and immediately start modifying the code and build their own version of
Git. Likewise, developers on other platforms can use the convenient GUI
tools provided by CMake to configure their build.

So let's start building CMake support for Git.

This is only the first step, and to make it easier to review, it only
allows for configuring builds on the platform that is easiest to
configure for: Linux.

The CMake script checks whether the headers are present(eg. libgen.h),
whether the functions are present(eg. memmem), whether the funtions work
properly (eg. snprintf) and generate the required compile definitions
for the platform. The script also searches for the required libraries,
if it fails to find the required libraries the respective executables
won't be built.(eg. If libcurl is not found then git-remote-http won't
be built). This will help building Git easier.

With a CMake script an out of source build of git is possible resulting
in a clean source tree.

Note: this patch asks for the minimum version v3.14 of CMake (which is
not all that old as of time of writing) because that is the first
version to offer a platform-independent way to generate hardlinks as
part of the build. This is needed to generate all those hardlinks for
the built-in commands of Git.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 592 ++++++++++++++++++++++++++++
 1 file changed, 592 insertions(+)
 create mode 100644 contrib/buildsystems/CMakeLists.txt

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
new file mode 100644
index 0000000000..1e910d9df8
--- /dev/null
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -0,0 +1,592 @@
+#
+#	Copyright (c) 2020 Sibi Siddharthan
+#
+
+#[[
+
+Instructions to run CMake:
+
+cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release
+Eg.
+From the root of git source tree
+	`cmake contrib/buildsystems/ `
+This will build the git binaries at the root
+
+For out of source builds, say build in 'git/git-build/'
+	`mkdir git-build;cd git-build; cmake ../contrib/buildsystems/`
+This will build the git binaries in git-build directory
+
+Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
+compiler flags
+Debug : -g
+Release: -O3
+RelWithDebInfo : -O2 -g
+MinSizeRel : -Os
+empty(default) :
+
+NOTE: -DCMAKE_BUILD_TYPE is optional. For multi-config generators like Visual Studio
+this option is ignored
+
+This process generates a Makefile(Linux/*BSD/MacOS) , Visual Studio solution(Windows) by default.
+Run `make` to build Git on Linux/*BSD/MacOS.
+Open git.sln on Windows and build Git.
+
+NOTE: By default CMake uses Makefile as the build tool on Linux and Visual Studio in Windows,
+to use another tool say `ninja` add this to the command line when configuring.
+`-G Ninja`
+
+]]
+cmake_minimum_required(VERSION 3.14)
+
+#set the source directory to root of git
+set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
+
+find_program(SH_EXE sh)
+
+#Create GIT-VERSION-FILE using GIT-VERSION-GEN
+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)
+	message("Generating GIT-VERSION-FILE")
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN
+		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+endif()
+
+#Parse GIT-VERSION-FILE to get the version
+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE git_version REGEX "GIT_VERSION = (.*)")
+string(REPLACE "GIT_VERSION = " "" git_version ${git_version})
+string(FIND ${git_version} "GIT" location)
+if(location EQUAL -1)
+	string(REGEX MATCH "[0-9]*\\.[0-9]*\\.[0-9]*" git_version ${git_version})
+else()
+	string(REGEX MATCH "[0-9]*\\.[0-9]*" git_version ${git_version})
+	string(APPEND git_version ".0") #for building from a snapshot
+endif()
+
+project(git
+	VERSION ${git_version}
+	LANGUAGES C)
+
+
+#macros for parsing the Makefile for sources
+macro(parse_makefile_for_sources list_var regex)
+	file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
+	string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
+	string(REPLACE "$(COMPAT_OBJS)" "" ${list_var} ${${list_var}}) #remove "$(COMPAT_OBJS)" This is only for libgit.
+	string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
+	string(REPLACE ".o" ".c;" ${list_var} ${${list_var}}) #change .o to .c, ; is for converting the string into a list
+	list(TRANSFORM ${list_var} STRIP) #remove trailing/leading whitespaces for each element in list
+	list(REMOVE_ITEM ${list_var} "") #remove empty list elements
+endmacro()
+
+include(CheckTypeSize)
+include(CheckCSourceRuns)
+include(CheckCSourceCompiles)
+include(CheckIncludeFile)
+include(CheckFunctionExists)
+include(CheckSymbolExists)
+include(CheckStructHasMember)
+
+find_package(ZLIB REQUIRED)
+find_package(CURL)
+find_package(EXPAT)
+find_package(Iconv)
+find_package(Intl)
+
+if(NOT Intl_FOUND)
+	add_compile_definitions(NO_GETTEXT)
+	if(NOT Iconv_FOUND)
+		add_compile_definitions(NO_ICONV)
+	endif()
+endif()
+
+include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
+if(CURL_FOUND)
+	include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
+endif()
+if(EXPAT_FOUND)
+	include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
+endif()
+if(Iconv_FOUND)
+	include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
+endif()
+if(Intl_FOUND)
+	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
+endif()
+
+#default behaviour
+include_directories(${CMAKE_SOURCE_DIR})
+add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
+add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)
+add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES
+			SHA1DC_INIT_SAFE_HASH_DEFAULT=0
+			SHA1DC_CUSTOM_INCLUDE_SHA1_C="cache.h"
+			SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="git-compat-util.h" )
+list(APPEND compat_SOURCES sha1dc_git.c sha1dc/sha1.c sha1dc/ubc_check.c block-sha1/sha1.c sha256/block/sha256.c compat/qsort_s.c)
+
+
+add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
+			ETC_GITATTRIBUTES="etc/gitattributes"
+			ETC_GITCONFIG="etc/gitconfig"
+			GIT_EXEC_PATH="libexec/git-core"
+			GIT_LOCALE_PATH="share/locale"
+			GIT_MAN_PATH="share/man"
+			GIT_INFO_PATH="share/info"
+			GIT_HTML_PATH="share/doc/git-doc"
+			DEFAULT_HELP_FORMAT="html"
+			DEFAULT_GIT_TEMPLATE_DIR="share/git-core/templates"
+			GIT_VERSION="${PROJECT_VERSION}.GIT"
+			GIT_USER_AGENT="git/${PROJECT_VERSION}.GIT"
+			BINDIR="bin"
+			GIT_BUILT_FROM_COMMIT="")
+
+set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+
+add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
+list(APPEND compat_SOURCES unix-socket.c)
+
+#header checks
+check_include_file(libgen.h HAVE_LIBGEN_H)
+if(NOT HAVE_LIBGEN_H)
+	add_compile_definitions(NO_LIBGEN_H)
+	list(APPEND compat_SOURCES compat/basename.c)
+endif()
+
+check_include_file(sys/sysinfo.h HAVE_SYSINFO)
+if(HAVE_SYSINFO)
+	add_compile_definitions(HAVE_SYSINFO)
+endif()
+
+check_c_source_compiles("
+#include <alloca.h>
+
+int main(void)
+{
+	char *p = (char *) alloca(2 * sizeof(int));
+
+	if (p)
+		return 0;
+	return 0;
+}"
+HAVE_ALLOCA_H)
+if(HAVE_ALLOCA_H)
+	add_compile_definitions(HAVE_ALLOCA_H)
+endif()
+
+check_include_file(strings.h HAVE_STRINGS_H)
+if(HAVE_STRINGS_H)
+	add_compile_definitions(HAVE_STRINGS_H)
+endif()
+
+check_include_file(sys/select.h HAVE_SYS_SELECT_H)
+if(NOT HAVE_SYS_SELECT_H)
+	add_compile_definitions(NO_SYS_SELECT_H)
+endif()
+
+check_include_file(sys/poll.h HAVE_SYS_POLL_H)
+if(NOT HAVE_SYS_POLL_H)
+	add_compile_definitions(NO_SYS_POLL_H)
+endif()
+
+check_include_file(poll.h HAVE_POLL_H)
+if(NOT HAVE_POLL_H)
+	add_compile_definitions(NO_POLL_H)
+endif()
+
+check_include_file(inttypes.h HAVE_INTTYPES_H)
+if(NOT HAVE_INTTYPES_H)
+	add_compile_definitions(NO_INTTYPES_H)
+endif()
+
+check_include_file(paths.h HAVE_PATHS_H)
+if(HAVE_PATHS_H)
+	add_compile_definitions(HAVE_PATHS_H)
+endif()
+
+#function checks
+set(function_checks
+	strcasestr memmem strlcpy strtoimax strtoumax strtoull
+	setenv mkdtemp poll pread memmem unsetenv hstrerror)
+
+foreach(f ${function_checks})
+	string(TOUPPER ${f} uf)
+	check_function_exists(${f} HAVE_${uf})
+	if(NOT HAVE_${uf})
+		add_compile_definitions(NO_${uf})
+	endif()
+endforeach()
+
+if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)
+	include_directories(${CMAKE_SOURCE_DIR}/compat/poll)
+	add_compile_definitions(NO_POLL)
+	list(APPEND compat_SOURCES compat/poll/poll.c)
+endif()
+
+if(NOT HAVE_STRCASESTR)
+	list(APPEND compat_SOURCES compat/strcasestr.c)
+endif()
+
+if(NOT HAVE_STRLCPY)
+	list(APPEND compat_SOURCES compat/strlcpy.c)
+endif()
+
+if(NOT HAVE_STRTOUMAX)
+	list(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c)
+endif()
+
+if(NOT HAVE_SETENV)
+	list(APPEND compat_SOURCES compat/setenv.c)
+endif()
+
+if(NOT HAVE_MKDTEMP)
+	list(APPEND compat_SOURCES compat/mkdtemp.c)
+endif()
+
+if(NOT HAVE_PREAD)
+	list(APPEND compat_SOURCES compat/pread.c)
+endif()
+
+if(NOT HAVE_MEMMEM)
+	list(APPEND compat_SOURCES compat/memmem.c)
+endif()
+
+if(NOT WIN32)
+	if(NOT HAVE_UNSETENV)
+		list(APPEND compat_SOURCES compat/unsetenv.c)
+	endif()
+
+	if(NOT HAVE_HSTRERROR)
+		list(APPEND compat_SOURCES compat/hstrerror.c)
+	endif()
+endif()
+
+check_function_exists(getdelim HAVE_GETDELIM)
+if(HAVE_GETDELIM)
+	add_compile_definitions(HAVE_GETDELIM)
+endif()
+
+check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
+check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC)
+if(HAVE_CLOCK_GETTIME)
+	add_compile_definitions(HAVE_CLOCK_GETTIME)
+endif()
+if(HAVE_CLOCK_MONOTONIC)
+	add_compile_definitions(HAVE_CLOCK_MONOTONIC)
+endif()
+
+#check for st_blocks in struct stat
+check_struct_has_member("struct stat" st_blocks "sys/stat.h" STRUCT_STAT_HAS_ST_BLOCKS)
+if(NOT STRUCT_STAT_HAS_ST_BLOCKS)
+	add_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)
+endif()
+
+#compile checks
+check_c_source_runs("
+#include<stdio.h>
+#include<stdarg.h>
+#include<string.h>
+#include<stdlib.h>
+
+int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
+{
+	int ret;
+	va_list ap;
+
+	va_start(ap, format);
+	ret = vsnprintf(str, maxsize, format, ap);
+	va_end(ap);
+	return ret;
+}
+
+int main(void)
+{
+	char buf[6];
+
+	if (test_vsnprintf(buf, 3, \"%s\", \"12345\") != 5
+		|| strcmp(buf, \"12\"))
+			return 1;
+	if (snprintf(buf, 3, \"%s\", \"12345\") != 5
+		|| strcmp(buf, \"12\"))
+			return 1;
+	return 0;
+}"
+SNPRINTF_OK)
+if(NOT SNPRINTF_OK)
+	add_compile_definitions(SNPRINTF_RETURNS_BOGUS)
+	list(APPEND compat_SOURCES compat/snprintf.c)
+endif()
+
+check_c_source_runs("
+#include<stdio.h>
+
+int main(void)
+{
+	FILE *f = fopen(\".\", \"r\");
+
+	return f != NULL;
+}"
+FREAD_READS_DIRECTORIES_NO)
+if(NOT FREAD_READS_DIRECTORIES_NO)
+	add_compile_definitions(FREAD_READS_DIRECTORIES)
+	list(APPEND compat_SOURCES compat/fopen.c)
+endif()
+
+check_c_source_compiles("
+#include <regex.h>
+#ifndef REG_STARTEND
+#error oops we dont have it
+#endif
+
+int main(void)
+{
+	return 0;
+}"
+HAVE_REGEX)
+if(NOT HAVE_REGEX)
+	include_directories(${CMAKE_SOURCE_DIR}/compat/regex)
+	list(APPEND compat_SOURCES compat/regex/regex.c )
+	add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
+endif()
+
+
+check_c_source_compiles("
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+int main(void)
+{
+	int val, mib[2];
+	size_t len;
+
+	mib[0] = CTL_HW;
+	mib[1] = 1;
+	len = sizeof(val);
+	return sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;
+}"
+HAVE_BSD_SYSCTL)
+if(HAVE_BSD_SYSCTL)
+	add_compile_definitions(HAVE_BSD_SYSCTL)
+endif()
+
+set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES})
+set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS})
+
+check_c_source_compiles("
+#include <iconv.h>
+
+extern size_t iconv(iconv_t cd,
+		char **inbuf, size_t *inbytesleft,
+		char **outbuf, size_t *outbytesleft);
+
+int main(void)
+{
+	return 0;
+}"
+HAVE_NEW_ICONV)
+if(HAVE_NEW_ICONV)
+	set(HAVE_OLD_ICONV 0)
+else()
+	set(HAVE_OLD_ICONV 1)
+endif()
+
+check_c_source_runs("
+#include <iconv.h>
+#if ${HAVE_OLD_ICONV}
+typedef const char *iconv_ibp;
+#else
+typedef char *iconv_ibp;
+#endif
+
+int main(void)
+{
+	int v;
+	iconv_t conv;
+	char in[] = \"a\";
+	iconv_ibp pin = in;
+	char out[20] = \"\";
+	char *pout = out;
+	size_t isz = sizeof(in);
+	size_t osz = sizeof(out);
+
+	conv = iconv_open(\"UTF-16\", \"UTF-8\");
+	iconv(conv, &pin, &isz, &pout, &osz);
+	iconv_close(conv);
+	v = (unsigned char)(out[0]) + (unsigned char)(out[1]);
+	return v != 0xfe + 0xff;
+}"
+ICONV_DOESNOT_OMIT_BOM)
+if(NOT ICONV_DOESNOT_OMIT_BOM)
+	add_compile_definitions(ICONV_OMITS_BOM)
+endif()
+
+unset(CMAKE_REQUIRED_LIBRARIES)
+unset(CMAKE_REQUIRED_INCLUDES)
+
+
+#programs
+set(PROGRAMS_BUILT
+	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
+	git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
+
+if(NOT CURL_FOUND)
+	list(APPEND excluded_progs git-http-fetch git-http-push)
+	add_compile_definitions(NO_CURL)
+	message(WARNING "git-http-push and git-http-fetch will not be built")
+else()
+	list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
+	if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
+		add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
+	endif()
+endif()
+
+if(NOT EXPAT_FOUND)
+	list(APPEND excluded_progs git-http-push)
+	add_compile_definitions(NO_EXPAT)
+else()
+	list(APPEND PROGRAMS_BUILT git-http-push)
+	if(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2)
+		add_compile_definitions(EXPAT_NEEDS_XMLPARSE_H)
+	endif()
+endif()
+
+list(REMOVE_DUPLICATES excluded_progs)
+list(REMOVE_DUPLICATES PROGRAMS_BUILT)
+
+
+foreach(p ${excluded_progs})
+	list(APPEND EXCLUSION_PROGS --exclude-program ${p} )
+endforeach()
+
+#for comparing null values
+list(APPEND EXCLUSION_PROGS empty)
+set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" FORCE)
+
+if(NOT EXISTS ${CMAKE_BINARY_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
+	list(REMOVE_ITEM EXCLUSION_PROGS empty)
+	message("Generating command-list.h")
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			OUTPUT_FILE ${CMAKE_BINARY_DIR}/command-list.h)
+endif()
+
+if(NOT EXISTS ${CMAKE_BINARY_DIR}/config-list.h)
+	message("Generating config-list.h")
+	execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			OUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h)
+endif()
+
+include_directories(${CMAKE_BINARY_DIR})
+
+#build
+#libgit
+parse_makefile_for_sources(libgit_SOURCES "LIB_OBJS")
+
+list(TRANSFORM libgit_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+list(TRANSFORM compat_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
+
+#libxdiff
+parse_makefile_for_sources(libxdiff_SOURCES "XDIFF_OBJS")
+
+list(TRANSFORM libxdiff_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+add_library(xdiff STATIC ${libxdiff_SOURCES})
+
+#libvcs-svn
+parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
+
+list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
+
+#link all required libraries to common-main
+add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
+if(Intl_FOUND)
+	target_link_libraries(common-main ${Intl_LIBRARIES})
+endif()
+if(Iconv_FOUND)
+	target_link_libraries(common-main ${Iconv_LIBRARIES})
+endif()
+
+#git
+parse_makefile_for_sources(git_SOURCES "BUILTIN_OBJS")
+
+list(TRANSFORM git_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
+add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})
+target_link_libraries(git common-main)
+
+add_executable(git-bugreport ${CMAKE_SOURCE_DIR}/bugreport.c)
+target_link_libraries(git-bugreport common-main)
+
+add_executable(git-credential-store ${CMAKE_SOURCE_DIR}/credential-store.c)
+target_link_libraries(git-credential-store common-main)
+
+add_executable(git-daemon ${CMAKE_SOURCE_DIR}/daemon.c)
+target_link_libraries(git-daemon common-main)
+
+add_executable(git-fast-import ${CMAKE_SOURCE_DIR}/fast-import.c)
+target_link_libraries(git-fast-import common-main)
+
+add_executable(git-http-backend ${CMAKE_SOURCE_DIR}/http-backend.c)
+target_link_libraries(git-http-backend common-main)
+
+add_executable(git-sh-i18n--envsubst ${CMAKE_SOURCE_DIR}/sh-i18n--envsubst.c)
+target_link_libraries(git-sh-i18n--envsubst common-main)
+
+add_executable(git-shell ${CMAKE_SOURCE_DIR}/shell.c)
+target_link_libraries(git-shell common-main)
+
+if(CURL_FOUND)
+	add_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c)
+
+	add_executable(git-imap-send ${CMAKE_SOURCE_DIR}/imap-send.c)
+	target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})
+
+	add_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c)
+	target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})
+
+	add_executable(git-remote-http ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/remote-curl.c)
+	target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )
+
+	if(EXPAT_FOUND)
+		add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
+		target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
+	endif()
+endif()
+
+add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)
+target_link_libraries(git-remote-testsvn common-main vcs-svn)
+
+add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)
+target_link_libraries(git-credential-cache common-main)
+
+add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)
+target_link_libraries(git-credential-cache--daemon common-main)
+
+
+set(git_builtin_extra
+	cherry cherry-pick format-patch fsck-objects
+	init merge-subtree restore show
+	stage status switch whatchanged)
+
+#Creating hardlinks
+foreach(s ${git_SOURCES} ${git_builtin_extra})
+	string(REPLACE "${CMAKE_SOURCE_DIR}/builtin/" "" s ${s})
+	string(REPLACE ".c" "" s ${s})
+	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
+	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
+endforeach()
+
+if(CURL_FOUND)
+	set(remote_exes
+		git-remote-https git-remote-ftp git-remote-ftps)
+	foreach(s ${remote_exes})
+		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
+		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+	endforeach()
+endif()
+
+add_custom_command(OUTPUT ${git_links} ${git_http_links}
+		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
+		DEPENDS git git-remote-http)
+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v5 2/8] cmake: generate the shell/perl/python scripts and templates, translations
  2020-06-26 16:11       ` [PATCH v5 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
  2020-06-26 16:11         ` [PATCH v5 1/8] Introduce CMake support for configuring Git Sibi Siddharthan via GitGitGadget
@ 2020-06-26 16:11         ` Sibi Siddharthan via GitGitGadget
  2020-06-26 16:11         ` [PATCH v5 3/8] cmake: installation support for git Sibi Siddharthan via GitGitGadget
                           ` (5 subsequent siblings)
  7 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-06-26 16:11 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

Implement the placeholder substitution to generate scripted
Porcelain commands, e.g. git-request-pull out of
git-request-pull.sh

Generate shell/perl/python scripts and template using CMake instead of
using sed like the build procedure in the Makefile does.

The text translations are only build if `msgfmt` is found in your path.

NOTE: The scripts and templates are generated during configuration.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 111 +++++++++++++++++++++++++++-
 1 file changed, 110 insertions(+), 1 deletion(-)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 1e910d9df8..6c5bb4e233 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -66,7 +66,7 @@ project(git
 	LANGUAGES C)
 
 
-#macros for parsing the Makefile for sources
+#macros for parsing the Makefile for sources and scripts
 macro(parse_makefile_for_sources list_var regex)
 	file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
 	string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
@@ -77,6 +77,16 @@ macro(parse_makefile_for_sources list_var regex)
 	list(REMOVE_ITEM ${list_var} "") #remove empty list elements
 endmacro()
 
+macro(parse_makefile_for_scripts list_var regex lang)
+	file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
+	string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
+	string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
+	string(REPLACE " " ";" ${list_var} ${${list_var}}) #convert string to a list
+	if(NOT ${lang}) #exclude for SCRIPT_LIB
+		list(TRANSFORM ${list_var} REPLACE "${lang}" "") #do the replacement
+	endif()
+endmacro()
+
 include(CheckTypeSize)
 include(CheckCSourceRuns)
 include(CheckCSourceCompiles)
@@ -112,6 +122,11 @@ if(Intl_FOUND)
 	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
 endif()
 
+find_program(MSGFMT_EXE msgfmt)
+if(NOT MSGFMT_EXE)
+	message(WARNING "Text Translations won't be build")
+endif()
+
 #default behaviour
 include_directories(${CMAKE_SOURCE_DIR})
 add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
@@ -590,3 +605,97 @@ add_custom_command(OUTPUT ${git_links} ${git_http_links}
 		COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
 		DEPENDS git git-remote-http)
 add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})
+
+
+#creating required scripts
+set(SHELL_PATH /bin/sh)
+set(PERL_PATH /usr/bin/perl)
+set(LOCALEDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
+set(GITWEBDIR ${FALLBACK_RUNTIME_PREFIX}/share/locale)
+set(INSTLIBDIR ${FALLBACK_RUNTIME_PREFIX}/share/perl5)
+
+#shell scripts
+parse_makefile_for_scripts(git_sh_scripts "SCRIPT_SH" ".sh")
+parse_makefile_for_scripts(git_shlib_scripts "SCRIPT_LIB" "")
+set(git_shell_scripts
+	${git_sh_scripts} ${git_shlib_scripts} git-instaweb)
+
+foreach(script ${git_shell_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.sh content NEWLINE_CONSUME)
+	string(REPLACE "@SHELL_PATH@" "${SHELL_PATH}" content "${content}")
+	string(REPLACE "@@DIFF@@" "diff" content "${content}")
+	string(REPLACE "@LOCALEDIR@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@GITWEBDIR@" "${GITWEBDIR}" content "${content}")
+	string(REPLACE "@@NO_CURL@@" "" content "${content}")
+	string(REPLACE "@@USE_GETTEXT_SCHEME@@" "" content "${content}")
+	string(REPLACE "# @@BROKEN_PATH_FIX@@" "" content "${content}")
+	string(REPLACE "@@PERL@@" "${PERL_PATH}" content "${content}")
+	string(REPLACE "@@SANE_TEXT_GREP@@" "-a" content "${content}")
+	string(REPLACE "@@PAGER_ENV@@" "LESS=FRX LV=-c" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+endforeach()
+
+#perl scripts
+parse_makefile_for_scripts(git_perl_scripts "SCRIPT_PERL" ".perl")
+
+#create perl header
+file(STRINGS ${CMAKE_SOURCE_DIR}/perl/header_templates/fixed_prefix.template.pl perl_header )
+string(REPLACE "@@PATHSEP@@" ":" perl_header "${perl_header}")
+string(REPLACE "@@INSTLIBDIR@@" "${INSTLIBDIR}" perl_header "${perl_header}")
+
+foreach(script ${git_perl_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/${script}.perl content NEWLINE_CONSUME)
+	string(REPLACE "#!/usr/bin/perl" "#!/usr/bin/perl\n${perl_header}\n" content "${content}")
+	string(REPLACE "@@GIT_VERSION@@" "${PROJECT_VERSION}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/${script} ${content})
+endforeach()
+
+#python script
+file(STRINGS ${CMAKE_SOURCE_DIR}/git-p4.py content NEWLINE_CONSUME)
+string(REPLACE "#!/usr/bin/env python" "#!/usr/bin/python" content "${content}")
+file(WRITE ${CMAKE_BINARY_DIR}/git-p4 ${content})
+
+#perl modules
+file(GLOB_RECURSE perl_modules "${CMAKE_SOURCE_DIR}/perl/*.pm")
+
+foreach(pm ${perl_modules})
+	string(REPLACE "${CMAKE_SOURCE_DIR}/perl/" "" file_path ${pm})
+	file(STRINGS ${pm} content NEWLINE_CONSUME)
+	string(REPLACE "@@LOCALEDIR@@" "${LOCALEDIR}" content "${content}")
+	string(REPLACE "@@NO_PERL_CPAN_FALLBACKS@@" "" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/perl/build/lib/${file_path} ${content})
+#test-lib.sh requires perl/build/lib to be the build directory of perl modules
+endforeach()
+
+
+#templates
+file(GLOB templates "${CMAKE_SOURCE_DIR}/templates/*")
+list(TRANSFORM templates REPLACE "${CMAKE_SOURCE_DIR}/templates/" "")
+list(REMOVE_ITEM templates ".gitignore")
+list(REMOVE_ITEM templates "Makefile")
+list(REMOVE_ITEM templates "blt")# Prevents an error when reconfiguring for in source builds
+
+list(REMOVE_ITEM templates "branches--")
+file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
+
+#templates have @.*@ replacement so use configure_file instead
+foreach(tm ${templates})
+	string(REPLACE "--" "/" blt_tm ${tm})
+	string(REPLACE "this" "" blt_tm ${blt_tm})# for this--
+	configure_file(${CMAKE_SOURCE_DIR}/templates/${tm} ${CMAKE_BINARY_DIR}/templates/blt/${blt_tm} @ONLY)
+endforeach()
+
+
+#translations
+if(MSGFMT_EXE)
+	file(GLOB po_files "${CMAKE_SOURCE_DIR}/po/*.po")
+	list(TRANSFORM po_files REPLACE "${CMAKE_SOURCE_DIR}/po/" "")
+	list(TRANSFORM po_files REPLACE ".po" "")
+	foreach(po ${po_files})
+		file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES)
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo
+				COMMAND ${MSGFMT_EXE} --check --statistics -o ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo ${CMAKE_SOURCE_DIR}/po/${po}.po)
+		list(APPEND po_gen ${CMAKE_BINARY_DIR}/po/build/locale/${po}/LC_MESSAGES/git.mo)
+	endforeach()
+	add_custom_target(po-gen ALL DEPENDS ${po_gen})
+endif()
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v5 3/8] cmake: installation support for git
  2020-06-26 16:11       ` [PATCH v5 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
  2020-06-26 16:11         ` [PATCH v5 1/8] Introduce CMake support for configuring Git Sibi Siddharthan via GitGitGadget
  2020-06-26 16:11         ` [PATCH v5 2/8] cmake: generate the shell/perl/python scripts and templates, translations Sibi Siddharthan via GitGitGadget
@ 2020-06-26 16:11         ` Sibi Siddharthan via GitGitGadget
  2020-06-26 16:11         ` [PATCH v5 4/8] cmake: support for testing git with ctest Sibi Siddharthan via GitGitGadget
                           ` (4 subsequent siblings)
  7 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-06-26 16:11 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

Install the built binaries and scripts using CMake

This is very similar to `make install`.
By default the destination directory(DESTDIR) is /usr/local/ on Linux
To set a custom installation path do this:
cmake `relative-path-to-srcdir`
	-DCMAKE_INSTALL_PREFIX=`preferred-install-path`

Then run `make install`

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 49 +++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 6c5bb4e233..bc9258cf3b 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -65,6 +65,8 @@ project(git
 	VERSION ${git_version}
 	LANGUAGES C)
 
+#TODO gitk git-gui gitweb
+#TODO Add pcre support
 
 #macros for parsing the Makefile for sources and scripts
 macro(parse_makefile_for_sources list_var regex)
@@ -699,3 +701,50 @@ if(MSGFMT_EXE)
 	endforeach()
 	add_custom_target(po-gen ALL DEPENDS ${po_gen})
 endif()
+
+
+#to help with the install
+list(TRANSFORM git_shell_scripts PREPEND "${CMAKE_BINARY_DIR}/")
+list(TRANSFORM git_perl_scripts PREPEND "${CMAKE_BINARY_DIR}/")
+
+#install
+install(TARGETS git git-shell
+	RUNTIME DESTINATION bin)
+install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver
+	DESTINATION bin)
+
+list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)
+install(TARGETS ${PROGRAMS_BUILT}
+	RUNTIME DESTINATION libexec/git-core)
+
+set(bin_links
+	git-receive-pack git-upload-archive git-upload-pack)
+
+foreach(b ${bin_links})
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
+endforeach()
+
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
+
+foreach(b ${git_links})
+	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
+	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+endforeach()
+
+foreach(b ${git_http_links})
+	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
+	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+endforeach()
+
+install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
+	DESTINATION libexec/git-core)
+
+install(DIRECTORY ${CMAKE_SOURCE_DIR}/mergetools DESTINATION libexec/git-core)
+install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5
+	FILES_MATCHING PATTERN "*.pm")
+install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)
+
+if(MSGFMT_EXE)
+	install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
+endif()
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v5 4/8] cmake: support for testing git with ctest
  2020-06-26 16:11       ` [PATCH v5 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                           ` (2 preceding siblings ...)
  2020-06-26 16:11         ` [PATCH v5 3/8] cmake: installation support for git Sibi Siddharthan via GitGitGadget
@ 2020-06-26 16:11         ` Sibi Siddharthan via GitGitGadget
  2020-06-26 16:11         ` [PATCH v5 5/8] cmake: support for testing git when building out of the source tree Sibi Siddharthan via GitGitGadget
                           ` (3 subsequent siblings)
  7 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-06-26 16:11 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch provides an alternate way to test git using ctest.
CTest ships with CMake, so there is no additional dependency being
introduced.

To perform the tests with ctest do this after building:
ctest -j[number of jobs]

NOTE: -j is optional, the default number of jobs is 1

Each of the jobs does this:
cd t/ && sh t[something].sh

The reason for using CTest is that it logs the output of the tests
in a neat way, which can be helpful during diagnosis of failures.

After the tests have run ctest generates three log files located in
`build-directory`/Testing/Temporary/

These log files are:

CTestCostData.txt:
This file contains the time taken to complete each test.

LastTestsFailed.log:
This log file contains the names of the tests that have failed in the
run.

LastTest.log:
This log file contains the log of all the tests that have run.
A snippet of the file is given below.

10/901 Testing: D:/my/git-master/t/t0009-prio-queue.sh
10/901 Test: D:/my/git-master/t/t0009-prio-queue.sh
Command: "sh.exe" "D:/my/git-master/t/t0009-prio-queue.sh"
Directory: D:/my/git-master/t
"D:/my/git-master/t/t0009-prio-queue.sh"
Output:
----------------------------------------------------------
ok 1 - basic ordering
ok 2 - mixed put and get
ok 3 - notice empty queue
ok 4 - stack order
passed all 4 test(s)
1..4
<end of output>
Test time =   1.11 sec

NOTE: Testing only works when building in source for now.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 124 ++++++++++++++++++++++++++++
 1 file changed, 124 insertions(+)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index bc9258cf3b..315f234b04 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -96,6 +96,7 @@ include(CheckIncludeFile)
 include(CheckFunctionExists)
 include(CheckSymbolExists)
 include(CheckStructHasMember)
+include(CTest)
 
 find_package(ZLIB REQUIRED)
 find_package(CURL)
@@ -748,3 +749,126 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/
 if(MSGFMT_EXE)
 	install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
 endif()
+
+
+if(BUILD_TESTING)
+
+#tests-helpers
+add_executable(test-fake-ssh ${CMAKE_SOURCE_DIR}/t/helper/test-fake-ssh.c)
+target_link_libraries(test-fake-ssh common-main)
+
+add_executable(test-line-buffer ${CMAKE_SOURCE_DIR}/t/helper/test-line-buffer.c)
+target_link_libraries(test-line-buffer common-main vcs-svn)
+
+add_executable(test-svn-fe ${CMAKE_SOURCE_DIR}/t/helper/test-svn-fe.c)
+target_link_libraries(test-svn-fe common-main vcs-svn)
+
+#test-tool
+parse_makefile_for_sources(test-tool_SOURCES "TEST_BUILTINS_OBJS")
+
+list(TRANSFORM test-tool_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/t/helper/")
+add_executable(test-tool ${CMAKE_SOURCE_DIR}/t/helper/test-tool.c ${test-tool_SOURCES})
+target_link_libraries(test-tool common-main)
+
+set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+			PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)
+
+#wrapper scripts
+set(wrapper_scripts
+	git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)
+
+set(wrapper_test_scripts
+	test-fake-ssh test-line-buffer test-svn-fe test-tool)
+
+
+foreach(script ${wrapper_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@@PROG@@" "${script}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
+endforeach()
+
+foreach(script ${wrapper_test_scripts})
+	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+	string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
+	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
+endforeach()
+
+file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
+string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
+string(REPLACE "@@PROG@@" "git-cvsserver" content "${content}")
+file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})
+
+#options for configuring test options
+option(PERL_TESTS "Perform tests that use perl" ON)
+option(PYTHON_TESTS "Perform tests that use python" ON)
+
+#GIT-BUILD-OPTIONS
+set(TEST_SHELL_PATH ${SHELL_PATH})
+set(DIFF diff)
+set(PYTHON_PATH /usr/bin/python)
+set(TAR tar)
+set(NO_CURL )
+set(NO_EXPAT )
+set(USE_LIBPCRE1 )
+set(USE_LIBPCRE2 )
+set(NO_LIBPCRE1_JIT )
+set(NO_PERL )
+set(NO_PTHREADS )
+set(NO_PYTHON )
+set(PAGER_ENV "LESS=FRX LV=-c")
+set(DC_SHA1 YesPlease)
+set(RUNTIME_PREFIX true)
+set(NO_GETTEXT )
+
+if(NOT CURL_FOUND)
+	set(NO_CURL 1)
+endif()
+
+if(NOT EXPAT_FOUND)
+	set(NO_EXPAT 1)
+endif()
+
+if(NOT Intl_FOUND)
+	set(NO_GETTEXT 1)
+endif()
+
+if(NOT PERL_TESTS)
+	set(NO_PERL 1)
+endif()
+
+if(NOT PYTHON_TESTS)
+	set(NO_PYTHON 1)
+endif()
+
+file(WRITE ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "SHELL_PATH='${SHELL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TEST_SHELL_PATH='${TEST_SHELL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PERL_PATH='${PERL_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DIFF='${DIFF}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PYTHON_PATH='${PYTHON_PATH}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "TAR='${TAR}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_CURL='${NO_CURL}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_EXPAT='${NO_EXPAT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "USE_LIBPCRE1='${USE_LIBPCRE1}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_LIBPCRE1_JIT='${NO_LIBPCRE1_JIT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PERL='${NO_PERL}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
+
+file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
+
+#test
+foreach(tsh ${test_scipts})
+	add_test(NAME ${tsh}
+		COMMAND ${SH_EXE} ${tsh}
+		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/t)
+endforeach()
+
+endif()#BUILD_TESTING
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v5 5/8] cmake: support for testing git when building out of the source tree
  2020-06-26 16:11       ` [PATCH v5 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                           ` (3 preceding siblings ...)
  2020-06-26 16:11         ` [PATCH v5 4/8] cmake: support for testing git with ctest Sibi Siddharthan via GitGitGadget
@ 2020-06-26 16:11         ` Sibi Siddharthan via GitGitGadget
  2020-06-26 16:11         ` [PATCH v5 6/8] cmake: support for building git on windows with mingw Sibi Siddharthan via GitGitGadget
                           ` (2 subsequent siblings)
  7 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-06-26 16:11 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch allows git to be tested when performin out of source builds.

This involves changing GIT_BUILD_DIR in t/test-lib.sh to point to the
build directory. Also some miscellaneous copies from the source directory
to the build directory.
The copies are:
t/chainlint.sed needed by a bunch of test scripts
po/is.po needed by t0204-gettext-rencode-sanity
mergetools/tkdiff needed by t7800-difftool
contrib/completion/git-prompt.sh needed by t9903-bash-prompt
contrib/completion/git-completion.bash needed by t9902-completion
contrib/svn-fe/svnrdump_sim.py needed by t9020-remote-svn

NOTE: t/test-lib.sh is only modified when tests are run not during
the build or configure.
The trash directory is still srcdir/t

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 315f234b04..2768ee5b71 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -862,6 +862,26 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n"
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
 
+#Make the tests work when building out of the source tree
+get_filename_component(CACHE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../CMakeCache.txt ABSOLUTE)
+if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})
+	file(RELATIVE_PATH BUILD_DIR_RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/CMakeCache.txt)
+	string(REPLACE "/CMakeCache.txt" "" BUILD_DIR_RELATIVE ${BUILD_DIR_RELATIVE})
+	#Setting the build directory in test-lib.sh before running tests
+	file(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.cmake
+		"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh GIT_BUILD_DIR_REPL REGEX \"GIT_BUILD_DIR=(.*)\")\n"
+		"file(STRINGS ${CMAKE_SOURCE_DIR}/t/test-lib.sh content NEWLINE_CONSUME)\n"
+		"string(REPLACE \"\${GIT_BUILD_DIR_REPL}\" \"GIT_BUILD_DIR=\\\"$TEST_DIRECTORY\\\"/../${BUILD_DIR_RELATIVE}\" content \"\${content}\")\n"
+		"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \${content})")
+	#misc copies
+	file(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)
+	file(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)
+	file(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-completion.bash DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)
+	file(COPY ${CMAKE_SOURCE_DIR}/contrib/svn-fe/svnrdump_sim.py DESTINATION ${CMAKE_BINARY_DIR}/contrib/svn-fe/)
+endif()
+
 file(GLOB test_scipts "${CMAKE_SOURCE_DIR}/t/t[0-9]*.sh")
 
 #test
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v5 6/8] cmake: support for building git on windows with mingw
  2020-06-26 16:11       ` [PATCH v5 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                           ` (4 preceding siblings ...)
  2020-06-26 16:11         ` [PATCH v5 5/8] cmake: support for testing git when building out of the source tree Sibi Siddharthan via GitGitGadget
@ 2020-06-26 16:11         ` Sibi Siddharthan via GitGitGadget
  2020-06-30  7:25           ` David Aguilar
  2020-06-26 16:11         ` [PATCH v5 7/8] cmake: support for building git on windows with msvc and clang Sibi Siddharthan via GitGitGadget
  2020-06-26 16:11         ` [PATCH v5 8/8] ci: modification of main.yml to use cmake for vs-build job Sibi Siddharthan via GitGitGadget
  7 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-06-26 16:11 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch facilitates building git on Windows with CMake using MinGW

NOTE: The funtions unsetenv and hstrerror are not checked in Windows
builds.
Reasons
NO_UNSETENV is not compatible with Windows builds.
lines 262-264 compat/mingw.h

compat/mingw.h(line 25) provides a definition of hstrerror which
conflicts with the definition provided in
git-compat-util.h(lines 733-736).

To use CMake on Windows with MinGW do this:
cmake `relative-path-to-srcdir` -G "MinGW Makefiles"

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 117 ++++++++++++++++++++++------
 1 file changed, 94 insertions(+), 23 deletions(-)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 2768ee5b71..2d7c0ed88e 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -42,6 +42,10 @@ cmake_minimum_required(VERSION 3.14)
 set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
 
 find_program(SH_EXE sh)
+if(NOT SH_EXE)
+	message(FATAL_ERROR "sh: shell interpreter was not found in your path, please install one."
+			"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
+endif()
 
 #Create GIT-VERSION-FILE using GIT-VERSION-GEN
 if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)
@@ -65,7 +69,9 @@ project(git
 	VERSION ${git_version}
 	LANGUAGES C)
 
+
 #TODO gitk git-gui gitweb
+#TODO Enable NLS on windows natively
 #TODO Add pcre support
 
 #macros for parsing the Makefile for sources and scripts
@@ -104,6 +110,7 @@ find_package(EXPAT)
 find_package(Iconv)
 find_package(Intl)
 
+
 if(NOT Intl_FOUND)
 	add_compile_definitions(NO_GETTEXT)
 	if(NOT Iconv_FOUND)
@@ -125,6 +132,14 @@ if(Intl_FOUND)
 	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
 endif()
 
+
+if(WIN32)
+	find_program(WINDRES_EXE windres)
+	if(NOT WINDRES_EXE)
+		message(FATAL_ERROR "Install windres on Windows for resource files")
+	endif()
+endif()
+
 find_program(MSGFMT_EXE msgfmt)
 if(NOT MSGFMT_EXE)
 	message(WARNING "Text Translations won't be build")
@@ -156,11 +171,35 @@ add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
 			BINDIR="bin"
 			GIT_BUILT_FROM_COMMIT="")
 
-set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
-add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+if(WIN32)
+	set(FALLBACK_RUNTIME_PREFIX /mingw64)
+	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+else()
+	set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
+	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
+endif()
+
+
+#Platform Specific
+if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+	include_directories(${CMAKE_SOURCE_DIR}/compat/win32)
+	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
+				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
+				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0
+				USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
+				UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
+	list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
+		compat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c
+		compat/win32/trace2_win32_process_info.c compat/win32/dirent.c
+		compat/nedmalloc/nedmalloc.c compat/strdup.c)
+	set(NO_UNIX_SOCKETS 1)
+
+elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+	add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
+	list(APPEND compat_SOURCES unix-socket.c)
+endif()
 
-add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
-list(APPEND compat_SOURCES unix-socket.c)
+set(EXE_EXTENSION ${CMAKE_EXECUTABLE_SUFFIX})
 
 #header checks
 check_include_file(libgen.h HAVE_LIBGEN_H)
@@ -223,7 +262,12 @@ endif()
 #function checks
 set(function_checks
 	strcasestr memmem strlcpy strtoimax strtoumax strtoull
-	setenv mkdtemp poll pread memmem unsetenv hstrerror)
+	setenv mkdtemp poll pread memmem)
+
+#unsetenv,hstrerror are incompatible with windows build
+if(NOT WIN32)
+	list(APPEND function_checks unsetenv hstrerror)
+endif()
 
 foreach(f ${function_checks})
 	string(TOUPPER ${f} uf)
@@ -444,7 +488,13 @@ unset(CMAKE_REQUIRED_INCLUDES)
 #programs
 set(PROGRAMS_BUILT
 	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
-	git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
+	git-shell git-remote-testsvn)
+
+if(NO_UNIX_SOCKETS)
+	list(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)
+else()
+	list(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)
+endif()
 
 if(NOT CURL_FOUND)
 	list(APPEND excluded_progs git-http-fetch git-http-push)
@@ -516,15 +566,34 @@ parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
 list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
 
+#add git.rc for gcc
+if(WIN32)
+	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+			COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
+				-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
+				-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
+			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+			VERBATIM)
+	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
+endif()
+
 #link all required libraries to common-main
 add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)
-target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
+
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})
 if(Intl_FOUND)
 	target_link_libraries(common-main ${Intl_LIBRARIES})
 endif()
 if(Iconv_FOUND)
 	target_link_libraries(common-main ${Iconv_LIBRARIES})
 endif()
+if(WIN32)
+	target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
+	add_dependencies(common-main git-rc)
+	target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+elseif(UNIX)
+	target_link_libraries(common-main pthread rt)
+endif()
 
 #git
 parse_makefile_for_sources(git_SOURCES "BUILTIN_OBJS")
@@ -575,11 +644,13 @@ endif()
 add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)
 target_link_libraries(git-remote-testsvn common-main vcs-svn)
 
-add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)
-target_link_libraries(git-credential-cache common-main)
+if(NOT NO_UNIX_SOCKETS)
+	add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)
+	target_link_libraries(git-credential-cache common-main)
 
-add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)
-target_link_libraries(git-credential-cache--daemon common-main)
+	add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)
+	target_link_libraries(git-credential-cache--daemon common-main)
+endif()
 
 
 set(git_builtin_extra
@@ -591,16 +662,16 @@ set(git_builtin_extra
 foreach(s ${git_SOURCES} ${git_builtin_extra})
 	string(REPLACE "${CMAKE_SOURCE_DIR}/builtin/" "" s ${s})
 	string(REPLACE ".c" "" s ${s})
-	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
-	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
+	file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git${EXE_EXTENSION} git-${s}${EXE_EXTENSION})\n")
+	list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s}${EXE_EXTENSION})
 endforeach()
 
 if(CURL_FOUND)
 	set(remote_exes
 		git-remote-https git-remote-ftp git-remote-ftps)
 	foreach(s ${remote_exes})
-		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
-		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
+		file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http${EXE_EXTENSION} ${s}${EXE_EXTENSION})\n")
+		list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s}${EXE_EXTENSION})
 	endforeach()
 endif()
 
@@ -722,20 +793,20 @@ set(bin_links
 	git-receive-pack git-upload-archive git-upload-pack)
 
 foreach(b ${bin_links})
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/bin/${b}${EXE_EXTENSION})")
 endforeach()
 
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
-install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git${EXE_EXTENSION})")
+install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell${EXE_EXTENSION})")
 
 foreach(b ${git_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+	install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
 endforeach()
 
 foreach(b ${git_http_links})
 	string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
-	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
+	install(CODE "file(CREATE_LINK  ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http${EXE_EXTENSION} ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b}${EXE_EXTENSION})")
 endforeach()
 
 install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
@@ -784,14 +855,14 @@ set(wrapper_test_scripts
 foreach(script ${wrapper_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "${script}" content "${content}")
+	string(REPLACE "@@PROG@@" "${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
 foreach(script ${wrapper_test_scripts})
 	file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
 	string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
-	string(REPLACE "@@PROG@@" "t/helper/${script}" content "${content}")
+	string(REPLACE "@@PROG@@" "t/helper/${script}${EXE_EXTENSION}" content "${content}")
 	file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/${script} ${content})
 endforeach()
 
@@ -857,7 +928,7 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PTHREADS='${NO_PTHREADS}'\
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_UNIX_SOCKETS='${NO_UNIX_SOCKETS}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PAGER_ENV='${PAGER_ENV}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "DC_SHA1='${DC_SHA1}'\n")
-file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X=''\n")
+file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X='${EXE_EXTENSION}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
 file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v5 7/8] cmake: support for building git on windows with msvc and clang.
  2020-06-26 16:11       ` [PATCH v5 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                           ` (5 preceding siblings ...)
  2020-06-26 16:11         ` [PATCH v5 6/8] cmake: support for building git on windows with mingw Sibi Siddharthan via GitGitGadget
@ 2020-06-26 16:11         ` Sibi Siddharthan via GitGitGadget
  2020-06-26 16:11         ` [PATCH v5 8/8] ci: modification of main.yml to use cmake for vs-build job Sibi Siddharthan via GitGitGadget
  7 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-06-26 16:11 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>

This patch adds support for Visual Studio and Clang builds

The minimum required version of CMake is upgraded to 3.15 because
this version offers proper support for Clang builds on Windows.

Libintl is not searched for when building with Visual Studio or Clang
because there is no binary compatible version available yet.

NOTE: In the link options invalidcontinue.obj has to be included.
The reason for this is because by default, Windows calls abort()'s
instead of setting errno=EINVAL when invalid arguments are passed to
standard functions.
This commit explains it in detail:
4b623d80f73528a632576990ca51e34c333d5dd6

On Windows the default generator is Visual Studio,so for Visual Studio
builds do this:

cmake `relative-path-to-srcdir`

NOTE: Visual Studio generator is a multi config generator, which means
that Debug and Release builds can be done on the same build directory.

For Clang builds do this:

On bash
CC=clang cmake `relative-path-to-srcdir` -G Ninja
		-DCMAKE_BUILD_TYPE=[Debug or Release]

On cmd
set CC=Clang
cmake `relative-path-to-srcdir` -G Ninja
		-DCMAKE_BUILD_TYPE=[Debug or Release]

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 contrib/buildsystems/CMakeLists.txt | 55 +++++++++++++++++++++++------
 1 file changed, 45 insertions(+), 10 deletions(-)

diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 2d7c0ed88e..47215df25b 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -108,8 +108,11 @@ find_package(ZLIB REQUIRED)
 find_package(CURL)
 find_package(EXPAT)
 find_package(Iconv)
-find_package(Intl)
 
+#Don't use libintl on Windows Visual Studio and Clang builds
+if(NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")))
+	find_package(Intl)
+endif()
 
 if(NOT Intl_FOUND)
 	add_compile_definitions(NO_GETTEXT)
@@ -133,7 +136,7 @@ if(Intl_FOUND)
 endif()
 
 
-if(WIN32)
+if(WIN32 AND NOT MSVC)#not required for visual studio builds
 	find_program(WINDRES_EXE windres)
 	if(NOT WINDRES_EXE)
 		message(FATAL_ERROR "Install windres on Windows for resource files")
@@ -145,6 +148,13 @@ if(NOT MSGFMT_EXE)
 	message(WARNING "Text Translations won't be build")
 endif()
 
+#Force all visual studio outputs to CMAKE_BINARY_DIR
+if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
+	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
+	add_compile_options(/MP)
+endif()
+
 #default behaviour
 include_directories(${CMAKE_SOURCE_DIR})
 add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
@@ -182,6 +192,10 @@ endif()
 
 #Platform Specific
 if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+	if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+		include_directories(${CMAKE_SOURCE_DIR}/compat/vcbuild/include)
+		add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
+	endif()
 	include_directories(${CMAKE_SOURCE_DIR}/compat/win32)
 	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
 				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
@@ -566,14 +580,22 @@ parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
 list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
 add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
 
-#add git.rc for gcc
 if(WIN32)
-	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
-			COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
-				-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
-				-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
-			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-			VERBATIM)
+	if(NOT MSVC)#use windres when compiling with gcc and clang
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+				COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
+					-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
+					-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
+				WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+				VERBATIM)
+	else()#MSVC use rc
+		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
+				COMMAND ${CMAKE_RC_COMPILER} /d MAJOR=${PROJECT_VERSION_MAJOR} /d MINOR=${PROJECT_VERSION_MINOR}
+					/d MICRO=${PROJECT_VERSION_PATCH} /d PATCHLEVEL=0 /d GIT_VERSION="${PROJECT_VERSION}.GIT"
+					/fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_SOURCE_DIR}/git.rc
+				WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+				VERBATIM)
+	endif()
 	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
 endif()
 
@@ -590,7 +612,13 @@ endif()
 if(WIN32)
 	target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
 	add_dependencies(common-main git-rc)
-	target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+	if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+		target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
+	elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+		target_link_options(common-main PUBLIC -municode -Wl,-nxcompat -Wl,-dynamicbase -Wl,-entry:wmainCRTStartup -Wl,invalidcontinue.obj)
+	elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+		target_link_options(common-main PUBLIC /IGNORE:4217 /IGNORE:4049 /NOLOGO /ENTRY:wmainCRTStartup /SUBSYSTEM:CONSOLE invalidcontinue.obj)
+	endif()
 elseif(UNIX)
 	target_link_libraries(common-main pthread rt)
 endif()
@@ -844,6 +872,13 @@ target_link_libraries(test-tool common-main)
 set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
 			PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/helper)
 
+if(MSVC)
+	set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+				PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)
+	set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
+				PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)
+endif()
+
 #wrapper scripts
 set(wrapper_scripts
 	git git-upload-pack git-receive-pack git-upload-archive git-shell git-remote-ext)
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 179+ messages in thread

* [PATCH v5 8/8] ci: modification of main.yml to use cmake for vs-build job
  2020-06-26 16:11       ` [PATCH v5 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
                           ` (6 preceding siblings ...)
  2020-06-26 16:11         ` [PATCH v5 7/8] cmake: support for building git on windows with msvc and clang Sibi Siddharthan via GitGitGadget
@ 2020-06-26 16:11         ` Sibi Siddharthan via GitGitGadget
  7 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan via GitGitGadget @ 2020-06-26 16:11 UTC (permalink / raw)
  To: git; +Cc: Sibi Siddharthan, Sibi Siddharthan

From: Sibi Siddharthan <sibisiv.siddharthan@gmail.com>

Teach .github/workflows/main.yml to use CMake for VS builds.

Modified the vs-test step to match windows-test step. This speeds
up the vs-test. Calling git-cmd from powershell and then calling git-bash
to perform the tests slows things down(factor of about 6). So git-bash
is directly called from powershell to perform the tests using prove.

NOTE: Since GitHub keeps the same directory for each job
(with respect to path) absolute paths are used in the bin-wrapper
scripts.

GitHub has switched to CMake 3.17.1 which changed the behaviour of
FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been
added to revert to the old behaviour.

In the configuration phase CMake looks for the required libraries for
building git (eg zlib,libiconv). So we extract the libraries before we
configure.

To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working
directory of script or path. So we copy the dlls before we configure.

Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
---
 .github/workflows/main.yml | 39 +++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 84a5dcff7a..44e0fe5839 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -145,13 +145,6 @@ jobs:
         ## Unzip and remove the artifact
         unzip artifacts.zip
         rm artifacts.zip
-    - name: generate Visual Studio solution
-      shell: powershell
-      run: |
-        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
-          make NDEBUG=1 DEVELOPER=1 vcxproj
-        "@
-        if (!$?) { exit(1) }
     - name: download vcpkg artifacts
       shell: powershell
       run: |
@@ -163,6 +156,17 @@ jobs:
         Remove-Item compat.zip
     - name: add msbuild to PATH
       uses: microsoft/setup-msbuild@v1.0.0
+    - name: copy dlls to root
+      shell: powershell
+      run: |
+        & compat\vcbuild\vcpkg_copy_dlls.bat release
+        if (!$?) { exit(1) }
+    - name: generate Visual Studio solution
+      shell: bash
+      run: |
+        cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows \
+        -DIconv_LIBRARY=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows/lib/libiconv.lib -DIconv_INCLUDE_DIR=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows/include \
+        -DMSGFMT_EXE=`pwd`/git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
     - name: MSBuild
       run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
     - name: bundle artifact tar
@@ -171,8 +175,6 @@ jobs:
         MSVC: 1
         VCPKG_ROOT: ${{github.workspace}}\compat\vcbuild\vcpkg
       run: |
-        & compat\vcbuild\vcpkg_copy_dlls.bat release
-        if (!$?) { exit(1) }
         & git-sdk-64-minimal\usr\bin\bash.exe -lc @"
           mkdir -p artifacts &&
           eval \"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts 2>&1 | grep ^tar)\"
@@ -203,7 +205,7 @@ jobs:
     - name: extract build artifacts
       shell: bash
       run: tar xf artifacts.tar.gz
-    - name: test (parallel)
+    - name: test
       shell: powershell
       env:
         MSYSTEM: MINGW64
@@ -214,12 +216,19 @@ jobs:
           # Let Git ignore the SDK and the test-cache
           printf '%s\n' /git-sdk-64-minimal/ /test-cache/ >>.git/info/exclude
 
-          cd t &&
-          PATH=\"`$PWD/helper:`$PATH\" &&
-          test-tool.exe run-command testsuite --jobs=10 -V -x --write-junit-xml \
-                  `$(test-tool.exe path-utils slice-tests \
-                          ${{matrix.nr}} 10 t[0-9]*.sh)
+          ci/run-test-slice.sh ${{matrix.nr}} 10
         "@
+    - name: ci/print-test-failures.sh
+      if: failure()
+      shell: powershell
+      run: |
+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc ci/print-test-failures.sh
+    - name: Upload failed tests' directories
+      if: failure() && env.FAILED_TEST_ARTIFACTS != ''
+      uses: actions/upload-artifact@v1
+      with:
+        name: failed-tests-windows
+        path: ${{env.FAILED_TEST_ARTIFACTS}}
   regular:
     needs: ci-config
     if: needs.ci-config.outputs.enabled == 'yes'
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 179+ messages in thread

* Re: [PATCH v5 6/8] cmake: support for building git on windows with mingw
  2020-06-26 16:11         ` [PATCH v5 6/8] cmake: support for building git on windows with mingw Sibi Siddharthan via GitGitGadget
@ 2020-06-30  7:25           ` David Aguilar
  2020-07-01 17:45             ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: David Aguilar @ 2020-06-30  7:25 UTC (permalink / raw)
  To: Sibi Siddharthan via GitGitGadget; +Cc: git, Sibi Siddharthan

On Fri, Jun 26, 2020 at 04:11:36PM +0000, Sibi Siddharthan via GitGitGadget wrote:
> From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> 
> This patch facilitates building git on Windows with CMake using MinGW
> 
> NOTE: The funtions unsetenv and hstrerror are not checked in Windows
> builds.
> Reasons
> NO_UNSETENV is not compatible with Windows builds.
> lines 262-264 compat/mingw.h
> 
> compat/mingw.h(line 25) provides a definition of hstrerror which
> conflicts with the definition provided in
> git-compat-util.h(lines 733-736).
> 
> To use CMake on Windows with MinGW do this:
> cmake `relative-path-to-srcdir` -G "MinGW Makefiles"
> 
> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> ---
>  contrib/buildsystems/CMakeLists.txt | 117 ++++++++++++++++++++++------
>  1 file changed, 94 insertions(+), 23 deletions(-)
> 
> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
> index 2768ee5b71..2d7c0ed88e 100644
> --- a/contrib/buildsystems/CMakeLists.txt
> +++ b/contrib/buildsystems/CMakeLists.txt
> @@ -42,6 +42,10 @@ cmake_minimum_required(VERSION 3.14)
>  set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
>  
>  find_program(SH_EXE sh)
> +if(NOT SH_EXE)
> +	message(FATAL_ERROR "sh: shell interpreter was not found in your path, please install one."
> +			"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
> +endif()
>  
>  #Create GIT-VERSION-FILE using GIT-VERSION-GEN
>  if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)
> @@ -65,7 +69,9 @@ project(git
>  	VERSION ${git_version}
>  	LANGUAGES C)
>  
> +
>  #TODO gitk git-gui gitweb
> +#TODO Enable NLS on windows natively
>  #TODO Add pcre support
>  
>  #macros for parsing the Makefile for sources and scripts
> @@ -104,6 +110,7 @@ find_package(EXPAT)
>  find_package(Iconv)
>  find_package(Intl)
>  
> +
>  if(NOT Intl_FOUND)
>  	add_compile_definitions(NO_GETTEXT)
>  	if(NOT Iconv_FOUND)
> @@ -125,6 +132,14 @@ if(Intl_FOUND)
>  	include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
>  endif()
>  
> +
> +if(WIN32)
> +	find_program(WINDRES_EXE windres)
> +	if(NOT WINDRES_EXE)
> +		message(FATAL_ERROR "Install windres on Windows for resource files")
> +	endif()
> +endif()
> +
>  find_program(MSGFMT_EXE msgfmt)
>  if(NOT MSGFMT_EXE)
>  	message(WARNING "Text Translations won't be build")
> @@ -156,11 +171,35 @@ add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
>  			BINDIR="bin"
>  			GIT_BUILT_FROM_COMMIT="")
>  
> -set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
> -add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
> +if(WIN32)
> +	set(FALLBACK_RUNTIME_PREFIX /mingw64)
> +	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
> +else()
> +	set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
> +	add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
> +endif()
> +
> +
> +#Platform Specific
> +if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
> +	include_directories(${CMAKE_SOURCE_DIR}/compat/win32)
> +	add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
> +				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
> +				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0
> +				USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
> +				UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
> +	list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
> +		compat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c
> +		compat/win32/trace2_win32_process_info.c compat/win32/dirent.c
> +		compat/nedmalloc/nedmalloc.c compat/strdup.c)
> +	set(NO_UNIX_SOCKETS 1)
> +
> +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
> +	add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
> +	list(APPEND compat_SOURCES unix-socket.c)
> +endif()
>  
> -add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
> -list(APPEND compat_SOURCES unix-socket.c)
> +set(EXE_EXTENSION ${CMAKE_EXECUTABLE_SUFFIX})
>  
>  #header checks
>  check_include_file(libgen.h HAVE_LIBGEN_H)
> @@ -223,7 +262,12 @@ endif()
>  #function checks
>  set(function_checks
>  	strcasestr memmem strlcpy strtoimax strtoumax strtoull
> -	setenv mkdtemp poll pread memmem unsetenv hstrerror)
> +	setenv mkdtemp poll pread memmem)
> +
> +#unsetenv,hstrerror are incompatible with windows build
> +if(NOT WIN32)
> +	list(APPEND function_checks unsetenv hstrerror)
> +endif()
>  
>  foreach(f ${function_checks})
>  	string(TOUPPER ${f} uf)
> @@ -444,7 +488,13 @@ unset(CMAKE_REQUIRED_INCLUDES)
>  #programs
>  set(PROGRAMS_BUILT
>  	git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
> -	git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
> +	git-shell git-remote-testsvn)
> +
> +if(NO_UNIX_SOCKETS)
> +	list(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)
> +else()
> +	list(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)
> +endif()
>  
>  if(NOT CURL_FOUND)
>  	list(APPEND excluded_progs git-http-fetch git-http-push)
> @@ -516,15 +566,34 @@ parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
>  list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
>  add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
>  
> +#add git.rc for gcc
> +if(WIN32)
> +	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
> +			COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
> +				-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
> +				-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
> +			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
> +			VERBATIM)
> +	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
> +endif()
> +
>  #link all required libraries to common-main
>  add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)
> -target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
> +
> +target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})
>  if(Intl_FOUND)
>  	target_link_libraries(common-main ${Intl_LIBRARIES})
>  endif()
>  if(Iconv_FOUND)
>  	target_link_libraries(common-main ${Iconv_LIBRARIES})
>  endif()
> +if(WIN32)
> +	target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
> +	add_dependencies(common-main git-rc)
> +	target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
> +elseif(UNIX)
> +	target_link_libraries(common-main pthread rt)
> +endif()


Small note about pthread.  In CMake land, the typical convention is to
use the FindThreads module. [1]

To use it, add this to the top-level:

	set(THREADS_PREFER_PTHREAD_FLAG TRUE)
	find_package(Threads REQUIRED)

and then use the Threads::Threads target with target_link_libraries()
instead of hard-coding "pthread" here.

That way it'll only use the "-pthread" flag and library links as needed.

I'm not sure if mingw makes this advice moot, but I figured it was worth
mentioning.

[1] https://cmake.org/cmake/help/latest/module/FindThreads.html
-- 
David

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v5 6/8] cmake: support for building git on windows with mingw
  2020-06-30  7:25           ` David Aguilar
@ 2020-07-01 17:45             ` Sibi Siddharthan
  2020-07-01 17:49               ` Sibi Siddharthan
  0 siblings, 1 reply; 179+ messages in thread
From: Sibi Siddharthan @ 2020-07-01 17:45 UTC (permalink / raw)
  To: David Aguilar; +Cc: Sibi Siddharthan via GitGitGadget, git

This module should not be used here as Git is built with pthreads in mind.
All of the Linux systems have the pthread library at install. For
Windows, there is a pthread layer implemented using Win32 calls in
compat/win32/pthread.c,h .

It would be nice if the library checks for pthreads on Windows
(libwinpthread and similar implementations), but it does not.

Thank You,
Sibi Siddharthan

On Tue, Jun 30, 2020 at 12:55 PM David Aguilar <davvid@gmail.com> wrote:
>
> On Fri, Jun 26, 2020 at 04:11:36PM +0000, Sibi Siddharthan via GitGitGadget wrote:
> > From: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> >
> > This patch facilitates building git on Windows with CMake using MinGW
> >
> > NOTE: The funtions unsetenv and hstrerror are not checked in Windows
> > builds.
> > Reasons
> > NO_UNSETENV is not compatible with Windows builds.
> > lines 262-264 compat/mingw.h
> >
> > compat/mingw.h(line 25) provides a definition of hstrerror which
> > conflicts with the definition provided in
> > git-compat-util.h(lines 733-736).
> >
> > To use CMake on Windows with MinGW do this:
> > cmake `relative-path-to-srcdir` -G "MinGW Makefiles"
> >
> > Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> > ---
> >  contrib/buildsystems/CMakeLists.txt | 117 ++++++++++++++++++++++------
> >  1 file changed, 94 insertions(+), 23 deletions(-)
> >
> > diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
> > index 2768ee5b71..2d7c0ed88e 100644
> > --- a/contrib/buildsystems/CMakeLists.txt
> > +++ b/contrib/buildsystems/CMakeLists.txt
> > @@ -42,6 +42,10 @@ cmake_minimum_required(VERSION 3.14)
> >  set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
> >
> >  find_program(SH_EXE sh)
> > +if(NOT SH_EXE)
> > +     message(FATAL_ERROR "sh: shell interpreter was not found in your path, please install one."
> > +                     "On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
> > +endif()
> >
> >  #Create GIT-VERSION-FILE using GIT-VERSION-GEN
> >  if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)
> > @@ -65,7 +69,9 @@ project(git
> >       VERSION ${git_version}
> >       LANGUAGES C)
> >
> > +
> >  #TODO gitk git-gui gitweb
> > +#TODO Enable NLS on windows natively
> >  #TODO Add pcre support
> >
> >  #macros for parsing the Makefile for sources and scripts
> > @@ -104,6 +110,7 @@ find_package(EXPAT)
> >  find_package(Iconv)
> >  find_package(Intl)
> >
> > +
> >  if(NOT Intl_FOUND)
> >       add_compile_definitions(NO_GETTEXT)
> >       if(NOT Iconv_FOUND)
> > @@ -125,6 +132,14 @@ if(Intl_FOUND)
> >       include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
> >  endif()
> >
> > +
> > +if(WIN32)
> > +     find_program(WINDRES_EXE windres)
> > +     if(NOT WINDRES_EXE)
> > +             message(FATAL_ERROR "Install windres on Windows for resource files")
> > +     endif()
> > +endif()
> > +
> >  find_program(MSGFMT_EXE msgfmt)
> >  if(NOT MSGFMT_EXE)
> >       message(WARNING "Text Translations won't be build")
> > @@ -156,11 +171,35 @@ add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
> >                       BINDIR="bin"
> >                       GIT_BUILT_FROM_COMMIT="")
> >
> > -set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
> > -add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
> > +if(WIN32)
> > +     set(FALLBACK_RUNTIME_PREFIX /mingw64)
> > +     add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
> > +else()
> > +     set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
> > +     add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
> > +endif()
> > +
> > +
> > +#Platform Specific
> > +if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
> > +     include_directories(${CMAKE_SOURCE_DIR}/compat/win32)
> > +     add_compile_definitions(HAVE_ALLOCA_H NO_POSIX_GOODIES NATIVE_CRLF NO_UNIX_SOCKETS WIN32
> > +                             _CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
> > +                             NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0
> > +                             USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
> > +                             UNICODE _UNICODE HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET)
> > +     list(APPEND compat_SOURCES compat/mingw.c compat/winansi.c compat/win32/path-utils.c
> > +             compat/win32/pthread.c compat/win32mmap.c compat/win32/syslog.c
> > +             compat/win32/trace2_win32_process_info.c compat/win32/dirent.c
> > +             compat/nedmalloc/nedmalloc.c compat/strdup.c)
> > +     set(NO_UNIX_SOCKETS 1)
> > +
> > +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
> > +     add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
> > +     list(APPEND compat_SOURCES unix-socket.c)
> > +endif()
> >
> > -add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
> > -list(APPEND compat_SOURCES unix-socket.c)
> > +set(EXE_EXTENSION ${CMAKE_EXECUTABLE_SUFFIX})
> >
> >  #header checks
> >  check_include_file(libgen.h HAVE_LIBGEN_H)
> > @@ -223,7 +262,12 @@ endif()
> >  #function checks
> >  set(function_checks
> >       strcasestr memmem strlcpy strtoimax strtoumax strtoull
> > -     setenv mkdtemp poll pread memmem unsetenv hstrerror)
> > +     setenv mkdtemp poll pread memmem)
> > +
> > +#unsetenv,hstrerror are incompatible with windows build
> > +if(NOT WIN32)
> > +     list(APPEND function_checks unsetenv hstrerror)
> > +endif()
> >
> >  foreach(f ${function_checks})
> >       string(TOUPPER ${f} uf)
> > @@ -444,7 +488,13 @@ unset(CMAKE_REQUIRED_INCLUDES)
> >  #programs
> >  set(PROGRAMS_BUILT
> >       git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
> > -     git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
> > +     git-shell git-remote-testsvn)
> > +
> > +if(NO_UNIX_SOCKETS)
> > +     list(APPEND excluded_progs git-credential-cache git-credential-cache--daemon)
> > +else()
> > +     list(APPEND PROGRAMS_BUILT git-credential-cache git-credential-cache--daemon)
> > +endif()
> >
> >  if(NOT CURL_FOUND)
> >       list(APPEND excluded_progs git-http-fetch git-http-push)
> > @@ -516,15 +566,34 @@ parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
> >  list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
> >  add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
> >
> > +#add git.rc for gcc
> > +if(WIN32)
> > +     add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
> > +                     COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
> > +                             -DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
> > +                             -i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
> > +                     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
> > +                     VERBATIM)
> > +     add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
> > +endif()
> > +
> >  #link all required libraries to common-main
> >  add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)
> > -target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
> > +
> > +target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES})
> >  if(Intl_FOUND)
> >       target_link_libraries(common-main ${Intl_LIBRARIES})
> >  endif()
> >  if(Iconv_FOUND)
> >       target_link_libraries(common-main ${Iconv_LIBRARIES})
> >  endif()
> > +if(WIN32)
> > +     target_link_libraries(common-main ws2_32 ntdll ${CMAKE_BINARY_DIR}/git.res)
> > +     add_dependencies(common-main git-rc)
> > +     target_link_options(common-main PUBLIC -municode -Wl,--nxcompat -Wl,--dynamicbase -Wl,--pic-executable,-e,mainCRTStartup)
> > +elseif(UNIX)
> > +     target_link_libraries(common-main pthread rt)
> > +endif()
>
>
> Small note about pthread.  In CMake land, the typical convention is to
> use the FindThreads module. [1]
>
> To use it, add this to the top-level:
>
>         set(THREADS_PREFER_PTHREAD_FLAG TRUE)
>         find_package(Threads REQUIRED)
>
> and then use the Threads::Threads target with target_link_libraries()
> instead of hard-coding "pthread" here.
>
> That way it'll only use the "-pthread" flag and library links as needed.
>
> I'm not sure if mingw makes this advice moot, but I figured it was worth
> mentioning.
>
> [1] https://cmake.org/cmake/help/latest/module/FindThreads.html
> --
> David

^ permalink raw reply	[flat|nested] 179+ messages in thread

* Re: [PATCH v5 6/8] cmake: support for building git on windows with mingw
  2020-07-01 17:45             ` Sibi Siddharthan
@ 2020-07-01 17:49               ` Sibi Siddharthan
  0 siblings, 0 replies; 179+ messages in thread
From: Sibi Siddharthan @ 2020-07-01 17:49 UTC (permalink / raw)
  To: David Aguilar; +Cc: Sibi Siddharthan via GitGitGadget, git

Sorry for top posting, I realized it only after clicking send :)

^ permalink raw reply	[flat|nested] 179+ messages in thread

end of thread, other threads:[~2020-07-01 17:50 UTC | newest]

Thread overview: 179+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-24  4:01 [PATCH 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
2020-04-24  4:01 ` [PATCH 1/8] Introduce CMake support for configuring Git on Linux Sibi Siddharthan via GitGitGadget
2020-04-24 17:05   ` Danh Doan
2020-04-24 21:06     ` Sibi Siddharthan
2020-04-24 22:56       ` Danh Doan
2020-04-25  3:50         ` Sibi Siddharthan
2020-04-25 13:34     ` Johannes Schindelin
2020-04-25 17:07   ` brian m. carlson
2020-04-25 17:36     ` Randall S. Becker
2020-04-25 18:01       ` Philip Oakley
2020-04-25 18:11     ` Sibi Siddharthan
2020-04-24  4:01 ` [PATCH 2/8] cmake: generate the shell/perl/python scripts and templates, translations Sibi Siddharthan via GitGitGadget
2020-04-24 17:19   ` Danh Doan
2020-04-24 21:19     ` Sibi Siddharthan
2020-04-24  4:01 ` [PATCH 3/8] cmake: installation support for git Sibi Siddharthan via GitGitGadget
2020-04-24 17:23   ` Danh Doan
2020-04-24 21:24     ` Sibi Siddharthan
2020-04-24  4:01 ` [PATCH 4/8] cmake: support for testing git with ctest Sibi Siddharthan via GitGitGadget
2020-04-24 17:28   ` Danh Doan
2020-04-24 21:26     ` Sibi Siddharthan
2020-04-24  4:01 ` [PATCH 5/8] cmake: support for testing git when building out of the source tree Sibi Siddharthan via GitGitGadget
2020-04-24 17:34   ` Danh Doan
2020-04-24 21:32     ` Sibi Siddharthan
2020-04-24 23:09       ` Danh Doan
2020-04-25  3:57         ` Sibi Siddharthan
2020-04-24  4:01 ` [PATCH 6/8] cmake: support for building git on windows with mingw Sibi Siddharthan via GitGitGadget
2020-04-24 17:39   ` Philip Oakley
2020-04-24 20:29     ` Sibi Siddharthan
2020-04-25 11:37       ` Philip Oakley
2020-04-25 12:09         ` Sibi Siddharthan
2020-04-24  4:01 ` [PATCH 7/8] cmake: support for building git on windows with msvc and clang Sibi Siddharthan via GitGitGadget
2020-04-24 17:39   ` Danh Doan
2020-04-24 21:35     ` Sibi Siddharthan
2020-04-24  4:01 ` [PATCH 8/8] ci: modification of main.yml to use cmake for vs-build job Sibi Siddharthan via GitGitGadget
2020-04-24 17:45   ` Danh Doan
2020-04-24 21:41     ` Sibi Siddharthan
2020-04-24 21:44     ` Johannes Schindelin
2020-04-24 18:56 ` [PATCH 0/8] CMake build system for git Junio C Hamano
2020-04-24 19:50   ` Sibi Siddharthan
2020-04-24 21:43     ` Junio C Hamano
2020-04-25  4:09       ` Sibi Siddharthan
2020-04-25 12:56         ` Philip Oakley
2020-04-25 13:29           ` Johannes Schindelin
2020-04-25 14:12             ` Sibi Siddharthan
2020-04-25 14:28               ` Johannes Schindelin
2020-04-25 14:38                 ` Sibi Siddharthan
2020-04-25 14:49                   ` Johannes Schindelin
2020-04-25 14:57                     ` Sibi Siddharthan
2020-04-26  0:41                       ` Danh Doan
2020-04-26  4:30                         ` Sibi Siddharthan
2020-04-25 12:24       ` Johannes Schindelin
2020-04-27 20:08         ` Jeff King
2020-04-27 20:12           ` Jeff King
2020-04-28 13:52             ` Danh Doan
2020-04-28 21:07               ` Jeff King
2020-04-29  8:42                 ` Sibi Siddharthan
2020-05-01 19:32                   ` Johannes Schindelin
2020-05-02 14:31                     ` Sibi Siddharthan
2020-05-02 14:58                       ` Randall S. Becker
2020-05-02 15:48                       ` Junio C Hamano
2020-05-03 15:33                         ` Sibi Siddharthan
2020-05-03 17:21                           ` Junio C Hamano
2020-05-03 19:42                             ` Konstantin Tokarev
2020-05-03 19:50                               ` Junio C Hamano
2020-05-04 14:31                               ` Johannes Schindelin
2020-05-04 21:59                                 ` Konstantin Tokarev
2020-05-05  4:16                                   ` Sibi Siddharthan
2020-05-05  6:16                                     ` Junio C Hamano
2020-05-05 16:23                                       ` Sibi Siddharthan
2020-05-05 18:17                                         ` Junio C Hamano
2020-05-06 18:43                                           ` Sibi Siddharthan
2020-05-07 11:48                                             ` Đoàn Trần Công Danh
2020-05-06 21:27                                         ` Johannes Schindelin
2020-05-07 20:54                                   ` Johannes Schindelin
2020-05-02 13:21                   ` Danh Doan
2020-05-02 14:50                     ` Sibi Siddharthan
2020-05-02 15:02                       ` Danh Doan
2020-05-02 15:16                         ` Sibi Siddharthan
2020-04-27 21:17           ` Junio C Hamano
2020-04-27 21:56             ` Michal Suchánek
2020-04-27 22:09             ` Jeff King
2020-04-27 22:23               ` Elijah Newren
2020-04-27 23:16                 ` Junio C Hamano
2020-04-28  5:36                 ` Jeff King
2020-05-12 16:50 ` [PATCH v2 00/11] " Sibi Siddharthan via GitGitGadget
2020-05-12 16:50   ` [PATCH v2 01/11] Introduce CMake support for configuring Git on Linux Sibi Siddharthan via GitGitGadget
2020-05-12 20:59     ` Junio C Hamano
2020-05-13 20:21       ` Sibi Siddharthan
2020-05-12 16:50   ` [PATCH v2 02/11] cmake: generate the shell/perl/python scripts and templates, translations Sibi Siddharthan via GitGitGadget
2020-05-12 21:19     ` Junio C Hamano
2020-05-13 20:07       ` Sibi Siddharthan
2020-05-12 16:50   ` [PATCH v2 03/11] cmake: installation support for git Sibi Siddharthan via GitGitGadget
2020-05-12 16:50   ` [PATCH v2 04/11] cmake: support for testing git with ctest Sibi Siddharthan via GitGitGadget
2020-05-12 16:50   ` [PATCH v2 05/11] cmake: support for testing git when building out of the source tree Sibi Siddharthan via GitGitGadget
2020-05-12 16:50   ` [PATCH v2 06/11] cmake: support for building git on windows with mingw Sibi Siddharthan via GitGitGadget
2020-05-14 15:25     ` Đoàn Trần Công Danh
2020-05-14 18:27       ` Sibi Siddharthan
2020-05-12 16:50   ` [PATCH v2 07/11] cmake: support for building git on windows with msvc and clang Sibi Siddharthan via GitGitGadget
2020-05-12 16:50   ` [PATCH v2 08/11] cmake: added checks for struct stat and libiconv Sibi Siddharthan via GitGitGadget
2020-05-12 21:16     ` Junio C Hamano
2020-05-13 20:05       ` Sibi Siddharthan
2020-05-14  2:00         ` Junio C Hamano
2020-05-14 15:31     ` Đoàn Trần Công Danh
2020-05-14 18:31       ` Sibi Siddharthan
2020-05-12 16:50   ` [PATCH v2 09/11] cmake: relocated script file contrib/buildsystems Sibi Siddharthan via GitGitGadget
2020-05-12 21:09     ` Junio C Hamano
2020-05-13 20:08       ` Sibi Siddharthan
2020-05-12 16:50   ` [PATCH v2 10/11] cmake: parse the makefile for the sources Sibi Siddharthan via GitGitGadget
2020-05-12 21:03     ` Junio C Hamano
2020-05-13 19:57       ` Sibi Siddharthan
2020-05-13 20:23         ` Junio C Hamano
2020-05-12 16:50   ` [PATCH v2 11/11] ci: modification of main.yml to use cmake for vs-build job Sibi Siddharthan via GitGitGadget
2020-05-12 21:27     ` Junio C Hamano
2020-05-13 19:45       ` Sibi Siddharthan
2020-05-25 19:16         ` Sibi Siddharthan
2020-05-25 20:03           ` Junio C Hamano
2020-05-25 20:56             ` Sibi Siddharthan
2020-05-25 21:40               ` Johannes Schindelin
2020-05-29 13:40   ` [PATCH v3 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
2020-05-29 13:40     ` [PATCH v3 1/8] Introduce CMake support for configuring Git Sibi Siddharthan via GitGitGadget
2020-05-29 19:27       ` Junio C Hamano
2020-05-30 18:50         ` Sibi Siddharthan
2020-05-31 16:17           ` Junio C Hamano
2020-05-30  8:00             ` Johannes Schindelin
2020-05-30 13:17       ` Đoàn Trần Công Danh
2020-05-29 13:40     ` [PATCH v3 2/8] cmake: generate the shell/perl/python scripts and templates, translations Sibi Siddharthan via GitGitGadget
2020-05-29 19:27       ` Junio C Hamano
2020-05-30 18:56         ` Sibi Siddharthan
2020-06-08 20:07           ` Sibi Siddharthan
2020-06-08 22:10             ` Junio C Hamano
2020-05-29 13:40     ` [PATCH v3 3/8] cmake: installation support for git Sibi Siddharthan via GitGitGadget
2020-05-29 13:40     ` [PATCH v3 4/8] cmake: support for testing git with ctest Sibi Siddharthan via GitGitGadget
2020-05-30 13:49       ` Đoàn Trần Công Danh
2020-05-30 19:04         ` Sibi Siddharthan
2020-05-31  1:28           ` Đoàn Trần Công Danh
2020-05-29 13:40     ` [PATCH v3 5/8] cmake: support for testing git when building out of the source tree Sibi Siddharthan via GitGitGadget
2020-05-29 13:40     ` [PATCH v3 6/8] cmake: support for building git on windows with mingw Sibi Siddharthan via GitGitGadget
2020-05-29 13:40     ` [PATCH v3 7/8] cmake: support for building git on windows with msvc and clang Sibi Siddharthan via GitGitGadget
2020-05-30 14:08       ` Đoàn Trần Công Danh
2020-05-30 19:08         ` Sibi Siddharthan
2020-05-29 13:40     ` [PATCH v3 8/8] ci: modification of main.yml to use cmake for vs-build job Sibi Siddharthan via GitGitGadget
2020-05-30 14:14       ` Đoàn Trần Công Danh
2020-05-30 19:13         ` Sibi Siddharthan
2020-06-12 18:29     ` [PATCH v4 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
2020-06-12 18:29       ` [PATCH v4 1/8] Introduce CMake support for configuring Git Sibi Siddharthan via GitGitGadget
2020-06-15 14:00         ` Øystein Walle
2020-06-15 20:04           ` Sibi Siddharthan
2020-06-12 18:29       ` [PATCH v4 2/8] cmake: generate the shell/perl/python scripts and templates, translations Sibi Siddharthan via GitGitGadget
2020-06-12 18:29       ` [PATCH v4 3/8] cmake: installation support for git Sibi Siddharthan via GitGitGadget
2020-06-12 18:29       ` [PATCH v4 4/8] cmake: support for testing git with ctest Sibi Siddharthan via GitGitGadget
2020-06-15 14:02         ` Øystein Walle
2020-06-15 19:45           ` Sibi Siddharthan
2020-06-12 18:29       ` [PATCH v4 5/8] cmake: support for testing git when building out of the source tree Sibi Siddharthan via GitGitGadget
2020-06-12 18:29       ` [PATCH v4 6/8] cmake: support for building git on windows with mingw Sibi Siddharthan via GitGitGadget
2020-06-15 14:03         ` Øystein Walle
2020-06-15 19:47           ` Sibi Siddharthan
2020-06-18  4:43             ` Junio C Hamano
2020-06-18 19:55               ` Sibi Siddharthan
2020-06-18 20:08                 ` Junio C Hamano
2020-06-18 20:40                   ` Sibi Siddharthan
2020-06-18 21:00                     ` Junio C Hamano
2020-06-19 17:15                       ` Sibi Siddharthan
2020-06-19 17:29                         ` Junio C Hamano
2020-06-12 18:29       ` [PATCH v4 7/8] cmake: support for building git on windows with msvc and clang Sibi Siddharthan via GitGitGadget
2020-06-15 14:04         ` Øystein Walle
2020-06-15 19:56           ` Sibi Siddharthan
2020-06-12 18:29       ` [PATCH v4 8/8] ci: modification of main.yml to use cmake for vs-build job Sibi Siddharthan via GitGitGadget
2020-06-26 16:11       ` [PATCH v5 0/8] CMake build system for git Sibi Siddharthan via GitGitGadget
2020-06-26 16:11         ` [PATCH v5 1/8] Introduce CMake support for configuring Git Sibi Siddharthan via GitGitGadget
2020-06-26 16:11         ` [PATCH v5 2/8] cmake: generate the shell/perl/python scripts and templates, translations Sibi Siddharthan via GitGitGadget
2020-06-26 16:11         ` [PATCH v5 3/8] cmake: installation support for git Sibi Siddharthan via GitGitGadget
2020-06-26 16:11         ` [PATCH v5 4/8] cmake: support for testing git with ctest Sibi Siddharthan via GitGitGadget
2020-06-26 16:11         ` [PATCH v5 5/8] cmake: support for testing git when building out of the source tree Sibi Siddharthan via GitGitGadget
2020-06-26 16:11         ` [PATCH v5 6/8] cmake: support for building git on windows with mingw Sibi Siddharthan via GitGitGadget
2020-06-30  7:25           ` David Aguilar
2020-07-01 17:45             ` Sibi Siddharthan
2020-07-01 17:49               ` Sibi Siddharthan
2020-06-26 16:11         ` [PATCH v5 7/8] cmake: support for building git on windows with msvc and clang Sibi Siddharthan via GitGitGadget
2020-06-26 16:11         ` [PATCH v5 8/8] ci: modification of main.yml to use cmake for vs-build job Sibi Siddharthan via GitGitGadget

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).