Browse files

[enhance] qml2js: extracted the launch script into tools/depenedencie…

…s/launch_helper.sh
  • Loading branch information...
1 parent e6329ed commit 805108334e9c89bb98790963e8ea6c2191c63319 @Aqua-Ye Aqua-Ye committed Jul 17, 2012
View
2 compiler/qml2js.mllib
@@ -1,3 +1,5 @@
+compiler/qml2js/LaunchHelper
+
compiler/qml2js/Qml2jsOptions
compiler/qml2js/Qml2js
compiler/qml2js/Qml2jsBackendOptions
View
29 compiler/qml2js/qml2js.ml
@@ -331,32 +331,7 @@ struct
Printf.fprintf oc "#!/usr/bin/env bash
/*usr/bin/env bash <<'EOF'
-
-if ! which node &>/dev/null; then
- echo \"--> node.js missing, please install nodejs from: http://nodejs.org\"
- exit 1
-fi;
-
-if ! which npm &>/dev/null; then
- echo \"--> npm missing, please install npm from: http://npmjs.org/\"
- exit 1
-fi
-
-function check-node-dependencies() (
- MISSING=\"\"
- for i in $1; do
- if ! npm list | grep -q \"$i\" && ! npm list -g | grep -q \"$i\"; then
- MISSING=\"$MISSING $i\"
- fi
- done
- if [ \"$MISSING\" != \"\" ]; then
- echo \"--> some node modules are missing, please run: npm install -g$MISSING\"
- exit 1;
- fi
-)
-
-check-node-dependencies \"mongodb formidable nodemailer simplesmtp imap\" || exit $?
-
+%s
EOF
if [ $? -ne 0 ]; then exit $?; fi;
@@ -370,7 +345,7 @@ if (process.version < '%s') {
}
*/
-" stdlib_qmljs_path stdlib_path static_path min_node_version
+" LaunchHelper.script stdlib_qmljs_path stdlib_path static_path min_node_version
min_node_version max_node_version;
let is_from_stdlib opx = String.is_prefix stdlib_path opx in
let load_oc = linking_generation_js_init env_opt generated_files oc in
View
32 tools/build/build_rules.ml
@@ -230,7 +230,7 @@ let pre_buildinfos = "compiler/buildinfos/buildInfos.ml.pre" in
let post_buildinfos = "compiler/buildinfos/buildInfos.ml.post" in
let buildinfos = "compiler/buildinfos/buildInfos.ml" in
rule "buildinfos: compiler/buildinfos/* -> compiler/buildinfos/buildInfos.ml"
- ~deps:[version_buildinfos ; pre_buildinfos ; generate_buildinfos ; post_buildinfos]
+ ~deps:[version_buildinfos; pre_buildinfos; generate_buildinfos; post_buildinfos]
~prods:(buildinfos :: (if Config.is_release then ["always_rebuild"] else []))
(fun env build ->
let version = env version_buildinfos in
@@ -256,20 +256,42 @@ let parser_files =
let files = List.fold_right (fun dir acc -> dir_ext_files "trx" dir @ dir_ext_files "ml" dir) dir ["general/surfaceAst.ml"] in
files
in
-let opaParserVersion = "compiler"/"opalang"/"classic_syntax"/"opaParserVersion.ml"
-in
-rule "opa parser version: opalang/*_syntax/* stdlib -> opalang/classic_syntax/opaParserVersion.ml"
+let opaParserVersion = "compiler"/"opalang"/"classic_syntax"/"opaParserVersion.ml" in
+rule "opa parser version: compiler/opalang/*_syntax/* stdlib -> compiler/opalang/classic_syntax/opaParserVersion.ml"
~deps:parser_files
~prod:opaParserVersion
(fun build env ->
let files = List.map (fun s-> P s) parser_files in
Seq[
Cmd(S ( [Sh"echo let hash = \\\" > "; P (opaParserVersion)]));
Cmd(S ( [Sh"cat"] @ files @ [Sh"|"; md5; Sh">>"; P opaParserVersion]));
- Cmd(S ( [Sh"echo \\\" >>"; P opaParserVersion ] ))
+ Cmd(S ( [Sh"echo \\\" >>"; P opaParserVersion ] ));
]
);
+let dependencies_path = "tools"/"dependencies" in
+let launch_helper_script = dependencies_path/"launch_helper.sh" in
+let qml2js_path = "compiler"/"qml2js" in
+let qml2js_file = qml2js_path/"qml2js.ml" in
+let launchHelper = qml2js_path/"launchHelper.ml" in
+
+rule "launchHelper: tools/dependencies/launch_helper.sh -> compiler/qml2js/launchHelper.ml"
+ ~prod:launchHelper
+ (fun env build ->
+ Seq[
+ Cmd(S[Sh"mkdir"; A"-p";P qml2js_path]);
+ Cmd(S([Sh"echo let script = \\\" > "; P launchHelper]));
+ Cmd(S([
+ Sh"cat"; P launch_helper_script;
+ Sh"|"; Sh"sed -e 's/\\\"/\\\\\\\"/g'";
+ Sh"|"; Sh"sed -e 's/\\\\\\//\\\\\\\\\\//g'";
+ Sh">>"; P launchHelper
+ ]));
+ Cmd(S([Sh"echo \\\" >>"; P launchHelper]))
+ ]
+ );
+
+
(* -- Internal use of built tools -- *)
rule " ofile"
View
7 tools/build/gen_myocamlbuild.sh
@@ -121,6 +121,13 @@ mkdir -p $BUILD_DIR/$CONFIG_PATH
cat $BLDDIR/myocamlbuild_suffix.ml
} > $MYOCAMLBUILD
+# Copy launch_helper.sh
+
+DEPENDENCIES_PATH=tools/dependencies
+LAUNCH_HELPER="$DEPENDENCIES_PATH/launch_helper.sh"
+mkdir -p $BUILD_DIR/$DEPENDENCIES_PATH
+cp $LAUNCH_HELPER $BUILD_DIR/$LAUNCH_HELPER
+
# Compile the myocamlbuild
OCAMLBUILD_LIB=$($OCAMLBUILD -where)
View
26 tools/dependencies/launch_helper.sh
@@ -0,0 +1,26 @@
+# File meant to be launched with bash - DO NOT EDIT THE FIRST LINE
+
+if ! which node &>/dev/null; then
+ echo "--> node.js missing, please install nodejs from: http://nodejs.org"
+ exit 1
+fi;
+
+if ! which npm &>/dev/null; then
+ echo "--> npm missing, please install npm from: http://npmjs.org/"
+ exit 1
+fi;
+
+function check-node-dependencies() (
+ MISSING=""
+ for i in $1; do
+ if ! npm list -parseable | sed -e '#\/.*\/node_modules\/.*\/node_modules\/.*#d' | grep -q "$i" && ! npm list -g -parseable | sed -e '#\/.*\/node_modules\/.*\/node_modules\/.*#d' | grep -q "$i"; then
+ MISSING="$MISSING $i"
+ fi
+ done
+ if [ "$MISSING" != "" ]; then
+ echo "--> some node modules are missing, please run: npm install -g$MISSING"
+ exit 1;
+ fi
+)
+
+check-node-dependencies "mongodb formidable nodemailer simplesmtp imap" || exit $?

0 comments on commit 8051083

Please sign in to comment.