Compiling the test package

Hi
I quote this page of the Cookbook:
“Finally the test_pkg can be compiled, but only after we have successfully compiled everything it requires.”
There is some thing that confuses me here. As far as I can see, the test_pkg contents which is shown in the same link, actually either imports or includes everything it requires. So why is it that, as shown in the example makefile, we have to compile them separately, before compiling test_pkg itself? Can’t we just compile the test_pkg alone?
Thanks

In reply to Farhad:

SystemVerilog requires that packages be compiled before being referenced or imported. You could compile the test_pkg alone, but you would have to use some other mechanism to ensure that the other packages had already been compiled.

In reply to Farhad:

Hi
I quote this page of the Cookbook:
“Finally the test_pkg can be compiled, but only after we have successfully compiled everything it requires.”
There is some thing that confuses me here. As far as I can see, the test_pkg contents which is shown in the same link, actually either imports or includes everything it requires. So why is it that, as shown in the example makefile, we have to compile them separately, before compiling test_pkg itself? Can’t we just compile the test_pkg alone?
Thanks

In principal you can pack anything of your environment and sequences test in one package, compiling it in the right order. Afterwards you can import this packae into your UVM toplevel module. But thgis is not a good approach, because it does snot allow reuse.
A better approach is to pack all data relaveant for a specific agent or env into a package. In the test_pkg you are importing these packages and adding the global env and the test code to be compiled. Afterwards you can simply import this test_pkg in the toplevel module of your UVM environment.

In reply to dave_59:

Thank you very much, Dave. Considering together the answers given by you and chr_sue, I think my problem is solved. I just wish we could mark more than one answer as the solution. Because actually I got my answer from the combination of the two replies!