Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[enhance] compiler, packages: Allows to have several backends (separa…

…ted opx)
  • Loading branch information...
commit 662e95ef9b9b11845c9901b777ba05846133606a 1 parent e17e648
@BourgerieQuentin BourgerieQuentin authored
View
51 Makefile
@@ -34,7 +34,7 @@ export
.PHONY: all
all: $(MYOCAMLBUILD)
- $(OCAMLBUILD) $(call target-tools,$(ALL_TOOLS)) opa-node-packages.stamp
+ $(OCAMLBUILD) $(call target-tools,$(ALL_TOOLS)) opa-packages.stamp
@$(call copy-tools,$(ALL_TOOLS))
ifndef NO_MANPAGES
$(MAKE) manpages
@@ -50,16 +50,16 @@ runtime-libs: $(MYOCAMLBUILD)
.PHONY: $(BUILD_DIR)/bin/opa
$(BUILD_DIR)/bin/opa: $(MYOCAMLBUILD)
- $(OCAMLBUILD) opa-node-packages.stamp $(target-tool-opa-bin)
+ $(OCAMLBUILD) opa-packages.stamp $(target-tool-opa-bin)
@$(copy-tool-opa-bin)
@utils/install.sh --quiet --dir $(realpath $(BUILD_DIR)) --ocaml-prefix $(OCAMLLIB)/../..
.PHONY: opa
opa: $(BUILD_DIR)/bin/opa
-.PHONY: opa-node-packages
+.PHONY: opa-packages
opa-packages: $(MYOCAMLBUILD)
- $(OCAMLBUILD) opa-node-packages.stamp
+ $(OCAMLBUILD) opa-packages.stamp
opa-node-packages: $(MYOCAMLBUILD)
$(OCAMLBUILD) opa-node-packages.stamp
@@ -73,7 +73,7 @@ OPA_TOOLS = opa-create
.PHONY: distrib
distrib: $(MYOCAMLBUILD)
- $(OCAMLBUILD) $(call target-tools,$(DISTRIB_TOOLS)) opa-node-packages.stamp
+ $(OCAMLBUILD) $(call target-tools,$(DISTRIB_TOOLS)) opa-packages.stamp
@$(call copy-tools,$(DISTRIB_TOOLS))
$(MAKE) $(OPA_TOOLS)
@@ -100,13 +100,27 @@ install-opa-create = mkdir -p $(PREFIX)/bin && $(INSTALL) $(BUILD_DIR)/bin/opa-c
.PHONY: install*
STDLIB_DIR = $(INSTALL_DIR)/lib/opa/stdlib
+
+FLAT_STDLIB_SUFFIX_DIR=stdlib.qmlflat
+STDLIB_FLAT_DIR=$(STDLIB_DIR)/$(FLAT_STDLIB_SUFFIX_DIR)
+BUILD_FLAT_DIR=$(BUILD_DIR)/$(FLAT_STDLIB_SUFFIX_DIR)
define install-package
-@printf "Installing into $(STDLIB_DIR)/$*.opx\r"
-@mkdir -p "$(STDLIB_DIR)/$*.opx/_build"
-@find "$(BUILD_DIR)/$*.opx" -maxdepth 1 ! -type d -exec $(INSTALL) {} "$(STDLIB_DIR)/$*.opx/" \;
-@$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.a "$(STDLIB_DIR)/$*.opx/_build/"
-@$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.cmi "$(STDLIB_DIR)/$*.opx/_build/"
-@$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.cmxa "$(STDLIB_DIR)/$*.opx/_build/"
+@printf "Installing into $(STDLIB_FLAT_DIR)/$*.opx\r"
+@mkdir -p "$(STDLIB_FLAT_DIR)/$*.opx/_build"
+@find "$(BUILD_FLAT_DIR)/$*.opx" -maxdepth 1 ! -type d -exec $(INSTALL) {} "$(STDLIB_FLAT_DIR)/$*.opx/" \;
+@$(INSTALL) $(BUILD_FLAT_DIR)/$*.opx/_build/*.a "$(STDLIB_FLAT_DIR)/$*.opx/_build/"
+@$(INSTALL) $(BUILD_FLAT_DIR)/$*.opx/_build/*.cmi "$(STDLIB_FLAT_DIR)/$*.opx/_build/"
+@$(INSTALL) $(BUILD_FLAT_DIR)/$*.opx/_build/*.cmxa "$(STDLIB_FLAT_DIR)/$*.opx/_build/"
+endef
+
+NODE_STDLIB_SUFFIX_DIR=stdlib.qmljs
+STDLIB_NODE_DIR=$(STDLIB_DIR)/$(NODE_STDLIB_SUFFIX_DIR)
+BUILD_NODE_DIR=$(BUILD_DIR)/$(NODE_STDLIB_SUFFIX_DIR)
+define install-node-package
+@printf "Installing into $(STDLIB_NODE_DIR)/$*.opx\r"
+@mkdir -p "$(STDLIB_NODE_DIR)/$*.opx/_build"
+@find "$(BUILD_NODE_DIR)/$*.opx" -maxdepth 1 ! -type d -exec $(INSTALL) {} "$(STDLIB_NODE_DIR)/$*.opx/" \;
+@$(INSTALL) $(BUILD_NODE_DIR)/$*.opx/*.js "$(STDLIB_NODE_DIR)/$*.opx/"
endef
define install-plugin
@@ -134,16 +148,25 @@ OPA_PLUGINS := $(shell cd stdlib && ./all_plugins.sh)
# for that
install-packageopt-%:
- $(if $(wildcard $(BUILD_DIR)/$*.opx/_build/*),$(install-package))
+ $(if $(wildcard $(BUILD_FLAT_DIR)/$*.opx/_build/*),$(install-package))
+
+install-node-packageopt-%:
+ $(if $(wildcard $(BUILD_NODE_DIR)/$*.opx/*.js),$(install-node-package))
install-package-%:
$(install-package)
+install-node-package-%:
+ $(install-node-package)
+
install-packages: $(addprefix install-packageopt-,$(OPA_PACKAGES))
- @printf "Installation to $(STDLIB_DIR) done.\n"
+ @printf "Installation to $(STDLIB_FLAT_DIR) done.\n"
+
+install-node-packages: $(addprefix install-node-packageopt-,$(OPA_PACKAGES))
+ @printf "Installation to $(STDLIB_NODE_DIR) done.\n"
install-all-packages: $(addprefix install-package-,$(OPA_PACKAGES))
- @printf "Installation to $(STDLIB_DIR) done.[K\n"
+ @printf "Installation to $(STDLIB_FLAT_DIR) done.[K\n"
install-pluginopt-%:
$(if $(wildcard $(BUILD_DIR)/$*.opp/),$(install-plugin))
View
43 build_rules.ml
@@ -837,18 +837,26 @@ let files_of_package pkg =
let files = List.sort String.compare files in
files in
-let make_all_packages = [stdlib_packages_dir/"all_packages.sh"; stdlib_packages_dir/"node.todo" ]in
-let all_packages_file = stdlib_packages_dir/"all.packages" in
+let packages_exclude_node = "node.exclude"in
+let packages_exclude_qmlflat = "qmlflat.exclude"in
+let make_all_packages = [stdlib_packages_dir/"all_packages.sh"; stdlib_packages_dir/packages_exclude_node ; stdlib_packages_dir/packages_exclude_qmlflat] in
+let all_packages_file nodebackend = if nodebackend then stdlib_packages_dir/"all.node.packages" else stdlib_packages_dir/"all.packages" in
+
+let all_packages_building nodebackend =
+ let prod = all_packages_file nodebackend in
+ rule (if nodebackend then "all.node.packages" else "all.packages")
+ ~deps: make_all_packages
+ ~prod
+ (fun env build ->
+ Cmd(S[
+ Sh"cd"; P (Pathname.pwd / stdlib_packages_dir); Sh"&&";
+ P"./all_packages.sh"; P (if nodebackend then packages_exclude_node else packages_exclude_qmlflat); Sh">"; P (Pathname.pwd / !Options.build_dir / prod);
+ ])
+ )
+in
-rule "all.packages"
- ~deps: make_all_packages
- ~prod: all_packages_file
- (fun env build ->
- Cmd(S[
- Sh"cd"; P (Pathname.pwd / stdlib_packages_dir); Sh"&&";
- P"./all_packages.sh"; Sh">"; P (Pathname.pwd / !Options.build_dir / all_packages_file);
- ])
- );
+all_packages_building true;
+all_packages_building false;
let make_all_plugins = stdlib_packages_dir/"all_plugins.sh" in
let all_plugins_file = stdlib_packages_dir/"all.plugins" in
@@ -888,7 +896,7 @@ rule "opa application creator"
let package_building ?(nodebackend=false) ~name ~stamp ~stdlib_only ~rebuild () =
rule name
- ~deps:[(* opacapi_validation; *)all_plugins_file;all_packages_file;"opacomp.stamp"]
+ ~deps:[(* opacapi_validation; *)all_plugins_file;all_packages_file nodebackend;"opacomp.stamp"]
~stamp
~prod:"i_dont_exist" (* forces ocamlbuild to always run the command *)
(fun env build ->
@@ -896,7 +904,7 @@ let package_building ?(nodebackend=false) ~name ~stamp ~stdlib_only ~rebuild ()
let plugins = string_list_of_file all_plugins_file in
let plugins = List.map (fun f -> "plugins" / f / f -.- "oppf") plugins in
build_list build plugins;
- let packages = string_list_of_file all_packages_file in
+ let packages = string_list_of_file (all_packages_file nodebackend) in
let packages =
if stdlib_only
then
@@ -943,10 +951,17 @@ let package_building ?(nodebackend=false) ~name ~stamp ~stdlib_only ~rebuild ()
(*List.concat (List.map (fun (_,files) -> List.map (fun f -> P f) files) list_package_files)*)
[A"--conf-opa-files"]
in
+ let opx_dir = if nodebackend then "stdlib.qmljs" else "stdlib.qmlflat" in
let extra_opt = if rebuild then [A"--rebuild"] else [] in
- let extra_opt = if nodebackend then A"--print"::A"code"::A"--no-warn-error"::A"root"::A"--back-end"::A"qmljs"::extra_opt else extra_opt in
+ let extra_opt =
+ [A"--opx-dir";A opx_dir;A"-I";A"."] @
+ if nodebackend then
+ A"--print"::A"code"::A"--no-warn-error"::A"root"::A"--back-end"::A"qmljs"::extra_opt
+ else A"--back-end"::A"qmlflat"::extra_opt
+ in
Seq[
Echo(conf, "conf");
+ Cmd(S([Sh"mkdir";A"-p";P opx_dir;]));
Cmd(S([Sh("MLSTATELIBS=\""^ opa_prefix ^"\"");
get_tool "opa-bin";
A"--autocompile";
View
8 compilerlib/objectFiles.ml
@@ -464,16 +464,18 @@ let defaultpaths =
!opxdir :: prefix_by_mlstatelibs InstallDir.lib_opa :: []
)
+let relative_stdlib = ref ""
let defaultpaths_for_stdlib =
(* need to delay the computation until after options have been parsed
* or else the --quiet option wouldn't have been set yet *)
- lazy (let dirname = prefix_by_mlstatelibs InstallDir.opa_packages in
+ lazy (let dirname = prefix_by_mlstatelibs (Filename.concat InstallDir.opa_packages !relative_stdlib) in
+ let dirplug = prefix_by_mlstatelibs InstallDir.opa_packages in
let formula =
Filename.concat (Printf.sprintf "$%s" InstallDir.name) InstallDir.opa_packages
in
try
if Sys.is_directory dirname then
- [dirname]
+ [dirname; dirplug]
else (
if is_separated () then
OManager.unquiet "%s (=%s) is not a directory. It won't be used as a default included directory."
@@ -1163,6 +1165,8 @@ let merge_consistency_info ~exn (acc_js_libs, acc_deps, acc_bsl_plugins) package
if exn then with_exn check_everything else check_everything ()
+let set_relative_stdlib path = relative_stdlib := path
+
let set_extrapaths ~no_stdlib paths =
(*
removing the paths dedicated to ocaml
View
2  compilerlib/objectFiles.mli
@@ -88,6 +88,8 @@ val get_compilation_directory_or_current_dir : unit -> filename
*)
val set_extrapaths : no_stdlib:bool -> filename list -> unit
+val set_relative_stdlib : filename -> unit
+
(**
Get all paths where the compiler should search its objects
*)
View
4 passes/surfaceAstPasses.ml
@@ -1,5 +1,5 @@
(*
- Copyright © 2011 MLstate
+ Copyright © 2011, 2012 MLstate
This file is part of OPA.
@@ -47,6 +47,8 @@ let pass_load_objects ~options (special_parsed_files, user_parsed_files) k =
let imports = List.map (fun s -> Package(`import, s), label s) i18n_to_import in
(name,content,imports @ code)
in
+ ObjectFiles.set_relative_stdlib
+ (Printf.sprintf "stdlib.%s" (OpaEnv.string_of_available_back_end options.OpaEnv.back_end));
ObjectFiles.set_extrapaths ~no_stdlib:(not options.OpaEnv.stdlib) options.OpaEnv.extrapath;
ObjectFiles.load
~extrajs:(
View
8 stdlib/all_packages.sh
@@ -1,9 +1,15 @@
#!/usr/bin/env bash
# script used to generate the list of packages
+exclude=$1
+
DIRS=$(find . -type d | sed "s/.\///")
-: ${PACKAGE_FILTER:=grep -E -v -f node.todo}
+if [ -f "$exclude" ]; then
+ : ${PACKAGE_FILTER:=grep -E -v -f $exclude}
+else
+ : ${PACKAGE_FILTER:=cat}
+fi
PACKAGES=''
for dir in $DIRS ; do
View
0  stdlib/node.todo → stdlib/node.exclude
File renamed without changes
View
0  stdlib/qmlflat.exclude
No changes.
Please sign in to comment.
Something went wrong with that request. Please try again.