diff options
author | Dan Gudmundsson <[email protected]> | 2010-10-19 10:34:08 +0200 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2010-11-15 10:13:07 +0100 |
commit | 029429cae951a9896d544eb7693fd130e4abc979 (patch) | |
tree | 4999245716dfbee0b648f27c2cfbf83cbc043967 /lib/wx | |
parent | 8577598667bff43f503f3cae87934c3e9918d135 (diff) | |
download | otp-029429cae951a9896d544eb7693fd130e4abc979.tar.gz otp-029429cae951a9896d544eb7693fd130e4abc979.tar.bz2 otp-029429cae951a9896d544eb7693fd130e4abc979.zip |
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.
Diffstat (limited to 'lib/wx')
-rw-r--r-- | lib/wx/c_src/Makefile.in | 8 | ||||
-rw-r--r-- | lib/wx/src/wxe_util.erl | 105 |
2 files changed, 19 insertions, 94 deletions
diff --git a/lib/wx/c_src/Makefile.in b/lib/wx/c_src/Makefile.in index 4713b5ae69..69418f62ef 100644 --- a/lib/wx/c_src/Makefile.in +++ b/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: diff --git a/lib/wx/src/wxe_util.erl b/lib/wx/src/wxe_util.erl index 78068fe1b0..02bca62486 100644 --- a/lib/wx/src/wxe_util.erl +++ b/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]). - |