首页 > > 详细

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.
 
 
联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!