Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build for Linux #19

Closed
newchief opened this issue Dec 31, 2013 · 2 comments
Closed

Build for Linux #19

newchief opened this issue Dec 31, 2013 · 2 comments
Assignees
Milestone

Comments

@newchief
Copy link

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!"

@kenz-gelsoft
Copy link
Owner

Thank you for some patches I'll integrates these ones.

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}
 )
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]
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);
     }

I'll investigate for seg fault problem after that.

@kenz-gelsoft
Copy link
Owner

commit 0f6e783 and 30a91b7 should fixe this.

Thanks for reporting!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants