File: libname.ml

package info (click to toggle)
ocaml-obuild 0.1.11-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 796 kB
  • sloc: ml: 6,570; sh: 171; ansic: 34; makefile: 11
file content (35 lines) | stat: -rw-r--r-- 1,206 bytes parent folder | download | duplicates (2)
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
open Ext.Fugue
open Types
open Ext.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_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
*)