Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/install_support' into de…
Browse files Browse the repository at this point in the history
…velop
  • Loading branch information
pschillinger committed Aug 29, 2018
2 parents 8d2e0dd + 78daeaa commit 945d5de
Show file tree
Hide file tree
Showing 18 changed files with 187 additions and 145 deletions.
13 changes: 1 addition & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
lib/*
locales/*
swiftshader/*
credits.html
icudtl.dat
natives_blob.bin
nw
nw_100_percent.pak
nw_200_percent.pak
resources.pak
snapshot_blob.bin

nwjs/
67 changes: 20 additions & 47 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,71 +21,44 @@ catkin_package(
# use add_library() or add_executable() as required
#add_library(${PROJECT_NAME} ${${PROJECT_NAME}_SRCS})

#FILE(GLOB BIN_FILES "bin/*")

# install executables
#install(PROGRAMS ${BIN_FILES} DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
#install(DIRECTORY launch DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})

#add_custom_target(nwjs_inst)
#add_custom_command(TARGET nwjs_inst POST_BUILD COMMAND bin/nwjs_install)

add_custom_command(OUTPUT nw
add_custom_command(OUTPUT nwjs
COMMAND bin/nwjs_install
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM
)

add_custom_target(nw_install DEPENDS nw)
add_custom_target(nw_install DEPENDS nwjs)

if(NOT ${CMAKE_CURRENT_SOURCE_DIR}/nw)
if(NOT ${CMAKE_CURRENT_SOURCE_DIR}/nwjs)
safe_execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bin/nwjs_install)
endif()

#############
## Install ##
#############

# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html

# call catkin_destinations() to populate CATKIN_*_DESTINATION cmake variables
catkin_destinations()

install(DIRECTORY
launch
src
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
INSTALL(PROGRAMS
bin/run_app
bin/shortcut
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install(PROGRAMS
bin/run_app
bin/shortcut
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
INSTALL(FILES
package.json
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

install(DIRECTORY
lib
locales
swiftshader
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
USE_SOURCE_PERMISSIONS
INSTALL(DIRECTORY
src
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

install(FILES
credits.html
flexbe.desktop
icudtl.dat
natives_blob.bin
nw_100_percent.pak
nw_200_percent.pak
package.json
resources.pak
snapshot_blob.bin
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
INSTALL(DIRECTORY
nwjs
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
USE_SOURCE_PERMISSIONS
)

install(PROGRAMS
nw
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
install(DIRECTORY
launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
3 changes: 2 additions & 1 deletion bin/nwjs_install
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash -e
cd "$( dirname "${BASH_SOURCE[0]}" )"
TEMPFILE="nwjs.tar.gz"
cd ..
mkdir -p ../nwjs
cd ../nwjs

# check if nw is already existing and abort if so
if [ -f nw ]; then
Expand Down
11 changes: 8 additions & 3 deletions bin/run_app
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#!/bin/bash

NW="$(rospack find flexbe_app)/nw"
if [ ! -x "${NW}" ]; then
ROOT_PATH="$(rospack find flexbe_app)"
NW=$ROOT_PATH/nwjs/nw
if [ ! -f $NW ]; then
ROOT_PATH=.
NW=$ROOT_PATH/nwjs/nw
fi
if [ ! -x $NW ]; then
echo "Cannot run flexbe_app, need to download nwjs first."
echo "Please build flexbe_app via catkin before using it or run the following command now:"
echo " rosrun flexbe_app nwjs_install"
exit -1
fi

"$NW" --password-store=basic "$@"
"$NW" --password-store=basic $ROOT_PATH "$@"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "FlexBE App",
"version": "2.0.7",
"version": "2.0.8",
"main": "src/main.js",
"window": {
"icon": "src/img/icon-128.png",
Expand Down
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<package>
<name>flexbe_app</name>
<version>2.0.7</version>
<version>2.0.8</version>
<description>
flexbe_app provides a user interface (editor + runtime control) for the FlexBE behavior engine.
</description>
Expand Down
11 changes: 11 additions & 0 deletions src/_model/behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Behavior = new (function() {
var file_name = undefined;
var manifest_path = undefined;

var readonly = false;


this.getBehaviorName = function() {
return behavior_name;
Expand Down Expand Up @@ -274,6 +276,14 @@ Behavior = new (function() {
root_sm = _root_sm;
}

this.setReadonly = function(_readonly) {
readonly = _readonly;
}

this.isReadonly = function() {
return readonly;
}

this.resetBehavior = function() {
behavior_name = "";
behavior_package = "";
Expand All @@ -299,6 +309,7 @@ Behavior = new (function() {
comment_notes = [];

root_sm = new Statemachine("", new WS.StateMachineDefinition([], [], []));
readonly = false;
}

this.setFiles = function(_file_name, _manifest_path) {
Expand Down
83 changes: 35 additions & 48 deletions src/io/io_behaviorloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ IO.BehaviorLoader = new (function() {
T.logInfo("Behavior state machine built.");

ActivityTracer.resetActivities();

ROS.getPackagePath(manifest.rosnode_name, (package_path) => {
ROS.getPackagePythonPath(manifest.rosnode_name, (python_path) => {
if (!python_path.startsWith(package_path)) {
Behavior.setReadonly(true);
}
UI.Statemachine.refreshView();
});
});
}

var resetEditor = function() {
Expand All @@ -52,48 +61,33 @@ IO.BehaviorLoader = new (function() {

resetEditor();

var package_name = manifest.rosnode_name;
ROS.getPackagePath(package_name, (package_path) => {
if (package_path == undefined) {
T.logError("Failed to load behavior: ROS package "+package_name+" not found, please check behavior manifest.");
return;
}
var file_path = path.join(package_path, 'src', package_name, manifest.codefile_name);
IO.Filesystem.readFile(file_path, (content) => {
T.logInfo("Parsing sourcecode...");
parseCode(content, manifest);
});
var file_path = path.join(manifest.codefile_path, manifest.codefile_name);
IO.Filesystem.readFile(file_path, (content) => {
T.logInfo("Parsing sourcecode...");
parseCode(content, manifest);
});
}

this.loadBehaviorInterface = function(manifest, callback) {
var package_name = manifest.rosnode_name;
ROS.getPackagePath(package_name, (package_path) => {
if (package_path == undefined) {
T.logError("Failed to load behavior: ROS package "+package_name+" not found, please check behavior manifest.");
var file_path = path.join(manifest.codefile_path, manifest.codefile_name);
IO.Filesystem.readFile(file_path, (content) => {
try {
var parsingResult = IO.CodeParser.parseSMInterface(content);
callback(parsingResult);
} catch (err) {
T.logError("Failed to parse behavior interface of " + manifest.name + ": " + err);
return;
}
var file_path = path.join(package_path, 'src', package_name, manifest.codefile_name);
IO.Filesystem.readFile(file_path, (content) => {
try {
var parsingResult = IO.CodeParser.parseSMInterface(content);
callback(parsingResult);
} catch (err) {
T.logError("Failed to parse behavior interface of " + manifest.name + ": " + err);
return;
}
});
});
}

this.updateManualSections = function(callback) {
var names = Behavior.createNames();
var package_name = names.rosnode_name;
ROS.getPackagePath(package_name, (package_path) => {
if (package_path == undefined) {
ROS.getPackagePythonPath(package_name, (folder_path) => {
if (folder_path == undefined) {
return;
}
var folder_path = path.join(package_path, 'src', package_name);
var file_path = path.join(folder_path, names.file_name);
IO.Filesystem.checkFileExists(folder_path, names.file_name, (exists) => {
if (exists) {
Expand All @@ -115,28 +109,21 @@ IO.BehaviorLoader = new (function() {
}

this.parseBehaviorSM = function(manifest, callback) {
var package_name = manifest.rosnode_name;
ROS.getPackagePath(package_name, (package_path) => {
if (package_path == undefined) {
T.logError("Failed to load behavior: ROS package "+package_name+" not found, please check behavior manifest.");
var file_path = path.join(manifest.codefile_path, manifest.codefile_name);
IO.Filesystem.readFile(file_path, (content) => {
console.log("Preparing sourcecode of behavior " + manifest.name + "...");
try {
parsingResult = IO.CodeParser.parseCode(content);
} catch (err) {
console.log("Code parsing failed: " + err);
return;
}
var file_path = path.join(package_path, 'src', package_name, manifest.codefile_name);
IO.Filesystem.readFile(file_path, (content) => {
console.log("Preparing sourcecode of behavior " + manifest.name + "...");
try {
parsingResult = IO.CodeParser.parseCode(content);
} catch (err) {
console.log("Code parsing failed: " + err);
return;
}
callback({
container_name: "",
container_sm_var_name: parsingResult.root_sm_name,
sm_defs: parsingResult.sm_defs,
sm_states: parsingResult.sm_states,
default_userdata: parsingResult.default_userdata
});
callback({
container_name: "",
container_sm_var_name: parsingResult.root_sm_name,
sm_defs: parsingResult.sm_defs,
sm_states: parsingResult.sm_states,
default_userdata: parsingResult.default_userdata
});
});
}
Expand Down
5 changes: 2 additions & 3 deletions src/io/io_behaviorpacker.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ IO.BehaviorPacker = new (function() {
this.loadBehaviorCode = function(callback) {
var names = Behavior.createNames();
var package_name = names.rosnode_name;
ROS.getPackagePath(package_name, (package_path) => {
if (package_path == undefined) {
ROS.getPackagePythonPath(package_name, (folder_path) => {
if (folder_path == undefined) {
return;
}
var folder_path = path.join(package_path, 'src', package_name);
var file_path = path.join(folder_path, names.file_name);
IO.Filesystem.checkFileExists(folder_path, names.file_name, (exists) => {
if (exists) {
Expand Down
5 changes: 2 additions & 3 deletions src/io/io_behaviorsaver.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ IO.BehaviorSaver = new (function() {
};
var names = Behavior.createNames();
var package_name = names.rosnode_name;
ROS.getPackagePath(package_name, (package_path) => {
var folder_path = path.join(package_path, 'src', package_name);
ROS.getPackagePythonPath(package_name, (folder_path) => {
var file_path = path.join(folder_path, names.file_name);
var file_tmp_path = path.join(folder_path, names.file_name_tmp);
if (RC.Controller.isConnected()) {
Expand All @@ -21,7 +20,7 @@ IO.BehaviorSaver = new (function() {
IO.Filesystem.checkFileExists(folder_path, names.file_name_tmp, function(src_exists) {
if (src_exists) {
IO.Filesystem.getFileContent(folder_path, names.file_name, function(content_onboard) {
IO.Filesystem.createFile(folder_path, names.file_name_tmp, content_onboard, function() {
IO.Filesystem.createFile(folder_path, names.file_name_tmp, content_onboard, function() {
create_callback(folder_path);
});
});
Expand Down
4 changes: 3 additions & 1 deletion src/io/io_manifestparser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
IO.ManifestParser = new (function() {
var that = this;

this.parseManifest = function(content, file_path) {
this.parseManifest = function(content, file_path, python_path) {
parser = new DOMParser();
xml = parser.parseFromString(content,"text/xml");

Expand All @@ -26,6 +26,7 @@ IO.ManifestParser = new (function() {
var path = xml.getElementsByTagName("executable")[0].getAttribute("package_path").split(".");
var rosnode_name = path[0];
var codefile_name = path[1] + ".py";
var codefile_path = python_path;
var class_name = xml.getElementsByTagName("executable")[0].getAttribute("class");

var params_element = xml.getElementsByTagName("params");
Expand Down Expand Up @@ -74,6 +75,7 @@ IO.ManifestParser = new (function() {
date: date,
rosnode_name: rosnode_name,
codefile_name: codefile_name,
codefile_path: codefile_path,
class_name: class_name,
params: param_list,
contains: contains_list,
Expand Down
Loading

0 comments on commit 945d5de

Please sign in to comment.