aboutsummaryrefslogtreecommitdiffstats
path: root/lib/wx/src
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2010-10-11 11:00:38 +0200
committerDan Gudmundsson <[email protected]>2010-11-15 10:13:07 +0100
commit8577598667bff43f503f3cae87934c3e9918d135 (patch)
tree7769951ae687f9c266ee938f0df221e291699529 /lib/wx/src
parentac433c8318566261a74ffe7fd0824fb99610bed3 (diff)
downloadotp-8577598667bff43f503f3cae87934c3e9918d135.tar.gz
otp-8577598667bff43f503f3cae87934c3e9918d135.tar.bz2
otp-8577598667bff43f503f3cae87934c3e9918d135.zip
Windows and Mac build issues
Diffstat (limited to 'lib/wx/src')
-rw-r--r--lib/wx/src/Makefile1
-rw-r--r--lib/wx/src/gen/gl.erl4
-rw-r--r--lib/wx/src/gen/wxGLCanvas.erl4
-rw-r--r--lib/wx/src/wxe_master.erl117
-rw-r--r--lib/wx/src/wxe_util.erl124
5 files changed, 130 insertions, 120 deletions
diff --git a/lib/wx/src/Makefile b/lib/wx/src/Makefile
index a9fd468959..3cc668375f 100644
--- a/lib/wx/src/Makefile
+++ b/lib/wx/src/Makefile
@@ -47,7 +47,6 @@ GEN_FILES = $(wildcard gen/wx*.erl) \
GEN_MODS = $(GEN_FILES:gen/%.erl= %,\n )
GEN_HRL = \
- $(EGEN)/gl_debug.hrl \
$(EGEN)/wxe_debug.hrl \
$(EGEN)/wxe_funcs.hrl
diff --git a/lib/wx/src/gen/gl.erl b/lib/wx/src/gen/gl.erl
index 56cb2f1e23..bf56067da1 100644
--- a/lib/wx/src/gen/gl.erl
+++ b/lib/wx/src/gen/gl.erl
@@ -235,8 +235,8 @@ cast(Op, Args) ->
rec() ->
receive
{'_egl_result_', Res} -> Res;
- {'_egl_error_', Res} -> error({error,Res})
- end.
+ {'_egl_error_', Op, Res} -> error({error,Res,Op})
+ end.
%% @hidden
send_bin(Bin) when is_binary(Bin) ->
diff --git a/lib/wx/src/gen/wxGLCanvas.erl b/lib/wx/src/gen/wxGLCanvas.erl
index ed5430dae1..e5d7bec4ca 100644
--- a/lib/wx/src/gen/wxGLCanvas.erl
+++ b/lib/wx/src/gen/wxGLCanvas.erl
@@ -105,7 +105,7 @@ new(#wx_ref{type=ParentT,ref=ParentRef}, Options)
({palette, #wx_ref{type=PaletteT,ref=PaletteRef}}, Acc) -> ?CLASS(PaletteT,wxPalette),[<<7:32/?UI,PaletteRef:32/?UI>>|Acc];
(BadOpt, _) -> erlang:error({badoption, BadOpt}) end,
BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
- wxe_master:init_opengl(),
+ {ok, _} = wxe_master:init_opengl(),
wxe_util:construct(?wxGLCanvas_new_2,
<<ParentRef:32/?UI, 0:32,BinOpt/binary>>).
@@ -131,7 +131,7 @@ new(#wx_ref{type=ParentT,ref=ParentRef},#wx_ref{type=SharedT,ref=SharedRef}, Opt
({palette, #wx_ref{type=PaletteT,ref=PaletteRef}}, Acc) -> ?CLASS(PaletteT,wxPalette),[<<7:32/?UI,PaletteRef:32/?UI>>|Acc];
(BadOpt, _) -> erlang:error({badoption, BadOpt}) end,
BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
- wxe_master:init_opengl(),
+ {ok, _} = wxe_master:init_opengl(),
wxe_util:construct(SharedOP,
<<ParentRef:32/?UI,SharedRef:32/?UI, BinOpt/binary>>).
diff --git a/lib/wx/src/wxe_master.erl b/lib/wx/src/wxe_master.erl
index 8751a259ce..d8592c133b 100644
--- a/lib/wx/src/wxe_master.erl
+++ b/lib/wx/src/wxe_master.erl
@@ -76,21 +76,11 @@ init_port() ->
%%--------------------------------------------------------------------
-%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
-%% Description: Starts the server
+%% Initlizes the opengl library
%%--------------------------------------------------------------------
init_opengl() ->
- PrivDir = priv_dir(),
- DynLib0 = "erl_gl",
- DynLib = case os:type() of
- {win32,_} ->
- DynLib0 ++ ".dll\0";
- _ ->
- DynLib0 ++ ".so\0"
- end,
- GLLib = filename:join(PrivDir, DynLib),
-
- wxe_util:call(?WXE_INIT_OPENGL, list_to_binary(GLLib)).
+ GLLib = wxe_util:wxgl_dl(),
+ wxe_util:call(?WXE_INIT_OPENGL, <<(list_to_binary(GLLib))/binary, 0:8>>).
%%====================================================================
%% gen_server callbacks
@@ -105,7 +95,7 @@ init_opengl() ->
%%--------------------------------------------------------------------
init([]) ->
DriverName = ?DRIVER,
- PrivDir = priv_dir(),
+ PrivDir = wxe_util:priv_dir(?DRIVER),
erlang:group_leader(whereis(init), self()),
case catch erlang:system_info(smp_support) of
true -> ok;
@@ -222,108 +212,9 @@ code_change(_OldVsn, State, _Extra) ->
%%%%%%%%%%%% INTERNAL %%%%%%%%%%%%%%%%%%%%%%%%
-%% If you want anything done, do it yourself.
-
-priv_dir() ->
- Type = erlang:system_info(system_architecture),
- {file, Path} = code:is_loaded(?MODULE),
- Priv = case filelib:is_regular(Path) of
- true ->
- Beam = filename:join(["ebin/",atom_to_list(?MODULE) ++ ".beam"]),
- filename:join(strip(Path, Beam), "priv");
- false ->
- code:priv_dir(wx)
- end,
- try
- {ok, Dirs0} = file:list_dir(Priv),
- Dirs1 = split_dirs(Dirs0),
- Dirs = lists:reverse(lists:sort(Dirs1)),
-
- Best = best_dir(hd(split_dirs([Type])),Dirs, Priv),
- filename:join(Priv, Best)
- catch _:_ ->
- error_logger:format("WX ERROR: Could not find suitable \'~s\' for ~s in: ~s~n",
- [?DRIVER, Type, Priv]),
- erlang:error({load_driver, "No driver found"})
- end.
-
-best_dir(Dir, Dirs0, Priv) ->
- Dirs = [{D,D} || D <- Dirs0],
- best_dir(Dir, Dirs, [], Priv).
-
-best_dir(Pre, [{[],_}|R], Acc, Priv) -> %% Empty skip'em
- best_dir(Pre, R, Acc, Priv);
-best_dir(Pre, [{Pre,Dir}|R], Acc, 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, Priv)
- end;
- _ ->
- best_dir(Pre, R, Acc, Priv)
- end;
-best_dir(Pre, [{[_|F],Dir}|R], Acc, Priv) ->
- best_dir(Pre, R, [{F,Dir}|Acc], Priv);
-best_dir(_Pre, [], [],_) -> throw(no_dir); %% Nothing found
-best_dir([_|Pre], [], Acc, Priv) ->
- best_dir(Pre, lists:reverse(Acc), [], 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)].
-
-
debug_ping(Port) ->
timer:sleep(1*333),
_R = (catch erlang:port_call(Port, 0, [])),
%% io:format("Erlang ping ~p ~n", [_R]),
debug_ping(Port).
-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]).
diff --git a/lib/wx/src/wxe_util.erl b/lib/wx/src/wxe_util.erl
index a2fb4641c9..78068fe1b0 100644
--- a/lib/wx/src/wxe_util.erl
+++ b/lib/wx/src/wxe_util.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2008-2009. All Rights Reserved.
+%% Copyright Ericsson AB 2008-2010. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -32,8 +32,9 @@
get_const/1,colour_bin/1,datetime_bin/1,
to_bool/1,from_bool/1]).
--include("wxe.hrl").
+-export([wxgl_dl/0, priv_dir/1]).
+-include("wxe.hrl").
to_bool(0) -> false;
to_bool(_) -> true.
@@ -199,3 +200,122 @@ check_previous() ->
erlang:error({Error, MF})
after 0 -> ok
end.
+
+
+%% If you want anything done, do it yourself.
+
+wxgl_dl() ->
+ DynLib0 = "erl_gl",
+ PrivDir = priv_dir(DynLib0),
+ DynLib = case os:type() of
+ {win32,_} ->
+ DynLib0 ++ ".dll";
+ _ ->
+ DynLib0 ++ ".so"
+ end,
+ GLLib = filename:join(PrivDir, DynLib),
+ case file:read_file_info(GLLib) of
+ {ok, _} ->
+ GLLib;
+ {error,_} ->
+ error({enoent, GLLib})
+ end.
+
+
+priv_dir(Driver) ->
+ Type = erlang:system_info(system_architecture),
+ {file, Path} = code:is_loaded(?MODULE),
+ Priv = case filelib:is_regular(Path) of
+ true ->
+ Beam = filename:join(["ebin/",atom_to_list(?MODULE) ++ ".beam"]),
+ filename:join(strip(Path, Beam), "priv");
+ false ->
+ code:priv_dir(wx)
+ end,
+ try
+ {ok, Dirs0} = file:list_dir(Priv),
+ Dirs1 = split_dirs(Dirs0),
+ Dirs = lists:reverse(lists:sort(Dirs1)),
+
+ 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]),
+ 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]).
+