Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove ostype sub dirs below wx/priv

This was intended for distributing several binaries in one package,
in standalone version, it has no need when included in otp.
  • Loading branch information...
commit 029429cae951a9896d544eb7693fd130e4abc979 1 parent 8577598
@dgud dgud authored
Showing with 22 additions and 95 deletions.
  1. +3 −1 .gitignore
  2. +4 −4 lib/wx/c_src/Makefile.in
  3. +15 −90 lib/wx/src/wxe_util.erl
View
4 .gitignore
@@ -286,10 +286,12 @@ a.out.dSYM/
/lib/wx/api_gen/wx_xml/*
/lib/wx/api_gen/gl_xml/*
/lib/wx/api_gen/??_doxygen
-/lib/wx/api_gen/??xml_generated
+/lib/wx/api_gen/*_generated
/lib/wx/wx-*.ez
/lib/wx/CONF_INFO
/lib/wx/doc/src/wx*.xml
+/lib/wx/priv/wxe_driver.*
+/lib/wx/priv/erl_gl.*
# xmerl
View
8 lib/wx/c_src/Makefile.in
@@ -79,7 +79,7 @@ WX_OBJECTS = $(GENERAL_O) $(GENERATED_O) $(RC_FILE)
OBJECTS = $(WX_OBJECTS) $(GL_OBJECTS)
TARGET_APIS = wxe_driver erl_gl
-TARGET_DIR = ../priv/$(SYS_TYPE)
+TARGET_DIR = ../priv
# -O2 -funroll-loops -ffast-math -fomit-frame-pointer
@@ -179,11 +179,11 @@ $(TARGET_DIR)/erl_gl$(SO_EXT): $(GL_OBJECTS)
ifeq ($(INSIDE_ERLSRC),true)
include $(ERL_TOP)/make/otp_release_targets.mk
release_spec: opt
- $(INSTALL_DIR) $(RELSYSDIR)/priv/$(SYS_TYPE)
+ $(INSTALL_DIR) $(RELSYSDIR)/priv
$(INSTALL_DATA) ../priv/erlang-logo32.png $(RELSYSDIR)/priv/
$(INSTALL_DATA) ../priv/erlang-logo64.png $(RELSYSDIR)/priv/
- $(INSTALL_PROGRAM) $(TARGET_DIR)/wxe_driver$(SO_EXT) $(RELSYSDIR)/priv/$(SYS_TYPE)
- $(INSTALL_PROGRAM) $(TARGET_DIR)/erl_gl$(SO_EXT) $(RELSYSDIR)/priv/$(SYS_TYPE)
+ $(INSTALL_PROGRAM) $(TARGET_DIR)/wxe_driver$(SO_EXT) $(RELSYSDIR)/priv/
+ $(INSTALL_PROGRAM) $(TARGET_DIR)/erl_gl$(SO_EXT) $(RELSYSDIR)/priv/
release_docs_spec:
View
105 lib/wx/src/wxe_util.erl
@@ -201,8 +201,7 @@ check_previous() ->
after 0 -> ok
end.
-
-%% If you want anything done, do it yourself.
+%% Get gl dynamic library
wxgl_dl() ->
DynLib0 = "erl_gl",
@@ -213,17 +212,9 @@ wxgl_dl() ->
_ ->
DynLib0 ++ ".so"
end,
- GLLib = filename:join(PrivDir, DynLib),
- case file:read_file_info(GLLib) of
- {ok, _} ->
- GLLib;
- {error,_} ->
- error({enoent, GLLib})
- end.
+ filename:join(PrivDir, DynLib).
-
-priv_dir(Driver) ->
- Type = erlang:system_info(system_architecture),
+priv_dir(Driver0) ->
{file, Path} = code:is_loaded(?MODULE),
Priv = case filelib:is_regular(Path) of
true ->
@@ -232,90 +223,24 @@ priv_dir(Driver) ->
false ->
code:priv_dir(wx)
end,
- try
- {ok, Dirs0} = file:list_dir(Priv),
- Dirs1 = split_dirs(Dirs0),
- Dirs = lists:reverse(lists:sort(Dirs1)),
+ Driver = case os:type() of
+ {win32,_} ->
+ Driver0 ++ ".dll";
+ _ ->
+ Driver0 ++ ".so"
+ end,
- Best = best_dir(hd(split_dirs([Type])),Dirs, Driver, Priv),
- filename:join(Priv, Best)
- catch _:_ ->
- error_logger:format("ERROR: Could not find suitable \'~s\' for ~s in: ~s~n",
- [Driver, Type, Priv]),
+ case file:read_file_info(filename:join(Priv, Driver)) of
+ {ok, _} ->
+ Priv;
+ {error, _} ->
+ error_logger:format("ERROR: Could not find \'~s\' in: ~s~n",
+ [Driver, Priv]),
erlang:error({load_driver, "No driver found"})
end.
-best_dir(Dir, Dirs0, Driver, Priv) ->
- Dirs = [{D,D} || D <- Dirs0],
- best_dir(Dir, Dirs, [], Driver, Priv).
-
-best_dir(Pre, [{[],_}|R], Acc, Driver, Priv) -> %% Empty skip'em
- best_dir(Pre, R, Acc, Driver, Priv);
-best_dir(Pre, [{Pre,Dir}|R], Acc, Driver, Priv) ->
- Real = dir_app(lists:reverse(Dir)),
- case file:list_dir(filename:join(Priv,Real)) of
- {ok, Fs} ->
- case lists:any(fun(File) -> filename:rootname(File) =:= Driver end, Fs) of
- true -> Real; %% Found dir and it contains a driver
- false -> best_dir(Pre, R, Acc, Driver, Priv)
- end;
- _ ->
- best_dir(Pre, R, Acc, Driver, Priv)
- end;
-best_dir(Pre, [{[_|F],Dir}|R], Acc, Driver, Priv) ->
- best_dir(Pre, R, [{F,Dir}|Acc], Driver, Priv);
-best_dir(_Pre, [], [], _,_) -> throw(no_dir); %% Nothing found
-best_dir([_|Pre], [], Acc, Driver, Priv) ->
- best_dir(Pre, lists:reverse(Acc), [], Driver, Priv);
-best_dir([], _, _,_,_) -> throw(no_dir). %% Nothing found
-
-split_dirs(Dirs0) ->
- ToInt = fun(Str) ->
- try
- list_to_integer(Str)
- catch _:_ -> Str
- end
- end,
- Split = fun(Dir) ->
- Toks = tokens(Dir,".-"),
- lists:reverse([ToInt(Str) || Str <- Toks])
- end,
- lists:map(Split,Dirs0).
-
-dir_app([]) -> [];
-dir_app([Dir]) -> Dir;
-dir_app(Dir) ->
- dir_app2(Dir).
-dir_app2([Int]) when is_integer(Int) ->
- integer_to_list(Int);
-dir_app2([Str]) when is_list(Str) ->
- Str;
-dir_app2([Head|Rest]) when is_integer(Head) ->
- integer_to_list(Head) ++ dir_app2(Rest);
-dir_app2([Head|Rest]) when is_list(Head) ->
- Head ++ dir_app2(Rest).
-
strip(Src, Src) ->
[];
strip([H|R], Src) ->
[H| strip(R, Src)].
-tokens(S,Seps) ->
- tokens1(S, Seps, []).
-
-tokens1([C|S], Seps, Toks) ->
- case lists:member(C, Seps) of
- true -> tokens1(S, Seps, [[C]|Toks]);
- false -> tokens2(S, Seps, Toks, [C])
- end;
-tokens1([], _Seps, Toks) ->
- lists:reverse(Toks).
-
-tokens2([C|S], Seps, Toks, Cs) ->
- case lists:member(C, Seps) of
- true -> tokens1(S, Seps, [[C], lists:reverse(Cs) |Toks]);
- false -> tokens2(S, Seps, Toks, [C|Cs])
- end;
-tokens2([], _Seps, Toks, Cs) ->
- lists:reverse([lists:reverse(Cs)|Toks]).
-
Please sign in to comment.
Something went wrong with that request. Please try again.