public:projects:nervland:notes:0007_nvland_environment_setup

NervLand: Environment setup & Introduction to Rust

  • First thing first I need a Rust development environment for that project.
  • 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
  • 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
  • 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
  • public/projects/nervland/notes/0007_nvland_environment_setup.txt
  • Last modified: 2022/02/27 09:09
  • by 127.0.0.1