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

Migration to dune #8801

Merged
merged 26 commits into from
Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,6 @@ tests/display/.unittest/
tests/unit/.unittest/
tests/threads/export/
tests/server/test.js.map
*.merlin
lib.sexp
src/compiler/version.ml
14 changes: 0 additions & 14 deletions .merlin

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.0.0",
"version": "2.0.0",
"tasks": [
{
"label": "make: haxe",
Expand Down
136 changes: 10 additions & 126 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ PACKAGE_SRC_EXTENSION=.tar.gz
MAKEFILENAME?=Makefile
PLATFORM?=unix

DUNE_COMMAND=dune
HAXE_OUTPUT=haxe
HAXELIB_OUTPUT=haxelib
PREBUILD_OUTPUT=prebuild
Expand All @@ -30,48 +31,6 @@ STATICLINK?=0

# Configuration

# Modules in these directories should only depend on modules that are in directories to the left
HAXE_DIRECTORIES=core core/ds core/json core/display syntax context context/display codegen codegen/gencommon generators generators/jvm optimization filters macro macro/eval macro/eval/bytes typing compiler
EXTLIB_LIBS=extlib-leftovers extc neko javalib swflib ttflib ilib objsize pcre ziplib
OCAML_LIBS=unix str threads dynlink
OPAM_LIBS=sedlex.ppx xml-light extlib ptmap sha

FINDLIB_LIBS=$(OCAML_LIBS)
FINDLIB_LIBS+=$(OPAM_LIBS)

# Includes, packages and compiler

HAXE_INCLUDES=$(HAXE_DIRECTORIES:%=-I _build/src/%)
EXTLIB_INCLUDES=$(EXTLIB_LIBS:%=-I libs/%)
ALL_INCLUDES=$(EXTLIB_INCLUDES) $(HAXE_INCLUDES)
FINDLIB_PACKAGES=$(FINDLIB_LIBS:%=-package %)
CFLAGS=
ALL_CFLAGS=-bin-annot -safe-string -thread -g -w -3 -w -40 $(CFLAGS) $(ALL_INCLUDES) $(FINDLIB_PACKAGES)

MESSAGE_FILTER=sed -e 's/_build\/src\//src\//' tmp.tmp

ifeq ($(BYTECODE),1)
TARGET_FLAG = bytecode
COMPILER = ocamlfind ocamlc
LIB_EXT = cma
MODULE_EXT = cmo
NATIVE_LIB_FLAG = -custom
else
TARGET_FLAG = native
COMPILER = ocamlfind ocamlopt
LIB_EXT = cmxa
MODULE_EXT = cmx
OCAMLDEP_FLAGS = -native
endif

CC_CMD = ($(COMPILER) $(ALL_CFLAGS) -c $< 2>tmp.tmp && $(MESSAGE_FILTER)) || ($(MESSAGE_FILTER) && exit 1)

# Meta information

BUILD_DIRECTORIES := $(HAXE_DIRECTORIES:%=_build/src/%)
HAXE_SRC := $(wildcard $(HAXE_DIRECTORIES:%=src/%/*.ml))
BUILD_SRC := $(HAXE_SRC:%=_build/%)

ADD_REVISION?=0

BRANCH=$(shell echo $$APPVEYOR_REPO_NAME | grep -q /haxe && echo $$APPVEYOR_REPO_BRANCH || echo $$TRAVIS_REPO_SLUG | grep -q /haxe && echo $$TRAVIS_BRANCH || git rev-parse --abbrev-ref HEAD)
Expand All @@ -87,94 +46,26 @@ PACKAGE_FILE_NAME=haxe_$(COMMIT_DATE)_$(COMMIT_SHA)
HAXE_VERSION=$(shell $(CURDIR)/$(HAXE_OUTPUT) -version 2>&1 | awk '{print $$1;}')
HAXE_VERSION_SHORT=$(shell echo "$(HAXE_VERSION)" | grep -oE "^[0-9]+\.[0-9]+\.[0-9]+")

# using $(CURDIR) on Windows will not work since it might be a Cygwin path
ifdef SYSTEMROOT
EXTENSION=.exe
else
export HAXE_STD_PATH=$(CURDIR)/std
endif

# Native libraries

ifneq ($(STATICLINK),0)
LIB_PARAMS= -cclib '-Wl,-Bstatic -lpcre -lz -Wl,-Bdynamic '
else
LIB_PARAMS?= -cclib -lpcre -cclib -lz
endif

NATIVE_LIBS=-thread -cclib libs/extc/extc_stubs.o -cclib libs/extc/process_stubs.o -cclib libs/objsize/c_objsize.o -cclib libs/pcre/pcre_stubs.o -ccopt -L/usr/local/lib $(LIB_PARAMS)

# Modules

-include Makefile.modules

# Rules

all: libs haxe tools

libs:
$(foreach lib,$(EXTLIB_LIBS),$(MAKE) -C libs/$(lib) $(TARGET_FLAG) &&) true

_build/%:%
mkdir -p $(dir $@)
cp $< $@

build_dirs:
@mkdir -p $(BUILD_DIRECTORIES)

_build/src/syntax/grammar.ml:src/syntax/grammar.mly
camlp5o -impl $< -o $@

_build/src/compiler/version.ml: FORCE
ifneq ($(ADD_REVISION),0)
$(MAKE) -f Makefile.version_extra -s --no-print-directory ADD_REVISION=$(ADD_REVISION) BRANCH=$(BRANCH) COMMIT_SHA=$(COMMIT_SHA) COMMIT_DATE=$(COMMIT_DATE) > _build/src/compiler/version.ml
else
echo let version_extra = None > _build/src/compiler/version.ml
endif

_build/src/core/defineList.ml: src-json/define.json prebuild
./$(PREBUILD_OUTPUT) define $< > $@

_build/src/core/metaList.ml: src-json/meta.json prebuild
./$(PREBUILD_OUTPUT) meta $< > $@

build_src: | $(BUILD_SRC) _build/src/syntax/grammar.ml _build/src/compiler/version.ml _build/src/core/defineList.ml _build/src/core/metaList.ml

prebuild: _build/src/core/json/json.ml _build/src/prebuild/main.ml
$(COMPILER) -safe-string -linkpkg -g -o $(PREBUILD_OUTPUT) -package sedlex.ppx -package extlib -I _build/src/core/json _build/src/core/json/json.ml _build/src/prebuild/main.ml
all: haxe tools

haxe: build_src
$(MAKE) -f $(MAKEFILENAME) build_pass_1
$(MAKE) -f $(MAKEFILENAME) build_pass_2
$(MAKE) -f $(MAKEFILENAME) build_pass_3
$(MAKE) -f $(MAKEFILENAME) build_pass_4

build_pass_1:
printf MODULES= > Makefile.modules
ls -1 $(HAXE_DIRECTORIES:%=_build/src/%/*.ml) | tr '\n' ' ' >> Makefile.modules

build_pass_2:
printf MODULES= > Makefile.modules
ocamlfind ocamldep -sort -slash $(HAXE_INCLUDES) $(MODULES) | sed -e "s/\.ml//g" >> Makefile.modules

build_pass_3:
ocamlfind ocamldep -slash $(OCAMLDEP_FLAGS) $(HAXE_INCLUDES) $(MODULES:%=%.ml) > Makefile.dependencies

build_pass_4: $(MODULES:%=%.$(MODULE_EXT))
$(COMPILER) -safe-string -linkpkg -g -o $(HAXE_OUTPUT) $(NATIVE_LIBS) $(NATIVE_LIB_FLAG) $(LFLAGS) $(FINDLIB_PACKAGES) $(EXTLIB_INCLUDES) $(EXTLIB_LIBS:=.$(LIB_EXT)) $(MODULES:%=%.$(MODULE_EXT))
haxe:
$(DUNE_COMMAND) build --workspace dune-workspace.dev src-prebuild/prebuild.exe
_build/default/src-prebuild/prebuild.exe libparams $(LIB_PARAMS) > lib.sexp
_build/default/src-prebuild/prebuild.exe version $(ADD_REVISION) $(BRANCH) $(COMMIT_SHA) > src/compiler/version.ml
$(DUNE_COMMAND) build --workspace dune-workspace.dev src/haxe.exe
cp -f _build/default/src/haxe.exe ./${HAXE_OUTPUT}

kill_exe_win:
ifdef SYSTEMROOT
-@taskkill /F /IM haxe.exe 2>/dev/null
endif

plugin:
ifeq ($(BYTECODE),1)
$(CC_CMD) $(PLUGIN).ml
else
$(COMPILER) $(ALL_CFLAGS) -shared -o $(PLUGIN).cmxs $(PLUGIN).ml
endif

# Only use if you have only changed gencpp.ml
quickcpp: build_src build_pass_4 copy_haxetoolkit

Expand Down Expand Up @@ -213,10 +104,6 @@ uninstall:
opam_install:
opam install $(OPAM_LIBS) camlp5 ocamlfind --yes

# Dependencies

-include Makefile.dependencies

# Package

package_src:
Expand Down Expand Up @@ -300,10 +187,7 @@ package_installer_mac: $(INSTALLER_TMP_DIR)/neko-osx64.tar.gz package_unix

# Clean

clean: clean_libs clean_haxe clean_tools clean_package

clean_libs:
$(foreach lib,$(EXTLIB_LIBS),$(MAKE) -C libs/$(lib) clean &&) true
clean: clean_haxe clean_tools clean_package

clean_haxe:
rm -f -r _build $(HAXE_OUTPUT) $(PREBUILD_OUTPUT)
Expand All @@ -324,4 +208,4 @@ FORCE:
.ml.cmo:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need the suffix rules?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not.

I was thinking that we could absorb most of the makefile into the prebuild program anyway. That should be more fun to maintain. We would then just use the makefile targets to pass information to prebuild.

$(CC_CMD)

.PHONY: haxe libs haxelib
.PHONY: haxe haxelib
11 changes: 0 additions & 11 deletions Makefile.version_extra

This file was deleted.

1 change: 1 addition & 0 deletions Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ PREBUILD_OUTPUT=prebuild.exe
EXTENSION=.exe
PACKAGE_SRC_EXTENSION=.zip
ARCH?=32
DUNE_COMMAND=dune.exe

ifeq ($(ARCH),64)
NEKO_ARCH_STR=64
Expand Down
1 change: 1 addition & 0 deletions dune
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(data_only_dirs extra lib std tests)
10 changes: 10 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(lang dune 1.11)
(name haxe)

(package
(name haxe)
)

(package
(name haxe_prebuild)
)
2 changes: 2 additions & 0 deletions dune-workspace.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(lang dune 1.11)
(profile release)
2 changes: 0 additions & 2 deletions extra/azure-pipelines/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ jobs:
displayName: Install OCaml libraries
- script: |
set -ex
opam config exec -- make -s STATICLINK=1 libs
opam config exec -- make -s STATICLINK=1 prebuild
opam config exec -- make -s -j`nproc` STATICLINK=1 haxe
opam config exec -- make -s haxelib
make -s package_bin
Expand Down
2 changes: 0 additions & 2 deletions extra/azure-pipelines/build-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ jobs:
displayName: Install OCaml libraries
- script: |
set -ex
opam config exec -- make -s STATICLINK=1 "LIB_PARAMS=/usr/local/opt/zlib/lib/libz.a /usr/local/lib/libpcre.a" libs
opam config exec -- make -s STATICLINK=1 "LIB_PARAMS=/usr/local/opt/zlib/lib/libz.a /usr/local/lib/libpcre.a" prebuild
opam config exec -- make -s -j`sysctl -n hw.ncpu` STATICLINK=1 "LIB_PARAMS=/usr/local/opt/zlib/lib/libz.a /usr/local/lib/libpcre.a" haxe
opam config exec -- make -s haxelib
make -s package_bin package_installer_mac
Expand Down
1 change: 0 additions & 1 deletion extra/azure-pipelines/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ jobs:
displayName: Expose mingw dll files
- powershell: |
Set-PSDebug -Trace 1
& "$(CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && opam config exec -- make -s -f Makefile.win libs prebuild 2>&1')
& "$(CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && opam config exec -- make -s -f Makefile.win -j`nproc` haxe 2>&1')
& "$(CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && opam config exec -- make -s -f Makefile.win haxelib 2>&1')
& "$(CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && opam config exec -- make -f Makefile.win echo_package_files package_bin package_installer_win package_choco 2>&1')
Expand Down
16 changes: 16 additions & 0 deletions libs/extc/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(include_subdirs no)

(library
(name extc)
(libraries extlib)
(c_names extc_stubs)
(modules extc)
(wrapped false)
)

(library
(name extproc)
(c_names process_stubs)
(modules process)
(wrapped false)
)
7 changes: 7 additions & 0 deletions libs/extlib-leftovers/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(include_subdirs no)

(library
(name extlib_leftovers)
(libraries extlib)
(wrapped false)
)
8 changes: 8 additions & 0 deletions libs/ilib/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(include_subdirs no)

(library
(name ilib)
(modules_without_implementation ilData ilMeta)
(libraries extlib)
(wrapped false)
)
8 changes: 4 additions & 4 deletions libs/ilib/ilMetaWriter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ let int_of_type_def_string = function

let int_of_type_def_flags f =
int_of_type_def_vis f.tdf_vis
logor
lor
int_of_type_def_layout f.tdf_layout
logor
lor
int_of_type_def_semantics f.tdf_semantics
logor
lor
int_of_type_def_impl f.tdf_impl
logor
lor
int_of_type_def_string f.tdf_string
7 changes: 7 additions & 0 deletions libs/javalib/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(include_subdirs no)

(library
(name javalib)
(libraries extlib)
(wrapped false)
)
6 changes: 6 additions & 0 deletions libs/json/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(include_subdirs no)

(library
(name json)
(preprocess (pps sedlex.ppx))
)
File renamed without changes.
7 changes: 7 additions & 0 deletions libs/neko/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(include_subdirs no)

(library
(name neko)
(libraries extlib)
(wrapped false)
)
9 changes: 9 additions & 0 deletions libs/objsize/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(include_subdirs no)

(library
(name objsize)
(c_names c_objsize)
(c_flags (-I../../../../libs/objsize)) ; TODO: This is stupid
(wrapped false)
(modules objsize)
)
7 changes: 7 additions & 0 deletions libs/pcre/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(include_subdirs no)

(library
(name pcre)
(c_names pcre_stubs)
(wrapped false)
)
8 changes: 8 additions & 0 deletions libs/swflib/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(include_subdirs no)

(library
(name swflib)
(libraries extc extlib extlib_leftovers)
(modules_without_implementation as3 as3hl)
(wrapped false)
)
Loading