Permalink
Browse files

[fix] plugins: Install and searching

	- Install all necessary files
	- Don't install unless files
	- Don't put absolute path on BslLoading object files
	- Search plugins on all compiler paths (especially install dir)
  • Loading branch information...
1 parent d7352df commit 837171693512c51a2336c22a12968877540171f1 @BourgerieQuentin BourgerieQuentin committed Oct 28, 2011
Showing with 50 additions and 16 deletions.
  1. +2 −6 Makefile
  2. +2 −0 compilerlib/objectFiles.ml
  3. +5 −0 compilerlib/objectFiles.mli
  4. +41 −10 opa/pass_BslLoading.ml
View
8 Makefile
@@ -86,12 +86,8 @@ endef
define install-plugin
@printf "Installing into $(STDLIB_DIR)/$*.opp^[[K\r"
@mkdir -p "$(STDLIB_DIR)/$*.opp"
-@$(INSTALL) $(BUILD_DIR)/$*.opp/*.cmi "$(STDLIB_DIR)/$*.opp/";
-@$(INSTALL) $(BUILD_DIR)/$*.opp/*.cmx "$(STDLIB_DIR)/$*.opp/";
-@if [ -d "$(BUILD_DIR)/$*.opp/plugins/$*/" ]; then \
- mkdir -p "$(STDLIB_DIR)/$*.opp/plugins/$*/" ; \
- $(INSTALL) $(BUILD_DIR)/$*.opp/plugins/$*/*.js "$(STDLIB_DIR)/$*.opp/plugins/$*/" ; \
-fi
+@$(INSTALL) $(BUILD_DIR)/$*.opp/*.bypass "$(STDLIB_DIR)/$*.opp/";
+@$(INSTALL) $(BUILD_DIR)/$*.opp/*MLRuntime.* "$(STDLIB_DIR)/$*.opp/";
endef
View
2 compilerlib/objectFiles.ml
@@ -1754,6 +1754,8 @@ let stdlib_package_names name =
let stdlib_packages (package_name,_pos) = stdlib_package_names package_name
+let get_paths () = !extrapaths
+
module Arg =
struct
module Arg = Base.Arg
View
5 compilerlib/objectFiles.mli
@@ -89,6 +89,11 @@ val get_compilation_directory_or_current_dir : unit -> filename
val set_extrapaths : no_stdlib:bool -> filename list -> unit
(**
+ Get all paths where the compiler should search its objects
+*)
+val get_paths : unit -> filename list
+
+(**
Set plugins version, from the loaded plugins
*)
val set_bsl_plugins : (basename * hash) list -> unit
View
51 opa/pass_BslLoading.ml
@@ -221,17 +221,51 @@ let upgrade_options plugins options =
extrapath ;
}
+let resolve_entry search_path entry =
+ let { S.plugin_name = basename ; extralib ; extrapath ; bypass } = entry in
+ match Filename.is_relative extrapath with
+ | false -> entry
+ | true ->
+ (* Searching plugin in extra path... *)
+ let candidates = List.filter_map
+ (fun p ->
+ let fullname = Filename.concat p extrapath in
+ #<If:BSL_LOADING>
+ OManager.verbose "Seraching %s on %s => %s : %b" extrapath p fullname (File.is_directory fullname);
+ #<End>;
+ if File.is_directory fullname then Some fullname else None
+ ) search_path in
+ let aux extrapath =
+ OManager.verbose "Select %s" extrapath;
+ {S.plugin_name = basename; extralib; extrapath;
+ bypass = Filename.concat extrapath (Filename.basename bypass)} in
+ match candidates with
+ | [] -> entry
+ | [extrapath] -> aux extrapath
+ | extrapath::_ as places ->
+ OManager.warning ~wclass:WarningClass.bsl_loading
+ "@\nThe plugin @{<bright>%S@} is found in several places :\n(%s).@\nI will use @{<bright>%S@}"
+ basename
+ (String.concat "; " places)
+ extrapath ;
+ aux extrapath
let process
~options
~code
=
+ (* Pass *)
+ let plugins = options.O.bypass_plugin in
+ let back_end = options.O.back_end in
+ let js_back_end = options.O.js_back_end in
+ let cwd = Sys.getcwd () in
+ let search_path = cwd :: ObjectFiles.get_paths () in
(* Separated compilation: loading *)
let () =
let iter (package_name, _) entries =
let iter_entry entry =
- let { S.plugin_name = basename ; extralib ; extrapath ; bypass } = entry in
+ let { S.plugin_name = basename ; extralib ; extrapath ; bypass } = resolve_entry search_path entry in
if not (Hashtbl.mem already_seen_plugin basename)
then (
BslLib.declare_visibility package_name basename ;
@@ -247,12 +281,6 @@ let process
in
let separation = Separation.create () in
- (* Pass *)
- let plugins = options.O.bypass_plugin in
- let extrapath = options.O.extrapath in
- let back_end = options.O.back_end in
- let js_back_end = options.O.js_back_end in
-
let commandline = FilePos.nopos "command line" in
let plugins = List.map (fun p -> (p, commandline)) plugins in
@@ -307,8 +335,6 @@ let process
BslLib.declare_visibility package_name OpabslgenPlugin.Self.basename ;
(* Search additional plug-ins.*)
- let cwd = Sys.getcwd () in
- let search_path = cwd :: extrapath in
List.iter (
fun (bypass_plugin, pos) ->
(* the bypass_plugin is containing the extension opp *)
@@ -356,7 +382,8 @@ let process
let () =
if not (File.is_directory filename)
then
- OManager.error "%a@\nI/O error: cannot find @{<bright>%S@}" FilePos.pp pos filename
+ OManager.error "%a@\nI/O error: cannot find @{<bright>%S@} on %s" FilePos.pp pos filename
+ (String.concat "; " search_path);
in
let inclusion = BslConvention.inclusion ~cwd filename in
@@ -366,6 +393,10 @@ let process
Hashtbl.add extralib_plugin basename extralib ;
Hashtbl.add extrapath_plugin basename extrapath ;
BslDynlink.load_bypass_plugin (BslDynlink.MarshalPlugin plugin) ;
+ let inclusion = BslConvention.inclusion ~cwd:"" bypass_plugin in
+ let extralib = inclusion.BslConvention.extralib in
+ let extrapath = inclusion.BslConvention.extrapath in
+ let plugin = inclusion.BslConvention.plugin in
Separation.add separation (S.make basename extralib extrapath plugin) ;
)
) plugins ;

0 comments on commit 8371716

Please sign in to comment.