Giter Site home page Giter Site logo

wxrust's Introduction

This repo has been abandoned years ago. As I (original author) commented here, I'm trying this again with now stable and mature language and solid ecosystem in the another repo.

April 1st, 2022.


wxRust

master: master build status / mac(0.10): Mac(0.10) build status

This is a Rust binding for the wxWidgets cross platform toolkit.

API

wxRust API documentation

How it works

The wxRust library is heavily based on the wxHaskell's wxc library.

The wxc is a C language binding for the C++ wxWidgets toolkit.

We utilize the rust-bindgen rust-bindgen build status automatic rust binding generator for its _unsafe low-level binding.

And we generate an OOP-style high-level binding (other modules than _unsafe) by codegen.py code generator.

Build

We use CMake for cross platform build, but Windows platform is not yet tested.

For Linux build instructions, see INSTALL.linux.md

Build Prerequisite

Use following Rust compiler version for your wxRust branch. We're using Servo master's one for main development.

wxRust branchSupported Rust compiler version
master master

Install the wxWidgets 3.0 (2.9.5 or later is required) and CMake as below (in the case of Homebrew):

brew install wxmac
brew install cmake

With some tweak you may be able to compile wxRust with a bit older versions (2.9.0 < x < 2.9.4) of wxWidgets. See issue #21 comments for details.

Build the library

At the project root directory,

Checkout git submodules:

git submodule init # for the first time.
git submodule update

And generate Makefiles and make:

mkdir build
cd build
cmake ..
make

Compile and Run the Test program

At the CMake binary directory:

make test && ./test

On Mac, Run as below:

make Test.app
open ./Test.app # or open in Finder

Generate Documentation

At the CMake binary directory:

make doc

Generates a rustdoc documentation under doc directory.

wxrust's People

Contributors

kenz-gelsoft avatar martindemello avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wxrust's Issues

Can't build on Gentoo Linux with wxWidgets-3.0.0.0 installed from portage

Although I can build wxRust for MacOSX with wxWidgets-3.0.0 and (with some tweak) for Linux with wxWidgets-2.9.4.1, now after I upgraded wxWidgets on my Linux box to version 3.0.0.0 (present in official Gentoo portage), I'm facing following error:

[ 92%] Generating wxrust.dummy
/root/wxrust/wxRust/src/advanced.rs:16:31: 16:50 error: invoking non-Rust fn in fn without #[fixed_stack_segment], #[deny(cstack)] on by default
/root/wxrust/wxRust/src/advanced.rs:16 unsafe { @ELJGridTable(ELJGridTable_Create(_obj, _EifGetNumberRows, _EifGetNumberCols, _EifGetValue, _EifSetValue, _EifIsEmptyCell, _EifClear,
^~~~~~~~~~~~~~~~~~~
/root/wxrust/wxRust/src/advanced.rs:22:25: 22:45 error: invoking non-Rust fn in fn without #[fixed_stack_segment], #[deny(cstack)] on by default
/root/wxrust/wxRust/src/advanced.rs:22 unsafe { @wxview(ELJGridTable_GetView(self.handle())) }
^~~~~~~~~~~~~~~~~~~~
/root/wxrust/wxRust/src/advanced.rs:25:17: 25:46 error: invoking non-Rust fn in fn without #[fixed_stack_segment], #[deny(cstack)] on by default
/root/wxrust/wxRust/src/advanced.rs:25 unsafe { ELJGridTable_SendTableMessage(self.handle(), id, val1, val2) }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/wxrust/wxRust/src/advanced.rs:39:41: 39:70 error: invoking non-Rust fn in fn without #[fixed_stack_segment], #[deny(cstack)] on by default
/root/wxrust/wxRust/src/advanced.rs:39 unsafe { @wxCalculateLayoutEvent(wxCalculateLayoutEvent_Create(id)) }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/wxrust/wxRust/src/advanced.rs:45:17: 45:48 error: invoking non-Rust fn in fn without #[fixed_stack_segment], #[deny(cstack)] on by default
/root/wxrust/wxRust/src/advanced.rs:45 unsafe { wxCalculateLayoutEvent_GetFlags(self.handle()) }

... and so on, tons of lines lihe these ones.

need samples

we need testing this library.

I'll port some sample programs from wxWidgets samples.

CMake not working

I'm running this on Arch Linux with Rust 0.10.

$ cmake .. -DwxWidgets_CONFIG_EXECUTABLE=/usr/bin/wx-config
Re-run cmake no build system arguments
CMake Warning at CMakeLists.txt:4 (find_package):
  By not providing "Findrustc.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "rustc", but
  CMake did not find one.

  Could not find a package configuration file provided by "rustc" with any of
  the following names:

    rustcConfig.cmake
    rustc-config.cmake

  Add the installation prefix of "rustc" to CMAKE_PREFIX_PATH or set
  "rustc_DIR" to a directory containing one of the above files.  If "rustc"
  provides a separate development package or SDK, be sure it has been
  installed.


CMake Warning at CMakeLists.txt:5 (find_package):
  By not providing "Findrustdoc.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "rustdoc", but
  CMake did not find one.

  Could not find a package configuration file provided by "rustdoc" with any
  of the following names:

    rustdocConfig.cmake
    rustdoc-config.cmake

  Add the installation prefix of "rustdoc" to CMAKE_PREFIX_PATH or set
  "rustdoc_DIR" to a directory containing one of the above files.  If
  "rustdoc" provides a separate development package or SDK, be sure it has
  been installed.


CMake Error at CMakeLists.txt:6 (include):
  include could not find load file:

    Rust


CMake Error at CMakeLists.txt:34 (rust_crate):
  Unknown CMake command "rust_crate".


-- Configuring incomplete, errors occurred!
See also "/home/gulshan/code/wxRust/build/CMakeFiles/CMakeOutput.log".

make wxObject params and return values Option<T>.

if it's NULL, we shouldn't call it's method.

let window = frame.findWindow("Window Name");
// if window not found, window becomes wxWindow(NULL),
// you shouldn't call on it, but you can do accidentally...
let label = window.getLabel(); // BOOOM

Is this repo in active development?

Hello,

Looking over the commit graph there appears to be no history since 2017. I was wondering if we could hand this off to someone to start maintaining or if we should create another repo to start from?

I don't want to loose all the work on this repo. It is also a little frustrating that WxWidgets wiki links to this repo as a binding and there is no support. GUI options are still a little limited in Rust but making progress.

I am coming from WxWidgets in C++ and thought this would be a good option to start with seeing as I am familiar with the lib.

SIGSEGV while running test on Linux

As I mentioned in #19, although I can finally build wxRust on Linux, test application is crashed by SIGSEGV whenever I push the button. Details are as follows:

GNU gdb (Gentoo 7.5.1 p2) 7.5.1
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>...
Reading symbols from ~/wxrust/wxRust/build/test...done.
(gdb) r
Starting program: ~/wxrust/wxRust/build/test 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
22:01:23: Debug: wxColour::Set - couldn't set to colour string 'MEDIUM GREY'
22:01:23: Debug: wxColour::Set - couldn't set to colour string 'MEDIUM GREY'
[New Thread 0xaef81b40 (LWP 26715)]
[New Thread 0xaecffb40 (LWP 26716)]
hello!

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
(gdb) bt
#0  0x00000000 in ?? ()
#1  0xb677c867 in wxGetTopLevelParent(wxWindow*) () from /usr/lib/libwx_gtk2u_core-2.9.so.4
#2  0xb66827a3 in wxDialogBase::GetParentForModalDialog(wxWindow*, long) const () from /usr/lib/libwx_gtk2u_core-2.9.so.4
#3  0xb660d41e in wxMessageDialog::wxMessageDialog(wxWindow*, wxString const&, wxString const&, long, wxPoint const&) () from /usr/lib/libwx_gtk2u_core-2.9.so.4
#4  0xb7529b68 in wxMessageDialog_Create () from wxc/libwxc.so
#5  0x0804c12c in core::wxMessageDialog::new::h5f5c862da2e835a9FAag::v0.0 ()
#6  0x0804b60c in MyButton::clicked::hddd191c8af96125TJaB::v0.0 ()
#7  0xb75575bf in wxClosure::Invoke(wxEvent*) () from wxc/libwxc.so
#8  0xb755770f in wxCallback::Invoke(wxEvent*) () from wxc/libwxc.so
#9  0xb7557426 in ELJApp::HandleEvent(wxEvent&) () from wxc/libwxc.so
#10 0xb615f518 in wxAppConsoleBase::HandleEvent(wxEvtHandler*, void (wxEvtHandler::*)(wxEvent&), wxEvent&) const () from /usr/lib/libwx_baseu-2.9.so.4
#11 0xb615f979 in wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const () from /usr/lib/libwx_baseu-2.9.so.4
#12 0xb62f7536 in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () from /usr/lib/libwx_baseu-2.9.so.4
#13 0xb62f7944 in wxEvtHandler::SearchDynamicEventTable(wxEvent&) () from /usr/lib/libwx_baseu-2.9.so.4
#14 0xb62f79fd in wxEvtHandler::TryHereOnly(wxEvent&) () from /usr/lib/libwx_baseu-2.9.so.4
#15 0xb62f7aa4 in wxEvtHandler::ProcessEventLocally(wxEvent&) () from /usr/lib/libwx_baseu-2.9.so.4
#16 0xb62f7b05 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib/libwx_baseu-2.9.so.4
#17 0xb62f784a in wxEvtHandler::SafelyProcessEvent(wxEvent&) () from /usr/lib/libwx_baseu-2.9.so.4
#18 0xb6779866 in wxWindowBase::HandleWindowEvent(wxEvent&) const () from /usr/lib/libwx_gtk2u_core-2.9.so.4
#19 0xb65e853f in ?? () from /usr/lib/libwx_gtk2u_core-2.9.so.4
#20 0xb5b790d3 in g_cclosure_marshal_VOID__VOIDv () from /usr/lib/libgobject-2.0.so.0
#21 0xb5b77637 in ?? () from /usr/lib/libgobject-2.0.so.0
#22 0xb5b90f79 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#23 0xb5b91b43 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#24 0xb5c3963a in gtk_button_clicked () from /usr/lib/libgtk-x11-2.0.so.0
#25 0xb5c3aa50 in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#26 0xb5b790d3 in g_cclosure_marshal_VOID__VOIDv () from /usr/lib/libgobject-2.0.so.0
#27 0xb5b75cc7 in ?? () from /usr/lib/libgobject-2.0.so.0
#28 0xb5b77637 in ?? () from /usr/lib/libgobject-2.0.so.0
#29 0xb5b90f79 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#30 0xb5b91b43 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#31 0xb5c3955a in gtk_button_released () from /usr/lib/libgtk-x11-2.0.so.0
#32 0xb5c395a4 in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#33 0xb5cf8b62 in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#34 0xb5b7620d in ?? () from /usr/lib/libgobject-2.0.so.0
#35 0xb5b77394 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#36 0xb5b89cd5 in ?? () from /usr/lib/libgobject-2.0.so.0
#37 0xb5b915b8 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#38 0xb5b91b43 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#39 0xb5e311a3 in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#40 0xb5cf6d0e in gtk_propagate_event () from /usr/lib/libgtk-x11-2.0.so.0
#41 0xb5cf70a8 in gtk_main_do_event () from /usr/lib/libgtk-x11-2.0.so.0
#42 0xb437a888 in ?? () from /usr/lib/libgdk-x11-2.0.so.0
#43 0xb5a84bd6 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#44 0xb5a84f75 in ?? () from /usr/lib/libglib-2.0.so.0
#45 0xb5a8544b in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
#46 0xb5cf5e3f in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
#47 0xb657fe27 in wxGUIEventLoop::Run() () from /usr/lib/libwx_gtk2u_core-2.9.so.4
#48 0xb6163c48 in wxAppConsoleBase::MainLoop() () from /usr/lib/libwx_baseu-2.9.so.4
---Type <return> to continue, or q <return> to quit---
#49 0xb615f412 in wxAppConsoleBase::OnRun() () from /usr/lib/libwx_baseu-2.9.so.4
#50 0xb664566e in wxAppBase::OnRun() () from /usr/lib/libwx_gtk2u_core-2.9.so.4
#51 0xb61fbde6 in wxEntry(int&, wchar_t**) () from /usr/lib/libwx_baseu-2.9.so.4
#52 0xb61fbe86 in wxEntry(int&, char**) () from /usr/lib/libwx_baseu-2.9.so.4
#53 0xb7541e42 in ELJApp_InitializeC () from wxc/libwxc.so
#54 0x08049ac0 in core::ELJApp::initializeC::h8bf3fe21ccb59d24XtaN::v0.0 ()
#55 0x08049885 in start::on_main::haf27ab5ad93909daP::v0.0 ()
#56 0xb7b1c068 in rt::task::__extensions__::build_start_wrapper::anon::anon::expr_fn::ae ()
   from ~/wxrust/wxRust/build/../../../../usr/local/lib/rustc/i686-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.9-pre.so
#57 0xb7b1a383 in rt::task::__extensions__::run::anon::expr_fn::ae ()
   from ~/wxrust/wxRust/build/../../../../usr/local/lib/rustc/i686-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.9-pre.so
#58 0xb7b1c363 in rt::task::Unwinder::try::try_fn::ha074f7dc17d93ad1kjam::v0.9$x2dpre ()
   from ~/wxrust/wxRust/build/../../../../usr/local/lib/rustc/i686-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.9-pre.so
#59 0xb740c272 in rust_try (f=0xb7b1c330 <rt::task::Unwinder::try::try_fn::ha074f7dc17d93ad1kjam::v0.9$x2dpre>, fptr=0xb7b1a340 <rt::task::__extensions__::run::anon::expr_fn::ae>, 
    env=0xae82d778) at ~/servo/src/compiler/rust/src/rt/rust_builtin.cpp:483
#60 0xb7b1a0d8 in rt::task::Task::run::h199ab8d6eb226980swab::v0.9$x2dpre ()
   from ~/wxrust/wxRust/build/../../../../usr/local/lib/rustc/i686-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.9-pre.so
#61 0xb7b1bd09 in rt::task::__extensions__::build_start_wrapper::anon::expr_fn::a5 ()
   from ~/wxrust/wxRust/build/../../../../usr/local/lib/rustc/i686-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.9-pre.so
#62 0xb7b7c285 in rt::context::Context::new::task_start_wrapper::h1b9fdc38dc3bcfa4B3av::v0.9$x2dpre ()
   from ~/wxrust/wxRust/build/../../../../usr/local/lib/rustc/i686-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.9-pre.so
#63 0x00000000 in ?? ()

Can't build on MacOSX with wxWidgets-3.0 @3.0.0_5 from macports

The error is:

[ 84%] Building CXX object wxc/CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/taskbaricon.cpp.o
[ 85%] Building CXX object wxc/CMakeFiles/wxc.dir/
/wxHaskell/wxc/src/cpp/textstream.cpp.o
[ 86%] Building CXX object wxc/CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/treectrl.cpp.o
[ 86%] Building CXX object wxc/CMakeFiles/wxc.dir/
/wxHaskell/wxc/src/cpp/wrapper.cpp.o
Linking CXX shared library libwxc.dylib
Undefined symbols:
"wxWindowBase::IsDescendant(wxWindowBase*) const", referenced from:
wxMDIParentFrameBase::TryBefore(wxEvent&) in apppath.cpp.o
wxMDIParentFrameBase::TryBefore(wxEvent&) in dragimage.cpp.o
wxMDIParentFrameBase::TryBefore(wxEvent&) in eljaccelerator.cpp.o
wxMDIParentFrameBase::TryBefore(wxEvent&) in eljartprov.cpp.o
wxMDIParentFrameBase::TryBefore(wxEvent&) in eljbitmap.cpp.o
wxMDIParentFrameBase::TryBefore(wxEvent&) in eljbrush.cpp.o
wxMDIParentFrameBase::TryBefore(wxEvent&) in eljbusyinfo.cpp.o
wxMDIParentFrameBase::TryBefore(wxEvent&) in eljbutton.cpp.o
wxMDIParentFrameBase::TryBefore(wxEvent&) in eljcalendarctrl.cpp.o
wxMDIParentFrameBase::TryBefore(wxEvent&) in eljcaret.cpp.o
...and so on

with VERBOSE=1:
make -f wxc/CMakeFiles/wxc.dir/build.make wxc/CMakeFiles/wxc.dir/depend
cd /Users/newchief/wxrust/wxRust/build && /opt/local/bin/cmake -E cmake_depends "Unix Makefiles" /Users/newchief/wxrust/wxRust /Users/newchief/wxrust/wxRust/wxc /Users/newchief/wxrust/wxRust/
build /Users/newchief/wxrust/wxRust/build/wxc /Users/newchief/wxrust/wxRust/build/wxc/CMakeFiles/wxc.dir/DependInfo.cmake --color=
make -f wxc/CMakeFiles/wxc.dir/build.make wxc/CMakeFiles/wxc.dir/build
Linking CXX shared library libwxc.dylib
cd /Users/newchief/wxrust/wxRust/build/wxc && /opt/local/bin/cmake -E cmake_link_script CMakeFiles/wxc.dir/link.txt --verbose=1
/usr/bin/c++ -I/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxWidgets/3.0/include/wx-3.0 -dynamiclib -Wl,-headerpad_max_install_names -o libwxc.dylib -install_name /Users/ne
wchief/wxrust/wxRust/build/wxc/libwxc.dylib CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/apppath.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/dragimage.cpp.o CMakeFiles/wxc.dir//wxHaske
ll/wxc/src/cpp/eljaccelerator.cpp.o CMakeFiles/wxc.dir/
/wxHaskell/wxc/src/cpp/eljartprov.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljbitmap.cpp.o CMakeFiles/wxc.dir//wxHaskell/wx
c/src/cpp/eljbrush.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljbusyinfo.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljbutton.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/
eljcalendarctrl.cpp.o CMakeFiles/wxc.dir/
/wxHaskell/wxc/src/cpp/eljcaret.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljcheckbox.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljc
hecklistbox.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljchoice.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljclipboard.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljcol
data.cpp.o CMakeFiles/wxc.dir/
/wxHaskell/wxc/src/cpp/eljcolour.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljcolourdlg.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljcombobox.c
pp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljconfigbase.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljcontrol.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljctxhelp.cpp.o
CMakeFiles/wxc.dir/
/wxHaskell/wxc/src/cpp/eljcursor.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljdataformat.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljdatetime.cpp.o CMake
Files/wxc.dir//wxHaskell/wxc/src/cpp/eljdc.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljdcsvg.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljdialog.cpp.o CMakeFiles/wxc.dir/
/wxHaskell/wxc/src/cpp/eljdirdlg.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljdnd.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljdrawing.cpp.o CMakeFiles/wxc.dir//wxHaskell/wx
c/src/cpp/eljevent.cpp.o CMakeFiles/wxc.dir/
/wxHaskell/wxc/src/cpp/eljfiledialog.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljfilehist.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/
cpp/eljfindrepldlg.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljfont.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljfontdata.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/el
jfontdlg.cpp.o CMakeFiles/wxc.dir/
/wxHaskell/wxc/src/cpp/eljframe.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljgauge.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljgrid.cpp.o
CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljhelpcontroller.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljicnbndl.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljicon.cpp.o CMak
eFiles/wxc.dir/
/wxHaskell/wxc/src/cpp/eljimage.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljimagelist.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljlayoutconstraints.cpp.o CM
akeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljlistbox.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljlistctrl.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljlocale.cpp.o CMakeFiles
/wxc.dir/
/wxHaskell/wxc/src/cpp/eljlog.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljmask.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljmdi.cpp.o CMakeFiles/wxc.dir//wxHaske
ll/wxc/src/cpp/eljmenu.cpp.o CMakeFiles/wxc.dir/
/wxHaskell/wxc/src/cpp/eljmenubar.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljmessagedialog.cpp.o CMakeFiles/wxc.dir//wxHaskell/wx
c/src/cpp/eljmime.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljminiframe.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljnotebook.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cp
p/eljpalette.cpp.o CMakeFiles/wxc.dir/
/wxHaskell/wxc/src/cpp/eljpanel.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljpen.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljprintdlg.
cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljprinting.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljprocess.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljradiobox.cpp.o
CMakeFiles/wxc.dir/
/wxHaskell/wxc/src/cpp/eljradiobutton.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljrc.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljregion.cpp.o CMakeFiles
/wxc.dir//wxHaskell/wxc/src/cpp/eljregioniter.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljsash.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljscrollbar.cpp.o CMakeFiles/wxc.d
ir/
/wxHaskell/wxc/src/cpp/eljscrolledwindow.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljsingleinst.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljsizer.cpp.o CMakeFiles/wxc.d
ir//wxHaskell/wxc/src/cpp/eljslider.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljspinctrl.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljsplitterwindow.cpp.o CMakeFiles/wxc.di
r/
/wxHaskell/wxc/src/cpp/eljstaticbox.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljstaticline.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljstatictext.cpp.o CMakeFiles/wxc.di
r//wxHaskell/wxc/src/cpp/eljstatusbar.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljsystemsettings.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljtextctrl.cpp.o CMakeFiles/wxc.
dir/
/wxHaskell/wxc/src/cpp/eljtimer.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljtipwnd.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljtglbtn.cpp.o CMakeFiles/wxc.dir//wxHas
kell/wxc/src/cpp/eljtoolbar.cpp.o CMakeFiles/wxc.dir/
/wxHaskell/wxc/src/cpp/eljvalidator.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/eljwindow.cpp.o CMakeFiles/wxc.dir//wxHaskell/wx
c/src/cpp/eljwizard.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/ewxw_main.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/extra.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/glcan
vas.cpp.o CMakeFiles/wxc.dir/
/wxHaskell/wxc/src/cpp/graphicscontext.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/image.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/managed.cpp.o C
MakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/mediactrl.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/previewframe.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/printout.cpp.o CMakeFiles
/wxc.dir/
/wxHaskell/wxc/src/cpp/sckaddr.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/socket.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/sound.cpp.o CMakeFiles/wxc.dir//wxHaskel
l/wxc/src/cpp/stc.cpp.o CMakeFiles/wxc.dir/
/wxHaskell/wxc/src/cpp/std.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/taskbaricon.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/textstr
eam.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/treectrl.cpp.o CMakeFiles/wxc.dir//wxHaskell/wxc/src/cpp/wrapper.cpp.o -L/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wx
Widgets/3.0/lib -L/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxWidgets/3.0/lib -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -f
ramework OpenGL -lwx_osx_cocoau_gl-3.0 -lwx_baseu-3.0 -Wl,-rpath,/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxWidgets/3.0/lib
Undefined symbols:
"wxWindowBase::IsDescendant(wxWindowBase*) const", referenced from:
wxMDIParentFrameBase::TryBefore(wxEvent&) in apppath.cpp.o
wxMDIParentFrameBase::TryBefore(wxEvent&) in dragimage.cpp.o
wxMDIParentFrameBase::TryBefore(wxEvent&) in eljaccelerator.cpp.o
wxMDIParentFrameBase::TryBefore(wxEvent&) in eljartprov.cpp.o

... and so on.

SingleInstanceChecker isAnotherRunning failing

SingleInstanceChecker::newDefault().isAnotherRunning() always returns a non zero value (looks like a pid), as if another instance of the app is running.

Some simplified code, to show my use:

fn main() {
    const NULLPTR: *mut c_void = 0 as *mut c_void;
    let closure = Closure::new(wx_main as *mut c_void, NULLPTR);
    let args: Vec<*mut i32> = Vec::new();
    RustApp::initializeC(&closure, args.len() as i32, args.as_ptr() as *mut *mut i8);
}

extern "C"
fn wx_main() {
    let sic = SingleInstanceChecker::newDefault();
    if sic.isAnotherRunning() == 0 {
        println!("Fresh app! ๐Ÿ˜ป");
    } else {
        println!("Another running! {} ๐Ÿ˜ฟ", sic.isAnotherRunning());
        panic!("Outahere");
    }
    let frame = Frame::new(&Window::null(), ID_ANY, "Hello, wxRust!", -1, -1, -1, -1, DEFAULT_FRAME_STYLE);
    frame.show();
    frame.raise();
}

Trying the check prior to RustApp init results in /usr/include/wx-3.0/wx/snglinst.h(58): assert "static_cast<wxApp*>(wxApp::GetInstance())" failed in CreateDefault(): must have application instance, so I figure wx_main is the right place for checking.

For info, the check works fine in the underlying wxHaskell:

main :: IO ()
main = do
  start $ singleMintegrator "fileName from elided args handling"

singleMintegrator :: String -> IO ()
singleMintegrator fileName = do
  sic <- singleInstanceCheckerCreateDefault
  running <- singleInstanceCheckerIsAnotherRunning sic

  if running
    then messageMintegrator fileName -- message existing instance
    else mintegrator fileName -- else set up new instance

Build for Linux

I had to make some changes in order to be able to build for Linux (Gentoo Linux with wxGTK-2.9.4.1-r1 from distribution):

  1. a symlink ../lib -> /usr/lib as clang's stddef.h need to be found in ../lib/clang/3.3/include during binding generation
  2. _unsafe.rs.patch should not be applied on Linux:
    diff --git a/CMakeLists.txt b/CMakeLists.txt
    index 2a8e19e..da4054f 100644
    --- a/CMakeLists.txt
    +++ b/CMakeLists.txt
    @@ -28,7 +28,7 @@ add_custom_command(
    --include time.h
    ${GENSRCS}
    > src/_unsafe.rs
  • COMMAND patch -p0 < src/_unsafe.rs.patch
    +# COMMAND patch -p0 < src/_unsafe.rs.patch
    DEPENDS bindgen.dummy ${GENSRCS}
    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
    )
  1. wxWidgets implementation for Linux is wxGtk not wxMac:

diff --git a/src/codegen.py b/src/codegen.py
index d94e00c..5641ac5 100644
--- a/src/codegen.py
+++ b/src/codegen.py
@@ -990,7 +990,7 @@ class Preprocessor(object):

 def _call_cpp(self, file):
     cppflags = Popen(['wx-config', '--cppflags'], stdout=PIPE).communicate()[0].split()
  •    cppflags.remove('-D__WXMAC__')
    
  •    cppflags.remove('-D__WXGTK__')
     cmdline = ['cpp', '-DWXC_TYPES_H'] + cppflags + ['-I/Users/kenz/src/wxRust/wxHaskell/wxc/src/include', file]
     return Popen(cmdline, stdout=PIPE).communicate()[0]
    
  1. For some reason rust-bindgen was unable to proceed with fail_on_bitfield, therefore I had to patch it too (patch for commit 6b77ae6202cec2204795504b89fa944400245667):

diff --git a/main.rs b/main.rs
index 10522c3..1bb3fea 100644
--- a/main.rs
+++ b/main.rs
@@ -359,10 +359,10 @@ fn visit_struct(cursor: &Cursor,
let bit = cursor.bit_width();
// If we encounter a bitfield, and fail_on_bitfield is set, throw an
// error and exit entirely.

  •    if (bit != None && ctx.fail_on_bitfield) {
    
  •        fail!("Cannot handle bitfield `{}` in struct `{}`",
    
  •              name, parent.spelling());
    
  •    }
    
    +// if (bit != None && ctx.fail_on_bitfield) {
    +// fail!("Cannot handle bitfield {} in struct {}",
    +// name, parent.spelling());
    +// }
    let field = mk_fieldinfo(name, ty, bit);
    fields.push(field);
    }

Now build completes and I am able to run test. Unfortunately, when I press the button, it segfaults after printing "hello!"

crates.io

I want to include wxRust in my Cargo.toml but I don't know what to use. I don't even know if wxRust is on crates.io at all. Would you mind publishing it there and adding a note in the repository specifying where it is?

Thanks!

Build problems

I'm trying to build this, but keep getting an error - if I figure i tout I'll update this and maybe PR the README or whatever's needed - meanwhile here's the problem I have.

Scanning dependencies of target wxrust
[ 87%] Generating ../rust-bindgen/target/debug/bindgen
Updating git repository https://github.com/rust-lang/log.git
Compiling rust-bindgen v0.13.0 (file:///Users/andrew/workspace/wxRust/rust-bindgen)
Running rustc build.rs --crate-name build_script_build --crate-type bin -g --out-dir /Users/andrew/workspace/wxRust/rust-bindgen/target/debug/build/rust-bindgen-be5058dd5296614b --emit=dep-info,link -L dependency=/Users/andrew/workspace/wxRust/rust-bindgen/target/debug -L dependency=/Users/andrew/workspace/wxRust/rust-bindgen/target/debug/deps
Compiling log v0.3.6 (https://github.com/rust-lang/log.git#d040d323)
Running rustc /Users/andrew/.cargo/git/checkouts/log-c58e1db3de7c154d/master/src/lib.rs --crate-name log --crate-type lib -g --cfg feature=\"use_std\" --cfg feature=\"default\" -C metadata=5439bf31eed317bd -C extra-filename=-5439bf31eed317bd --out-dir /Users/andrew/workspace/wxRust/rust-bindgen/target/debug/deps --emit=dep-info,link -L dependency=/Users/andrew/workspace/wxRust/rust-bindgen/target/debug/deps -L dependency=/Users/andrew/workspace/wxRust/rust-bindgen/target/debug/deps --cap-lints allow
build.rs:1:1: 1:22 error: #[feature] may not be used on the stable release channel
build.rs:1 #![feature(path_ext)]
^~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error

I've tried using rustup, setting 'nightly' as rust version in the wxRust/ folder (parent of 'build/'). Then I get this:

patching file wxc/src/include/wxc_glue.h
Reversed (or previously applied) patch detected! Skipping patch.
4 out of 4 hunks ignored -- saving rejects to file wxc/src/include/wxc_glue.h.rej
[ 0%] Built target patch_wxc_glue_h
[ 86%] Built target wxc
[ 87%] Generating ../rust-bindgen/target/debug/bindgen
Compiling rust-bindgen v0.13.0 (file:///Users/andrew/workspace/wxRust/rust-bindgen)
Compiling log v0.3.6 (https://github.com/rust-lang/log.git#d040d323)
Running rustc build.rs --crate-name build_script_build --crate-type bin -g -C metadata=be5058dd5296614b --out-dir /Users/andrew/workspace/wxRust/rust-bindgen/target/debug/build/rust-bindgen-be5058dd5296614b --emit=dep-info,link -L dependency=/Users/andrew/workspace/wxRust/rust-bindgen/target/debug/deps
Running rustc /Users/andrew/.cargo/git/checkouts/log-c58e1db3de7c154d/master/src/lib.rs --crate-name log --crate-type lib -g --cfg feature=\"use_std\" --cfg feature=\"default\" -C metadata=5439bf31eed317bd -C extra-filename=-5439bf31eed317bd --out-dir /Users/andrew/workspace/wxRust/rust-bindgen/target/debug/deps --emit=dep-info,link -L dependency=/Users/andrew/workspace/wxRust/rust-bindgen/target/debug/deps --cap-lints allow
error[E0432]: unresolved import std::fs::PathExt
--> build.rs:4:5
|
4 | use std::fs::PathExt;
| ^^^^^^^^^^^^^^^^ no PathExt in std::fs

error: aborting due to previous error

Build failed, waiting for other jobs to finish...
error: Could not compile rust-bindgen.

Caused by:
Process didn't exit successfully: rustc build.rs --crate-name build_script_build --crate-type bin -g -C metadata=be5058dd5296614b --out-dir /Users/andrew/workspace/wxRust/rust-bindgen/target/debug/build/rust-bindgen-be5058dd5296614b --emit=dep-info,link -L dependency=/Users/andrew/workspace/wxRust/rust-bindgen/target/debug/deps (exit code: 101)
make[2]: *** [../rust-bindgen/target/debug/bindgen] Error 101
make[1]: *** [CMakeFiles/wxrust.dir/all] Error 2
make: *** [all] Error 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.