From 72c3aa3f643e5854757a8bea8b5d01305e0f4c66 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Tue, 18 Jan 2022 18:19:49 +0100 Subject: [PATCH] Misc: remove ocamlbuild from the repo --- CHANGES.md | 1 + CONTRIBUTING.md | 2 +- README.md | 3 - dune-project | 14 ---- js_of_ocaml-ocamlbuild.opam | 38 ---------- js_of_ocaml-ocamlbuild.opam.template | 15 ---- manual/contribute.wiki | 2 +- manual/overview.wiki | 2 - ocamlbuild/dune | 5 -- ocamlbuild/ocamlbuild_js_of_ocaml.ml | 99 ------------------------- ocamlbuild/ocamlbuild_js_of_ocaml.mli | 100 -------------------------- 11 files changed, 3 insertions(+), 278 deletions(-) delete mode 100644 js_of_ocaml-ocamlbuild.opam delete mode 100644 js_of_ocaml-ocamlbuild.opam.template delete mode 100644 ocamlbuild/dune delete mode 100644 ocamlbuild/ocamlbuild_js_of_ocaml.ml delete mode 100644 ocamlbuild/ocamlbuild_js_of_ocaml.mli diff --git a/CHANGES.md b/CHANGES.md index 280d19b0fa..c5ad90c5f4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -20,6 +20,7 @@ * Lib: add deprecation warning for deprecated code * PPX: json can now be derived for mutable records (#1184) * Runtime: use crypto.getRandomValues when available (#1209) +* Misc: move js_of_ocaml-ocamlbuild out to its own repo ## Bug fixes * Compiler: fix sourcemap warning for empty cma (#1169) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3a7208e778..9e7b49f3a6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,7 +22,7 @@ We actively welcome pull requests. ### Install dependencies ``` -opam install --deps-only -t js_of_ocaml js_of_ocaml-lwt js_of_ocaml-compiler js_of_ocaml-ocamlbuild js_of_ocaml-toplevel js_of_ocaml-ppx js_of_ocaml-ppx_deriving_json js_of_ocaml-tyxml +opam install --deps-only -t js_of_ocaml js_of_ocaml-lwt js_of_ocaml-compiler js_of_ocaml-toplevel js_of_ocaml-ppx js_of_ocaml-ppx_deriving_json js_of_ocaml-tyxml opam install odoc lwt_log cohttp-lwt-unix yojson ocp-indent graphics higlo ``` diff --git a/README.md b/README.md index ade232cf9c..81ea86e9b4 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,6 @@ Js_of_ocaml is composed of multiple packages: - js_of_ocaml-ppx_deriving_json - js_of_ocaml-lwt, lwt support. - js_of_ocaml-tyxml, tyxml support. -- js_of_ocaml-ocamlbuild, an ocamlbuild plugin to compile to - javascript. - js_of_ocaml-toplevel, lib and tools to build an ocaml toplevel to javascript. @@ -152,4 +150,3 @@ comparison, and hashing functions can yield results different from usual: | ppx/ | ppx syntax extensions | | runtime/ | runtime system | | toplevel/ | web-based OCaml toplevel | -| ocamlbuild/ | ocamlbuild plugin for js_of_ocaml | diff --git a/dune-project b/dune-project index b07d263a99..3060a40d50 100644 --- a/dune-project +++ b/dune-project @@ -53,20 +53,6 @@ lwt_log )) -(package - (name js_of_ocaml-ocamlbuild) - (synopsis "Compiler from OCaml bytecode to JavaScript") - (description - "Js_of_ocaml is a compiler from OCaml bytecode to JavaScript. It makes it possible to run pure OCaml programs in JavaScript environment like browsers and Node.js") - (depends - (ocaml (>= 4.04)) - ocamlbuild - (num :with-test) - (ppx_expect (and (>= v0.14.2) :with-test)) - (ppxlib (and (>= 0.22.0) :with-test)) - (re (and (>= 1.9.0) :with-test)) -)) - (package (name js_of_ocaml-ppx_deriving_json) (synopsis "Compiler from OCaml bytecode to JavaScript") diff --git a/js_of_ocaml-ocamlbuild.opam b/js_of_ocaml-ocamlbuild.opam deleted file mode 100644 index 5bd2d2cc3c..0000000000 --- a/js_of_ocaml-ocamlbuild.opam +++ /dev/null @@ -1,38 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -synopsis: "Compiler from OCaml bytecode to JavaScript" -description: - "Js_of_ocaml is a compiler from OCaml bytecode to JavaScript. It makes it possible to run pure OCaml programs in JavaScript environment like browsers and Node.js" -maintainer: ["Ocsigen team "] -authors: ["Ocsigen team "] -license: - "GPL-2.0-or-later AND LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception" -homepage: "https://ocsigen.org/js_of_ocaml/latest/manual/overview" -doc: "https://ocsigen.org/js_of_ocaml/latest/manual/overview" -bug-reports: "https://github.com/ocsigen/js_of_ocaml/issues" -depends: [ - "dune" {>= "2.9"} - "ocaml" {>= "4.04"} - "ocamlbuild" - "num" {with-test} - "ppx_expect" {>= "v0.14.2" & with-test} - "ppxlib" {>= "0.22.0" & with-test} - "re" {>= "1.9.0" & with-test} - "odoc" {with-doc} -] -dev-repo: "git+https://github.com/ocsigen/js_of_ocaml.git" -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "--promote-install-files=false" - "@install" - "@doc" {with-doc} - ] - ["dune" "install" "-p" name "--create-install-files" name] -] diff --git a/js_of_ocaml-ocamlbuild.opam.template b/js_of_ocaml-ocamlbuild.opam.template deleted file mode 100644 index 9c0918390f..0000000000 --- a/js_of_ocaml-ocamlbuild.opam.template +++ /dev/null @@ -1,15 +0,0 @@ -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "--promote-install-files=false" - "@install" - "@doc" {with-doc} - ] - ["dune" "install" "-p" name "--create-install-files" name] -] diff --git a/manual/contribute.wiki b/manual/contribute.wiki index 0a6ba2f3cc..d59f5eb374 100644 --- a/manual/contribute.wiki +++ b/manual/contribute.wiki @@ -22,7 +22,7 @@ We actively welcome pull requests. === Install dependencies {{{ -opam install --deps-only js_of_ocaml js_of_ocaml-lwt js_of_ocaml-compiler js_of_ocaml-ocamlbuild js_of_ocaml-toplevel js_of_ocaml-ppx js_of_ocaml-ppx_deriving_json js_of_ocaml-tyxml +opam install --deps-only js_of_ocaml js_of_ocaml-lwt js_of_ocaml-compiler js_of_ocaml-toplevel js_of_ocaml-ppx js_of_ocaml-ppx_deriving_json js_of_ocaml-tyxml opam install lwt reactiveData tyxml ppxlib cohttp-lwt-unix menhir ppx_expect yojson sexplib }}} diff --git a/manual/overview.wiki b/manual/overview.wiki index d2af5de26c..748ec59c57 100644 --- a/manual/overview.wiki +++ b/manual/overview.wiki @@ -20,8 +20,6 @@ Js_of_ocaml is composed of multiple packages: * js_of_ocaml-ppx_deriving_json * js_of_ocaml-lwt, lwt support. * js_of_ocaml-tyxml, tyxml support. - * js_of_ocaml-ocamlbuild, an ocamlbuild plugin to compile to - javascript. * js_of_ocaml-toplevel, lib and tools to build an ocaml toplevel to javascript. diff --git a/ocamlbuild/dune b/ocamlbuild/dune deleted file mode 100644 index 86248e968e..0000000000 --- a/ocamlbuild/dune +++ /dev/null @@ -1,5 +0,0 @@ -(library - (name ocamlbuild_js_of_ocaml) - (public_name js_of_ocaml-ocamlbuild) - (synopsis "Js_of_ocaml ocamlbuild plugin") - (libraries ocamlbuild str)) diff --git a/ocamlbuild/ocamlbuild_js_of_ocaml.ml b/ocamlbuild/ocamlbuild_js_of_ocaml.ml deleted file mode 100644 index e31fd03f03..0000000000 --- a/ocamlbuild/ocamlbuild_js_of_ocaml.ml +++ /dev/null @@ -1,99 +0,0 @@ -(* Js_of_ocaml library - * http://www.ocsigen.org/js_of_ocaml/ - * Copyright (C) 2013 Jacques-Pascal Deplaix - * Laboratoire PPS - CNRS Université Paris Diderot - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, with linking exception; - * either version 2.1 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) - -open Ocamlbuild_plugin -module Pack = Ocamlbuild_pack - -let fold f = - let l = ref [] in - (try - while true do - l @:= [ f () ] - done - with _ -> ()); - !l - -let split_comma = Str.split_delim (Str.regexp " *[, ] *") - -let fold_pflag scan = - List.fold_left - (fun acc x -> try split_comma (scan x (fun x -> x)) @ acc with _ -> acc) - [] - -let ocamlfind cmd f = - let p = Printf.sprintf in - let cmd = List.map (p "\"%s\"") cmd in - let cmd = p "ocamlfind query %s" (String.concat " " cmd) in - Pack.My_unix.run_and_open cmd (fun ic -> fold (fun () -> f ic)) - -let link_opts prod = - let all_pkgs, predicates = - let tags = Tags.elements (tags_of_pathname prod) in - let pkgs = fold_pflag (fun x -> Scanf.sscanf x "package(%[^)])") tags in - let predicates = fold_pflag (fun x -> Scanf.sscanf x "predicate(%[^)])") tags in - "js_of_ocaml" :: pkgs, predicates - in - (* Findlib usually set pkg_* predicate for all selected packages *) - (* It doesn't do it with 'query' command, we have to it manually. *) - let cmd = "-format" :: "pkg_%p" :: "-r" :: all_pkgs in - let predicates_pkgs = ocamlfind cmd (fun ic -> input_line ic) in - let all_predicates = - String.concat "," (("javascript" :: predicates) @ predicates_pkgs) - in - (* query findlib for linking option *) - let cmd = "-o-format" :: "-r" :: "-predicates" :: all_predicates :: all_pkgs in - ocamlfind cmd (fun ic -> A (input_line ic)) - -let init () = - let dep = "%.byte" in - let prod = "%.js" in - let f env _ = - let dep = env dep in - let prod = env prod in - let link_opts = link_opts prod in - let tags = tags_of_pathname prod ++ "js_of_ocaml" in - Cmd - (S - [ A "js_of_ocaml" - ; A "--no-runtime" - ; T tags - ; S link_opts - ; A "-o" - ; Px prod - ; P dep - ]) - in - rule "js_of_ocaml: .byte -> .js" ~dep ~prod f; - flag [ "js_of_ocaml"; "debug" ] (S [ A "--pretty"; A "--debug-info"; A "--source-map" ]); - flag [ "js_of_ocaml"; "pretty" ] (A "--pretty"); - flag [ "js_of_ocaml"; "debuginfo" ] (A "--debug-info"); - flag [ "js_of_ocaml"; "noinline" ] (A "--no-inline"); - flag [ "js_of_ocaml"; "sourcemap" ] (A "--source-map"); - pflag [ "js_of_ocaml" ] "opt" (fun n -> S [ A "--opt"; A n ]); - pflag [ "js_of_ocaml" ] "set" (fun n -> S [ A "--set"; A n ]) - -let oasis_support ~executables = - let aux x = if List.mem x executables then Pathname.update_extension "js" x else x in - Options.targets := List.map aux !Options.targets - -let dispatcher ?(oasis_executables = []) = function - | After_rules -> init () - | After_options -> oasis_support ~executables:oasis_executables - | _ -> () diff --git a/ocamlbuild/ocamlbuild_js_of_ocaml.mli b/ocamlbuild/ocamlbuild_js_of_ocaml.mli deleted file mode 100644 index 300beae4dc..0000000000 --- a/ocamlbuild/ocamlbuild_js_of_ocaml.mli +++ /dev/null @@ -1,100 +0,0 @@ -(* Js_of_ocaml library - * http://www.ocsigen.org/js_of_ocaml/ - * Copyright (C) 2013 Jacques-Pascal Deplaix - * Laboratoire PPS - CNRS Université Paris Diderot - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, with linking exception; - * either version 2.1 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) - -(** Ocamlbuild plugin to build with js_of_ocaml *) - -(** - {2 Initialize} - - Initialize the js_of_ocaml ocamlbuild plugin with the following - code in {i myocamlbuild.ml}: - {[ - let _ = Ocamlbuild_plugin.dispatch Ocamlbuild_js_of_ocaml.dispatcher - ]} - {b Side note}: {!Ocamlbuild_plugin.dispatch} should be used only - once. The last call will override previous ones. - - {3 With Oasis} - - If you use oasis, {b myocamlbuild.ml} should look like: - {[ - let _ = - Ocamlbuild_plugin.dispatch - (fun hook -> - dispatch_default hook; - Ocamlbuild_js_of_ocaml.dispatcher - ~oasis_executables:["src/yourprogram.byte"] - hook; - ) - ]} - - - {2 Build } - - Build a JavaScript program {b myprog.js} by calling the command: - {[ - ocamlbuild -use-ocamlfind -plugin-tag "package(js_of_ocaml.ocamlbuild)" myprog.js - ]} - It will first build the bytecode {b myprog.byte} and finally produce {b myprog.js} (in {b _build}). - - - {2 Options} - - One can pass option to the Js_of_ocaml compiler using tags. - See <>. - - Available tags: - - {b pretty}: Pretty print the generated javascript. - - {b debuginfo}: Output debug information. - - {b noinline}: Disable inlining - - {b sourcemap}: Generate sourcemap - - {b tailcall(none)}: Set the tailcall optimisation (default "trampoline") - - {b opt(3)}: Set the compilation profile (default 1) - - {b debug}: enables {b pretty}, {b debuginfo}, {b sourcemap} - - - {3 Exemples} - - In the {b _tags} file: - {[ - :pretty, opt(3) - ]} - - - {2 Dispatchers} *) - -val dispatcher : - ?oasis_executables:Ocamlbuild_plugin.Pathname.t list -> Ocamlbuild_plugin.hook -> unit -(** The main dispatcher - - [?oasis_executables] is the paths of the executables - (having the .byte extension) you want to compile - as a javascript executable. The former executables are still compiled. - - Side note: {!Ocamlbuild_plugin.dispatch} should be used only once as - it record only one function for an ocamlbuild module. -*) - -(** {2 Low level functions} *) - -val oasis_support : executables:Ocamlbuild_plugin.Pathname.t list -> unit -(** Map each targets given as argument to ocamlbuild and replace each element - that exists in [~executables] by its corresponding .js target. -*)