Skip to content

Commit

Permalink
[enhance] qml2js: output package.json for plugins.
Browse files Browse the repository at this point in the history
  • Loading branch information
arthuraa committed Jul 13, 2012
1 parent 9bf96df commit 2dbccef
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Makefile
Expand Up @@ -144,7 +144,8 @@ define install-plugin
@mkdir -p "$(STDLIB_DIR)/$*.opp" @mkdir -p "$(STDLIB_DIR)/$*.opp"
@$(INSTALL) $(BUILD_DIR)/$(PLUGINS_DIR)/$*.opp/*.bypass "$(STDLIB_DIR)/$*.opp/"; @$(INSTALL) $(BUILD_DIR)/$(PLUGINS_DIR)/$*.opp/*.bypass "$(STDLIB_DIR)/$*.opp/";
@$(INSTALL) $(BUILD_DIR)/$(PLUGINS_DIR)/$*.opp/*NodeJsPackage.js "$(STDLIB_DIR)/$*.opp/"; @$(INSTALL) $(BUILD_DIR)/$(PLUGINS_DIR)/$*.opp/*NodeJsPackage.js "$(STDLIB_DIR)/$*.opp/";
@$(if $(wildcard $(BUILD_DIR)/$(PLUGINS_DIR)/$*.opp/*MLRuntime.*), $(INSTALL) $(BUILD_DIR)/$(PLUGINS_DIR)/$*.opp/*MLRuntime.* "$(STDLIB_DIR)/$*.opp/") @$(INSTALL) $(BUILD_DIR)/$(PLUGINS_DIR)/$*.opp/package.json "$(STDLIB_DIR)/$*.opp/";
@$(if $(wildcard $(BUILD_DIR)/$(PLUGINS_DIR)/$*.opp/*MLRuntime.*), $(INSTALL) $(BUILD_DIR)/$*.opp/*MLRuntime.* "$(STDLIB_DIR)/$*.opp/")
endef endef




Expand Down
13 changes: 13 additions & 0 deletions compiler/libbsl/bslregister.ml
Expand Up @@ -866,6 +866,17 @@ let make_iterator rename =
in in
{ BR.output = output } { BR.output = output }


let output_package_json () =
let path = Filename.dirname !nodejspackage in
let dest = Filename.concat path "package.json" in
let main = Filename.basename !nodejspackage in
let oc = handle_open_out dest in
Printf.fprintf oc "{\n";
Printf.fprintf oc " \"name\": \"%s\",\n" !opp_dir;
Printf.fprintf oc " \"version\": \"0.0.0\",\n";
Printf.fprintf oc " \"main\": \"%s\"\n" main;
Printf.fprintf oc "}\n";
handle_close_out dest oc


(* after finalization of register session, actually produce files *) (* after finalization of register session, actually produce files *)
let files_generation ( finalized_t : BR.finalized_t ) = let files_generation ( finalized_t : BR.finalized_t ) =
Expand All @@ -880,6 +891,8 @@ let files_generation ( finalized_t : BR.finalized_t ) =


output !nodejspackage BR.out_nodejs_package finalized_t ; output !nodejspackage BR.out_nodejs_package finalized_t ;


output_package_json ();

output !jskeys BR.out_js_keys finalized_t ; output !jskeys BR.out_js_keys finalized_t ;


output !marshalplugin BR.out_ml_marshal_plugin finalized_t ; output !marshalplugin BR.out_ml_marshal_plugin finalized_t ;
Expand Down
7 changes: 4 additions & 3 deletions compiler/qml2js/qml2js.ml
Expand Up @@ -218,7 +218,7 @@ struct
let oc = open_out_gen [Open_wronly; Open_creat; Open_trunc] 0o600 filename in let oc = open_out_gen [Open_wronly; Open_creat; Open_trunc] 0o600 filename in
let package_name = (Filename.basename env_opt.compilation_directory) in let package_name = (Filename.basename env_opt.compilation_directory) in
Printf.fprintf oc "{\n"; Printf.fprintf oc "{\n";
Printf.fprintf oc " \"name\": %S,\n" package_name; Printf.fprintf oc " \"name\": \"%s\",\n" package_name;
Printf.fprintf oc " \"version\": \"0.0.0\",\n"; Printf.fprintf oc " \"version\": \"0.0.0\",\n";
Printf.fprintf oc " \"main\": \"a.js\"\n"; Printf.fprintf oc " \"main\": \"a.js\"\n";
Printf.fprintf oc "}\n"; Printf.fprintf oc "}\n";
Expand Down Expand Up @@ -365,7 +365,7 @@ check-node-dependencies \"mongodb formidable nodemailer simplesmtp imap\" || exi
EOF EOF
if [ $? -ne 0 ]; then exit $?; fi; if [ $? -ne 0 ]; then exit $?; fi;
NODE_PATH=\"$NODE_PATH:/usr/local/lib/node_modules\" node \"$0\" \"$@\"; exit $?; NODE_PATH=\"$NODE_PATH:/usr/local/lib/node_modules:%s:%s\" node \"$0\" \"$@\"; exit $?;
if (process.version < '%s') { if (process.version < '%s') {
console.error('Your version of node seems to be too old. Please upgrade to a more recent version of node (>= %s)'); console.error('Your version of node seems to be too old. Please upgrade to a more recent version of node (>= %s)');
Expand All @@ -375,7 +375,8 @@ if (process.version < '%s') {
} }
*/ */
" stdlib_qmljs_path min_node_version min_node_version max_node_version; " stdlib_qmljs_path stdlib_path min_node_version
min_node_version max_node_version;
let is_from_stdlib opx = String.is_prefix stdlib_path opx in 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 let load_oc = linking_generation_js_init env_opt generated_files oc in
let js_file opx = Filename.concat opx "a.js" in let js_file opx = Filename.concat opx "a.js" in
Expand Down

0 comments on commit 2dbccef

Please sign in to comment.