113.33.03

This commit is contained in:
Jeremie Dimino 2016-04-26 17:03:48 +01:00
parent 5b78706d34
commit ba530c73b9
9 changed files with 47 additions and 162 deletions

View File

@ -2,7 +2,8 @@ version = "$(pkg_version)"
description = "Monadic let-bindings" description = "Monadic let-bindings"
requires = "ppx_core ppx_driver" requires = "ppx_core ppx_driver"
archive(ppx_driver, byte ) = "ppx_let.cma" archive(ppx_driver, byte ) = "ppx_let.cma"
archive(ppx_driver, native ) = "ppx_let.cmxa" archive(ppx_driver, native) = "ppx_let.cmxa"
archive(ppx_driver, native, plugin) = "ppx_let.cmxs" plugin(ppx_driver, byte ) = "ppx_let.cma"
plugin(ppx_driver, native) = "ppx_let.cmxs"
exists_if = "ppx_let.cma" exists_if = "ppx_let.cma"
ppx(-ppx_driver) = "./ppx" ppx(-ppx_driver,-custom_ppx) = "./ppx"

View File

@ -26,8 +26,8 @@ all: $(SETUP)
./$(SETUP) -all $(ALLFLAGS) ./$(SETUP) -all $(ALLFLAGS)
$(MAKE) $(NAME).install $(MAKE) $(NAME).install
$(NAME).install: js-utils/gen_install.ml setup.log setup.data $(NAME).install: install.ml setup.log setup.data
ocaml -I js-utils js-utils/gen_install.ml ocaml install.ml
install: $(NAME).install install: $(NAME).install
opam-installer -i --prefix $(PREFIX) $(NAME).install opam-installer -i --prefix $(PREFIX) $(NAME).install

7
_oasis
View File

@ -2,7 +2,7 @@ OASISFormat: 0.4
OCamlVersion: >= 4.02.3 OCamlVersion: >= 4.02.3
FindlibVersion: >= 1.3.2 FindlibVersion: >= 1.3.2
Name: ppx_let Name: ppx_let
Version: 113.33.00 Version: 113.33.03
Synopsis: Monadic let-bindings Synopsis: Monadic let-bindings
Authors: Jane Street Group, LLC <opensource@janestreet.com> Authors: Jane Street Group, LLC <opensource@janestreet.com>
Copyrights: (C) 2015-2016 Jane Street Group LLC <opensource@janestreet.com> Copyrights: (C) 2015-2016 Jane Street Group LLC <opensource@janestreet.com>
@ -10,10 +10,13 @@ Maintainers: Jane Street Group, LLC <opensource@janestreet.com>
License: Apache-2.0 License: Apache-2.0
LicenseFile: LICENSE.txt LicenseFile: LICENSE.txt
Homepage: https://github.com/janestreet/ppx_let Homepage: https://github.com/janestreet/ppx_let
Plugins: StdFiles (0.3), DevFiles (0.3), META (0.3) Plugins: StdFiles (0.3), DevFiles (0.3)
XStdFilesAUTHORS: false XStdFilesAUTHORS: false
XStdFilesREADME: false XStdFilesREADME: false
BuildTools: ocamlbuild BuildTools: ocamlbuild
BetaFeatures: section_object
AlphaFeatures: ocamlbuild_more_args
XOCamlbuildPluginTags: package(js-build-tools.ocamlbuild_goodies)
FilesAB: META.ab FilesAB: META.ab
Description: Description:
Part of the Jane Street's PPX rewriters collection. Part of the Jane Street's PPX rewriters collection.

2
_tags
View File

@ -1,7 +1,7 @@
<**/*.ml{,i}>: warn(-40), no_alias_deps <**/*.ml{,i}>: warn(-40), no_alias_deps
<**/*>: thread <**/*>: thread
# This prevents the implicit addition of -ppx options by ocamlfind # This prevents the implicit addition of -ppx options by ocamlfind
<**/*.ml{,i}>: predicate(ppx_driver) <**/*>: predicate(custom_ppx)
<as_ppx/ppx.{byte,native}>: predicate(ppx_driver) <as_ppx/ppx.{byte,native}>: predicate(ppx_driver)
<src/*>: linkall <src/*>: linkall
# OASIS_START # OASIS_START

10
install.ml Normal file
View File

@ -0,0 +1,10 @@
#use "topfind";;
#require "js-build-tools.oasis2opam_install";;
open Oasis2opam_install;;
generate ~package:"ppx_let"
[ oasis_lib "ppx_let"
; file "META" ~section:"lib"
; oasis_exe "ppx" ~dest:"../lib/ppx_let/ppx"
]

View File

@ -1,102 +0,0 @@
(* Generate <package>.install from setup.log *)
#use "install_tags.ml"
module String_map = Map.Make(String)
let string_map_of_list =
List.fold_left
(fun acc (k, v) ->
assert (not (String_map.mem k acc));
String_map.add k v acc)
String_map.empty
let lines_of_file fn =
let ic = open_in fn in
let rec loop acc =
match input_line ic with
| exception End_of_file ->
close_in ic;
List.rev acc
| line ->
loop (line :: acc)
in
loop []
let read_setup_log () =
lines_of_file "setup.log"
|> List.map (fun line -> Scanf.sscanf line "%S %S" (fun tag arg -> (tag, arg)))
let read_setup_data () =
lines_of_file "setup.data"
|> List.map (fun line -> Scanf.sscanf line "%[^=]=%S" (fun k v -> (k, v)))
let remove_cwd =
let prefix = Sys.getcwd () ^ "/" in
let len_prefix = String.length prefix in
fun fn ->
let len = String.length fn in
if len >= len_prefix && String.sub fn 0 len_prefix = prefix then
String.sub fn len_prefix (len - len_prefix)
else
fn
let gen_section oc name files =
let pr fmt = Printf.fprintf oc (fmt ^^ "\n") in
pr "%s: [" name;
List.iter
(fun (src, dst) ->
let src = remove_cwd src in
let dst =
match dst with
| None -> Filename.basename src
| Some fn -> fn
in
if src = dst then
pr " %S" src
else
pr " %S {%S}" src dst)
files;
pr "]"
let rec filter_log tags log acc =
match log with
| [] -> acc
| (tag, fname) :: rest ->
match String_map.find tag tags with
| exception Not_found -> filter_log tags rest acc
| dst -> filter_log tags rest ((fname, dst) :: acc)
let () =
let log = read_setup_log () in
let setup_data = read_setup_data () in
let ext_dll =
match List.assoc "ext_dll" setup_data with
| ext -> ext
| exception Not_found -> ".so"
in
let merge name files map =
match String_map.find name map with
| files' -> String_map.add name (files @ files') map
| exception Not_found -> String_map.add name files map
in
let sections =
List.fold_left
(fun acc (name, tags, extra_files) ->
let tags = string_map_of_list tags in
let files = filter_log tags log [] @ extra_files in
if name = "lib" then
let stubs, others =
List.partition
(fun (fn, _) -> Filename.check_suffix fn ext_dll)
files
in
merge "lib" others (merge "stublibs" stubs acc)
else
merge name files acc)
String_map.empty sections
|> String_map.bindings
|> List.filter (fun (_, l) -> l <> [])
in
let oc = open_out (package_name ^ ".install") in
List.iter (fun (name, files) -> gen_section oc name files) sections;
close_out oc

View File

@ -1,13 +0,0 @@
let package_name = "ppx_let"
let sections =
[ ("lib",
[ ("built_lib_ppx_let", None)
],
[ ("META", None)
])
; ("bin",
[ ("built_exec_ppx", Some "../lib/ppx_let/ppx")
],
[])
]

View File

@ -2,28 +2,13 @@
(* OASIS_STOP *) (* OASIS_STOP *)
# 3 "myocamlbuild.ml" # 3 "myocamlbuild.ml"
(* Temporary hacks *) module JS = Jane_street_ocamlbuild_goodies
let js_hacks = function
| After_rules ->
rule "Generate a cmxs from a cmxa"
~dep:"%.cmxa"
~prod:"%.cmxs"
~insert:`top
(fun env _ ->
Cmd (S [ !Options.ocamlopt
; A "-shared"
; A "-linkall"
; A "-I"; A (Pathname.dirname (env "%"))
; A (env "%.cmxa")
; A "-o"
; A (env "%.cmxs")
]));
(* Pass -predicates to ocamldep *) let dev_mode = true
pflag ["ocaml"; "ocamldep"] "predicate" (fun s -> S [A "-predicates"; A s])
| _ -> ()
let () = let () =
Ocamlbuild_plugin.dispatch (fun hook -> Ocamlbuild_plugin.dispatch (fun hook ->
js_hacks hook; JS.alt_cmxs_of_cmxa_rule hook;
JS.pass_predicates_to_ocamldep hook;
if dev_mode && not Sys.win32 then JS.track_external_deps hook;
dispatch_default hook) dispatch_default hook)

1
opam
View File

@ -13,6 +13,7 @@ depends: [
"ocamlbuild" {build} "ocamlbuild" {build}
"oasis" {build & >= "0.4"} "oasis" {build & >= "0.4"}
"ocamlfind" {build & >= "1.3.2"} "ocamlfind" {build & >= "1.3.2"}
"js-build-tools" {build}
"ppx_core" "ppx_core"
"ppx_driver" "ppx_driver"
] ]