Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use autotools instead of GYP to build libuv; works on Windows #45

Merged
merged 2 commits into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ _release/
_esy/
*esy.lock/
node_modules/
libuv-scratch/
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "src/c/vendor/gyp"]
path = src/c/vendor/gyp
url = https://chromium.googlesource.com/external/gyp.git
[submodule "src/c/vendor/libuv"]
path = src/c/vendor/libuv
url = https://github.com/libuv/libuv.git
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ before_script:
- opam list

script:
- make check-ejected-build
- '[ ! -d _cache/_build ] || cp -r _cache/_build .'
- make
- make test
- '[ "$REVDEPS" != yes ] || make examples'
- mkdir -p _cache
Expand Down
38 changes: 35 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,40 @@ test-installation-ci :
opam remove -y luv
opam pin remove -y luv

AUTOGEN_OUTPUT := src/c/vendor/configure
AUTOGEN_SCRATCH := libuv-scratch

.PHONY : eject-build
eject-build :
rm -rf $(AUTOGEN_SCRATCH)
cp -r src/c/vendor/libuv $(AUTOGEN_SCRATCH)
(cd $(AUTOGEN_SCRATCH) && ./autogen.sh)
rm -rf $(AUTOGEN_OUTPUT)
mkdir -p $(AUTOGEN_OUTPUT)
mkdir -p $(AUTOGEN_OUTPUT)/m4
(diff -qr src/c/vendor/libuv $(AUTOGEN_SCRATCH) || true) \
| sed 's#^Only in ##' \
| sed 's#: #/#' \
| sed 's#^$(AUTOGEN_SCRATCH)/##' \
| xargs -I FILE cp -r $(AUTOGEN_SCRATCH)/FILE $(AUTOGEN_OUTPUT)/FILE
rm -rf $(AUTOGEN_SCRATCH)
(cd $(AUTOGEN_OUTPUT) && rm -rf aclocal.m4 autom4te.cache m4)
(cd src/c/vendor/libuv && git rev-parse HEAD) \
> $(AUTOGEN_OUTPUT)/commit-hash

.PHONY : check-ejected-build
check-ejected-build :
@((cd src/c/vendor/libuv && git rev-parse HEAD) \
| diff $(AUTOGEN_OUTPUT)/commit-hash -) || \
(echo; \
echo The vendored configure script is out of sync with libuv. Run; \
echo; \
echo " make eject-build"; \
echo; \
echo and commit the changes to $(AUTOGEN_OUTPUT).; \
echo; \
false)

.PHONY : docs
docs : api-docs luvbook

Expand Down Expand Up @@ -127,12 +161,10 @@ VERSION := $(shell git describe --abbrev=0)
RELEASE := luv-$(VERSION)

.PHONY : release
release : clean
release : check-ejected-build clean
rm -rf $(RELEASE) $(RELEASE).tar $(RELEASE).tar.gz _release
mkdir $(RELEASE)
cp -r dune-project LICENSE.md luv.opam README.md src $(RELEASE)
rm -rf $(RELEASE)/src/c/vendor/gyp/test
rm -rf $(RELEASE)/src/c/vendor/gyp/tools
rm -rf $(RELEASE)/src/c/vendor/libuv/docs
rm -rf $(RELEASE)/src/c/vendor/libuv/img
sed -i "s/version: \"dev\"/version: \"$(VERSION)\"/" $(RELEASE)/luv.opam
Expand Down
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,6 @@ Luv has several pieces, with slightly different permissive licenses:
generally include the full libuv source. Portions of libuv are variously
[licensed][libuv-license] under the MIT, 2-clause BSD, 3-clause BSD, and ISC
licenses.
- Similarly, this repo links to [gyp][gyp], which is part of the libuv build
process, and is included in Luv release archives. gyp is
[licensed][gyp-license] under the 3-clause BSD license.
- The user guide is a very heavily reworked version of [uvbook][uvbook],
originally by Nikhil Marathe, which was incorporated into the libuv docs as
the [libuv user guide][libuv-guide], and made available under
Expand All @@ -200,10 +197,8 @@ Luv has several pieces, with slightly different permissive licenses:
[libuv-docs]: http://docs.libuv.org/en/v1.x/
[experiment]: https://aantron.github.io/luv/introduction.html
[lwt]: https://github.com/ocsigen/lwt#readme
[gyp]: https://gyp.gsrc.io/
[license]: https://github.com/aantron/luv/blob/master/LICENSE.md
[libuv-license]: https://github.com/libuv/libuv/blob/v1.x/LICENSE
[gyp-license]: https://chromium.googlesource.com/external/gyp/+/refs/heads/master/LICENSE
[uvbook]: https://github.com/nikhilm/uvbook
[libuv-guide]: http://docs.libuv.org/en/v1.x/guide.html
[guide-license]: https://github.com/aantron/luv/blob/master/docs/LICENSE
Expand Down
1 change: 0 additions & 1 deletion luv.opam
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ dev-repo: "git+https://github.com/aantron/luv.git"

depends: [
"base-unix" {build}
"conf-python-3" {build}
"ctypes" {>= "0.13.0"}
"dune" {>= "2.0.0"}
"ocaml" {>= "4.02.0"}
Expand Down
9 changes: 0 additions & 9 deletions src/c/copy-so.ml

This file was deleted.

32 changes: 17 additions & 15 deletions src/c/dune
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,24 @@

; The vendored libuv.
(rule
(targets libuv.a dlluv.so)
(deps (source_tree vendor) link-gyp.ml copy-so.ml)
(targets libuv.a dlluv%{ext_dll})
(deps (source_tree vendor))
(action (progn
(run ocaml link-gyp.ml)
(chdir vendor/libuv
(run python3 gyp_uv.py -f make -Duv_library=static_library))
(setenv CFLAGS -fPIC
(setenv BUILDTYPE Release
(run make -C vendor/libuv/out libuv)))
(run cp vendor/libuv/out/Release/libuv.a libuv.a)
(chdir vendor/libuv
(run python3 gyp_uv.py -f make -Duv_library=shared_library))
(setenv CFLAGS -fPIC
(setenv BUILDTYPE Release
(run make -C vendor/libuv/out libuv)))
(run ocaml copy-so.ml))))
(bash "cp -r vendor/configure/* vendor/libuv/")
(chdir vendor/libuv (progn
(bash
"sh configure --host `ocamlc -config | awk '/host/ {print $NF}'` \
'CC=%{cc}' CFLAGS=-DNDEBUG --silent --enable-silent-rules")
(ignore-outputs (bash
"make V=0 -o aclocal.m4 -o Makefile.in -o configure -o configure.status \
-o Makefile libuv.la"))
(ignore-outputs (bash
"sh libtool --silent --no-warnings --mode install cp libuv.la `pwd`"))))
(bash "cp vendor/libuv/libuv.a .")
(bash
"cp vendor/libuv/libuv.so.1.0.0 dlluv.so || \
cp vendor/libuv/libuv.1.dylib dlluv.so || \
cp vendor/libuv/libuv.dll.a dlluv.dll"))))

(data_only_dirs vendor)

Expand Down
10 changes: 0 additions & 10 deletions src/c/link-gyp.ml

This file was deleted.

Loading