* [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
* 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 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
* [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
* 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 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
* [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
* 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 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
* [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
* 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 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 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 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 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
* [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
* 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 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
* [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
* 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 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 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
* [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 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 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
* 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 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 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 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
* [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
* 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 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 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 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
* 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 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 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
* [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
* 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 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
* [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 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 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
* [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
* 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 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
* [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
* 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 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
* [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
* 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 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 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 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
* 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 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
* [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
* [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
* 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
* [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