diff --git a/_tags b/_tags new file mode 100644 index 0000000..ee5dfac --- /dev/null +++ b/_tags @@ -0,0 +1,31 @@ + or : include + + : release + : release, ocamlmklib + : release + + : include_sfml_system + : use_libsfml_system + : use_libsfml_system, use_libocsfmlsystem + + + : include_sfml_window + : use_libsfml_window + : use_libsfml_window, use_libocsfmlwindow + + + : include_sfml_graphics + : use_libsfml_graphics + : use_libsfml_graphics, use_libocsfmlgraphics + + + : include_sfml_audio + : use_libsfml_audio + : use_libsfml_audio, use_libocsfmlaudio + + : include_sfml_network + : use_libsfml_network + : use_libsfml_network, use_libocsfmlnetwork + + + : colorize_code, custom_intro \ No newline at end of file diff --git a/myocamlbuild.ml b/myocamlbuild.ml index 200bdc1..c37a425 100644 --- a/myocamlbuild.ml +++ b/myocamlbuild.ml @@ -2,23 +2,7 @@ open Ocamlbuild_plugin open Pathname let link_to_static_sfml_libraries = false ;; -let compiler = List.hd (CppCompiler.available ()) ;; - -let link_one to_c lib = - let open CppCompiler.Library in - match lib with - | Library filename -> ( - match soname filename with - | Some name -> A ("-l" ^ name) - | None -> - if to_c then A filename - else S [] - ) - | Framework (path, name) -> S [A ("-F" ^ path) ; A "-framework" ; A name] - -let link to_c libs = - S (List.map (link_one to_c) libs) - +let compiler = List.hd (CppCompiler.available ()) ;; let add_sfml_flags static = let open FindSfml in @@ -29,25 +13,23 @@ let add_sfml_flags static = List.map (fun cp -> Sfml.LibraryMap.find cp lib) in - let add_flags compilation_mode lib = - let open SfmlConfiguration in - flag [ "ocamlmklib" ; "c" ; compilation_mode ; "use_libsfml_system" ] & link true (libs_of_components lib [System]) ; - flag [ "ocamlmklib" ; "c" ; compilation_mode ; "use_libsfml_window" ] & link true (libs_of_components lib [System ; Window]); - flag [ "ocamlmklib" ; "c" ; compilation_mode ; "use_libsfml_graphics" ] & link true (libs_of_components lib [System ; Window ; Graphics]) ; - flag [ "ocamlmklib" ; "c" ; compilation_mode ; "use_libsfml_audio" ] & link true (libs_of_components lib [System ; Audio ]) ; - flag [ "ocamlmklib" ; "c" ; compilation_mode ; "use_libsfml_network" ] & link true (libs_of_components lib [System ; Network ]) ; + if static then flag ["c++"; "compile"] (A "-DSFML_STATIC") ; - flag [ "ocamlmklib" ; "ocaml" ; compilation_mode ; "use_libsfml_system" ] & link false (libs_of_components lib [System]) ; - flag [ "ocamlmklib" ; "ocaml" ; compilation_mode ; "use_libsfml_window" ] & link false (libs_of_components lib [System ; Window]) ; - flag [ "ocamlmklib" ; "ocaml" ; compilation_mode ; "use_libsfml_graphics" ] & link false (libs_of_components lib [System ; Window ; Graphics]) ; - flag [ "ocamlmklib" ; "ocaml" ; compilation_mode ; "use_libsfml_audio" ] & link false (libs_of_components lib [System ; Audio ]) ; - flag [ "ocamlmklib" ; "ocaml" ; compilation_mode ; "use_libsfml_network" ] & link false (libs_of_components lib [System ; Network ]) + let add_flags lib = + let open SfmlConfiguration in + let includedir = sfml.Sfml.includedir in + CppLibrary.register ~libraries:(libs_of_components lib [System]) + ~includedir "libsfml_system" compiler ; + CppLibrary.register ~libraries:(libs_of_components lib [System ; Window]) + ~includedir "libsfml_window" compiler ; + CppLibrary.register ~libraries:(libs_of_components lib [System ; Window ; Graphics]) + ~includedir "libsfml_graphics" compiler ; + CppLibrary.register ~libraries:(libs_of_components lib [System ; Audio]) + ~includedir "libsfml_audio" compiler ; + CppLibrary.register ~libraries:(libs_of_components lib [System ; Network]) + ~includedir "libsfml_network" compiler ; in - - flag [ "c++" ; "compile" ] (A (CppCompiler.BuildFlags.add_include_path sfml.Sfml.includedir compiler)) ; - if static then flag ["c++"; "compile"] (A "-DSFML_STATIC") ; - let stub_dir s = Printf.sprintf "../Ocsfml%s/ocsfml_%s_stub" (String.capitalize s) s in @@ -72,28 +54,23 @@ let add_sfml_flags static = List.iter (fun s -> - (* - flag ["link"; "ocaml"; "use_libocsfml"^s] - (S [ A("-LOcsfml" ^ String.capitalize s) ]) ; - - flag ["link"; "ocaml"; "use_libocsfml"^s] - (S [ A("-locsfml"^s) ]) ; -*) let d = Printf.sprintf "Ocsfml%s" (String.capitalize s) in + dep ["link"; "ocaml"; "native"; "use_libocsfml"^s] [d^"/libocsfml"^s^"."^(!Options.ext_lib)] ; + dep ["link"; "ocaml"; "byte"; "use_libocsfml"^s] [d^"/dllocsfml"^s^"."^(!Options.ext_dll)] ; ocaml_lib (d ^ "/ocsfml" ^ s); - ) ["system" ; "window" ; "graphics" ; "audio" ; "network"] ; + ) ["system" ; "window" ; "graphics" ; "audio" ; "network"] ; - add_flags "release" sfml.Sfml.library ; + add_flags sfml.Sfml.library ; if compiler = CppCompiler.Clang then ( - flag ["ocamlmklib" ] (S [A"-lc++"]) ; + flag ["ocamlmklib"] (S [A"-lc++"]) ; ) else if CppCompiler.frontend compiler = CppCompiler.GccCompatible then ( @@ -103,13 +80,18 @@ let add_sfml_flags static = let add_other_flags () = let open FindBoost.Boost in + let boost = find compiler [] in - flag [ "c++" ; "compile"] (A (CppCompiler.BuildFlags.add_include_path boost.FindBoost.Boost.includedir compiler)) ; + flag [ "c++" ; "compile"] + (A (CppCompiler.BuildFlags.add_include_path boost.FindBoost.Boost.includedir compiler)) ; let ocaml_dir = input_line (Unix.open_process_in "ocamlc -where") in - flag [ "c++" ; "compile" ] (A (CppCompiler.BuildFlags.add_include_path ocaml_dir compiler)) ; + flag [ "c++" ; "compile" ] + (A (CppCompiler.BuildFlags.add_include_path ocaml_dir compiler)) ; + let camlpp_dir = "../camlpp" in - flag [ "c++" ; "compile" ] (A (CppCompiler.BuildFlags.add_include_path camlpp_dir compiler)) ; + flag [ "c++" ; "compile" ] + (A (CppCompiler.BuildFlags.add_include_path camlpp_dir compiler)) ; flag [ "c++" ; "compile" ; "gcc"] (A "-std=c++0x") ; flag [ "c++" ; "compile" ; "mingw"] (A "-std=c++0x") ; @@ -127,6 +109,7 @@ let _ = dispatch (function add_other_flags () | After_rules -> flag ["ocaml"; "doc" ; "colorize_code"] & A "-colorize-code" ; - flag ["ocaml"; "doc" ; "custom_intro"] & S [ A "-intro" ; A "../Documentation/intro.camldoc" ] + flag ["ocaml"; "doc" ; "custom_intro"] + & S [ A "-intro" ; A "../Documentation/intro.camldoc" ] | _ -> () )