程序代写代做代考 Hive C Build Tool

Build Tool

Your final project is to create a program that will compile a C project by recursively descending into directories and launching processes which compile a file of code by calling GCC. Each directory (except the topmost) will make a .a (code archive or static library). The topmost directory will create an executable.

Look through the directory that it starts in
a) it will recursively descend into child directories
b) after all of the (a) descents are completed, it will launch a new process for every “.c” file in the current directory; that process will call gcc on the .c file making a .o file.
c) When all the .c files are complete, one of two things must happen:
c1) If you are NOT in the directory that you started in (the topmost), you must create a “.a” file based on the name of the directory path that you are in. When the .a file is complete, it should be moved to the top level (i.e. the directory that you started in).
c2) If you are in the top level (the directory that you started in) you should launch the linker to link all of the .a files and all of the top-level .o files into a single executable.

There should be a limit of 4 compile processes running at a time.

So, for example, If I have a directory structure that looks like this:
MyProgram
|
+ library1
|
– lib1.c
– lib2.c
– lib3.c
|
+ library2
|
– file1.c
– file2.c
+ SomeOtherLibrary
|
somecode.c
– main.c
– helper.c

Your program would look for directories and find library1 and library2.
It would “go into” library1. It would find no subdirectories. It would launch 3 processes and create lib1.o, lib2.o, lib3.o. When all processes have completed, it would create library1.a from those three .o files. It would move the “.a” file into MyProgram.
It would then “go into” library2. It would find SomeOtherLibrary and “go into” that directory. Inside SomeOtherLibrary, it would launch a process to compile somecode.c. It would then create SomeOtherLibrary.a and move that up to MyProgram. Then it would complete the work on library2 – launching processes and compiling file1.c and file2.c into their respective .o files. It would then make “library2.a” and move that up to “MyProgram”.
Finally, with no directories left to work on, it would work on MyProgram. It would compile main.c and helper.c into .o files by launching processes, same as before. Finally, it would link the .o files and the .a files together into a single executable called MyProgram.
If any source file fails to compile, you can stop the whole process. You should capture the standard output from all processes and write it out into your standard output. GCC returns a status code of non-zero on failure.
Some information about static libraries can be found here: https://stackoverflow.com/questions/2734719/how-to-compile-a-static-library-in-linux
You must submit buildable C source code to get credit for this assignment.

Rubric
Poor
OK
Good
Great
Comments
None/Excessive (0)
“What” not “Why”, few (5)
Some “what” comments or missing some (7)
Anything not obvious has reasoning (10)
Variable/Function naming
Single letters everywhere (0)
Lots of abbreviations (5)
Full words most of the time (8)
Full words, descriptive (10)
Structure
Globals everywhere, indentation doesn’t match braces {}, no helper functions (0)

Indentation wrong
OR
Missing helper functions (7)
Indentation correct, helper functions(10)
Recurses Directories
None (0)
Attempts to walk directories (7)
Walks directories without recursion (13)
Recursively walks directories (20)
Creates Processes to Compile
None (0)
Compiles without processes (7)
Compiles with processes without limit (13)
Compiles with correctly limited processes (20)
Creates Shared Libraries
None (0)
Attempts to create shared libraries (7)
Creates shared libraries, doesn’t move them (13)
Creates shares library and moves them correctly (20)
Links result to executable
None (0)

Correctly links all components into an executable (10)