|
@@ -347,7 +347,7 @@ let get_meta_string meta key =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-let get_meta_string_path ctx meta key =
|
|
|
|
|
|
+let get_meta_string_path meta key =
|
|
let rec loop = function
|
|
let rec loop = function
|
|
| [] -> ""
|
|
| [] -> ""
|
|
| (k,[Ast.EConst (Ast.String name),_], pos) :: _ when k=key->
|
|
| (k,[Ast.EConst (Ast.String name),_], pos) :: _ when k=key->
|
|
@@ -367,6 +367,28 @@ let get_meta_string_path ctx meta key =
|
|
loop meta
|
|
loop meta
|
|
;;
|
|
;;
|
|
|
|
|
|
|
|
+
|
|
|
|
+let get_meta_string_full_filename meta key =
|
|
|
|
+ let rec loop = function
|
|
|
|
+ | [] -> ""
|
|
|
|
+ | (k,_, pos) :: _ when k=key->
|
|
|
|
+ if (Filename.is_relative pos.pfile) then
|
|
|
|
+ Gencommon.normalize (Filename.concat (Sys.getcwd()) pos.pfile)
|
|
|
|
+ else
|
|
|
|
+ pos.pfile
|
|
|
|
+ | _ :: l -> loop l
|
|
|
|
+ in
|
|
|
|
+ loop meta
|
|
|
|
+;;
|
|
|
|
+
|
|
|
|
+let get_meta_string_full_dirname meta key =
|
|
|
|
+ let name = get_meta_string_full_filename meta key in
|
|
|
|
+ try
|
|
|
|
+ Gencommon.normalize (Filename.dirname name)
|
|
|
|
+ with Invalid_argument _ -> ""
|
|
|
|
+;;
|
|
|
|
+
|
|
|
|
+
|
|
let get_field_access_meta field_access key =
|
|
let get_field_access_meta field_access key =
|
|
match field_access with
|
|
match field_access with
|
|
| FInstance(_,_,class_field)
|
|
| FInstance(_,_,class_field)
|
|
@@ -376,6 +398,14 @@ match field_access with
|
|
|
|
|
|
let get_code meta key =
|
|
let get_code meta key =
|
|
let code = get_meta_string meta key in
|
|
let code = get_meta_string meta key in
|
|
|
|
+ let magic_var = "${GENCPP_SOURCE_DIRECTORY}" in
|
|
|
|
+ let code = if ExtString.String.exists code magic_var then begin
|
|
|
|
+ let source_directory = get_meta_string_full_dirname meta key in
|
|
|
|
+ let _,code = ExtString.String.replace code magic_var source_directory in
|
|
|
|
+ code
|
|
|
|
+ end else
|
|
|
|
+ code
|
|
|
|
+ in
|
|
if (code<>"") then code ^ "\n" else code
|
|
if (code<>"") then code ^ "\n" else code
|
|
;;
|
|
;;
|
|
|
|
|
|
@@ -2741,7 +2771,7 @@ let find_referenced_types ctx obj super_deps constructor_deps header_only for_de
|
|
end
|
|
end
|
|
in
|
|
in
|
|
let add_extern_class klass =
|
|
let add_extern_class klass =
|
|
- let include_file = get_meta_string_path ctx klass.cl_meta (if for_depends then Meta.Depend else Meta.Include) in
|
|
|
|
|
|
+ let include_file = get_meta_string_path klass.cl_meta (if for_depends then Meta.Depend else Meta.Include) in
|
|
if (include_file<>"") then
|
|
if (include_file<>"") then
|
|
add_type ( path_of_string include_file )
|
|
add_type ( path_of_string include_file )
|
|
else if (not for_depends) && (has_meta_key klass.cl_meta Meta.Include) then
|
|
else if (not for_depends) && (has_meta_key klass.cl_meta Meta.Include) then
|
|
@@ -3463,7 +3493,7 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla
|
|
output_cpp "#include <hx/Scriptable.h>\n";
|
|
output_cpp "#include <hx/Scriptable.h>\n";
|
|
|
|
|
|
output_cpp ( get_class_code class_def Meta.CppFileCode );
|
|
output_cpp ( get_class_code class_def Meta.CppFileCode );
|
|
- let inc = get_meta_string_path ctx class_def.cl_meta Meta.CppInclude in
|
|
|
|
|
|
+ let inc = get_meta_string_path class_def.cl_meta Meta.CppInclude in
|
|
if (inc<>"") then
|
|
if (inc<>"") then
|
|
output_cpp ("#include \"" ^ inc ^ "\"\n");
|
|
output_cpp ("#include \"" ^ inc ^ "\"\n");
|
|
|
|
|
|
@@ -4086,7 +4116,7 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla
|
|
List.iter ( gen_forward_decl h_file ) referenced;
|
|
List.iter ( gen_forward_decl h_file ) referenced;
|
|
|
|
|
|
output_h ( get_class_code class_def Meta.HeaderCode );
|
|
output_h ( get_class_code class_def Meta.HeaderCode );
|
|
- let inc = get_meta_string_path ctx class_def.cl_meta Meta.HeaderInclude in
|
|
|
|
|
|
+ let inc = get_meta_string_path class_def.cl_meta Meta.HeaderInclude in
|
|
if (inc<>"") then
|
|
if (inc<>"") then
|
|
output_h ("#include \"" ^ inc ^ "\"\n");
|
|
output_h ("#include \"" ^ inc ^ "\"\n");
|
|
|
|
|
|
@@ -5480,7 +5510,7 @@ let generate_source common_ctx =
|
|
(match object_def with
|
|
(match object_def with
|
|
| TClassDecl class_def when is_extern_class class_def ->
|
|
| TClassDecl class_def when is_extern_class class_def ->
|
|
build_xml := !build_xml ^ (get_class_code class_def Meta.BuildXml);
|
|
build_xml := !build_xml ^ (get_class_code class_def Meta.BuildXml);
|
|
- let source = get_meta_string_path common_ctx class_def.cl_meta Meta.SourceFile in
|
|
|
|
|
|
+ let source = get_meta_string_path class_def.cl_meta Meta.SourceFile in
|
|
if (source<>"") then
|
|
if (source<>"") then
|
|
extern_src := source :: !extern_src;
|
|
extern_src := source :: !extern_src;
|
|
| TClassDecl class_def ->
|
|
| TClassDecl class_def ->
|