diff --git a/P04_Modularisieren_von_C_Code/README.md b/P04_Modularisieren_von_C_Code/README.md index e135a32..9b83ae0 100644 --- a/P04_Modularisieren_von_C_Code/README.md +++ b/P04_Modularisieren_von_C_Code/README.md @@ -311,7 +311,7 @@ Prüfen Sie schliesslich die Umsetzung Aufgabe mittels `make dep-clean dep && firefox src/*.png.` -### 4.1 Neue Regeln hinzufügen +### 4.1 Neue Regeln hinzufügen Führen Sie im `Makefile` an den angegebenen Stellen folgende @@ -336,12 +336,16 @@ Ergänzungen durch Die Umsetzung der obigen Änderungen sind erfolgreich, wenn Sie folgende Shell Command Line erfolgreich ausführen können und in -Firefox die Abhängigkeiten der C-Files von den Inclu-de Files +Firefox die Abhängigkeiten der C-Files von den Include Files dargestellt wird. `make dep-clean dep && firefox src/*.png.` +### 4.2 Resultate analysieren und erklären + +* Analysieren Sie die in der vorherigen Aufgabe erstellten grafischen Darstellungen. +* Erklären Sie was dargestellt wird und stellen Sie den Bezug zum zugehörigen C-Code her. (04_grading)= @@ -490,7 +494,7 @@ Es gibt als Teil dieses Tool-Sets verschiedene Übersetzer. Der hier verwendete ist der Basis-übersetzer: `dot`. Das `dot`-File Format kennt viele Möglichkeiten die Knoten und Kanten -eines Graphen und de-ren Anordnung anzugeben. +eines Graphen und deren Anordnung anzugeben. Der Vorteil eines solchen Tool-Sets ist, dass man den Inhalt (den Graphen) einfach definieren kann und sich nicht um das komplexe @@ -511,7 +515,7 @@ digraph G { } subgraph cluster_c1 { - label="others"; style=filled; col-or=lightgrey; + label="others"; style=filled; color=lightgrey; { B; C; rank=same; } } @@ -521,6 +525,13 @@ digraph G { } ``` +```{eval-rst} +.. figure:: bsp_dot.png + :width: 210px + :name: bsp_dot + :align: center +``` + #### 6.2.3 png File @@ -529,4 +540,4 @@ Format. Es wird oft in Web Pages verwendet. ___ -Version: 15.02.2022 \ No newline at end of file +Version: 22.02.2022 diff --git a/P04_Modularisieren_von_C_Code/work/modularize/src/trace.h b/P04_Modularisieren_von_C_Code/work/modularize/src/trace.h deleted file mode 100644 index 14958d8..0000000 --- a/P04_Modularisieren_von_C_Code/work/modularize/src/trace.h +++ /dev/null @@ -1,16 +0,0 @@ -/* ---------------------------------------------------------------------------- - * -- _____ ______ _____ - - * -- |_ _| | ____|/ ____| - - * -- | | _ __ | |__ | (___ Institute of Embedded Systems - - * -- | | | '_ \| __| \___ \ Zuercher Hochschule Winterthur - - * -- _| |_| | | | |____ ____) | (University of Applied Sciences) - - * -- |_____|_| |_|______|_____/ 8401 Winterthur, Switzerland - - * ---------------------------------------------------------------------------- - */ -/** - * @file - * @brief Lab implementation - */ -// begin students to add code for task 4.2 - -// end students to add code diff --git a/P04_Modularisieren_von_C_Code/work/modularize/src/triangle.c b/P04_Modularisieren_von_C_Code/work/modularize/src/triangle.c index 20c23fb..b6a414b 100644 --- a/P04_Modularisieren_von_C_Code/work/modularize/src/triangle.c +++ b/P04_Modularisieren_von_C_Code/work/modularize/src/triangle.c @@ -15,7 +15,6 @@ #include #include "read.h" #include "rectang.h" -#include "trace.h" /// max side length #define MAX_NUMBER 1000 diff --git a/P04_Modularisieren_von_C_Code/work/modularize/tests/tests.c b/P04_Modularisieren_von_C_Code/work/modularize/tests/tests.c index 699b64a..5100394 100644 --- a/P04_Modularisieren_von_C_Code/work/modularize/tests/tests.c +++ b/P04_Modularisieren_von_C_Code/work/modularize/tests/tests.c @@ -135,36 +135,6 @@ static void test_not_right_angled(void) assert_lines(OUTFILE, out_txt, sizeof(out_txt)/sizeof(*out_txt)); } -static void test_trace(void) -{ - // arrange - const char *err_txt[] = { - "TRACE: main()\n", - "TRACE: getInt(1000)\n", - "TRACE: getInt(1000)\n", - "TRACE: getInt(1000)\n", - "TRACE: rectangular(3, 4, 6)\n", - "TRACE: getInt(1000)\n", - "TRACE: getInt(1000)\n", - "TRACE: getInt(1000)\n", - "TRACE: rectangular(5, 4, 4)\n", - "TRACE: getInt(1000)\n", - "TRACE: getInt(1000)\n", - "TRACE: getInt(1000)\n", - "TRACE: rectangular(3, 5, 5)\n", - "TRACE: getInt(1000)\n", - "TRACE: getInt(1000)\n", - "TRACE: getInt(1000)\n", - "TRACE: rectangular(33, 43, 55)\n", - "TRACE: getInt(1000)\n", - }; - // act - int exit_code = system(XSTR(TARGET) " 1>" OUTFILE " 2>" ERRFILE " <" INFILE_NOT_RIGHT_ANGLED); - // assert - CU_ASSERT_EQUAL(exit_code, 0); - assert_lines(ERRFILE, err_txt, sizeof(err_txt)/sizeof(*err_txt)); -} - static void test_error(void) { // arrange @@ -199,7 +169,6 @@ int main(void) TestMainBasic("Triangle", setup, teardown , test_right_angled , test_not_right_angled - , test_trace , test_error ); } diff --git a/P04_Modularisieren_von_C_Code/work/show-dependencies/src/data.h b/P04_Modularisieren_von_C_Code/work/show-dependencies/src/data.h index 7a20b76..ab1880b 100644 --- a/P04_Modularisieren_von_C_Code/work/show-dependencies/src/data.h +++ b/P04_Modularisieren_von_C_Code/work/show-dependencies/src/data.h @@ -1,19 +1,18 @@ /** * @file - * @brief Access to the GCC produced dependency data (via gcc -H command line option). + * @brief Access to the GCC produced dependency data (via -H command line option). */ // begin of include guard // BEGIN-STUDENTS-TO-ADD-CODE - - +#ifndef _DATA_H_ +#define _DATA_H_ // END-STUDENTS-TO-ADD-CODE // includes which are needed in this header file // BEGIN-STUDENTS-TO-ADD-CODE - - +#include // END-STUDENTS-TO-ADD-CODE @@ -22,17 +21,22 @@ * @brief Directory container for file entries of the dependency file. */ // BEGIN-STUDENTS-TO-ADD-CODE - - +typedef struct { + const char *name; ///< @brief the path name of the directory as given by the GCC produced dependency file. +} dir_t; // END-STUDENTS-TO-ADD-CODE + /** * @brief File container for the file entries of the dependency file. */ // BEGIN-STUDENTS-TO-ADD-CODE - - +typedef struct { + const char *name; ///< @brief The base name of the file from the GGC produced dependency file (i.e. the plain name, without any directory path). + size_t dir; ///< @brief The index of the directory entry which represents the path as given by the dependency file. + size_t level; ///< @brief The level as read out from the dependecy file. +} file_t; // END-STUDENTS-TO-ADD-CODE @@ -41,8 +45,12 @@ * @brief Overall container for all directories and all files from the dependency file. */ // BEGIN-STUDENTS-TO-ADD-CODE - - +typedef struct { + size_t n_dirs; ///< @brief The number of valid entries in the dirs list. + dir_t *dirs; ///< @brief The list of directories. + size_t n_files; ///< @brief The number of valid entries in the files list. + file_t *files; ///< @brief The list of files from the dependency file (the sequence is relevant to determine the dependencies). +} data_t; // END-STUDENTS-TO-ADD-CODE @@ -53,14 +61,12 @@ * @return The container of the read data from stdin. See the documentation on gcc -H for details on the dependencies, etc. */ // BEGIN-STUDENTS-TO-ADD-CODE - - +const data_t data_read_all(const char *root); // END-STUDENTS-TO-ADD-CODE // end of include guard // BEGIN-STUDENTS-TO-ADD-CODE - - +#endif // _DATA_H_ // END-STUDENTS-TO-ADD-CODE diff --git a/P04_Modularisieren_von_C_Code/work/show-dependencies/src/output.c b/P04_Modularisieren_von_C_Code/work/show-dependencies/src/output.c index 088d984..3a3d33e 100644 --- a/P04_Modularisieren_von_C_Code/work/show-dependencies/src/output.c +++ b/P04_Modularisieren_von_C_Code/work/show-dependencies/src/output.c @@ -36,12 +36,11 @@ static size_t dependencies(file_t files[], size_t len, size_t curr) if (files[file].level == level + 1) { // Write to stdout " file -> include;\n" where file and include are the DOT node names of the respective files // BEGIN-STUDENTS-TO-ADD-CODE - - - - - - + printf(" "); + print_node(files[curr]); + printf(" -> "); + print_node(files[file]); + printf(";\n"); // END-STUDENTS-TO-ADD-CODE file = dependencies(files, len, file); } else { @@ -62,11 +61,9 @@ void output_dot(const data_t data) for (size_t file = 0; file < data.n_files; file++) { // Write to stdout " file [label=\"name\"];\n" where file is the DOT node name and name is the file name // BEGIN-STUDENTS-TO-ADD-CODE - - - - - + printf(" "); + print_node(data.files[file]); + printf(" [label=\"%s\"];\n", data.files[file].name); // END-STUDENTS-TO-ADD-CODE } // directory clusters @@ -77,11 +74,9 @@ void output_dot(const data_t data) if (data.files[file].dir == dir) { // Write to stdout " file;\n" where file is the DOT node name // BEGIN-STUDENTS-TO-ADD-CODE - - - - - + printf(" "); + print_node(data.files[file]); + printf(";\n"); // END-STUDENTS-TO-ADD-CODE } } diff --git a/P04_Modularisieren_von_C_Code/work/show-dependencies/src/output.h b/P04_Modularisieren_von_C_Code/work/show-dependencies/src/output.h index 21f46e3..e0a1b1e 100644 --- a/P04_Modularisieren_von_C_Code/work/show-dependencies/src/output.h +++ b/P04_Modularisieren_von_C_Code/work/show-dependencies/src/output.h @@ -4,9 +4,17 @@ */ // define proper header file here, with include gaurd, etc. // BEGIN-STUDENTS-TO-ADD-CODE +#ifndef _OUTPUT_H_ +#define _OUTPUT_H_ + +#include "data.h" + +/** + * @brief Produces DOT output of the dependencies given in data. + * @param data [IN] Container of the dependenciy data. + */ +void output_dot(const data_t data); - - - +#endif // _OUTPUT_H_ // END-STUDENTS-TO-ADD-CODE