Commit Graph

22 Commits

Author SHA1 Message Date
Kostia Balytskyi
1ec25289aa distutils_rust: add support for features
Summary: We want this for `hgdev` features.

Reviewed By: markbt

Differential Revision: D10217919

fbshipit-source-id: 47d07162efb676e014ef427a4c199041999630b2
2018-10-12 14:55:09 -07:00
Jun Wu
21c22375e0 distutils_rust: download Rust automatically
Summary:
We have seen build errors on platforms like Ubuntu due to an old version of
Rust was installed. Upgrading Rust on all platforms supported by Mercurial
could be fairly painful. Therefore just install Rust directly as part of the
build step.

This patch changes `distutils_rust` to install Rust to `build/` and use `cargo`
from there.

Reviewed By: singhsrb

Differential Revision: D9985861

fbshipit-source-id: 07ddd3880b11ac67822333352290ad30b3b14b79
2018-09-21 17:35:23 -07:00
Jun Wu
b9e5d34651 distutils_rust: reformat
Summary: Solves a "trailing spaces" issue complained by test-check-code.t

Reviewed By: phillco

Differential Revision: D9815679

fbshipit-source-id: f7e93ea69a1462a3ac1cd675f181d5cd0bdbc5f5
2018-09-13 13:26:32 -07:00
Kostia Balytskyi
0380c26787 hg: make distutils_rust support long paths on Windows
Summary:
This makes sure that we can instruct `setup.py` to make every Rust binary
long-paths aware on Windows. Yay.

Reviewed By: markbt

Differential Revision: D9809915

fbshipit-source-id: e58787d41c7e8bc5698283fd67dfb3cc6d21321d
2018-09-13 09:35:18 -07:00
Kostia Balytskyi
cf2ddc6ae6 hg.rust: add support for rust binary in setup.py and make local
Summary:
This causes `make local` to build the new binary, copy the result into the
`.../hg` dir and rename it into `hg.rust` (while `hgmain` seems like a good
crate name, it seems like the binary should be called `hg.rust`, at least for
now)

Reviewed By: quark-zju

Differential Revision: D9218057

fbshipit-source-id: 49a0e09ae78b8cdb64c7158da3bb4179a47d4af9
2018-08-17 10:51:47 -07:00
Jun Wu
7e746bab1e distutils_rust: move download_vendored_crates to fb/
Summary:
`download_vendored_crates` is fb LFS specific. Therefore move it.
This should also fix the OSS build.

Reviewed By: DurhamG

Differential Revision: D8944876

fbshipit-source-id: 8cb85bec9d74d60c839a6f7f90b036d5be282bb0
2018-07-20 17:37:57 -07:00
Jun Wu
e69a04e705 distutils_rust: fix check-code
Summary: `raise Exception` is forbidden by check-code.

Reviewed By: DurhamG

Differential Revision: D8944877

fbshipit-source-id: 8c6fda3a428a7e95d3b5b2a7f94f37e045423cb7
2018-07-20 17:37:57 -07:00
Kostia Balytskyi
a7a555e755 lfs: attempt 2 to fix paths after the refactoring
Reviewed By: singhsrb

Differential Revision: D8935124

fbshipit-source-id: 239a3a6181f7f2ec11b0861f35ad36bef04abe80
2018-07-20 10:06:05 -07:00
Durham Goode
11bfd6564f lfs: fix lfs pointer paths
Summary:
A recent refactor changed the location of the lfs helper, but a number
of paths weren't correct so this broke make local. This fixes them.

Reviewed By: singhsrb

Differential Revision: D8922233

fbshipit-source-id: 90b2997c702aabb352052a410d82554dfa083526
2018-07-19 14:21:04 -07:00
Kostia Balytskyi
d70332c0c1 lfs: migrate hg to use a moved version of lfs
Summary:
We need to tweak users of `lfs` to (a) use if from the new location (b) pass
`-l` if `lfs.py` is used on the command line

Reviewed By: quark-zju

Differential Revision: D8894564

fbshipit-source-id: 652b0b4eba00fd1361f10b41a4c749ad4df7bb5f
2018-07-19 11:41:40 -07:00
Liubov Dmitrieva
c7b0012cfe build: build rust binaries
Summary:
build rust binaries as part of mercurial build

by default they appear together with hg and chg in the folder called scripts but it can be configured.

Reviewed By: quark-zju

Differential Revision: D8270436

fbshipit-source-id: df928b89e6530c285c3eab438769c53f545d4098
2018-06-05 03:53:25 -07:00
Jun Wu
584656dff3 codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).

Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.

Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.

An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.

As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.

Reviewed By: wez, phillco, simpkins, pkaush, singhsrb

Differential Revision: D8173629

fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-25 22:17:29 -07:00
Jun Wu
4b81417575 setup: remove Cargo.lock automatically
Summary:
When building Rust extensions, remove Cargo.lock automatically so they
always get regenerated. This avoids issues when vendored crates are upgraded
but the local Cargo.lock is still using old versions.

Reviewed By: DurhamG

Differential Revision: D7562864

fbshipit-source-id: 25187ef2c5a9be8d6059f02a1113f3ddb55ebe99
2018-04-21 03:42:58 -07:00
Jun Wu
7de540805d setup: build rust extensions in a shared directory
Summary:
This avoids building shared dependencies (ex. regex) over and over. The only
downside is cargo will take a lock and cannot build projects in parallel.
But `setup.py` does not support building extensions in parallel. So it's
fine.

Changed `matcher` to also enable lto like existing extensions, so `cpython`
build result can be reused.

Before (on devserver):

  $ time python setup.py build_rust_ext
  real    2m19.401s
  user    3m35.118s
  sys     0m8.277s
  $ du -hs build/temp.linux-x86_64-2.7/
  115M    build/temp.linux-x86_64-2.7/

After:

  $ time python setup.py build_rust_ext
  real    2m4.371s
  user    2m25.864s
  sys     0m5.198s
  $ du -hs build/temp.linux-x86_64-2.7/
  58M     build/temp.linux-x86_64-2.7/

`cargo` builds things in parallel. The speed improvement would be more
significant on laptops.

Differential Revision: D7512429

fbshipit-source-id: 378e721890bdfe53c8adbe364ad5f0b374023ff5
2018-04-13 21:51:49 -07:00
Kostia Balytskyi
0b9d49d16a windows: fix build_nupkg.py to work in a new setup
Summary: We probably want this script to work going forward. A lot of cleanup is needed, but at least now it produces a working binary.

Differential Revision: D6770776

fbshipit-source-id: dc2d44bd66e16c5bee53aadf262d6d3dee2fea96
2018-04-13 21:50:54 -07:00
Mark Thomas
32a26237e8 distutils_rust: untar vendored crates to correct location
Summary:
The vendored crates currently untar to build/build.  Now that the build script
chdirs to build/, there's no need to pass that to tarfile.extractall.

Test Plan: `make clean ; make local`

Reviewers: quark, #mercurial

Reviewed By: quark

Differential Revision: https://phabricator.intern.facebook.com/D6713510

Signature: 6713510:1515785178:042124a6592aa04ab1e6748596f6615cd61e8df3
2018-01-12 11:34:24 -08:00
Jun Wu
32d36d135d distutils_rust: download vendored crates from LFS
Summary: Switch from dewey to in-repo LFS utility.

Test Plan:
Run `make local` on my Arch Linux. Check `hg-vendored-crates.tar.gz` was
downloaded and stored in `build/`. Run `make local` again and make sure it
says:

  hg-vendored-crates.tar.gz was already downloaded and up-to-date

Reviewers: mbthomas, #mercurial

Reviewed By: mbthomas

Differential Revision: https://phabricator.intern.facebook.com/D6706906

Signature: 6706906:1515723430:233ccbb47286dbc4e5d856ff4b20c848b281928c
2018-01-11 17:16:44 -08:00
Mark Thomas
75980fb243 build: vendor in Rust dependencies
Summary:
Rust dependencies are vendored in by downloading a package containing all Rust
dependencies.

The package can be updated using the new `vendorcrates.py` script.

Test Plan: Build using the vendored packages.

Reviewers: quark, #mercurial

Reviewed By: quark

Differential Revision: https://phabricator.intern.facebook.com/D6689642

Tasks: T24908724

Signature: 6689642:1515548647:8051ec3dadd98873f0312bb67978846ba029b558
2018-01-09 17:48:32 -08:00
Jun Wu
fb45633a19 distutils_rust: use atomic replace to install the .so file
Summary:
Python loads .so using mmap. Rewriting a .so in-place when there is a Python
process with that .so mmap-ed could crash that Python process. Therefore
let's avoid rewriting the destination .so in-place.

This was discovered by a txnclose Python hook I used to keep binaries
up-to-date. It caused segfault after building the Rust extensions currently
loaded by the Python process running the hook.

Test Plan: `hg push` triggering that txnclose hook won't crash on the remote.

Reviewers: durham, #sourcecontrol

Reviewed By: durham

Differential Revision: https://phabricator.intern.facebook.com/D6686739

Signature: 6686739:1515532516:24c0b7066ff15a39a7bd824e779569f4a886d7df
2018-01-09 13:05:51 -08:00
Phil Cohen
c0545cf009 build: fix issue if destdir is missing
Summary: Fixes an issue where the build would fail if the directory had not been made.

Test Plan: ./setup.py build works now

Reviewers: mbthomas, #mercurial

Differential Revision: https://phabricator.intern.facebook.com/D6681061
2018-01-08 19:29:53 -08:00
Mark Thomas
c9db9d4c02 checks: fixup test-check-module-imports for rust changes
Summary:
Fix up test-check-module-imports, mostly by using absolute imports where
possible.

Also, some lfs errors have been removed, so remove their tests failures too.

Test Plan: Run test-check-module-imports test.

Reviewers: durham, #mercurial

Reviewed By: durham

Differential Revision: https://phabricator.intern.facebook.com/D6679241

Tasks: T24908724

Signature: 6679241:1515457419:2f8683206c8d43af99254c9f75f08af374673c2f
2018-01-08 17:01:31 -08:00
Mark Thomas
2e81565606 fb-hgext: integrate rust libraries and extensions with setup.py
Summary:
Move the rust libraries and extensions to their new locations, and integrate
them with the hg-crew setup.py.

Test Plan: Run `python setup.py build` and verify rust extensions are built.

Reviewers: durham, #mercurial

Reviewed By: durham

Subscribers: fried, jsgf, mitrandir

Differential Revision: https://phabricator.intern.facebook.com/D6677251

Tasks: T24908724

Signature: 6677251:1515450235:920faf40babbce9b09e3283ff9ca328d1c5c51e6
2018-01-08 15:26:24 -08:00