Giter VIP home page Giter VIP logo

spatialos-sdk-rs's Introduction

SpatialOS SDK for Rust

An integration of the SpatialOS C API and the Rust programming language.

Note: This is an unofficial integration of the SpatialOS C API with Rust. Improbable does not officially support Rust as a worker language.

Quick start

Requirements

To develop in this repository you'll need:

  1. Rust v1.40
  2. A SpatialOS account
  3. The Spatial CLI installed and available on your PATH.

Setup

  1. Clone this repository.

  2. Install cargo-spatial.

    $ cargo install --path ./cargo-spatial --force
    
  3. Set the SPATIAL_LIB_DIR environment variable to the location of the SpatialOS dependencies.

    $ export SPATIAL_LIB_DIR=$(pwd)/dependencies
    
  4. Download the C API dependencies.

    $ cargo spatial download sdk --sdk-version 14.8.0 --with-test-schema
    
  5. Build the spatialos-sdk crate.

    $ cd spatialos-sdk && cargo build
    

At this point, the spatialos-sdk crate has been built and linked successfully and can be used in user code.

Running the Example Project

To run the example project, you will need to:

  1. Navigate to the example project:
$ cd project-example
  1. Generate Rust code from the project's SpatialOS schema.
$ cargo spatial codegen
  1. Launch a local deployment:
$ cargo spatial local launch

Its ready to go when you see a message like the following in your console.

Access the Inspector at http://localhost:21000/inspector

Navigate to http://localhost:21000/inspector in your browser to view your deployment. You should see 4 workers already connected, these were started by the SpatialOS Runtime.

If you want to manually launch another instance of the worker, run the following command from the project-example directory:

$ cargo run -- --worker-id RustWorker999 --worker-type RustWorker receptionist

This will allow you to see the log output of the worker as it runs.

Running the test-suite

There are some integration tests that live in the test-suite crate. These utilize and test generated code. To run these tests:

$ cd test-suite && cargo spatial codegen && cargo test

Testing the code generator

To regenerate the schema bundle, run the following:

$ ./dependencies/schema-compiler/schema_compiler --schema_path=project-example/schema --schema_path=dependencies/std-lib project-example/schema/example.schema --bundle_json_out=spatialos-sdk-code-generator/data/test.sb.json

To run the code generator tests, run the following:

$ cargo test -p spatialos-sdk-code-generator

To display Rusts auto-generated debug representation of the schema bundle, run the following:

$ cargo test -p spatialos-sdk-code-generator -- --nocapture

Updating Rust bindings

To update the Rust bindings found in spatialos-sdk-sys run the following command from the root of the repository:

$ cargo run --bin generate_bindings -- -i ./dependencies/headers/include/improbable/ -o ./spatialos-sdk-sys/src/

Note: this depends on bindgen which has clang as a dependency. See bindgen's documentation for more info.

License

Licensed under either of Apache License, Version 2.0 or MIT at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

spatialos-sdk-rs's People

Contributors

jamiebrynes7 avatar randompoison avatar dependabot-preview[bot] avatar dgavedissian avatar jacmob avatar johnpmayer avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.