4.13.1 • Published 3 years ago

orchestrator-core v4.13.1

Weekly downloads
2,302
License
MIT
Repository
github
Last release
3 years ago

Orchestrator for node.js

Currently, all the build is performed through node-gyp. Gyp generates Visual Studio 2017 project files on the fly, and there currently is nothing checked into the oc.sln file.

TODO: add a ceremonial/sacrificial C++ project to the oc solution to facilitate debugging. It won't be the actual project file used to generate the package!

Install

# Go to node directory.
cd \src\TScience\Orchestrator\oc\oc_node_authoring

# Build debug
npm install . # Note period

(or npm install -g .) # Global

Building

  • As a pre-requisite, build oc.sln as Release.
# Set up environment for 64-bit native
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"

# Build the solution as Release | x64
MsBuild.exe D:\src\TScience\Orchestrator\oc\oc.sln /t:Build /p:Configuration=Release /p:Platform=x64	
  • Build the node.js integration layer
  • See node-gyp docs for more info.
# Go to node directory.
cd \src\TScience\Orchestrator\oc\oc_node_authoring

# Set up visual studio for node-gyp
npm config set msvs_version 2019

# Build debug
npm run rebuild:dev
  • You can look at what the rebuild:dev command is doing by looking at package.json
  • You can see how the Visual Studio project file is being generated by inspecting the binding.gyp file.

Run tests

# Go to node directory.
cd \src\TScience\Orchestrator\oc\oc_node_authoring

# Run tests
npm run test

Debugging

There are tests and a sample. Most likely you will be debugging one of these. To debug, you can use Visual Studio or Vscode.

Output Directory

To Debug C++ code in oc_node_authoring, I had to perform the following.

Node-pre-gyp is responsible for the process of pulling down the "tarball" (.tgz) file and unarchiving and placing the binaries. This process is a direct stand-in for the "normal" path (node-gyp) of building the binaries on your machine when you perform "npm install" - it's just placing the binaries in the spot that the build process would normally copy the output. To that end, if you use something like "Visual Studio" or other platform tools, the output directory is something like "./build/Debug" or "./build/Release".

Currently, in the build process, we truncate the build output directory so the user experience (ie, node.js code) can load the library without directory structure. For example:

const oc = require('orchestrator-core.node') <= "Good"

vs.

const oc = require('./build/Release/orchestrator-core.node') <= "Bad"

However, truncating the build output to the local directory (for some reason) causes havoc when attempting to debug on Windows with Visual Studio/Visual Studio Code.

To debug C++ code, try the following:

package.json

 "binary": {
  "module_name": "orchestrator-core",
  "module_path": "./build/Debug",
  "host": "https://bfsmodelsscratch.azureedge.net/native"
 },

binding.gyp

    # "target_defaults": {
    #     "msvs_configuration_attributes": {
    #         "OutputDirectory": ""
    #     }
    # },    

oc_app.js

const oc = require('./build/Debug/orchestrator-core.node');

Rebuild (See below for more details):

npm run rebuild:dev

This shifts the build to ./build/Debugand enables you to debug C++ code.

Visual Studio

Here's an example configuring Visual Studio using the sample.

  • These settings are using oc_abi but you can set breakpoints in code in the node.js interop layer.
  • Make sure this configuration is for Release | x64
  • Set the command to where your node executable is found.
  • Set command arguments to oc_app.js
  • Set Working directory to TScience\Orchestrator\oc\oc_node

Visual Studio - oc_interop

Similarly, you can configure for tests - see the configuration for Visual Studio Code below.

Visual Studio Code

In launch.json (Click Shift-Ctrl-D and click on the gear symbol), you can add something like the following (fixing the paths).

Note: This sets up the C++ debugger (cppvsdbg).

        {
            "type": "cppvsdbg",
            "request": "launch",
            "name": "Launch nodejs app via NPM",
            "program": "C:\\Program Files\\nodejs\\node.exe",
            "args": [
                "oc_app.js"
            ],
            "cwd": "d:\\src\\TScience\\Orchestrator\\oc\\oc_node_authoring"
        },
        {
            "type": "cppvsdbg",
            "request": "launch",
            "name": "Launch MOCHA test via NPM",
            "program": "C:\\Program Files\\nodejs\\node.exe",
            "stopAtEntry": false,
            "args": [
                ".\\node_modules\\mocha\\bin\\mocha",
                "tests/",
                // "-g",
                // "Remove"
            ],
            "cwd": "d:\\src\\TScience\\Orchestrator\\oc\\oc_node_authoring",
            "externalConsole": false
        },

Note: -g in the MOCHA test stands for grep. You can filter specific tests. For example: "Remove"

    it('Remove example.', async function () {
        // Arrange
        var orc = new oc.Orchestrator();
4.13.1

3 years ago

4.13.0-rc1

3 years ago

4.13.0

3 years ago

4.13.0-rc0

3 years ago

4.12.0-beta.1

3 years ago

4.12.0-beta

3 years ago

4.12.0-preview

3 years ago

4.11.1-beta.6

3 years ago

4.11.1-beta.5

3 years ago

4.11.1-beta.4

3 years ago

4.11.1-beta.3

3 years ago

4.11.1-beta.2

3 years ago

4.11.0-beta.2

3 years ago

4.11.0-beta.1

3 years ago

4.11.0-beta.0

4 years ago

4.11.0-rc0

4 years ago