Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve artefact workflow #325

Merged
merged 255 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
255 commits
Select commit Hold shift + click to select a range
ce0890f
Introduced an ArtefactStore objects and getter in build_config.
hiker Mar 2, 2024
14a3483
Avoid circular import.
hiker Mar 2, 2024
1e16da4
Updated documentation.
hiker Mar 2, 2024
7d23ee7
Remove debut output.
hiker Mar 6, 2024
116e244
Added three standard artefacts with separate functions to files.
hiker Mar 6, 2024
c7dc9d3
hiker#5 Test warnings are either filtered or changed to be alerted wh…
Mar 11, 2024
34853c4
hiker#5, hiker#4: Renamed duplicated filenames in test subdirectories…
Mar 11, 2024
d0fb208
Merge pull request #6 from hiker/small_documentation_update
jasonjunweilyu Mar 12, 2024
14d0e59
Merge pull request #7 from hiker/278_absolute_paths_in_compilation
jasonjunweilyu Mar 12, 2024
7791733
hiker#4: Improved the test error fix to be easier to understand
Mar 12, 2024
63d2ddc
Merge pull request #9 from hiker/fix_test_error
hiker Mar 12, 2024
ea7b813
Removed absolute path patch, since this breaks a test.
hiker Mar 12, 2024
d4b5d8a
Fixed failing tests.
hiker Mar 12, 2024
b8a45c3
Resolve merge conflict with branch fix_test_error by incorporating bo…
Mar 13, 2024
ecbcfd4
Merge branch 'create_artefact_store' into add_standard_artefacts
hiker Mar 13, 2024
2268191
Fix styling problems reported by Flake8
Mar 13, 2024
2cfcb1a
Fix "_metric_send_conn not set, cannot send metrics" warning not issu…
Mar 13, 2024
e080c44
Merge pull request #10 from hiker/fix_test_warning
hiker Mar 14, 2024
ab9245c
Merge branch 'bom_master' into create_artefact_store
hiker Mar 14, 2024
6b290c2
Remove cosmetic change done to follow other coding standards.
hiker Mar 14, 2024
71e1b4a
Remove more cosmetic changes (which pylint required).
hiker Mar 14, 2024
ea16694
More removal of cosmetic changes, and some useless code.
hiker Mar 14, 2024
3160570
Add --links option to rsync.
hiker Mar 14, 2024
ed9da03
Merge branch 'bom_master' into 11_rsync_links
hiker Mar 14, 2024
e37b854
Merge remote-tracking branch 'upstream/master' into bom_master
hiker Mar 20, 2024
f3519e2
Extend Fortran analyser to detect use statements with an OpenMP senti…
hiker Mar 20, 2024
844586d
Use existing variable.
hiker Mar 20, 2024
2da2a4f
Merge remote-tracking branch 'upstream/master' into 11_rsync_links
hiker Mar 25, 2024
2a209ba
Merge remote-tracking branch 'upstream/master' into create_artefact_s…
hiker Mar 26, 2024
a8ef7a4
Remove unused glob import.
hiker Mar 26, 2024
ab3ac33
Removed unused glob import.
hiker Mar 26, 2024
380a210
Merge branch 'metomi/master' into bom_master after solving conflicts
Mar 26, 2024
9b9a510
Fixed typo picked up in review.
hiker Mar 26, 2024
0e4e65a
Merge pull request #8 from hiker/create_artefact_store
jasonjunweilyu Mar 27, 2024
3e27672
Merge pull request #12 from hiker/11_rsync_links
jasonjunweilyu Mar 27, 2024
6a55726
Merge remote-tracking branch 'origin/master' into 13_omp_sentinels
hiker Mar 27, 2024
12111d4
Merge branch 'master' into bom_master
Mar 27, 2024
4162c78
Merge remote-tracking branch 'upstream/master' into create_artefact_s…
hiker Mar 28, 2024
8877c49
Merge branch 'create_artefact_store' into add_standard_artefacts
hiker Mar 28, 2024
f9ed77e
Fixed failing tests.
hiker Mar 28, 2024
f22bbbf
Replaced _artefact_store with getter as much as possible.
hiker Mar 28, 2024
94a2970
Merge pull request #16 from hiker/create_artefact_store
jasonjunweilyu Mar 28, 2024
ea6c34c
Merge remote-tracking branch 'upstream/master' into create_artefact_s…
hiker Apr 12, 2024
119c613
#3 Introduce Tool, Compiler, and ToolRepository.
hiker Apr 15, 2024
840050e
#3 Made ToolRepository a singleton.
hiker Apr 15, 2024
5a22091
#3 Added ToolBox.
hiker Apr 15, 2024
d288c0e
#3 Added dedicated enum for categories.
hiker Apr 15, 2024
5fd2cfc
#3 Add the category to a tool.
hiker Apr 15, 2024
a5dd2af
#3 Use tool category when adding a tool to the tool box.
hiker Apr 15, 2024
b74055b
#3 Added preprocessor, and dictionary-like accesses to ToolBox.
hiker Apr 15, 2024
126b585
#3 Added tool_box as mandatory parameter for a BuildConfig.
hiker Apr 15, 2024
0bd9c31
#3 Start to use new compiler objects for Fortran compilation.
hiker Apr 16, 2024
c13476e
#3 Added tests for Compiler class.
hiker Apr 16, 2024
c980171
#3 Add specific C- and Fortran-compiler classes. Updated tests.
hiker Apr 16, 2024
1a7300d
#3 Fixed typing.
hiker Apr 16, 2024
36a6c05
#3 Moved function to remove into Flags object, added test file for Fl…
hiker Apr 16, 2024
44073c1
# Fixed tests to work with new Fortran compiler handling.
hiker Apr 17, 2024
2a5bc86
#3 Use for compiler variables if defined.
hiker Apr 17, 2024
6f1c18a
#3 Add is_available flag to tools, added types.
hiker Apr 17, 2024
5ab1d75
#3 Added cpp as Fortran preprocessor.
hiker Apr 17, 2024
622b748
#3 Removed unnecessary code.
hiker Apr 17, 2024
f2f73cd
#3 Properly ignore mypy warnings.
hiker Apr 17, 2024
09e93a2
Support ToolBox for preprocessing.
hiker Apr 17, 2024
51b02ec
#3 Add a specific 'preprocess' method to Preprocessor.
hiker Apr 17, 2024
f917c07
#3 Changed order in which compiler flags are used.
hiker Apr 19, 2024
7d8a057
Merge branch 'master' into create_artefact_store
MatthewHambley Apr 19, 2024
1d154d7
#3 Use toolbox in compile_c step.
hiker Apr 19, 2024
302d58b
#3 Added get_hash function to compiler.
hiker Apr 19, 2024
4068505
#3 Added conftest.py file (with a fixture to create a C-compiler).
hiker Apr 22, 2024
f24d939
#3 Introduce fixtures for Fortran compiler and tool_box.
hiker Apr 22, 2024
075ed40
#3 Remove explicit compiler information from MpCommonArgs (since it's…
hiker Apr 22, 2024
15fca77
Merge branch 'master' into bom_master
hiker Apr 22, 2024
d862762
Merge branch 'bom_master' of github.com:hiker/fab into bom_master
hiker Apr 22, 2024
880355a
Merge branch 'create_artefact_store' into add_standard_artefacts
hiker Apr 22, 2024
e999cd1
Merge branch 'master' into 3_better_compiler_support
hiker Apr 22, 2024
fdc402c
#3 Added linker as tool.
hiker Apr 23, 2024
b50b3df
#3 Added test for linking shared libraries.
hiker Apr 23, 2024
b3806f1
#3 Pass compiler flags to the linker if a compiler was specified.
hiker Apr 23, 2024
2cf63d3
#3 Remove unused function.
hiker Apr 23, 2024
2fffe56
#3 Removed more unused code.
hiker Apr 23, 2024
7a8c293
#3 Automatically add a linker for each compiler.
hiker Apr 24, 2024
555de52
#3 Fixed typo.
hiker Apr 24, 2024
abec46d
#3 Support vendor for compiler and linker.
hiker Apr 24, 2024
d4ad3f0
#3 Make linker having a vendor, too.
hiker Apr 24, 2024
a64c9b7
#3 Add set_default_vendor method to tool repository.
hiker Apr 24, 2024
8a8781d
Ignore build directory for git.
hiker Apr 29, 2024
d967f7f
Merge branch 'master' into add_standard_artefacts
hiker Apr 29, 2024
5472d7d
Updated test.
hiker Apr 29, 2024
4c2f0d8
Merge remote-tracking branch 'upstream/master' into 3_better_compiler…
hiker Apr 29, 2024
ccbe839
Merge remote-tracking branch 'upstream/master' into bom_master
hiker Apr 29, 2024
227a153
# Fix some mypy errors and warnings.
hiker Apr 29, 2024
b8c64b9
Avoid using get() for singleton, instead use __new__ which makes mypy…
hiker Apr 30, 2024
e309c15
Changed the transformation_script parameter of function psyclone to a…
Apr 30, 2024
31a4877
Make mypy happy by using patch.object.
hiker Apr 30, 2024
fbb15ea
Remove more comments and confusion about mypy :)
hiker Apr 30, 2024
7f52d40
Try to make mypy happy on older python versions.
hiker Apr 30, 2024
ca58d67
Make flake8 happy.
hiker Apr 30, 2024
c218bcd
Sort imported name alphabetically.
hiker Apr 30, 2024
e14d5b3
Try to fix failing hash test (and add some additional improvements in…
hiker Apr 30, 2024
0986b43
Removed fpath= for input transformation_script function to pass mypy …
Apr 30, 2024
2e15f19
Fix mypy typing check errors for psyclone unit test
Apr 30, 2024
1eeaa35
Fix config typing issue with mypy in psyclone unit test
Apr 30, 2024
a45d62b
Fix flake8 issues; Revert Config mypy typing fix
Apr 30, 2024
a4a9aab
Add comment to ignore typing check for fpath parameter of input trans…
Apr 30, 2024
5978e80
Fix assert check after transformation_script function is changed from…
Apr 30, 2024
e70885d
Filter out 'no transformation script' warning for psyclone system test
Apr 30, 2024
d2c6db0
Replace 'ignore' typing of fpath of transformation_script with removi…
Apr 30, 2024
a2ac207
#3 Support proper tests to check if tools are available.
hiker Apr 30, 2024
3a5e86a
1. Updated transformation_script description; 2. Modified mock_transf…
May 3, 2024
4ab3737
Updated lfric/atm.py and lfric/gungho.py examples to pass in transfor…
May 3, 2024
92545f8
Added description for the psyclone step to instructions on writing a …
May 3, 2024
f7cbf39
#3 Added git as a tool.
hiker May 6, 2024
632fa8c
#3 Fix incorrect | usage in typing.
hiker May 6, 2024
e0261c7
#3 Added unit tests for git.
hiker May 7, 2024
f6357a1
#3 Renamed git.py to versioning.py, to avoid name clash with the corr…
hiker May 7, 2024
042e8d8
#3 Converted svn and fcm to tools.
hiker May 8, 2024
87bce71
#3 Fixed missing whitespace.
hiker May 8, 2024
14e4f7c
Modified the documentation for writing a config with PSyclone
May 9, 2024
d38f020
Add config as a parameter for run_psyclone for the transformation_scr…
May 10, 2024
672bb9c
#3 Replaced ar with tool object.
hiker May 10, 2024
8987f99
#3 Added tests for ar.py.
hiker May 13, 2024
eee5043
#3 Removed debug output.
hiker May 13, 2024
f9fdbbb
#3 Converted PSyclone to be a tool.
hiker May 13, 2024
be36931
#3 Removed debug print, fixed python 3.7 typing information.
hiker May 13, 2024
8c790ce
#3 Updated comments.
hiker May 13, 2024
ade5f67
Modified the get_optimisation_script function examples and updated th…
May 13, 2024
15212ae
#3 Add Rsync tool.
hiker May 13, 2024
48c7543
#3 Removed now unused function.
hiker May 13, 2024
664c89c
#3 Added test for rsync.
hiker May 13, 2024
44756f7
#3 Fixed all mypy warnings about functions not checked.
hiker May 13, 2024
064ea35
#3 Replace all mock-tests to use subprocess so the name of the execut…
hiker May 13, 2024
22a1b91
#3 Remove duplicated flags.
hiker May 13, 2024
2e1b0a1
#3 Fixed changed order of linking.
hiker May 13, 2024
921daa8
#3 Removed run_command function.
hiker May 13, 2024
fc668cd
#3 Fixed 3.8 typing error.
hiker May 13, 2024
47a0a70
#3 Fixed unused imports.
hiker May 13, 2024
4389374
#3 Move flags checksum into Flags, and remove now unused tools.py file.
hiker May 14, 2024
3a015d2
#3 Renamed newtools to tools.
hiker May 14, 2024
202e274
#3 Made custom function for all git functions called (instead of just…
hiker May 14, 2024
3667030
#3 Updated and fixed comments.
hiker May 14, 2024
860d5a3
#3 Fixed errors in comments.
hiker May 14, 2024
25a1f58
Fixed minor errors in documentation.
hiker May 15, 2024
2562c22
Merge pull request #19 from hiker/18_optimisation_script
hiker May 15, 2024
72f7ab5
#3 Make it easier to create wrapper around standard compiler.
hiker May 15, 2024
53aeb62
#3 Added documentation for all tool related classes and their usage.
hiker May 15, 2024
8723a4e
#3 Added MISC category.
hiker May 21, 2024
358ae23
Addressed reviewer's comments.
hiker May 29, 2024
71e0b2f
Updated cli to properly use ToolBox etc, removing hard-coded gnu comm…
hiker May 29, 2024
b33b8b5
Merge remote-tracking branch 'origin/bom_master' into 3_better_compil…
hiker May 29, 2024
1109a88
Fixed mypy failures, including changes to import statement to avoid c…
hiker May 29, 2024
8e303f5
#3 Fix circular import.
hiker May 30, 2024
393f98a
Added #TODO so that this can be removed once fparser supports sentinels.
hiker Jun 2, 2024
2464e99
Fix typing problems by ignoring fparser.
hiker Jun 2, 2024
cce68e9
Merge pull request #21 from hiker/3_better_compiler_support
jasonjunweilyu Jun 3, 2024
8d9b5c5
Merge remote-tracking branch 'origin/bom_master' into 13_omp_sentinels
hiker Jun 3, 2024
572055a
Merge pull request #24 from hiker/13_omp_sentinels
jasonjunweilyu Jun 3, 2024
01558a2
Merge branch 'bom_master' into add_standard_artefacts
hiker Jun 3, 2024
4d85e70
Replaced more string names for artefacts with enums.
hiker Jun 4, 2024
10067a1
Removed EXECUTABLES from constants.
hiker Jun 4, 2024
137eb84
Moved Artefact class out of ArtefactStore and renamed it to ArtefactSet.
hiker Jun 4, 2024
b95611f
Moved OBJECT_FILES from constants into ArtefactSet.
hiker Jun 4, 2024
5f6625c
Moved OBJECT_ARCHIVES from constants to ArtefactSet.
hiker Jun 4, 2024
3d58184
Moved PRAGMAD_C from constants to ArtefactSet.
hiker Jun 4, 2024
f2942b1
Turned 'all_source' into an enum.
hiker Jun 4, 2024
d005c47
Allow integer as revision.
hiker Jun 4, 2024
73f91d4
Fixed flake8 error.
hiker Jun 4, 2024
6d5e82e
Removed specific functions to add/get fortran source files etc.
hiker Jun 5, 2024
37f7adc
Removed non-existing and unneccessary collections.
hiker Jun 5, 2024
ac93579
Try to fix all run_configs.
hiker Jun 4, 2024
2f633b9
Fixed rebase issues.
hiker Jun 6, 2024
03c6076
Added replace functionality to ArtefactStore, updated test_artefacts …
hiker Jun 6, 2024
499c9b5
Started to replace artefacts when files are pre-processed.
hiker Jun 6, 2024
7570696
Removed linker argument from linking step in all examples.
hiker Jun 7, 2024
41d9273
Try to get jules to link.
hiker Jun 7, 2024
56f001a
Fixed build_jules.
hiker Jun 7, 2024
8fb2be1
Fixed other issues raised in reviews.
hiker Jun 7, 2024
71cd141
Merge pull request #26 from hiker/3_better_compiler_support
jasonjunweilyu Jun 7, 2024
5b959c3
Merge branch '3_better_compiler_support' into add_standard_artefacts
hiker Jun 7, 2024
0f6c1a5
Try to get jules to link.
hiker Jun 7, 2024
588f647
Fixed other issues raised in reviews.
hiker Jun 7, 2024
cd81ce3
Merge branch 'bom_master' into add_standard_artefacts
hiker Jun 7, 2024
e857c94
Simplify handling of X90 files by replacing the X90 with x90, meaning…
hiker Jun 7, 2024
e024824
Make OBJECT_ARCHIVES also a dict, migrate more code to replace/add fi…
hiker Jun 11, 2024
a1346cf
Merge branch '3_better_compiler_support' into improve_artefact_workflow
hiker Jun 11, 2024
a0c2b98
Fixed some examples.
hiker Jun 11, 2024
169ff69
Merge branch 'master' into 3_better_compiler_support
hiker Jun 11, 2024
a34febc
Fix flake8 error.
hiker Jun 11, 2024
df893d6
Fixed failing tests.
hiker Jun 11, 2024
a2a8a54
Support empty comments.
hiker Jun 11, 2024
f03bc37
Fix preprocessor to not unnecessary remove and add files that are alr…
hiker Jun 12, 2024
7632775
Allow find_soure_files to be called more than once by adding files (n…
hiker Jun 12, 2024
e73179f
Updated lfric_common so that files created by configurator are writte…
hiker Jun 12, 2024
f7919ce
Use c_build_files instead of pragmad_c.
hiker Jun 12, 2024
50f4a42
Removed unnecessary str.
hiker Jun 12, 2024
36fa57b
Documented the new artefact set handling.
hiker Jun 13, 2024
77b2b97
Fixed typo.
hiker Jun 13, 2024
5c895ba
Fixed formatting of documentation, properly used ArtefactSet names.
hiker Jun 13, 2024
f0e660d
Removed setter for tool.is_available, which was only used for testing.
hiker Jun 17, 2024
9f1ffc3
#3 Fix documentation and coding style issues from review.
hiker Jun 17, 2024
a0531a2
Renamed Categories into Category.
hiker Jun 17, 2024
4ff887c
Minor coding style cleanup.
hiker Jun 17, 2024
8a3b02d
Removed more unnecessary ().
hiker Jun 17, 2024
10ae159
Re-added (invalid) grab_pre_build call.
hiker Jun 17, 2024
622d0bd
Fixed typo.
hiker Jun 17, 2024
3f48703
Renamed set_default_vendor to set_default_compiler_suite.
hiker Jun 18, 2024
ba9245d
Renamed VendorTool to CompilerSuiteTool.
hiker Jun 18, 2024
f8c4418
Also accept a Path as exec_name specification for a tool.
hiker Jun 18, 2024
6a7aef8
Move the check_available function into the base class.
hiker Jun 18, 2024
0b73089
Fixed some types and documentation.
hiker Jun 18, 2024
7796246
Fix typing error.
hiker Jun 18, 2024
412a136
Added explanation for meta-compiler.
hiker Jun 18, 2024
8ec2227
Improved error handling and documentation.
hiker Jun 18, 2024
6d1a1ee
Replace mpiifort with mpifort to be a tiny bit more portable.
hiker Jun 18, 2024
8d4c66f
Use classes to group tests for git/svn/fcm together.
hiker Jun 18, 2024
46bc4ef
Fixed issue in get_transformation script, and moved script into lfric…
hiker Jun 18, 2024
ffdfd1a
Merge remote-tracking branch 'upstream/master' into 3_better_compiler…
hiker Jun 18, 2024
4f436f3
Code improvement as suggested by review.
hiker Jun 19, 2024
52d5751
Fixed run config
hiker Jun 19, 2024
562d56f
Merge branch 'add_standard_artefacts' into improve_artefact_workflow
hiker Jun 20, 2024
ca7e477
Merge pull request #28 from hiker/add_standard_artefacts
jasonjunweilyu Jun 20, 2024
516ec34
Added reference to ticket.
hiker Jun 20, 2024
c17545a
Merge branch 'bom_master' into improve_artefact_workflow
hiker Jun 20, 2024
ee2fc85
Updated type information.
hiker Jun 20, 2024
5912e59
More typing fixes.
hiker Jun 20, 2024
83ba6a1
Fixed typing warnings.
hiker Jun 21, 2024
7e66eca
As requested by reviewer removed is_working_copy functionality.
hiker Jun 21, 2024
ddd3cf2
Issue a warning (which can be silenced) when a tool in a toolbox is r…
hiker Jun 21, 2024
68bc218
Fixed flake8.
hiker Jun 21, 2024
2bdcb8c
Merge remote-tracking branch 'upstream/master' into 3_better_compiler…
hiker Jun 21, 2024
c02729c
Fixed flake8.
hiker Jun 21, 2024
a29be95
Merge remote-tracking branch 'upstream/master' into 3_better_compiler…
hiker Jun 21, 2024
03bed8e
Merge branch 'master' into 3_better_compiler_support
hiker Jun 24, 2024
9ccdefd
Merge branch '3_better_compiler_support' into bom_master
hiker Jun 24, 2024
00fa8b2
Merge branch '3_better_compiler_support' into improve_artefact_workflow
hiker Jun 24, 2024
c21d34f
Merge branch '3_better_compiler_support' into add_standard_artefacts
hiker Jun 24, 2024
d8fe42b
Merge branch 'add_standard_artefacts' into improve_artefact_workflow
hiker Jun 24, 2024
2f069c8
Merge branch 'bom_master' into add_standard_artefacts
hiker Jun 24, 2024
9abfc1d
Merge branch 'add_standard_artefacts' into improve_artefact_workflow
hiker Jun 24, 2024
87b8012
Addressed issues raised in review.
hiker Jun 24, 2024
523e876
Removed now unnecessary operations.
hiker Jun 24, 2024
538e4da
Updated some type information.
hiker Jun 24, 2024
90e3795
Extend Fortran analyser to detect use statements with an OpenMP senti…
hiker Mar 20, 2024
054921d
Use existing variable.
hiker Mar 20, 2024
2aa6d30
Added #TODO so that this can be removed once fparser supports sentinels.
hiker Jun 2, 2024
9843e77
Fix typing problems by ignoring fparser.
hiker Jun 2, 2024
7bb451f
Added more tests for directives that should be ignored, cleaned up so…
hiker Jul 17, 2024
4d41847
Merge branch '297_omp_sentinels' into improve_artefact_workflow
hiker Jul 18, 2024
284d854
Merge remote-tracking branch 'upstream/master' into improve_artefact_…
hiker Jul 19, 2024
d91969e
Renamed ALL_SOURCE to INITIAL_SOURCE.
hiker Jul 23, 2024
b57a237
Addressed other documentation issues raised in review.
hiker Jul 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Documentation/source/advanced_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ in particular where it creates files within it.
*.o (compiled object files)
*.mod (mod files)
metrics/
my_program.exe
my_program
log.txt

The *project workspace* folder takes its name from the project label passed in to the build configuration.
Expand Down
4 changes: 2 additions & 2 deletions Documentation/source/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Glossary
Fab's built-in steps come with sensible defaults so the user doesn't have to write unnecessary config.

As an example, the Fortran preprocessor has a default artefact getter which reads *".F90"* files
from the :term:`Artefact Collection` called ``"all_source"``.
from the :term:`Artefact Collection` called ``"INITIAL_SOURCE"``.

Artefact getters are derived from :class:`~fab.artefacts.ArtefactsGetter`.

Expand Down Expand Up @@ -65,7 +65,7 @@ Glossary
A folder inside the :term:`Fab Workspace`, containing all source and output from a build config.

Root Symbol
The name of a Fortran PROGRAM, or ``"main"`` for C code. Fab builds an exe for every root symbol it's given.
The name of a Fortran PROGRAM, or ``"main"`` for C code. Fab builds an executable for every root symbol it's given.

Source Tree
The :class:`~fab.steps.analyse.analyse` step produces a dependency tree of the entire project source.
Expand Down
54 changes: 44 additions & 10 deletions Documentation/source/writing_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Please see the documentation for :func:`~fab.steps.find_source_files.find_source
including how to exclude certain source code from the build. More grab steps can be found in the :mod:`~fab.steps.grab`
module.

After the find_source_files step, there will be a collection called ``"all_source"``, in the artefact store.
After the find_source_files step, there will be a collection called ``"INITIAL_SOURCE"``, in the artefact store.

.. [1] See :func:`~fab.steps.c_pragma_injector.c_pragma_injector` for an example of a step which
creates artefacts in the source folder.
Expand All @@ -94,7 +94,7 @@ which must happen before we analyse it.

Steps generally create and find artefacts in the :term:`Artefact Store`, arranged into named collections.
The :func:`~fab.steps.preprocess.preprocess_fortran`
automatically looks for Fortran source code in a collection named `'all_source'`,
automatically looks for Fortran source code in a collection named `'INITIAL_SOURCE'`,
which is the default output from the preceding :funcfind_source_files step.
It filters just the (uppercase) ``.F90`` files.

Expand Down Expand Up @@ -179,7 +179,7 @@ before you run the :func:`~fab.steps.analyse.analyse` step below.


After the psyclone step, two new source files will be created for each .x90 file in the `'build_output'` folder.
These two output files will be added under ``"psyclone_output"`` collection to the artefact store.
These two output files will be added under ``FORTRAN_BUILD_FILES`` collection to the artefact store.
hiker marked this conversation as resolved.
Show resolved Hide resolved


.. _Analyse Overview:
Expand All @@ -190,11 +190,10 @@ Analyse
We must :func:`~fab.steps.analyse.analyse` the source code to determine which
Fortran files to compile, and in which order.

The Analyse step looks for source to analyse in several collections:
The Analyse step looks for source to analyse in two collections:

* ``.f90`` found in the source
* ``.F90`` we pre-processed into ``.f90``
* preprocessed c
* ``FORTRAN_BUILD_FILES``, which contains all ``.f90`` found in the source, all ``.F90`` files we pre-processed into ``.f90``, and files created by any additional step (e.g. PSyclone).
hiker marked this conversation as resolved.
Show resolved Hide resolved
* ``C_BUILD_FILES``, all preprocessed c files.

.. code-block::
:linenos:
Expand Down Expand Up @@ -227,14 +226,14 @@ The Analyse step looks for source to analyse in several collections:
Here we tell the analyser which :term:`Root Symbol` we want to build into an executable.
Alternatively, we can use the ``find_programs`` flag for Fab to discover and build all programs.

After the Analyse step, there will be a collection called ``"build_trees"``, in the artefact store.
After the Analyse step, there will be a collection called ``BUILD_TREES``, in the artefact store.
hiker marked this conversation as resolved.
Show resolved Hide resolved


Compile and Link
================

The :func:`~fab.steps.compile_fortran.compile_fortran` step compiles files in
the ``"build_trees"`` collection. The :func:`~fab.steps.link.link_exe` step
the ``BUILD_TREES`` collection. The :func:`~fab.steps.link.link_exe` step
then creates the executable.

.. code-block::
Expand Down Expand Up @@ -269,7 +268,42 @@ then creates the executable.
link_exe(state)


After the :func:`~fab.steps.link.link_exe` step, the executable name can be found in a collection called ``"executables"``.
After the :func:`~fab.steps.link.link_exe` step, the executable name can be found in a collection called ``EXECUTABLES``.

ArtefactStore
=============
Each build configuration contains an artefact store, containing various
sets of artefacts. The artefact sets used by Fab are defined in the
enum :class:`~fab.artefacts.ArtefactSet`. The most important sets are ``FORTRAN_BUILD_FILES``,
``C_BUILD_FILES``, which will always contain all known source files that
will need to be analysed for dependencies, compiled, and linked. All existing
steps in Fab will make sure to maintain these artefact sets consistently,
for example, if a ``.F90`` file is preprocessed, the ``.F90`` file in
MatthewHambley marked this conversation as resolved.
Show resolved Hide resolved
``FORTRAN_BUILD_FILES`` will be replaced with the corresponding preprocessed
``.f90`` file. Similarly, new files (for examples created by PSyclone)
will be added to ``FORTRAN_BUILD_FILES``. A user script can adds its own
artefacts using strings as keys if required.

The exact flow of artefact sets is as follows. Note that any artefact
sets mentioned here can typically be overwritten by the user, but then
it is the user's responsibility to maintain the default artefact sets
(or change them all):

..
My apologies for the LONG lines, they were the only way I could find
to have properly indented paragraphs :(

1. :func:`~fab.steps.find_source_files.find_source_files` will add all source files it finds to ``INITIAL_SOURCE`` (by default, can be overwritten by the user). Any ``.F90`` and ``.f90`` file will also be added to ``FORTRAN_BUILD_FILES``, any ``.c`` file to ``C_BUILD_FILES``, and any ``.x90`` or ``.X90`` file to ``X90_BUILD_FILES``. It can be called several times if files from different root directories need to be added, and it will automatically update the ``*_BUILD_FILES`` sets.
2. Any user script that creates new files can add files to ``INITIAL_SOURCE`` if required, but also to the corresponding ``*_BUILD_FILES``. This will happen automatically if :func:`~fab.steps.find_source_files.find_source_files` is called to add these newly created files.
3. If :func:`~fab.steps.c_pragma_injector.c_pragma_injector` is being called, it will handle all files in ``C_BUILD_FILES``, and will replace all the original C files with the newly created ones. For backward compatibility it will also store the new objects in the ``PRAGMAD_C`` set.
hiker marked this conversation as resolved.
Show resolved Hide resolved
4. If :func:`~fab.steps.preprocess.preprocess_c` is called, it will preprocess all files in ``C_BUILD_FILES`` (at this stage typically preprocess the files in the original source folder, writing the output files to the build folder), and update that artefact set accordingly. For backward compatibility it will also store the preprocessed files in ``PREPROCESSED_C``.
5. If :func:`~fab.steps.preprocess.preprocess_fortran` is called, it will preprocess all files in ``FORTRAN_BUILD_FILES`` that end on ``.F90``, creating new ``.f90`` files in the build folder. These files will be added to ``PREPROCESSED_FORTRAN``. Then the original ``.F90`` are removed from ``FORTRAN_BUILD_FILES``, and the new preprocessed files (which are in ``PREPROCESSED_FORTRAN``) will be added. Then any ``.f90`` files that are not already in the build folder (an example of this are files created by a user script) are copied from the original source folder into the build folder, and ``FORTRAN_BUILD_FILES`` is updated to use the files in the new location.
6. If :func:`~fab.steps.psyclone.preprocess_x90` is called, it will similarly preprocess all ``.X90`` files in ``X90_BUILD_FILES``, creating the output files in the build folder, and replacing the files in ``X90_BUILD_FILES``.
7. If :func:`~fab.steps.psyclone.psyclone` is called, it will process all files in ``X90_BUILD_FILES`` and add any newly created file to ``FORTRAN_BUILD_FILES``, and removing them from ``X90_BUILD_FILES``.
8. The :func:`~fab.steps.analyse.analyse` step analyses all files in ``FORTRAN_BUILD_FILES`` and ``C_BUILD_FILES``, and add all dependencies to ``BUILD_TREES``.
9. The :func:`~fab.steps.compile_c.compile_c` and :func:`~fab.steps.compile_fortran.compile_fortran` steps will compile all files from ``C_BUILD_FILES`` and ``FORTRAN_BUILD_FILES``, and add them to ``OBJECT_FILES``.
10. If :func:`~fab.steps.archive_objects.archive_objects` is called, it will create libraries based on ``OBJECT_FILES``, adding the libraries to ``OBJECT_ARCHIVES``.
11. If :func:`~fab.steps.link.link_exe` is called, it will either use ``OBJECT_ARCHIVES``, or if this is empty, use ``OBJECT_FILES``, create the binaries, and add them to ``EXECUTABLES``.
hiker marked this conversation as resolved.
Show resolved Hide resolved


Flags
Expand Down
27 changes: 6 additions & 21 deletions run_configs/lfric/atm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env python3

'''Example LFRic_atm build script.
'''

import logging

from fab.build_config import BuildConfig, AddFlags
Expand All @@ -16,7 +20,8 @@
from fab.tools import ToolBox

from grab_lfric import lfric_source_config, gpl_utils_source_config
from lfric_common import configurator, fparser_workaround_stop_concatenation
from lfric_common import (configurator, fparser_workaround_stop_concatenation,
get_transformation_script)

logger = logging.getLogger('fab')

Expand Down Expand Up @@ -162,26 +167,6 @@ def file_filtering(config):
]


def get_transformation_script(fpath, config):
''':returns: the transformation script to be used by PSyclone.
:rtype: Path

'''
optimisation_path = config.source_root / 'optimisation' / 'meto-spice'
for base_path in [config.source_root, config.build_output]:
try:
relative_path = fpath.relative_to(base_path)
except ValueError:
pass
local_transformation_script = optimisation_path / (relative_path.with_suffix('.py'))
if local_transformation_script.exists():
return local_transformation_script
global_transformation_script = optimisation_path / 'global.py'
if global_transformation_script.exists():
return global_transformation_script
return ""


if __name__ == '__main__':
lfric_source = lfric_source_config.source_root / 'lfric'
gpl_utils_source = gpl_utils_source_config.source_root / 'gpl_utils'
Expand Down
27 changes: 6 additions & 21 deletions run_configs/lfric/gungho.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
# For further details please refer to the file COPYRIGHT
# which you should have received as part of this distribution
# ##############################################################################
'''
A simple build script for gungho_model
'''

import logging

from fab.build_config import BuildConfig
Expand All @@ -18,31 +22,12 @@
from fab.tools import ToolBox

from grab_lfric import lfric_source_config, gpl_utils_source_config
from lfric_common import configurator, fparser_workaround_stop_concatenation
from lfric_common import (configurator, fparser_workaround_stop_concatenation,
get_transformation_script)

logger = logging.getLogger('fab')


def get_transformation_script(fpath, config):
''':returns: the transformation script to be used by PSyclone.
:rtype: Path

'''
optimisation_path = config.source_root / 'optimisation' / 'meto-spice'
for base_path in [config.source_root, config.build_output]:
try:
relative_path = fpath.relative_to(base_path)
except ValueError:
pass
local_transformation_script = optimisation_path / (relative_path.with_suffix('.py'))
if local_transformation_script.exists():
return local_transformation_script
global_transformation_script = optimisation_path / 'global.py'
if global_transformation_script.exists():
return global_transformation_script
return ""


if __name__ == '__main__':
lfric_source = lfric_source_config.source_root / 'lfric'
gpl_utils_source = gpl_utils_source_config.source_root / 'gpl_utils'
Expand Down
94 changes: 66 additions & 28 deletions run_configs/lfric/lfric_common.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import logging
import os
import shutil
from typing import Optional
from pathlib import Path

from fab.artefacts import ArtefactSet
from fab.build_config import BuildConfig
from fab.steps import step
from fab.steps.find_source_files import find_source_files
from fab.tools import Category, Tool

logger = logging.getLogger('fab')
Expand All @@ -21,79 +25,113 @@ def check_available(self):
return True


# todo: is this part of psyclone? if so, put it in the psyclone step module?
hiker marked this conversation as resolved.
Show resolved Hide resolved
# ============================================================================
@step
def configurator(config, lfric_source: Path, gpl_utils_source: Path, rose_meta_conf: Path, config_dir=None):

rose_picker_tool = gpl_utils_source / 'rose_picker/rose_picker'
gen_namelist_tool = lfric_source / 'infrastructure/build/tools/GenerateNamelist'
gen_loader_tool = lfric_source / 'infrastructure/build/tools/GenerateLoader'
gen_feigns_tool = lfric_source / 'infrastructure/build/tools/GenerateFeigns'

config_dir = config_dir or config.source_root / 'configuration'
config_dir.mkdir(parents=True, exist_ok=True)

env = os.environ.copy()
rose_lfric_path = gpl_utils_source / 'lib/python'
env['PYTHONPATH'] += f':{rose_lfric_path}'

# "rose picker"
# creates rose-meta.json and config_namelists.txt in gungho/source/configuration
# rose picker
# -----------
# creates rose-meta.json and config_namelists.txt in
# gungho/build
logger.info('rose_picker')
rose_picker = Script(rose_picker_tool)
rose_picker.run(additional_parameters=[str(rose_meta_conf),
'-directory', str(config_dir),
rose_picker.run(additional_parameters=[rose_meta_conf,
'-directory', config_dir,
'-include_dirs', lfric_source],
env=env)
rose_meta = config_dir / 'rose-meta.json'

# "build_config_loaders"
# build_config_loaders
# --------------------
# builds a bunch of f90s from the json
logger.info('GenerateNamelist')
gen_namelist = Script(gen_namelist_tool)
gen_namelist.run(additional_parameters=['-verbose',
str(config_dir / 'rose-meta.json'),
'-directory', str(config_dir)])
gen_namelist.run(additional_parameters=['-verbose', rose_meta,
'-directory', config_dir],
cwd=config_dir)

# create configuration_mod.f90 in source root
# -------------------------------------------
logger.info('GenerateLoader')
names = [name.strip() for name in
open(config_dir / 'config_namelists.txt').readlines()]
configuration_mod_fpath = config_dir / 'configuration_mod.f90'
gen_loader = Script(gen_loader_tool)
names = [name.strip() for name in open(config_dir / 'config_namelists.txt').readlines()]
configuration_mod_fpath = config.source_root / 'configuration_mod.f90'
gen_loader.run(additional_parameters=[configuration_mod_fpath,
*names])

# create feign_config_mod.f90 in source root
# ------------------------------------------
logger.info('GenerateFeigns')
feign_config = Script(gen_feigns_tool)
feign_config_mod_fpath = config.source_root / 'feign_config_mod.f90'
feign_config.run(additional_parameters=[str(config_dir / 'rose-meta.json'),
'-output', feign_config_mod_fpath])
feign_config_mod_fpath = config_dir / 'feign_config_mod.f90'
gft = Script(gen_feigns_tool)
gft.run(additional_parameters=[rose_meta,
'-output', feign_config_mod_fpath])

# put the generated source into an artefact
# todo: we shouldn't need to do this, should we?
# it's just going to be found in the source folder with everything else.
config._artefact_store['configurator_output'] = [
configuration_mod_fpath,
feign_config_mod_fpath
]
find_source_files(config, source_root=config_dir)


# ============================================================================
@step
def fparser_workaround_stop_concatenation(config):
"""
fparser can't handle string concat in a stop statement. This step is a workaround.
fparser can't handle string concat in a stop statement. This step is
a workaround.
hiker marked this conversation as resolved.
Show resolved Hide resolved

https://github.com/stfc/fparser/issues/330

"""
feign_config_mod_fpath = config.source_root / 'feign_config_mod.f90'
feign_path = None
for file_path in config.artefact_store[ArtefactSet.FORTRAN_BUILD_FILES]:
if file_path.name == 'feign_config_mod.f90':
feign_path = file_path
break
else:
raise RuntimeError("Could not find 'feign_config_mod.f90'.")

# rename "broken" version
broken_version = feign_config_mod_fpath.with_suffix('.broken')
shutil.move(feign_config_mod_fpath, broken_version)
broken_version = feign_path.with_suffix('.broken')
shutil.move(feign_path, broken_version)

# make fixed version
bad = "_config: '// &\n 'Unable to close temporary file'"
good = "_config: Unable to close temporary file'"

open(feign_config_mod_fpath, 'wt').write(
open(feign_path, 'wt').write(
open(broken_version, 'rt').read().replace(bad, good))


# ============================================================================
def get_transformation_script(fpath: Path,
config: BuildConfig) -> Optional[Path]:
''':returns: the transformation script to be used by PSyclone.
'''

optimisation_path = config.source_root / 'optimisation' / 'meto-spice'
relative_path = None
for base_path in [config.source_root, config.build_output]:
try:
relative_path = fpath.relative_to(base_path)
except ValueError:
pass
if relative_path:
local_transformation_script = (optimisation_path /
(relative_path.with_suffix('.py')))
if local_transformation_script.exists():
return local_transformation_script

global_transformation_script = optimisation_path / 'global.py'
if global_transformation_script.exists():
return global_transformation_script
return None
5 changes: 2 additions & 3 deletions run_configs/um/build_um.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
import re
import warnings

from fab.artefacts import CollectionGetter
from fab.artefacts import ArtefactSet, CollectionGetter
from fab.build_config import AddFlags, BuildConfig
from fab.constants import PRAGMAD_C
from fab.steps import step
from fab.steps.analyse import analyse
from fab.steps.archive_objects import archive_objects
Expand Down Expand Up @@ -177,7 +176,7 @@ def replace_in_file(inpath, outpath, find, replace):

preprocess_c(
state,
source=CollectionGetter(PRAGMAD_C),
source=CollectionGetter(ArtefactSet.C_BUILD_FILES),
path_flags=[
# todo: this is a bit "codey" - can we safely give longer strings and split later?
AddFlags(match="$source/um/*", flags=[
Expand Down
Loading