Commit b983b8f2 authored by yoogx's avatar yoogx

* Rework generation of makefile when using scenario files

        For openaadl/ocarina#255
parent 24790482
...@@ -191,12 +191,12 @@ package body Ocarina.Backends.Build_Utils is ...@@ -191,12 +191,12 @@ package body Ocarina.Backends.Build_Utils is
Normalize_Pathname (Name_Buffer (1 .. Name_Len))); Normalize_Pathname (Name_Buffer (1 .. Name_Len)));
Resolved_Filename : constant String := Resolved_Filename : constant String :=
(if Relative_Path then (if Relative_Path then
Format_Pathname (Normalized_Dir & "/" Format_Pathname (Normalized_Dir & "/"
& Get_Name_String (Filename)) & Get_Name_String (Filename))
else else
Normalize_Pathname (Get_Name_String (Filename), Normalize_Pathname (Get_Name_String (Filename),
Normalized_Dir)); Normalized_Dir));
begin begin
Dirname := Get_String_Name (Dir_Name (Resolved_Filename)); Dirname := Get_String_Name (Dir_Name (Resolved_Filename));
...@@ -676,8 +676,12 @@ package body Ocarina.Backends.Build_Utils is ...@@ -676,8 +676,12 @@ package body Ocarina.Backends.Build_Utils is
Name_Tables.Append (M.C_Libraries, Name_Find); Name_Tables.Append (M.C_Libraries, Name_Find);
elsif Name_Buffer (Name_Len - 1 .. Name_Len) = ".c" then elsif Name_Buffer (Name_Len - 1 .. Name_Len) = ".c" then
Get_Name_String (Source_Dirname); if Source_Dirname /= Get_String_Name ("./") then
Get_Name_String_And_Append (Source_Basename); Get_Name_String (Source_Dirname);
Get_Name_String_And_Append (Source_Basename);
else
Get_Name_String (Source_Basename);
end if;
Name_Tables.Append (M.C_Sources, Name_Find); Name_Tables.Append (M.C_Sources, Name_Find);
...@@ -1939,7 +1943,12 @@ package body Ocarina.Backends.Build_Utils is ...@@ -1939,7 +1943,12 @@ package body Ocarina.Backends.Build_Utils is
Set_Str_To_Name_Buffer Set_Str_To_Name_Buffer
(Base_Name (Name_Buffer (1 .. Name_Len))); (Base_Name (Name_Buffer (1 .. Name_Len)));
Name_Buffer (Name_Len - 1 .. Name_Len) := "o "; 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;
Write_Name (Name_Find); Write_Name (Name_Find);
exit when J = Name_Tables.Last (CPP_Sources); exit when J = Name_Tables.Last (CPP_Sources);
...@@ -1996,54 +2005,34 @@ package body Ocarina.Backends.Build_Utils is ...@@ -1996,54 +2005,34 @@ package body Ocarina.Backends.Build_Utils is
--------------------- ---------------------
procedure Compile_C_Files (C_Sources : Name_Tables.Instance) is procedure Compile_C_Files (C_Sources : Name_Tables.Instance) is
pragma Unreferenced (C_Sources);
begin begin
Write_Line ("compile-c-files:"); -- Define VPATH, search path for All Prerequisites
if Length (C_Sources) > 0 then
for J in Name_Tables.First .. Name_Tables.Last (C_Sources) loop Write_Str ("VPATH = ../..");
declare if Scenario_Dir /= null then
O_File : Name_Id; Write_Str (":" & Scenario_Dir.all);
Include_Dir : Name_Id; end if;
begin Write_Eol;
Get_Name_String (C_Sources.Table (J)); Write_Eol;
Name_Buffer (Name_Len) := 'o';
Set_Str_To_Name_Buffer
(Base_Name (Name_Buffer (1 .. Name_Len)));
O_File := Name_Find;
Get_Name_String (C_Sources.Table (J)); -- Generic rule for compiling C files
while (Name_Buffer (Name_Len) /= Directory_Separator)
and then Name_Len > 0
loop
Name_Len := Name_Len - 1;
end loop;
if Name_Len > 0 then Write_Line ("%.o : %.c");
Set_Str_To_Name_Buffer (Name_Buffer (1 .. Name_Len)); Write_Char (ASCII.HT);
Include_Dir := Name_Find; Write_Str ("$(CC) -c $(INCLUDE) $(CFLAGS) " &
else "-I$(RUNTIME_PATH)/include ");
Include_Dir := No_Name; if Scenario_Dir /= null then
end if; Write_Str ("-I" & Scenario_Dir.all & " ");
end if;
Write_Line (" $< -o $@");
Write_Eol;
Write_Char (ASCII.HT); -- compile-c-files rule, simply biuld $(USER_OBJS)
Write_Str ("$(CC) -c $(INCLUDE) $(CFLAGS) " &
"-I$(RUNTIME_PATH)/include ");
if Include_Dir /= No_Name then Write_Line ("compile-c-files: $(USER_OBJS) $(C_OBJECTS)");
Write_Str ("-I");
Write_Str ("'");
Write_Name (Include_Dir);
Write_Str ("'");
end if;
Write_Str (" '");
Write_Name (C_Sources.Table (J));
Write_Str ("' -o ");
Write_Name (O_File);
Write_Eol;
end;
end loop;
end if;
end Compile_C_Files; end Compile_C_Files;
----------------------- -----------------------
...@@ -2061,7 +2050,13 @@ package body Ocarina.Backends.Build_Utils is ...@@ -2061,7 +2050,13 @@ package body Ocarina.Backends.Build_Utils is
Include_Dir : Name_Id; Include_Dir : Name_Id;
begin begin
Get_Name_String (CPP_Sources.Table (J)); Get_Name_String (CPP_Sources.Table (J));
Name_Buffer (Name_Len - 1 .. Name_Len) := "o ";
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 Set_Str_To_Name_Buffer
(Base_Name (Name_Buffer (1 .. Name_Len))); (Base_Name (Name_Buffer (1 .. Name_Len)));
O_File := Name_Find; O_File := Name_Find;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2009 Telecom ParisTech, 2010-2015 ESA & ISAE. -- -- Copyright (C) 2009 Telecom ParisTech, 2010-2020 ESA & ISAE. --
-- -- -- --
-- Ocarina is free software; you can redistribute it and/or modify under -- -- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -168,9 +168,6 @@ package Ocarina.Backends.Execution_Tests is ...@@ -168,9 +168,6 @@ package Ocarina.Backends.Execution_Tests is
Command_Name_Path : String_Ptr; Command_Name_Path : String_Ptr;
-- The command name path -- The command name path
Scenario_Dir : String_Ptr;
-- Path to scenario directory
Create_Referencial : Boolean := False; Create_Referencial : Boolean := False;
-- Decides if we make a regression test or if we write a referencial -- Decides if we make a regression test or if we write a referencial
-- file -- file
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2008-2009 Telecom ParisTech, 2010-2018 ESA & ISAE. -- -- Copyright (C) 2008-2009 Telecom ParisTech, 2010-2020 ESA & ISAE. --
-- -- -- --
-- Ocarina is free software; you can redistribute it and/or modify under -- -- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -112,6 +112,9 @@ package Ocarina.Backends is ...@@ -112,6 +112,9 @@ package Ocarina.Backends is
Generated_Sources_Directory : Name_Id := No_Name; Generated_Sources_Directory : Name_Id := No_Name;
-- Generated code will be in this directory -- Generated code will be in this directory
Scenario_Dir : String_Ptr;
-- Path to scenario directory, required to get source path to user code
Compile_Generated_Sources : aliased Boolean := False; Compile_Generated_Sources : aliased Boolean := False;
Remove_Generated_Sources : aliased Boolean := False; Remove_Generated_Sources : aliased Boolean := False;
Do_Coverage_Test : aliased Boolean := False; Do_Coverage_Test : aliased Boolean := False;
......
...@@ -289,6 +289,12 @@ package body Ocarina.Backends.PO_HI_C is ...@@ -289,6 +289,12 @@ package body Ocarina.Backends.PO_HI_C is
Write_Line ("RUNTIME_PATH=$(BUILD_DIR)/../polyorb-hi-c"); Write_Line ("RUNTIME_PATH=$(BUILD_DIR)/../polyorb-hi-c");
Write_Str ("USER_SOURCES_DIRS="); Write_Str ("USER_SOURCES_DIRS=");
if Scenario_Dir /= null then
Write_Space;
Write_Str ("""-I" & Scenario_Dir.all & """");
end if;
if Length (User_Source_Dirs) > 0 then if Length (User_Source_Dirs) > 0 then
for J in Name_Tables.First .. Name_Tables.Last (User_Source_Dirs) loop for J in Name_Tables.First .. Name_Tables.Last (User_Source_Dirs) loop
Write_Space; Write_Space;
......
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