Skip to content

Commit

Permalink
Refactoring; preparation for Rust integration (possibly broken)
Browse files Browse the repository at this point in the history
  • Loading branch information
rvanasa committed Feb 21, 2018
1 parent e190d60 commit 60af53a
Show file tree
Hide file tree
Showing 159 changed files with 161 additions and 33 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

### Local Configuration

1. Install [Node.js](https://nodejs.org/en/)
2. Clone/download the repository
3. Run `npm i` to install dependencies
4. Run `node index dev` to run on port 8080
5. Visit http://localhost:8080 in your browser
1. Download/install [Rust](https://www.rust-lang.org/)
2. Download/install [Node.js](https://nodejs.org/en/)
3. Download/install [Emscripten SDK](https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html)
4. Run `rustup target add wasm32-unknown-emscripten` to install the Emscripten compile target
5. Run `npm i` to install dependencies
6. Run `node index dev` to run on port 8080
7. Visit http://localhost:8080 in your browser

### Current Features
- Pretty-printing bundled Fungi code/traces
Expand Down
2 changes: 1 addition & 1 deletion nodemon.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"ignore": ["www/**/*", "dist/**/*"]
"ignore": ["src/www/**/*", "dist/**/*"]
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Fungi Visualization Tool",
"main": "index.js",
"repository": "https://github.com/Adapton/fungi-vis.git",
"author": "Adapton Project (http://adapton.org)",
"author": "Adapton Project",
"scripts": {
"start": "node index"
},
Expand Down
8 changes: 4 additions & 4 deletions sorc.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module.exports = {
basePath: __dirname,
basePath: __dirname + '/src',
verbose: 'dev',
packages: [{
path: '/src/app',
path: '/server/app',
env: ['dev', 'prod'],
eager: true,
}, {
path: '/src/lib',
path: '/server/lib',
}, {
env: 'dev',
path: '/src/dev',
path: '/server/dev',
eager: true,
}],
};
106 changes: 106 additions & 0 deletions src/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "fungi-vis"
version = "0.1.0"
authors = ["Adapton Project"]

[dependencies]
fungi-lang = "^0.1.20"
13 changes: 13 additions & 0 deletions src/rust/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// #[macro_use]
// extern crate fungi_lang;

// use fungi_lang::vis;

fn main() {
println!("Hello Rust!");
}

#[no_mangle]
pub fn test(input: &str) {
println!("~~ {} ~~", input);
}
2 changes: 1 addition & 1 deletion src/app/App.js → src/server/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = function()
{
var app = express();

app.set('views', 'view');
app.set('views', this.config.basePath + '/www/view');
app.set('view engine', 'ejs');

app.use(compression());
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/app/Site.js → src/server/app/Site.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function(App, Config, log)
var webpack = require('webpack');
var devMiddleware = require('webpack-dev-middleware');

var compiler = webpack(require(this.config.basePath + '/webpack.config'));
var compiler = webpack(require(this.config.basePath + '/../webpack.config'));
App.use(require('webpack-hot-middleware')(compiler, {log}));
App.use(devMiddleware(compiler, {
stats: {colors: true},
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions src/www/app/service/rust.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var wasm = require('../../../rust/src/main.rs');

module.exports = function RustService()
{
wasm.initialize({noExitRuntime: true})
.then(module =>
{
var test = module.cwrap('test', 'number', ['string']);


});
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 7 additions & 13 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
var webpack = require('webpack');

// var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyPlugin = require('copy-webpack-plugin');

var ENV = process.env.npm_lifecycle_event;
var isBuild = ENV === 'build';

var srcPath = __dirname + '/www';
var wwwPath = __dirname + '/src/www';
var rustPath = __dirname + '/src/rust';
var destPath = __dirname + '/dist';
// var rustPath = __dirname + '/lib';

var config = {
entry: {
app: srcPath + '/app/main.js',
module: srcPath + '/app/module.js',
app: wwwPath + '/app/main.js',
module: wwwPath + '/app/module.js',
},
output: {
path: destPath,
Expand All @@ -38,34 +37,29 @@ var config = {
}, {
test: /\.(png|jpg|ico)$/,
loader: 'file-loader',
}/*, {
}, {
test: /\.rs$/,
use: {
loader: 'rust-wasm-loader',
options: {
path: rustPath,
}
}
}*/],
}],
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.optimize.ModuleConcatenationPlugin(),
// new webpack.optimize.UglifyJsPlugin({
// sourceMap: true,
// }),
// new HtmlWebpackPlugin({
// // chunks: ['app'],
// template: srcPath + '/../view/webapp.ejs',
// inject: 'head',
// }),
new ExtractTextPlugin('bundle/[name].css'),
],
};

if(isBuild)
{
config.plugins.push(new CopyPlugin([{from: srcPath}]));
config.plugins.push(new CopyPlugin([{from: wwwPath}]));
}

module.exports = config;
6 changes: 0 additions & 6 deletions www/app/service/engine.service.js

This file was deleted.

0 comments on commit 60af53a

Please sign in to comment.