Repository: brendanzab/gl-rs (language: rust)

Issue:
Build fails on OS X 10.10.2
Hi,

I have installed last version of rust (rustc 1.0.0-nightly (b9ba643b7 2015-02-13 21:15:39 +0000)), and when I launch "cargo build" I get the following error:

```
   Compiling khronos_api v0.0.5 (file:///Users/KillKRT/Documents/Development/gl-rs)
   Compiling gl_common v0.0.4 (file:///Users/KillKRT/Documents/Development/gl-rs)
   Compiling xml-rs v0.1.18
src/khronos_api/src/lib.rs:4:36: 4:68 error: couldn't read src/khronos_api/api/gl.xml: couldn't open path as file (no such file or directory (No such file or directory); path=src/khronos_api/api/gl.xml; mode=open; access=read)
src/khronos_api/src/lib.rs:4 pub static GL_XML: &'static [u8] = include_bytes!("../api/gl.xml");
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/khronos_api/src/lib.rs:7:37: 7:70 error: couldn't read src/khronos_api/api/egl.xml: couldn't open path as file (no such file or directory (No such file or directory); path=src/khronos_api/api/egl.xml; mode=open; access=read)
src/khronos_api/src/lib.rs:7 pub static EGL_XML: &'static [u8] = include_bytes!("../api/egl.xml");
                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/khronos_api/src/lib.rs:10:37: 10:70 error: couldn't read src/khronos_api/api/wgl.xml: couldn't open path as file (no such file or directory (No such file or directory); path=src/khronos_api/api/wgl.xml; mode=open; access=read)
src/khronos_api/src/lib.rs:10 pub static WGL_XML: &'static [u8] = include_bytes!("../api/wgl.xml");
                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/khronos_api/src/lib.rs:13:37: 13:70 error: couldn't read src/khronos_api/api/glx.xml: couldn't open path as file (no such file or directory (No such file or directory); path=src/khronos_api/api/glx.xml; mode=open; access=read)
src/khronos_api/src/lib.rs:13 pub static GLX_XML: &'static [u8] = include_bytes!("../api/glx.xml");
                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 4 previous errors
Build failed, waiting for other jobs to finish...
Could not compile `khronos_api`.
```



Discussion / hints:
You need to run `git submodule update --init`

This is only needed if you clone the gl-rs repo itself, and shouldn't happen if you use gl-rs as a dependency of another package.

Thank you... That worked! Anyway I cannot still understand how to compile the examples. Why I cannot find them in the target folder?

The examples require `glfw` to compile. Since `glfw` is not available on crates.io, we had to make some modifications to allowing uploading gl-rs on it.

To compile the examples:
- Remove the first line of the Cargo.toml: https://github.com/bjz/gl-rs/blob/master/Cargo.toml#L1
- Restore the two commented-out lines: https://github.com/bjz/gl-rs/blob/master/Cargo.toml#L34-35
- Run `cargo test` (just `cargo build` doesn't compile the examples)

Note that the `static_triangle` example is maybe crashing (https://github.com/bjz/gl-rs/issues/308)

Thank you for you support.

I've modified my `Cargo.toml` as suggested, but I got these errors:

```
examples/struct_triangle.rs:17:12: 17:17 error: feature has been removed
examples/struct_triangle.rs:17 #![feature(phase)]
                                          ^~~~~
error: aborting due to previous error
Build failed, waiting for other jobs to finish...
examples/static_basic.rs:25:5: 25:9 error: cannot borrow immutable local variable `glfw` as mutable
examples/static_basic.rs:25     glfw.window_hint(WindowHint::ContextVersion(3, 2));
                                ^~~~
examples/static_basic.rs:26:5: 26:9 error: cannot borrow immutable local variable `glfw` as mutable
examples/static_basic.rs:26     glfw.window_hint(WindowHint::OpenglForwardCompat(true));
                                ^~~~
examples/static_basic.rs:27:5: 27:9 error: cannot borrow immutable local variable `glfw` as mutable
examples/static_basic.rs:27     glfw.window_hint(WindowHint::OpenglProfile(OpenGlProfileHint::Core));
                                ^~~~
examples/static_basic.rs:33:5: 33:11 error: cannot borrow immutable local variable `window` as mutable
examples/static_basic.rs:33     window.make_current();
                                ^~~~~~
examples/static_basic.rs:36:19: 36:49 error: closure cannot assign to immutable local variable `window`
examples/static_basic.rs:36     gl::load_with(|s| window.get_proc_address(s));
                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
examples/static_basic.rs:40:9: 40:13 error: cannot borrow immutable local variable `glfw` as mutable
examples/static_basic.rs:40         glfw.poll_events();
                                    ^~~~
examples/static_basic.rs:49:9: 49:15 error: cannot borrow immutable local variable `window` as mutable
examples/static_basic.rs:49         window.swap_buffers();
                                    ^~~~~~
error: aborting due to 7 previous errors
```

I guess some feature has been changed/removed in recent nightly build.

The examples look seriously outdated :-/

Ugh weird - I wonder if we have disabled the glfw examples on travis :/

Oh wait, yeah, it would be the examples in gl-rs

`let glfw = ...` should be `let mut glfw = ...`

I would suggest to put `git submodule update --init` in the README as I think it is a good idea to let people know how to solve a problem like this without referring to the issues.


Fix patch:
diff --git a/README.md b/README.md
index 29ee1139..d387c828 100644
--- a/README.md
+++ b/README.md
@@ -38,3 +38,14 @@ The Khronos XML API Registry, exposed as byte string constants.
 [build-dependencies]
 khronos_api = "1.0.0"
 ```
+
+## Compiling from source
+
+`khronos_api` uses a git submodule. You will need to initialize it before building:
+
+```sh
+git submodule update --init
+```
+
+A batch cargo script is provided at `bin/cargo`. [See the script](https://github.com/bjz/gl-rs/blob/master/bin/cargo)
+for some example usages.


Test patch: