File: libname.ml

package info (click to toggle)
ocaml-obuild 0.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,456 kB
  • sloc: ml: 14,491; sh: 211; ansic: 34; makefile: 11
file content (38 lines) | stat: -rw-r--r-- 1,135 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
open Types
open Filepath

exception EmptyLibName

(* represent a library in a form abc[.def.xyz] *)
type t = {
  main_name : string;
  subnames : string list;
}

let of_string s =
  match String_utils.split '.' s with
  | [] -> raise EmptyLibName
  | x :: xs -> { main_name = x; subnames = xs }

let to_string lname = String.concat "." (lname.main_name :: lname.subnames)
let to_string_nodes lname = lname.main_name :: lname.subnames
let append lname sub = { lname with subnames = lname.subnames @ [ sub ] }
let to_libstring lib = String.concat "_" (to_string_nodes lib)

let to_cmxs (compileType : ocaml_compilation_option) lib =
  fn (to_libstring lib ^ extDP compileType ^ ".cmxs")

let to_cmxa (compileType : ocaml_compilation_option) lib =
  fn (to_libstring lib ^ extDP compileType ^ ".cmxa")

let to_cma (compileType : ocaml_compilation_option) lib =
  fn (to_libstring lib ^ extDP compileType ^ ".cma")

let to_cmca b = if b = Native then to_cmxa else to_cma

(* only used for stdlib stuff *)
(*
let of_cmca b file =
  let suffix = if b = Native then ".cmxa" else ".cma" in
  Filename.chop_suffix (fn_to_string file) suffix
*)