Commit b98d79fe authored by yoogx's avatar yoogx

* Revisit circuitry to compile C++

        For openaadl/ocarina#257
parent afdd5740
......@@ -2006,7 +2006,7 @@ package body Ocarina.Backends.Build_Utils is
procedure Compile_C_Files (C_Sources : Name_Tables.Instance) is
begin
-- Define VPATH, search path for All Prerequisites
-- Define VPATH, search path for all prerequisites
Write_Str ("VPATH = ../..");
if Scenario_Dir /= null then
......@@ -2048,58 +2048,33 @@ package body Ocarina.Backends.Build_Utils is
procedure Compile_CPP_Files (CPP_Sources : Name_Tables.Instance) is
begin
Write_Line ("compile-cpp-files:");
if Length (CPP_Sources) > 0 then
for J in Name_Tables.First .. Name_Tables.Last (CPP_Sources) loop
declare
O_File : Name_Id;
Include_Dir : Name_Id;
begin
Get_Name_String (CPP_Sources.Table (J));
if Name_Buffer (Name_Len - 2 .. Name_Len) = "cpp" then
Name_Buffer (Name_Len - 2 .. Name_Len) := "o ";
elsif Name_Buffer (Name_Len - 1 .. Name_Len) = "cc" then
Name_Buffer (Name_Len - 1 .. Name_Len) := "o ";
end if;
Set_Str_To_Name_Buffer
(Base_Name (Name_Buffer (1 .. Name_Len)));
O_File := Name_Find;
Write_Str (":");
Write_Str
(Dir_Name (Get_Name_String (CPP_Sources.Table (J))));
exit when J = Name_Tables.Last (CPP_Sources);
end loop;
end if;
Write_Eol;
Write_Eol;
Get_Name_String (CPP_Sources.Table (J));
while (Name_Buffer (Name_Len) /= Directory_Separator)
and then Name_Len > 0
loop
Name_Len := Name_Len - 1;
end loop;
-- Generic rule for compiling C++ files
if Name_Len > 0 then
Set_Str_To_Name_Buffer (Name_Buffer (1 .. Name_Len));
Include_Dir := Name_Find;
else
Include_Dir := No_Name;
end if;
Write_Line ("%.o : %.cpp");
Write_Char (ASCII.HT);
Write_Str ("$(CXX) -c $(INCLUDE) $(CFLAGS) " &
"-I$(RUNTIME_PATH)/include ");
if Scenario_Dir /= null then
Write_Str ("-I" & Scenario_Dir.all & " ");
end if;
Write_Line (" $< -o $@");
Write_Eol;
Write_Char (ASCII.HT);
Write_Str ("$(CC) -c $(INCLUDE) $(CFLAGS) ");
-- compile-c-files rule, simply biuld $(USER_OBJS)
if Include_Dir /= No_Name then
Write_Str ("-I");
Write_Str ("'");
Write_Name (Include_Dir);
Write_Str ("'");
end if;
Write_Line ("compile-cpp-files: $(USER_OBJS) $(CPP_OBJECTS)");
Write_Str (" '");
Write_Name (CPP_Sources.Table (J));
Write_Str ("' -o ");
Write_Name (O_File);
Write_Eol;
end;
end loop;
end if;
end Compile_CPP_Files;
-----------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment