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

Issue:
Repository reorganization
Proposition:
- Move everything related to the `gl` crate (`Cargo.toml`, `src/gl`, `tests` and `examples`) in a `gl` subdirectory.
- Move `gl_generator`, `khronos_api` and `gl_common` directories from `src` to the crate root.
- Add a `gl_tests` crate (which we won't publish) that is used to test the output of `gl_generator` instead of `gl` itself (solves #314).

All five crates (`gl`, `gl_generator`, `gl_common`, `khronos_api`, `gl_tests`) would be at the same level at the root of the repository, alongside with `.gitignore`, `.travis.yml`, etc.



Discussion / hints:
:+1:


Fix patch:
diff --git a/.gitignore b/.gitignore
index 8c61d044..77f87c6d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,11 @@
 .DS_store
-/target
-/examples/*/target
-Cargo.lock
-/src/gl_generator/target/
+/gl/target/
+/gl/Cargo.lock
+/gl_common/target/
+/gl_common/Cargo.lock
+/gl_generator/target/
+/gl_generator/Cargo.lock
+/gl_tests/target/
+/gl_tests/Cargo.lock
+/khronos_api/target/
+/khronos_api/Cargo.lock
diff --git a/.gitmodules b/.gitmodules
index 09843ee0..01e0f355 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,3 @@
-[submodule "src/khronos_api/api"]
-	path = src/khronos_api/api
+[submodule "khronos_api/api"]
+	path = khronos_api/api
 	url = https://github.com/capnm/Khronos_XML_API
diff --git a/.travis.yml b/.travis.yml
index 85d10bae..4047ca6c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,8 +6,11 @@ env:
   global:
     - secure: SH7xrrH8ONXcrpHzKVJsBuLX1AikKBTBBI0SsEfCWfDZsAur0rQW5ZlPPorhQ0iZUbvw5xwY26T+0EYdBAWOwp7AOBM2iwoGZ15ERTd8o2JX3ZlMQ9AvDHNaXAc6YToj69DaiaimX+oX9DtZeRfQ309Lkp4D1YMrf4X/jhNpQdI=
 
+script:
+  - ./test-all.sh
+
 after_script:
   # the doc directory needs to be in the root for rust-ci
-  - cargo doc
-  - ln -s target/doc doc
+  - cargo doc --manifest-path gl/Cargo.toml
+  - ln -s gl/target/doc doc
   - curl http://www.rust-ci.org/artifacts/put?t=$RUSTCI_TOKEN | sh
diff --git a/Cargo.toml b/gl/Cargo.toml
similarity index 78%
rename from Cargo.toml
rename to gl/Cargo.toml
index c9281b18..24cae986 100644
--- a/Cargo.toml
+++ b/gl/Cargo.toml
@@ -9,23 +9,19 @@ authors = ["Brendan Zabarauskas <bjzaba@yahoo.com.au>",
 ]
 description = "OpenGL bindings"
 license = "Apache-2.0"
-build = "src/gl/build.rs"
+build = "build.rs"
 repository = "https://github.com/bjz/gl-rs/"
 
-[lib]
-name = "gl"
-path = "src/gl/lib.rs"
-
 [build-dependencies.gl_generator]
-path = "src/gl_generator"
+path = "../gl_generator"
 version = "*"
 
 [build-dependencies.khronos_api]
-path = "src/khronos_api"
+path = "../khronos_api"
 version = "0.0.5"
 
 [dependencies.gl_common]
-path = "src/gl_common"
+path = "../gl_common"
 version = "0.0.4"
 
 [dependencies]
diff --git a/gl/build.rs b/gl/build.rs
new file mode 100644
index 00000000..61c445ce
--- /dev/null
+++ b/gl/build.rs
@@ -0,0 +1,17 @@
+extern crate gl_generator;
+extern crate khronos_api;
+
+use std::os;
+use std::old_io::File;
+use std::old_io::BufferedWriter;
+
+fn main() {
+    let dest = Path::new(os::getenv("OUT_DIR").unwrap());
+
+    let mut file = BufferedWriter::new(File::create(&dest.join("bindings.rs")).unwrap());
+    gl_generator::generate_bindings(gl_generator::GlobalGenerator,
+                                    gl_generator::registry::Ns::Gl,
+                                    gl_generator::Fallbacks::All,
+                                    khronos_api::GL_XML, vec![], "4.5", "core",
+                                    &mut file).unwrap();
+}
diff --git a/examples/static_basic.rs b/gl/examples/static_basic.rs
similarity index 100%
rename from examples/static_basic.rs
rename to gl/examples/static_basic.rs
diff --git a/examples/static_triangle.rs b/gl/examples/static_triangle.rs
similarity index 100%
rename from examples/static_triangle.rs
rename to gl/examples/static_triangle.rs
diff --git a/examples/struct_triangle.rs b/gl/examples/struct_triangle.rs
similarity index 100%
rename from examples/struct_triangle.rs
rename to gl/examples/struct_triangle.rs
diff --git a/src/gl/lib.rs b/gl/src/lib.rs
similarity index 100%
rename from src/gl/lib.rs
rename to gl/src/lib.rs
diff --git a/src/gl_common/Cargo.toml b/gl_common/Cargo.toml
similarity index 100%
rename from src/gl_common/Cargo.toml
rename to gl_common/Cargo.toml
diff --git a/src/gl_common/src/lib.rs b/gl_common/src/lib.rs
similarity index 100%
rename from src/gl_common/src/lib.rs
rename to gl_common/src/lib.rs
diff --git a/src/gl_generator/Cargo.toml b/gl_generator/Cargo.toml
similarity index 100%
rename from src/gl_generator/Cargo.toml
rename to gl_generator/Cargo.toml
diff --git a/src/gl_generator/generators/global_gen.rs b/gl_generator/generators/global_gen.rs
similarity index 100%
rename from src/gl_generator/generators/global_gen.rs
rename to gl_generator/generators/global_gen.rs
diff --git a/src/gl_generator/generators/mod.rs b/gl_generator/generators/mod.rs
similarity index 100%
rename from src/gl_generator/generators/mod.rs
rename to gl_generator/generators/mod.rs
diff --git a/src/gl_generator/generators/static_gen.rs b/gl_generator/generators/static_gen.rs
similarity index 100%
rename from src/gl_generator/generators/static_gen.rs
rename to gl_generator/generators/static_gen.rs
diff --git a/src/gl_generator/generators/static_struct_gen.rs b/gl_generator/generators/static_struct_gen.rs
similarity index 100%
rename from src/gl_generator/generators/static_struct_gen.rs
rename to gl_generator/generators/static_struct_gen.rs
diff --git a/src/gl_generator/generators/struct_gen.rs b/gl_generator/generators/struct_gen.rs
similarity index 100%
rename from src/gl_generator/generators/struct_gen.rs
rename to gl_generator/generators/struct_gen.rs
diff --git a/src/gl_generator/generators/ty.rs b/gl_generator/generators/ty.rs
similarity index 100%
rename from src/gl_generator/generators/ty.rs
rename to gl_generator/generators/ty.rs
diff --git a/src/gl_generator/lib.rs b/gl_generator/lib.rs
similarity index 98%
rename from src/gl_generator/lib.rs
rename to gl_generator/lib.rs
index dc045c74..69a25103 100644
--- a/src/gl_generator/lib.rs
+++ b/gl_generator/lib.rs
@@ -37,7 +37,8 @@
 //!
 //!     gl_generator::generate_bindings(gl_generator::GlobalGenerator,
 //!                                     gl_generator::registry::Ns::Gl,
-//!                                     khronos_api::GL_XML, vec![], "4.5", "core"
+//!                                     gl_generator::Fallbacks::All,
+//!                                     khronos_api::GL_XML, vec![], "4.5", "core",
 //!                                     &mut file).unwrap();
 //! }
 //! ~~~
diff --git a/src/gl_generator/registry.rs b/gl_generator/registry.rs
similarity index 100%
rename from src/gl_generator/registry.rs
rename to gl_generator/registry.rs
diff --git a/src/khronos_api/Cargo.toml b/khronos_api/Cargo.toml
similarity index 100%
rename from src/khronos_api/Cargo.toml
rename to khronos_api/Cargo.toml
diff --git a/src/khronos_api/api b/khronos_api/api
similarity index 100%
rename from src/khronos_api/api
rename to khronos_api/api
diff --git a/src/khronos_api/src/lib.rs b/khronos_api/src/lib.rs
similarity index 100%
rename from src/khronos_api/src/lib.rs
rename to khronos_api/src/lib.rs


Test patch:
diff --git a/gl_tests/Cargo.toml b/gl_tests/Cargo.toml
new file mode 100644
index 00000000..fc77865e
--- /dev/null
+++ b/gl_tests/Cargo.toml
@@ -0,0 +1,20 @@
+[package]
+# we don't include some metadata to avoid accidental publishes
+name = "gl_tests"
+version = "0.0.1"
+build = "build.rs"
+
+[build-dependencies.gl_generator]
+path = "../gl_generator"
+version = "*"
+
+[build-dependencies.khronos_api]
+path = "../khronos_api"
+version = "0.0.5"
+
+[dependencies.gl_common]
+path = "../gl_common"
+version = "0.0.4"
+
+[dependencies]
+libc = "*"
diff --git a/src/gl/build.rs b/gl_tests/build.rs
similarity index 100%
rename from src/gl/build.rs
rename to gl_tests/build.rs
diff --git a/gl_tests/src/lib.rs b/gl_tests/src/lib.rs
new file mode 100644
index 00000000..44ae78fc
--- /dev/null
+++ b/gl_tests/src/lib.rs
@@ -0,0 +1,1 @@
+include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
diff --git a/tests/generators_symbols.rs b/gl_tests/tests/generators_symbols.rs
similarity index 100%
rename from tests/generators_symbols.rs
rename to gl_tests/tests/generators_symbols.rs
diff --git a/tests/gl_symbols.rs b/gl_tests/tests/gl_symbols.rs
similarity index 59%
rename from tests/gl_symbols.rs
rename to gl_tests/tests/gl_symbols.rs
index e67ec88d..03ed239f 100644
--- a/tests/gl_symbols.rs
+++ b/gl_tests/tests/gl_symbols.rs
@@ -1,16 +1,16 @@
 //! This test ensures that the GL symbols are defined and that fallback works correctly.
 
-extern crate gl;
+extern crate gl_tests;
 extern crate libc;
 
 #[test]
 #[ignore]
 fn symbols_exist() { unsafe {
-	gl::Clear(gl::COLOR_BUFFER_BIT);
-	let _: libc::c_uint = gl::CreateProgram();
-	gl::CompileShader(5);
+	gl_tests::Clear(gl_tests::COLOR_BUFFER_BIT);
+	let _: libc::c_uint = gl_tests::CreateProgram();
+	gl_tests::CompileShader(5);
 
-    gl::GetActiveUniformBlockiv(0, 0, gl::UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER,
+    gl_tests::GetActiveUniformBlockiv(0, 0, gl_tests::UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER,
         std::ptr::null_mut());
 } }
 
@@ -24,6 +24,6 @@ fn fallback_works() {
         }
     };
 
-    gl::GenFramebuffers::load_with(loader);
-    assert!(gl::GenFramebuffers::is_loaded());
+    gl_tests::GenFramebuffers::load_with(loader);
+    assert!(gl_tests::GenFramebuffers::is_loaded());
 }
diff --git a/tests/loading.rs b/gl_tests/tests/loading.rs
similarity index 82%
rename from tests/loading.rs
rename to gl_tests/tests/loading.rs
index 442154cc..6fd9dc67 100644
--- a/tests/loading.rs
+++ b/gl_tests/tests/loading.rs
@@ -1,5 +1,5 @@
 extern crate libc;
-extern crate gl;
+extern crate gl_tests;
 extern crate gl_common;
 
 struct X;
@@ -12,5 +12,5 @@ impl gl_common::GlFunctionsSource for X {
 
 #[test]
 fn main() {
-    gl::load(&X);
+    gl_tests::load(&X);
 }
diff --git a/tests/no_warning.rs b/gl_tests/tests/no_warning.rs
similarity index 100%
rename from tests/no_warning.rs
rename to gl_tests/tests/no_warning.rs
diff --git a/test-all.sh b/test-all.sh
new file mode 100755
index 00000000..6fb79255
--- /dev/null
+++ b/test-all.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+cargo test --verbose --manifest-path gl_generator/Cargo.toml
+cargo test --verbose --manifest-path gl/Cargo.toml
+cargo test --verbose --manifest-path gl_tests/Cargo.toml