NervLand: Environment setup & Introduction to Rust
- First thing first I need a Rust development environment for that project.
- Downloading rustup from https://www.rust-lang.org/fr/tools/install
- Other installation pacakges available at: https://forge.rust-lang.org/infra/other-installation-methods.html
- To install in a correct folder:
set CARGO_HOME=D:\Softs\Cargo rustup-init.exe
- ⇒ rust now installed in D:/Softs/Cargo
- Installing the extensions for visual studio code: rust-analyzer and rust
- Now creating our new NervLand git project: OK
- Checking out project:
$ git clone ssh://git@gitlab.nervtech.org:22002/nerv/nervland.git NervLand
/ - Preparing script to support nvl_home: OK
- Creating initial rust project:
cargo init NervLand
- Now following tutorial on https://sotrh.github.io/learn-wgpu/
- Update .git/config file with content:
[core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true ignorecase = true autocrlf = false
- Found this page with a lot of resources for game development in Rust: https://arewegameyet.rs/
- ECS library: bevy_ecs or specs
- Documentation for WGSL language: https://www.w3.org/TR/WGSL/
- Documentation to read on Rust: https://doc.rust-lang.org/book/
- Implemented RenderPipeline test tutorial from: https://sotrh.github.io/learn-wgpu/beginner/tutorial3-pipeline/#what-s-a-pipeline
- Working on tutorial https://sotrh.github.io/learn-wgpu/beginner/tutorial5-textures/:
- But I get the ERROR message:
2022-02-21T08:03:06Z ERROR wgpu_hal::dx12::instance] ID3D12Device::CopyDescriptors: Source ranges and dest ranges overlap, which results in undefined behavior. [ EXECUTION ERROR #653: COPY_DESCRIPTORS_INVALID_RANGES] error: process didn't exit successfully: `target\debug\nerv_land.exe` (exit code: 1)
- ⇒ trying to use the source files from: https://github.com/sotrh/learn-wgpu/tree/master/code/beginner/tutorial5-textures/src
- ⇒ Updating the nvidia drivers fixed this issue.
- Note: it's a good idea to use
cargo check
regularly to speed up the development process. - To build a release version with cargo we use:
$ cargo build --release
- Continuing with https://sotrh.github.io/learn-wgpu/beginner/tutorial6-uniforms/: OK
- Continuing with https://sotrh.github.io/learn-wgpu/beginner/tutorial7-instancing/: OK
- wgpu documentation access: https://docs.rs/wgpu/0.12.0/wgpu/struct.RenderPass.html#method.draw_indexed
- Continuing with https://sotrh.github.io/learn-wgpu/beginner/tutorial8-depth/: OK
- Continuing with https://sotrh.github.io/learn-wgpu/beginner/tutorial9-models/: OK
- Enabled “Run build script” for rust-analyzer in VSCode with
“rust-analyzer.cargo.runBuildScripts”: true
in settings.json
- Now I should really read the Rust programming book: OK
- Written notes at: The Rust Programming Language
- Note Found the fibers crate for Rust: can use this to execute tasks in fibers.
- Note Found the veryfast crate to build a memory pool allocator (?)
- One thing that is starting to be a pain here is that I canno use a rust brush with syntaxhighlighter4 plugin for dokuwiki lol ⇒ So let's see if I can add that myself.
- Add rust brush function in wiki/lib/plugins/syntaxhighlighter4/dist/syntaxhighlighter.js at the end of the function list:
/* 63 */ /***/ (function(module, exports, __webpack_require__) { // This is an extension function to support the rust brush: 'use strict'; var BrushBase = __webpack_require__(22); var regexLib = __webpack_require__(3).commonRegExp; function Brush() { var keywords = 'break case catch class continue ' + 'default delete do else enum export extends false ' + 'for function if implements import in instanceof ' + 'interface let new null package private protected ' + 'static return super switch ' + 'this throw true try typeof var while with yield' + ' any bool declare get module never number public readonly set string'; // TypeScript-specific, everything above is common with JavaScript this.regexList = [{ regex: regexLib.multiLineDoubleQuotedString, css: 'string' }, { regex: regexLib.multiLineSingleQuotedString, css: 'string' }, { regex: regexLib.singleLineCComments, css: 'comments' }, { regex: regexLib.multiLineCComments, css: 'comments' }, { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }]; this.forHtmlScript(regexLib.scriptScriptTags); }; Brush.prototype = new BrushBase(); Brush.aliases = ['rust']; module.exports = Brush; /***/ })
- And registering that function at the beginning of the file:
console.log("Registering rust brush!"); registerBrush(__webpack_require__(63)); // rust
- But that doesn't seem to be enough: maybe we need to “reload” our plugin somehow ?
- Hmmm not quite working: checking if we can modify one of the existing brush. ⇒ Nope, no effect either. So let's restart the server then.
- Damn it, still not working! So maybe I really need to refer to a dedicated git project to install the plugin then: let's try that.
- Arrggh… still not working at all. There is something I'm missing here…
- okay so: this is really starting to piss me off now 🤬! I just want a minor change in that source .js file man, come on!
- Fewww…. So in the end this was simply a collection of
rm -Rf cache/*
+ running in private web page to avoid the cache + restarting the server and all: but now it seem I can finally get that rust brush to start working! Let's try to finalize it. - ⇒ okay, so, not the best parsing yet, but it's not that bad for a start.
- Added support for rust code snippet in vscode:
"CodeRust": { "prefix": "cccrs", "body": [ "<sxh rust; highlight: []>${1}</sxh>$0" ] },
- ⇒ Now updating my overall project structure: I'm considering placing everything for Rust in my NervSeed project directly 🤔:
- I could create a rust folder, and store multiple rust workspaces in there (?)
- OK, trying that, starting with an nvtask library in there:
$ cargo new nvtask --lib
- Running default cargo workspace tests:
$ cargo test
- Ignore target/ folder with .gitignore file: OK