Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
295 lines (260 sloc) 10.9 KB
description
Contributing to nidium

[warning: nidium is currently under heavy development and we are looking for contributors to join our efforts. The main goal of nidium is to enable developers to build cross platform application with JavaScript.]

Depending of your skills you can help us on various areas :

  • If you know C/C++ by porting nidium to a new platform, fixing bugs or, adding new features.
  • If you know JavaScript help us to improve the HTML5 compatibility layer for supporting more well-known JavaScript libraries. You can also build awesome applications or library unleashing the power of nidium.
  • If you know Python you can contribute to our build & documentation system
  • Review & improve our documentation
  • Test nidium on your computer/devices and report bugs.
  • Spread the word about nidium : social network, blog, etc.

If you are interested in contributing to nidium, drop us a message on Slack, IRC or GitHub so we can help you and give you insights.

Overview of nidium projects

  • nidium : Our main product, also known as nidium Frontend enable you to build graphical software with JavaScript. It expose various API including Canvas, WebGL, Audio, Timers, Sockets, Threading, Files, ...
  • nidium server: A version of nidium tailored for servers (headless nidium)
  • libnidiumcore: A library for spidermonkey embedders with all the core features of nidium (Timers, Sockets, Threading, Files)
  • libapenetwork: A fast cross-platform async network library. This library is used as the main event loop of nidium.
  • Konstructor: A python script that handles the building of third-party libraries and other usefull stuff.

Building nidium

To build nidium you need about 6GB of disk space. A build from scratch may take 30 min to a few hours, depending of the speed of your computer.

On a debian based system, a few commands will get you started.

$ apt-get install libpci-dev python2.7 git make patch clang pkg-config libgtk2.0-dev libgtk-3-dev mesa-common-dev libglu1-mesa-dev libosmesa6-dev yasm libasound2 libasound2-dev libbz2-1.0
$ git clone https://github.com/nidium/NidiumTools.git
$ git clone --recursive https://github.com/nidium/Nidium.git
$ export PYTHONPATH=$(pwd)/NidiumTools/src
$ cd Nidium
$ ./configure_frontend
$ ./bin/nidium

Three configure script are available for building the product of your choice :

  • configure_frontend
  • configure_server
  • configure_libnidiumcore

Each of these configure script accept various options. The most useful one are :

  • --debug : Build nidium (and spidermonkey) in debug mode, when developping on nidium, you should always enable this flag as it will help you to catch errors sooner.

Note : debug build result in increased binary size and reduced performance.

  • --asan : Enable clang address sanitizer and leak sanitizer.
  • --cpu-profiling : Enable CPU profiling trough gperftools.
  • --unit-tests : Build & Run unit-tests.
  • --help : Show all options & usage.

nidium directory structure

Directory Usage
bin/ nidium executable
build/ Build files for nidium and third party
docs/ Documentation of JavaScript bindings using doukmentor
gyp/ Build files for nidium. We are using GYP as a tool to generate the buildfiles for each platform.
patch/ Patch for third party libraries.
resources/ Icons, OS specific files resources.
src Nidium source code
src/AV/ Audio & Video framework
src/Binding/ JavaScript Bindings
src/Core/ Various base helper (Path, Args, DB, SharedMessages, TaskManager, Context)
src/Embed/ JavaScript files bundled with nidium. Contains various additions to native JS class.
src/Frontend/ Code related to nidium frontend (NML, Context, Application entrypoint for each OS)
src/Graphics/ OpenGL related code (Canvas 2D & 3D, Image, Skia interactions)
src/IO/ Input/Output related code (File, Stream)
src/Interface/ Specific implementation for each OS :
  • System : System directories, Notifications, Language.
  • Interface : Window creation/interaction, Menu, File picker, Input hander
src/Net/ Implementation of HTTP and WebSocket protocol (client & server)
src/Server/ Nidium server implementation
src/libapenetwork/ libapenetwork subrepo (event loop)
tests/ Nidium unit-tests
tests/gunittest/ Low-level tests in C++, based on the googletest framework.
tests/jsunittests/ JavaScript unit-tests for nidium bindings.
tests/jsautotest/ JavaScript unit-tests automatically created by the examples from the documentation.
tests/tests-server/ HTTP server used for network tests (Socket, HTTP, WebSocket). One pubic server is running at http://tests.nidium.com but you can run your own. Check the README.md file in the directory.
third-party/ Third-party libraries downloaded by the configure script when they are needed in the build-process.

Note : The extracted directories are symlinked to this directory depending of the configuration used during the configure script. The real files are stored in hidden directories (.default .default-debug, ...)
tools/ Nidium Installer for each platform & various tools

Coding practices

  • Nidium use a subset of C++11, general usage of the standard library is allowed but :
    • Don't use C++ stream.
  • In C++ code, use nullptr for pointers. In C code, use NULL.
  • Forward-declare classes in your header files instead of including them whenever possible.
  • Don't put an else right after a return. Delete the else, it's unnecessary and increases indentation level.
  • For logging use nidium logging system.
  • For JavaScript binding use ClassMapper.
  • Rooting of JavaScript object/value can be tricky, make sure to read our rooting guide.
  • If you are adding a new features, make sure to add unit-tests and documentation to your code.

Coding Style

In general, follow the style of the surrounding code, and adhere to the following style guide. Code will be read often, so structured, and readable code is welcome, as well as sensible naming of variables, classes, functions etc.

  • No tabs. No whitespace at the end of a line.
  • Indentation is 4 spaces
  • Unix-style linebreaks (\n), not Windows-style (\r\n).
  • 80 characters or less
  • Use K&R style for control structure, class and function declaration.
  • Pointer star go with the variable name not the type Foo *foo = new Foo();
  • Use camelCase for variables, methods and functions :
    • int myFunction();
    • ClasName::methodName();
    • int myVar = 0;
  • Use CamelCase for class class, member variable, static method, namespace
    • ClassName::StaticMethod
    • namespace Nidium
  • Use uppercase for macros or define (e.g MY_MACRO). You can use lowercase for function like macro (e.g ndm_log())
  • Prefixes :
    • g_=global g_Global
    • m_=member (variable) m_VariableName
    • k Used for constant inside enum e.g. enum HTTPMethod { kHTTPMethod_get }
  • Namespace : Nidium use one namespace per directory in src/
    • using statements are not allowed in header files (We don't want to pollute the global scope of compilation units that use the header file.)
    • Don't indent code inside namespace

**Control structure style : **

if (...) {
} else if (...) {
} else {
}

// Short conditional statements may be written on one line if this enhances readability.
if (...) x = z;

// Always use curly brace for single-line statements
if (...) {
    x = z;
}

while (...) {
}

for (...; ...; ...) {
}

switch (...) {
  case 1: {
    // When you need to declare a variable in a switch, put the block in braces
    int var;
    break;
  }
  case 2:
    ...
    break;
  default:
    break;
}

Class, Namespace, Function:

namespace Nidium {

class MyClass : public A
{
public:
    MyClass(int var, int anotherVar)
        : m_Var(var), m_Var2(anotherVar)
    {
       ...
    }

    // Tiny constructors and destructors can be written on a single line.
    MyClass() { }

    // Tiny functions can be written in a single line.
    int myFunction() { return mVar; }

    static int StaticMethod()
    {
        ...
    }
    
private:
    // Member variable are prefixed with m_
    int m_Var;
    int m_Var2 = 0; // Variable should be initialised when declared
};

} // namespace Nidium

License block :

Nidium MIT license should be but at the top of each new file.

For C/C++/JavaScript :

/*
   Copyright 2017 Nidium Inc. All rights reserved.
   Use of this source code is governed by a MIT license
   that can be found in the LICENSE file.
*/

For Python and Bash :

# Copyright 2017 Nidium Inc. All rights reserved.
# Use of this source code is governed by a MIT license
# that can be found in the LICENSE file.