Permalink
Browse files

Implement 'Object' section, thanks to Philippe Veber

Ignore-this: 57e3aa2075fbf8891e133cbedc82442

darcs-hash:20120821221215-a43a9-abaa1f451214b6fca1ca6400cc59b755b52fb404
  • Loading branch information...
1 parent 00b04b8 commit deea3a59bf9d3f4e03b465f4fe91ba1dba4cb4ec @gildor478 gildor478 committed Aug 21, 2012
View
2 _oasis
@@ -70,10 +70,12 @@ Library oasis
OASISExecutable,
OASISFlag,
OASISLibrary,
+ OASISObject,
OASISPackage,
OASISSourceRepository,
OASISTest,
OASISPlugin,
+ OASISFindlib,
OASISSchema,
OASISSection,
OASISData,
View
@@ -0,0 +1,20 @@
+Name: object
+Version: 0.0.1
+OASISFormat: 0.3
+Authors: Philippe Veber
+Homepage: http://example.com
+License: LGPL with OCaml linking exception
+Synopsis: Example for object sections
+BuildTools: ocamlbuild
+BuildDepends: oUnit (>= 0.1.1)
+Plugins: META (0.3)
+
+Object single_module
+ Path: src1
+ Modules: Single
+ Install: true
+
+Object packed_modules
+ Path: src2
+ Modules: M1, M2
+ Install: true
View
@@ -793,6 +793,7 @@ dispatch
function
| After_rules ->
begin
+ flag ["ocaml"; "compile"] & S[A"-warn-error"; A"+8"];
try
let gettext =
BaseEnvLight.var_get
View
@@ -6117,10 +6117,12 @@ let setup_t =
"OASISExecutable";
"OASISFlag";
"OASISLibrary";
+ "OASISObject";
"OASISPackage";
"OASISSourceRepository";
"OASISTest";
"OASISPlugin";
+ "OASISFindlib";
"OASISSchema";
"OASISSection";
"OASISData";
View
@@ -20,7 +20,7 @@
################################################################################
# OASIS_START
-# DO NOT EDIT (digest: 0e62ab6c871c5ff24dbe4ca8f3684337)
+# DO NOT EDIT (digest: 30b50993f19311a293781368d85c0608)
oasis/FormatExt
oasis/FormatMarkdown
oasis/ODNFunc
@@ -42,10 +42,12 @@ oasis/OASISDocument
oasis/OASISExecutable
oasis/OASISFlag
oasis/OASISLibrary
+oasis/OASISObject
oasis/OASISPackage
oasis/OASISSourceRepository
oasis/OASISTest
oasis/OASISPlugin
+oasis/OASISFindlib
oasis/OASISSchema
oasis/OASISSection
oasis/OASISData
View
@@ -28,6 +28,7 @@ type t =
| BExec (* Executable *)
| BExecLib (* Library coming with executable *)
| BLib (* Library *)
+ | BObj (* Library *)
| BDoc (* Document *)
let to_log_event_file t nm =
@@ -36,6 +37,7 @@ let to_log_event_file t nm =
| BExec -> "exec"
| BExecLib -> "exec_lib"
| BLib -> "lib"
+ | BObj -> "obj"
| BDoc -> "doc")^
"_"^nm
@@ -99,6 +101,8 @@ let fold t nm f acc =
(f_ "executable %s")
| BLib ->
(f_ "library %s")
+ | BObj ->
+ (f_ "object %s")
| BDoc ->
(f_ "documentation %s"))
nm);
@@ -161,3 +165,20 @@ let of_library ffn (cs, bs, lib) =
in
evs, unix_lst
+
+let of_object ffn (cs, bs, obj) =
+ let unix_lst =
+ OASISObject.generated_unix_files
+ ~ctxt:!BaseContext.default
+ ~source_file_exists:(fun fn ->
+ OASISFileUtil.file_exists_case (OASISHostPath.of_unix fn))
+ ~is_native:(bool_of_string (is_native ()))
+ (cs, bs, obj)
+ in
+ let evs =
+ [BObj,
+ cs.cs_name,
+ List.map (List.map ffn) unix_lst]
+ in
+ evs, unix_lst
+
View
@@ -29,6 +29,7 @@ type t =
| BExec (* Executable. *)
| BExecLib (* Library coming with executable. *)
| BLib (* Library. *)
+ | BObj (* Object. *)
| BDoc (* Document. *)
(** Register files built. Each files built is provided as a list
@@ -45,7 +46,7 @@ val unregister : t -> name -> unit
*)
val fold : t -> name -> ('a -> host_filename -> 'a) -> 'a -> 'a
-(** Check if a library/doc/exec has been built.
+(** Check if a library/object/doc/exec has been built.
*)
val is_built : t -> name -> bool
@@ -68,3 +69,11 @@ val of_library :
(unix_filename -> host_filename) ->
common_section * build_section * library ->
(t * name * host_filename list list) list * unix_filename list list
+
+(** [of_object loc_fn (cs, bs, lib)] Same as {!of_executable}, but
+ using {!OASISObject.generated_unix_files}.
+ *)
+val of_object :
+ (unix_filename -> host_filename) ->
+ common_section * build_section * object_ ->
+ (t * name * host_filename list list) list * unix_filename list list
View
@@ -58,6 +58,6 @@ let init pkg =
(f_ "Executable '%s' not yet built.")
cs.cs_name)))))
- | Library _ | Flag _ | Test _ | SrcRepo _ | Doc _ ->
+ | Library _ | Object _ | Flag _ | Test _ | SrcRepo _ | Doc _ ->
())
pkg.sections
View
@@ -264,6 +264,7 @@ let clean, distclean =
(f t.package (cs, doc))
args
| Library _
+ | Object _
| Executable _
| Flag _
| SrcRepo _ ->
View
@@ -207,6 +207,15 @@ let to_package conf st =
acc
stmt
+ | TSObject (nm, stmt) ->
+ schema_stmt
+ OASISObject.generator
+ nm
+ OASISObject.schema
+ (oasis_version pkg_data)
+ acc
+ stmt
+
| TSExecutable (nm, stmt) ->
schema_stmt
OASISExecutable_intern.generator
@@ -292,7 +301,7 @@ let to_package conf st =
let pkg =
(* Map of findlib name to internal libraries *)
let _, _, internal_of_findlib =
- OASISLibrary.findlib_mapping pkg
+ OASISFindlib.findlib_mapping pkg
in
let map_internal_libraries sct =
@@ -302,7 +311,7 @@ let to_package conf st =
let is_internal, lnm =
try
true, internal_of_findlib lnm
- with (OASISLibrary.FindlibPackageNotFound _) ->
+ with (OASISFindlib.FindlibPackageNotFound _) ->
false, lnm
in
if is_internal then
@@ -367,6 +376,13 @@ let to_package conf st =
sct
bs,
lib)
+ | Object (cs, bs, obj) as sct ->
+ Object
+ (cs,
+ map_internal
+ sct
+ bs,
+ obj)
| Executable (cs, bs, exec) as sct ->
Executable
(cs,
@@ -56,6 +56,7 @@ type stmt =
type top_stmt =
| TSLibrary of name * stmt
+ | TSObject of name * stmt
| TSExecutable of name * stmt
| TSFlag of name * stmt
| TSSourceRepository of name * stmt
@@ -70,8 +70,10 @@ let build_graph pkg =
List.iter
(function
| InternalLibrary nm ->
- let dvrtx = G.vertex_of_value g (`Library, nm) in
- G.add_edge g vrtx dvrtx
+ let dvrtx =
+ try G.vertex_of_value g (`Library, nm)
+ with Not_found -> G.vertex_of_value g (`Object, nm) in
+ G.add_edge g vrtx dvrtx
| FindlibPackage (fndlb_nm, ver_opt) ->
let dvrtx = G.add_vertex g (`FindlibPackage, fndlb_nm) in
Hashtbl.add ext_of_vrtx dvrtx
@@ -85,6 +87,7 @@ let build_graph pkg =
(fun (vrtx, sct) ->
match sct with
| Library (cs, bs, _)
+ | Object (cs, bs, _)
| Executable (cs, bs, _) ->
add_build_section vrtx bs
| Test (cs, {test_tools = build_tools})
View
@@ -251,7 +251,7 @@ let check_package ~ctxt pkg =
%s, possible conflict.")
sct_str varname (MapString.find varname mp);
MapString.add varname sct_str mp
- | Library _ | Doc _ | SrcRepo _ | Test _ ->
+ | Library _ | Object _ | Doc _ | SrcRepo _ | Test _ ->
mp)
MapString.empty
pkg.sections
Oops, something went wrong.

0 comments on commit deea3a5

Please sign in to comment.