sapling/eden/scm/Makefile
Lukas Piatkowski c763ab4b40 eden/scm: provide getdeps.py way of building eden/scm on GitHub
Summary:
In order to do what the title says, this diff does:
1. Add the `eden/oss/.../third-party/rust/.../Cargo.toml` files. As mentioned in the previous diff, those are required by GitHub so that the third party dependencies that are local in fbsource are properly defined with a "git" dependency in order for Cargo to "link" crates properly.
2. Changes to `eden/scm/Makefile` to add build/install commands for getdeps to invoke. Those command knowing that they are called from withing getdeps context they link the dependencies brought by getdeps into their proper places that match their folder layout in fbsource. Those Makefile commands also pass a GETDEPS_BUILD env to the setup.py invocations so that it knows it is being called withing a getdeps build.
3. Changes to `eden/scm/setup.py` that add "thriftasset" that makes use of the getdeps.py provided "thrift" binary to build .py files out of thrift files.
4. Changes to `distutils_rust` to use the vendored crates dir provided by getdeps.
5. Changes to `getdeps/builder.py` and `getdeps/manifest.py` that enable more fine-grained configuratior of how Makefile builds are invoked.
6. Changes to `getdeps/buildopts.py` and `getdeps/manifest.py` to disable overriding PATH and pkgconfig env, so that "eden/scm" builds in getdeps using system libraries rather than getdeps-provided ones (NOTE: I've tried to use getdeps provided libraries, but the trickiest bit was that Rust links with Python, which is currently not providable by getdeps, so if you try to build everything the system provided Python libraries will collide with getdeps provided ones)
7. Added `opensource/fbcode_builder/manifests/eden_scm` for the getdeps build.

Reviewed By: quark-zju

Differential Revision: D22336485

fbshipit-source-id: 244d10c9e06ee83de61e97e62a1f2a2184d2312f
2020-07-02 17:53:37 -07:00

192 lines
6.2 KiB
Makefile

# Portions Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
# Copyright Matt Mackall <mpm@selenic.com> and others
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
# If you want to change PREFIX, do not just edit it below. The changed
# value wont get passed on to recursive make calls. You should instead
# override the variable on the command like:
#
# % make PREFIX=/opt/ install
export PREFIX=/usr/local
ifeq ($(OS),Windows_NT)
PYTHON := python
else
PYTHON := python2
endif
PYTHON3 := python3.6
$(eval HGROOT := $(shell pwd))
HGPYTHONS ?= $(HGROOT)/build/pythons
PURE=
PYFILES:=$(shell find mercurial hgext -name '*.py' 2>/dev/null)
DOCFILES=edenscm/mercurial/help/*.txt
export LANGUAGE=C
export LC_ALL=C
TESTFLAGS ?= $(shell echo $$HGTESTFLAGS)
OSXVERSIONFLAGS ?= $(shell echo $$OSXVERSIONFLAGS)
HGNAME ?= hg
HGNAME3 ?= hg3
# Set this to e.g. "mingw32" to use a non-default compiler.
COMPILER=
COMPILERFLAG_tmp_ =
COMPILERFLAG_tmp_${COMPILER} ?= -c $(COMPILER)
COMPILERFLAG=${COMPILERFLAG_tmp_${COMPILER}}
help:
@echo 'Commonly used make targets:'
@echo ' all - build program'
@echo ' install - install program and man pages to $$PREFIX ($(PREFIX))'
@echo ' install-home - install with setup.py install --home=$$HOME ($(HOME))'
@echo ' local - build for inplace usage'
@echo ' tests - run all tests in the automatic test suite'
@echo ' test-foo - run only specified tests (e.g. test-merge1.t)'
@echo ' dist - run all tests and create a source tarball in dist/'
@echo ' clean - remove files created by other targets'
@echo ' (except installed files or dist source tarball)'
@echo ' update-pot - update i18n/hg.pot'
@echo
@echo 'Example for a system-wide installation under /usr/local:'
@echo ' make all && su -c "make install" && hg version'
@echo
@echo 'Example for a local installation (usable in this directory):'
@echo ' make local && ./hg version'
all: build
local:
$(PYTHON) setup.py $(PURE) \
build_py -c -d . \
build_clib $(COMPILERFLAG) \
build_ext $(COMPILERFLAG) -i \
build_rust_ext -i -l $(RFLAG)\
build_pyzip -i \
build_mo
ifeq ($(OS),Windows_NT)
cp build/scripts-2.7/$(HGNAME).exe $(HGNAME).exe
else
$(RM) $(HGNAME)
cp build/scripts-2.7/$(HGNAME) $(HGNAME)
endif
local3:
HGNAME=$(HGNAME3) $(PYTHON3) setup3.py $(PURE) \
build_py -c -d . \
build_clib $(COMPILERFLAG) \
build_ext $(COMPILERFLAG) -i \
build_rust_ext -i -l $(RFLAG)\
build_pyzip -i \
build_mo
ifeq ($(OS),Windows_NT)
cp build/scripts-3*/$(HGNAME3).exe $(HGNAME3).exe
else
$(RM) $(HGNAME3)
cp build/scripts-3*/$(HGNAME3) $(HGNAME3)
endif
build:
$(PYTHON) setup.py $(PURE) build $(COMPILERFLAG)
wheel:
FORCE_SETUPTOOLS=1 $(PYTHON) setup.py $(PURE) bdist_wheel $(COMPILERFLAG)
getdepshelper:
ifeq ($(OS),Windows_NT)
mkdir ../../../../build/eden_scm
mklink ../../../../build/eden_scm build
mklink ../fbthrift/thrift ../../thrift
nklink ../fb303/fb303 ../../fb303
mkdir ../../common/rust
mklink ../../../rust-shed/shed ../../common/rust/shed
else
mkdir -p ../../../../build/eden_scm
ln -sf ../../../../build/eden_scm build
ln -sf ../fbthrift/thrift ../../thrift
ln -sf ../fb303/fb303 ../../fb303
mkdir -p ../../common/rust
ln -sf ../../../rust-shed/shed ../../common/rust/shed
endif
getdepsbuild: export GETDEPS_BUILD=1
getdepsbuild: getdepshelper build
cleanbutpackages:
-$(PYTHON) setup.py clean --all # ignore errors from this command
-$(PYTHON3) setup3.py clean --all # ignore errors from this command
find contrib doc i18n edenscm edenscmnative tests \
\( -name '*.py[cdo]' -o -name '*.so' \) -exec rm -f '{}' ';'
rm -f MANIFEST MANIFEST.in edenscm/hgext/__index__.py tests/*.err
rm -f edenscm/mercurial/__modulepolicy__.py
if test -d .hg; then rm -f edenscm/mercurial/__version__.py; fi
rm -rf build/*
rm -rf build edenscm/mercurial/locale
ifeq ($(OS),Windows_NT)
$(RM) -r hg-python $(HGNAME).exe python27.dll
else
$(RM) $(HGNAME)
endif
clean: cleanbutpackages
rm -rf packages
install: build
$(PYTHON) setup.py $(PURE) install --root="$(DESTDIR)/" --prefix="$(PREFIX)" --force
install-home: build
$(PYTHON) setup.py $(PURE) install --home="$(HOME)" --prefix="" --force
install-getdeps: export GETDEPS_BUILD=1
install-getdeps: getdepsbuild
$(PYTHON) setup.py $(PURE) install --root="$(DESTDIR)/" --prefix="$(PREFIX)" --force
check: tests
update-pot: i18n/hg.pot
i18n/hg.pot: $(PYFILES) $(DOCFILES) i18n/posplit i18n/hggettext
$(PYTHON) i18n/hggettext edenscm/mercurial/commands.py \
edenscm/hgext/*.py edenscm/hgext/*/__init__.py \
edenscm/mercurial/fileset.py edenscm/mercurial/revset.py \
edenscm/mercurial/templatefilters.py edenscm/mercurial/templatekw.py \
edenscm/mercurial/templater.py \
edenscm/mercurial/filemerge.py \
edenscm/mercurial/hgweb/webcommands.py \
edenscm/mercurial/util.py \
$(DOCFILES) > i18n/hg.pot.tmp
# All strings marked for translation in Mercurial contain
# ASCII characters only. But some files contain string
# literals like this '\037\213'. xgettext thinks it has to
# parse them even though they are not marked for translation.
# Extracting with an explicit encoding of ISO-8859-1 will make
# xgettext "parse" and ignore them.
echo $(PYFILES) | xargs \
xgettext --package-name "Mercurial" \
--msgid-bugs-address "<mercurial-devel@mercurial-scm.org>" \
--copyright-holder "Matt Mackall <mpm@selenic.com> and others" \
--from-code ISO-8859-1 --join --sort-by-file --add-comments=i18n: \
--keyword=_n:1,2 -d hg -p i18n -o hg.pot.tmp
$(PYTHON) i18n/posplit i18n/hg.pot.tmp
# The target file is not created before the last step. So it never is in
# an intermediate state.
mv -f i18n/hg.pot.tmp i18n/hg.pot
%.po: i18n/hg.pot
# work on a temporary copy for never having a half completed target
cp $@ $@.tmp
msgmerge --no-location --update $@.tmp $^
mv -f $@.tmp $@
# Packaging targets
.PHONY: help all local local3 build cleanbutpackages clean install install-home install-getdeps getdepsbuild getdepshelper