-
Notifications
You must be signed in to change notification settings - Fork 868
CMake Build #1896
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
Merged
Merged
CMake Build #1896
Changes from 96 commits
Commits
Show all changes
185 commits
Select commit
Hold shift + click to select a range
8f5bc53
Modifying #ifdef structure for cmake syntax
islas 4cee02d
Modifying #ifdef structure for cmake syntax
islas ae7e647
Ignoring _build directory
islas a7ce282
Adding some helper cmake modules
islas 2dd8305
Fairly confident this was a bug
islas a254e82
Adding nonzero macro check for function returns rather than failing s…
islas ed596dd
Current state of cmake build
islas 5977e85
Rename to reflect c preprocessing
islas 2fed911
Making registry work in out of source build
islas f8f35b3
Splitting out helper macro for definition expansion
islas b62817b
Simplifying #if[n]defs
islas 4fa4b99
Adding missing &
islas 713cc58
Making registry runner take known defs
islas 29df3b5
Adding folders to build
islas 7ecc386
Preprocessing into f90
islas 65e54fa
Various helper or missing modules
islas 3bd942c
Runner for configure checks
islas c2442cf
Noting how it might eventually be done
islas 808b126
I believe this was a bug, no idea how it was even working before
islas 888a68c
Compiling the rest of grib2 io
islas b8612c6
Switching io_int/intio tags to #defines
islas 3c755bd
Adjusting for new ioint tags
islas bd029ae
Compiling io_int
islas 60b47ea
No longer needed with set policy, might need to reinstate for older v…
islas f4c77a6
Outputting nl_* routines as f90, and processing md_calls with m4
islas 326b799
Adding many missing defines, linking and option selections
islas 8ebc808
Adjusting regex to handle generator expressions better
islas e99b7e7
Output options selected
islas 7373479
Closing the gap in differences between make and cmake builds
islas cd18dcf
Removing redundant files
islas 23b5f9b
Updating [p]netCDF find capabilities
islas b452ed5
Adding main to compilation
islas 34c5e44
New cmake modules to help ease building
islas c4e92b9
Script to facilitate cleaning cmake build
islas a81ae42
Removing dead comments
islas b2ce015
Reworking external/ build
islas a70da4c
Fully compiling
islas 06b3d22
Adding install rules for em_real
islas 09ee8e9
Adding runtime generated files to ignore list
islas e923a63
Adding libdir and prefix to created variables
islas 0971f3c
Building pnetcdf io lib and re-enabling macro
islas dcbda56
Adding in source file swap for MPI comms using RSL LITE
islas 074f514
Compilation scheme using arch/configure.defaults now working
islas 577bddb
Fixing syntax for generator expression
islas 33c7e80
Removing lingering unprotected link library
islas 9c0979e
Cleaning up
islas c59908c
Adding double fp64 link data
islas 588fa40
Symlinks for all test cases except for esmf coupling
islas a271b3f
Adding cmake package config template
islas b5b0c8c
Grabbing version from README
islas 6859ab3
Better message output
islas be1f37d
Fixing link installs
islas 7401b96
Adding externals to export targets
islas b4cc8e5
Clean up and setting install files
islas c4cc7a6
Clean up
islas d0d4963
Setting up export namespace and cmake package
islas b32d0e4
Fixing indentation
islas a1c598b
Cleaning up cmake modules
islas 91b28cd
Adding key sanitization and option string output
islas c66b531
Reinstating old c preproc then m4 processing since gfortran is unable to
islas c95e94d
Make Jasper optional for grib2
islas f2ede49
Add flags specific for GNU builds
islas be71c8e
Adding share files
islas 5c3a283
Removing double WRF
islas 472246e
Switching to official toolchain *_INIT options
islas 5cbdbce
Minor fixes to build commands
islas 505d53b
This probably follows original cmake finding order but to be safe reo…
islas 05ec5e8
Fixing symlink creation for second passes
islas 33f5c30
Final touches to linking and include files
islas 1609176
Adding base includes to install
islas d74021d
Setting message out to smaller names
islas 5eab6f1
Removing old prefix
islas 52e8d4c
Resurrecting nl_set/get routines to maintain old makefile system
islas db73d7f
Removing these to reinstate the old stubs to support makefile build
islas cad26c6
Adjusting include paths for removal of redundant code
islas cb108d8
Using original stub file names
islas 73bc589
Adding check for large file support
islas cf4ecaa
Typo in adding definitions
islas ad0620d
Sanitizing in situ code compile/run checks
islas 8dedc47
Adding proper logic for large file support and nc4 features
islas 22fe732
Removing or commenting obsolete code
islas 632130e
Merge branch 'develop' of https://github.com/wrf-model/WRF into cmake…
islas 633c6c7
Fixing variable typo
islas 1907754
Exporting module directory and adding that to include path for WRF_Core
islas eaa9f4d
Don't make cxx lib required for netcdf
islas 8849b86
Don't use RSL_LITE if no MPI
islas 478cea3
Using a more shell-agnostic redirection
islas f5617fb
Only linking to RSL_LITE if available
islas 0c03b43
Using a separate module folder for each exec to not conflict on paral…
islas 1f0aa9f
Adding correct settings for nesting without MPI enabled
islas a893f52
Accounting for config-set variables
islas 9a89eeb
Allow selection of suboptions procedurally
islas 38dde8d
Proper creation of WRF target
islas 42ff2ba
Logic and fixes to allow for double precision compilation
islas 2d1cefa
Rolling back to older cmake process to allow version checking to work
islas 4aea7ee
Version check for GNU flags
islas 091b2fe
Modifying #ifdef structure for cmake syntax
islas 82ed6c1
Modifying #ifdef structure for cmake syntax
islas 8f252f8
Ignoring _build directory
islas a6676c4
Fairly confident this was a bug
islas 6497be3
Adding nonzero macro check for function returns rather than failing s…
islas 3998795
Making registry work in out of source build
islas 3eb5cb6
Simplifying #if[n]defs
islas af7f3a4
Adding missing &
islas f2b882a
I believe this was a bug, no idea how it was even working before
islas d541360
Switching io_int/intio tags to #defines
islas db27276
Adjusting for new ioint tags
islas 5a9d615
Removing redundant files
islas 051e229
Reworking external/ build
islas 96c9353
Adding runtime generated files to ignore list
islas 5539455
Building pnetcdf io lib and re-enabling macro
islas 7ff2f7e
Reinstating old c preproc then m4 processing since gfortran is unable to
islas 0396669
Adjusting include paths for removal of redundant code
islas 9a76186
Logic and fixes to allow for double precision compilation
islas 5eaa938
Remove all references to idx tags autogen file
islas d102f6d
Removing dimspec check since some configurations fail silently
islas 5c5a106
Better logic for presenting configurations
islas e44fab2
Making sure to cd back
islas 547bac1
Aligning with WPS configure_reader.py
islas b85a5e1
Synchronizing separated commits from build cleanup
islas 864b6a9
Fix bug where string compare fails when values not defined
islas 177d95b
Allow stanza selection and direct option pass-through without user pr…
islas ad11946
Changing visibility of linked omp lib as that can cause netcdf linked…
islas 7341c8e
Print build type
islas 4d82c75
Setting preproc macros to suppress further automatic processing to av…
islas 73f71f5
Find omp/mpi if finding wrf and was built with said options
islas d453c43
Applying m4 flags
islas 558d9d1
Using cpp instead of fortran compiler for more standardized flag usage
islas 8c64748
sh compliant
islas bc3a808
Remove non-existent fortran module dirs
islas 5079720
Fixing fseek tests
islas a4c5cce
Fixing bad syntax
islas 8e19a34
IPO control and per-file optimization set
islas df258c2
Wrapping build type in quotes for when not set
islas 2b8dc1b
Fixing missing symbols due to MPI wrapper forcing IPO usage even when…
islas 9d473f0
Finally deducing the true nature of nesting logic requiring stubbed m…
islas 0439324
Allow control of build and install directories
islas 2958e9c
Split netCDF and netCDF-Fortran finding into two separate modules
islas 59fad14
Adjust to split netCDF packages
islas ba79d5f
Adding library path to package finds to allow rpath automated generat…
islas f65b612
Full support for out-of-source build and installs
islas 73e17f2
Setup em_real to do out-of-source install
islas bcd8bde
Setup ideal cases to do out-of-source installs
islas bf1f546
First draft of ideal tests for cmake
islas 2437541
Compilation of multiple tests at the same time for cmake now works
islas 95acd4d
Fix builds to work correctly when not mpi
islas 4364f9a
Adding version checking to JASPER as selected version is very important
islas 94ed78c
Add stand-in code for native netCDF[-Fortran] cmake builds
islas 1003f72
Make optional packages default off and must be requested on
islas d91185d
Use installed binary location rather than specifying it manually
islas 54e9e0f
Fix em_real install path
islas 7abfaeb
Fix typo in argpack
islas a7117e1
Get ideal tests now working within same repo directory simultaneously
islas d1b1bab
Merge upstream develop
islas 331d416
Adding correct logic for CLM
islas 4b79242
Using new ccpp kind file
islas 06be911
Merge upstream/develop
islas 17e8905
Revert "Making registry work in out of source build"
islas 7743a35
Removing unofficial tests
islas 8ba0eef
Add missing traditional flag to cpp
islas 46182a9
Revert syntax changes due to traditional flag now in place
islas 6684d46
Missed one single backslash
islas 5a91180
Note that -c is the default clean option
islas 4b61b40
Update command descriptions to reflect actual shell command execution
islas 25f7104
Remove clean links as no softlinks are created now
islas ceea17d
Add documentation on new build method
islas bac485c
Noting default values more concisely and improving printing of options
islas 62b0e93
Correctly installing cmake config files so other projects can link ag…
islas 67ac1a0
Set default build type to release if not specified
islas 2c7c396
Set MPI to default on if available
islas c454589
Add ability to set default option selection for string options based …
islas b09c6c5
Set default WRF_NESTING value to 1/BASIC
islas b60bd7e
Change Darwin configurations to include architecture before (MACOS) s…
islas 983f82a
Use arm64 as architecture string rather than aarch64 for Darwin
islas 7fa4005
Merge branch 'develop' of github.com:wrf-model/WRF into cmakeBuild
islas 8c42cca
Add shared physics files to cmake compilation
islas f7f6fcb
Fix install location of tables and data
islas b04996b
Set p3 tables to newer correct values
islas 464f539
Remove COAMPS option
islas 33fb761
Set correct location for MPTABLE.TBL
islas f6da85a
Move install namelist.input files up one to match other installs
islas 759df03
Use install location so links don't rely on build location and add .e…
islas 981aafa
Switch to symlinks for binaries
islas 31e07db
Create analogous run/ directory in install/
islas 7895715
Change install of mixing_ratio to link to better identify where it is…
islas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,366 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| import sys | ||
| import re | ||
| import inspect | ||
| import platform | ||
|
|
||
| archBlock = re.compile( r"(?:#[ ]*)(ARCH(?:.*\n)*?)(?:#{5,})", re.I ) | ||
| kvPair = re.compile( r"^(\w+)(?:[ \t]*=[ \t]*)(.*?)$", re.I | re.M ) | ||
| # Make this gnarly and complicated since configure.defaults has no standard formatting | ||
| # v start v OS V typical v MACOS | ||
| osAndArch = re.compile( r"^ARCH[ ]+(\w+)[ ]+((?:\w+.*?),|(?:[(].*?[)]))", re.I ) | ||
| # Just grab the first two words, thats what you get | ||
| osAndArchAlt = re.compile( r"^ARCH[ ]+(\w+)[ ]+(\w+)", re.I ) | ||
|
|
||
| referenceVar = re.compile( r"[$][(](\w+)[)]", re.I ) | ||
|
|
||
| class Stanza(): | ||
|
|
||
| def __init__( self, lines ) : | ||
| self.lines_ = lines | ||
| self.os_ = None | ||
| self.archs_ = [] | ||
| self.kvPairs_ = {} | ||
|
|
||
| def parse( self ) : | ||
| # First get os & archs | ||
| osarchMatch = osAndArch.match( self.lines_ ) | ||
|
|
||
| if osarchMatch is None : | ||
| osarchMatch = osAndArchAlt.match( self.lines_ ) | ||
| if osarchMatch is None : | ||
| print( "Could not find OS and architecture info in " + self.lines_.partition("\n")[0] ) | ||
|
|
||
| self.os_ = osarchMatch.group(1) | ||
| self.archs_ = osarchMatch.group(2).strip(",").split( " " ) | ||
|
|
||
| for kvPairMatch in kvPair.finditer( self.lines_ ) : | ||
| self.kvPairs_[ kvPairMatch.group(1) ] = kvPairMatch.group(2) | ||
| self.removeComments( kvPairMatch.group(1) ) | ||
|
|
||
| # Now sanitize | ||
| self.sanitize() | ||
|
|
||
| def dereference( self, field, fatal=False ) : | ||
| if field in self.kvPairs_ : | ||
| prevField = self.kvPairs_[field] | ||
|
|
||
| for refVarIter in referenceVar.finditer( prevField ) : | ||
| if refVarIter is not None : | ||
| # Grab group 1 and check that it is in our kv pairs | ||
| refVar = refVarIter.group(1) | ||
| if refVar not in self.kvPairs_ : | ||
| if fatal : | ||
| print( "Could not rereference : " + refVar ) | ||
| exit(1) | ||
| else: | ||
| continue | ||
|
|
||
| # Recursively deref | ||
| self.dereference( refVar, fatal ) | ||
|
|
||
| # Replace in original | ||
| self.kvPairs_[field] = self.kvPairs_[field].replace( | ||
| "$({var})".format( var=refVar ), | ||
| self.kvPairs_[refVar] | ||
| ) | ||
|
|
||
| def removeReferences( self, field, specifics=[] ) : | ||
| if field in self.kvPairs_ : | ||
| if specifics : | ||
| for specific in specifics : | ||
| self.kvPairs_[ field ] = self.kvPairs_[ field ].replace( | ||
| "$({var})".format( var=specific ), | ||
| "" | ||
| ) | ||
| else : | ||
| self.kvPairs_[ field ] = referenceVar.sub( "", self.kvPairs_[ field ] ) | ||
|
|
||
|
|
||
| def removeComments( self, field ) : | ||
| if field in self.kvPairs_ : | ||
| self.kvPairs_[ field ] = self.kvPairs_[ field ].split( "#", 1 )[0] | ||
|
|
||
| def splitIntoFieldAndFlags( self, field ) : | ||
| # Fix flags being mixed with programs | ||
| if field in self.kvPairs_ : | ||
| fieldValue = self.kvPairs_[ field ] | ||
|
|
||
| self.kvPairs_[field] = fieldValue.partition(" ")[0] | ||
| self.kvPairs_[field + "_FLAGS"] = fieldValue.partition(" ")[1] | ||
|
|
||
| def sanitize( self ) : | ||
| # Fix problematic variables | ||
| self.dereference( "DM_FC" ) | ||
| self.dereference( "DM_CC" ) | ||
| self.removeReferences( "FCBASEOPTS_NO_G" ) | ||
| # Get rid of all these mixed up flags, these are handled by cmake natively or | ||
| # just in the wrong place | ||
| self.removeReferences( "FCBASEOPTS", [ "FCDEBUG", "FORMAT_FREE", "BYTESWAPIO", ] ) | ||
| # Now deref | ||
| self.dereference( "FCBASEOPTS" ) | ||
|
|
||
| # Now fix certain ones that are mixing programs with flags all mashed into one option | ||
| self.splitIntoFieldAndFlags( "DM_FC" ) | ||
| self.splitIntoFieldAndFlags( "DM_CC" ) | ||
| self.splitIntoFieldAndFlags( "M4" ) | ||
|
|
||
| # Remove rogue compile commands that should *NOT* even be here | ||
| keysToSanitize = [ | ||
| "ARFLAGS", | ||
| "CFLAGS_LOCAL", | ||
| "CPP", | ||
| "ESMF_LDFLAG", | ||
| "LDFLAGS_LOCAL", | ||
| "MODULE_SRCH_FLAG", | ||
| "RLFLAGS", | ||
| "TRADFLAG", | ||
| "FCBASEOPTS", | ||
| "FCBASEOPTS_NO_G", | ||
| "FCOPTIM", | ||
| "FORMAT_FIXED", | ||
| "FORMAT_FREE" | ||
| ] | ||
|
|
||
| for keyToSan in keysToSanitize : | ||
| if keyToSan in self.kvPairs_ : | ||
| self.kvPairs_[ keyToSan ] = self.kvPairs_[ keyToSan ].replace( "-c", "" ) | ||
|
|
||
|
|
||
|
|
||
| # Now deref all the rest | ||
| for key in self.kvPairs_ : | ||
| self.dereference( key ) | ||
| # And for final measure strip | ||
| self.kvPairs_[ key ] = self.kvPairs_[ key ].strip() | ||
|
|
||
| def __str__( self ): | ||
| # base = """OS {os:<8} ARCHITECTURES {archs:<20} | ||
| # >> SFC = {SFC:<12} | ||
| # >> SCC = {SCC:<12} | ||
| # >> CCOMP = {CCOMP:<12} | ||
| # >> DM_FC = {DM_FC:<12} | ||
| # >> DM_CC = {DM_CC:<12} | ||
| # """ | ||
| base = """{rec} {os:<10} {SFC:<11} / {SCC:<11} / {CCOMP:<11} / {DM_FC:<11} / {DM_CC:<11}""" | ||
| text = inspect.cleandoc( base ).format( | ||
| os=str(self.os_), | ||
| rec=( "!!" if platform.system().lower() != self.os_.lower() else "Ok" ), | ||
| # archs=str(self.archs_), | ||
| SFC=str( self.kvPairs_["SFC"].partition(" ")[0] ), | ||
| SCC=str( self.kvPairs_["SCC"].partition(" ")[0] ), | ||
| CCOMP=str( self.kvPairs_["CCOMP"].partition(" ")[0] ), | ||
| DM_FC=str( self.kvPairs_["DM_FC"].partition(" ")[0] ), | ||
| DM_CC=str( self.kvPairs_["DM_CC"].partition(" ")[0] ) | ||
| ) | ||
| # text += "\n" + "\n".join( [ "{key:<18} = {value}".format( key=key, value=value) for key, value in self.kvPairs_.items() ] ) | ||
| return text | ||
|
|
||
| @staticmethod | ||
| def findFirstDifference( rhStanza, lhStanza, maxLength=32 ) : | ||
| diff = False | ||
| value = "" | ||
| valuesToCheck = [ | ||
| "ARCH_LOCAL", | ||
| "BYTESWAPIO", | ||
| "CFLAGS_LOCAL", | ||
| "DM_CC", | ||
| "DM_FC", | ||
| "DM_FC_FLAGS", | ||
| "DM_CC_FLAGS", | ||
| "FCBASEOPTS", | ||
| "FCDEBUG", | ||
| "FCNOOPT", | ||
| "FCOPTIM", | ||
| "M4_FLAGS", | ||
| "SCC", | ||
| "SFC" | ||
| ] | ||
| for rhKey, rhValue in rhStanza.kvPairs_.items() : | ||
| if rhKey in valuesToCheck and rhKey in lhStanza.kvPairs_ : | ||
| # Qualifies for difference | ||
| if rhValue != lhStanza.kvPairs_[rhKey] : | ||
| diff = True | ||
| value = "{key:<12} = {value}".format( key=rhKey, value=lhStanza.kvPairs_[rhKey] ) | ||
|
|
||
| # Truncate | ||
| value = ( value[:maxLength] + "..." ) if len( value ) > maxLength else value | ||
|
|
||
| return diff, value | ||
|
|
||
|
|
||
| def getStringOptionSelection( topLevelCmake, searchString ) : | ||
| topLevelCmakeFP = open( topLevelCmake, "r" ) | ||
| topLevelCmakeLines = topLevelCmakeFP.read() | ||
| topLevelCmakeFP.close() | ||
|
|
||
| stringOptionsMatch = re.search( | ||
| r"set\s*[(]\s*" + searchString + r"\s*(.*?)[)]", | ||
| topLevelCmakeLines, | ||
| re.I | re.S | re.M | ||
| ) | ||
| if stringOptionsMatch is None : | ||
| print( "Syntax error in parsing " + searchString + " from " + topLevelCmake ) | ||
| exit(1) | ||
|
|
||
| options = [ option.split( "#", 1 )[0].strip() for option in stringOptionsMatch.group(1).split( "\n" ) ] | ||
| # Weed out empties | ||
| options = [ option for option in options if option ] | ||
|
|
||
| optionsFmt = ", ".join( [ "{idx} : {opt}".format( idx=options.index( opt ), opt=opt ) for opt in options ] ) | ||
| selection = int( input( "Select option from {optionsStr} [0-{max}] ({opts}) : ".format( optionsStr=searchString, max=len(options)-1, opts=optionsFmt ) ) ) | ||
|
|
||
| if selection < 0 or selection > len(options) : | ||
| print( "Invalid option selection for " + searchString + "!" ) | ||
| exit(1) | ||
|
|
||
| return options[selection] | ||
|
|
||
| def getSubOptions( topLevelCmake, ignoreOptions ) : | ||
| topLevelCmakeFP = open( topLevelCmake, "r" ) | ||
| topLevelCmakeLines = topLevelCmakeFP.read() | ||
| topLevelCmakeFP.close() | ||
|
|
||
| stringOptionsMatch = re.finditer( | ||
| r"set\s*[(]\s*(\w+)\s*(ON|OFF)\s*CACHE\s*BOOL\s*\"(.*?)\"\s*[)]", | ||
| topLevelCmakeLines, | ||
| re.I | re.M | ||
| ) | ||
| # Remove commented ones and ones that don't follow pattern set( <OPT> ON|OFF CACHE BOOL "<OPT>" ) | ||
| options = [ [ option.group( 1 ), option.group( 2 ) ] for option in stringOptionsMatch if option.group( 1 ) == option.group( 3 ) and option.group(0).split( "#", 1 )[0].strip() ] | ||
|
|
||
| # Remove ignore options | ||
| options = [ option for option in options if option[0] not in ignoreOptions ] | ||
| subOptions = {} | ||
|
|
||
| if options : | ||
| subOptionQuit = False | ||
| optionToggleIdx = -1 | ||
|
|
||
| # Print menu | ||
| optionStr = "{idx:<3} {option:<24} : {value:<5}" | ||
| print( optionStr.format( idx="ID", option="Option", value="Default" ) ) | ||
| for opt in options : | ||
| print( optionStr.format( idx=options.index(opt), option=opt[0], value=opt[1] ) ) | ||
|
|
||
| print( "Enter ID to toggle option on or off, q to quit : " ) | ||
| # Loop until q, toggle from default not current value | ||
| while not subOptionQuit : | ||
| optionToggleIdx = input() | ||
| try: | ||
| optionToggleIdx = int( optionToggleIdx ) | ||
| if optionToggleIdx < 0 or optionToggleIdx >= len( options ) : | ||
| print( "Not a valid index" ) | ||
| else: | ||
| subOptions[ options[optionToggleIdx][0] ] = "ON" if not ( options[optionToggleIdx][1] == "ON" ) else "OFF" | ||
| print( "Set {option} to {value}".format( option=options[optionToggleIdx][0], value=subOptions[ options[optionToggleIdx][0] ] ) ) | ||
| except ValueError as err : | ||
| subOptionQuit = optionToggleIdx.lower() == "q" | ||
|
|
||
| return subOptions | ||
|
|
||
| def generateCMakeToolChainFile( cmakeToolChainTemplate, output, stanza, optionsDict={} ) : | ||
| cmakeToolChainTemplateFP = open( cmakeToolChainTemplate, "r" ) | ||
| cmakeToolChainTemplateLines = cmakeToolChainTemplateFP.read() | ||
| cmakeToolChainTemplateFP.close() | ||
|
|
||
| configStanza = cmakeToolChainTemplateLines.format( | ||
| ARCH_LOCAL=stanza.kvPairs_["ARCH_LOCAL"], | ||
| BYTESWAPIO=stanza.kvPairs_["BYTESWAPIO"], | ||
| CFLAGS_LOCAL=stanza.kvPairs_["CFLAGS_LOCAL"], | ||
| DM_CC=stanza.kvPairs_["DM_CC"], | ||
| DM_FC=stanza.kvPairs_["DM_FC"], | ||
| DM_FC_FLAGS=stanza.kvPairs_["DM_FC_FLAGS"], | ||
| DM_CC_FLAGS=stanza.kvPairs_["DM_CC_FLAGS"], | ||
| FCBASEOPTS=stanza.kvPairs_["FCBASEOPTS"], | ||
| FCDEBUG=stanza.kvPairs_["FCDEBUG"], | ||
| FCNOOPT=stanza.kvPairs_["FCNOOPT"], | ||
| FCOPTIM=stanza.kvPairs_["FCOPTIM"], | ||
| M4_FLAGS=stanza.kvPairs_["M4_FLAGS"], | ||
| SCC=stanza.kvPairs_["SCC"], | ||
| SFC=stanza.kvPairs_["SFC"] | ||
| ) | ||
|
|
||
| # Extra stufff not from stanza but options | ||
| fmtOption = "set( {opt:<32} {value:<12} CACHE STRING \"Set by configuration\" FORCE )" | ||
| configStanza += "\n" + "\n".join( [ fmtOption.format( opt=key, value=value ) for key, value in optionsDict.items() ] ) | ||
|
|
||
| outputFP = open( output, "w" ) | ||
| outputFP.write( configStanza ) | ||
| outputFP.close() | ||
|
|
||
| def main() : | ||
| configFile = sys.argv[1] | ||
| cmakeTemplateFile = sys.argv[2] | ||
| cmakeConfigFile = sys.argv[3] | ||
| cmakeFile = sys.argv[4] | ||
|
|
||
| coreOption = getStringOptionSelection( cmakeFile, "WRF_CORE_OPTIONS" ) | ||
| nestingOption = getStringOptionSelection( cmakeFile, "WRF_NESTING_OPTIONS" ) | ||
| caseOption = getStringOptionSelection( cmakeFile, "WRF_CASE_OPTIONS" ) | ||
|
|
||
| # These are yes | ||
| yesValues = [ "yes", "y", "true", "1" ] | ||
|
|
||
| #!TODO Expand this for all wrf options | ||
| useMPI = input( "[DM] Use MPI? [Y/n] : " ).lower() in yesValues | ||
| useOpenMP = input( "[SM] Use OpenMP? [Y/n] : " ).lower() in yesValues | ||
|
|
||
| alreadyAsked = [ "USE_MPI", "USE_OPENMP" ] | ||
|
|
||
| doSuboptionMenu = input( "Configure additional options? [Y/n] : " ).lower() in yesValues | ||
| subOptions = {} | ||
| if doSuboptionMenu : | ||
| subOptions = getSubOptions( cmakeFile, alreadyAsked ) | ||
|
|
||
|
|
||
| fp = open( configFile, 'r' ) | ||
| lines = fp.read() | ||
| fp.close() | ||
|
|
||
| # Now grab the blocks and parse | ||
| stanzas = [] | ||
| uniqueConfigs = {} | ||
| stanzaIdx = 0 | ||
| for stanzaBlock in archBlock.finditer( lines ) : | ||
| stanza = Stanza( stanzaBlock.group(1) ) | ||
| stanza.parse() | ||
|
|
||
| stanzas.append( stanza ) | ||
| stanzaConfig = str( stanza ) | ||
| stanzaId = "{idx:<3} ".format( idx=stanzaIdx ) | ||
| if stanzaConfig not in uniqueConfigs : | ||
| uniqueConfigs[ stanzaConfig ] = { "stanza" : stanza, "idx" : stanzaIdx } | ||
| print( stanzaId + stanzaConfig + "[first entry]" ) | ||
| else : | ||
| diff, value = Stanza.findFirstDifference( uniqueConfigs[ stanzaConfig ]["stanza"], stanza ) | ||
| if diff : | ||
| print( stanzaId + stanzaConfig + "@{idx} diff => {value}".format( idx=uniqueConfigs[ stanzaConfig ][ "idx" ], value=value ) ) | ||
| else : | ||
| print( stanzaId + stanzaConfig + "[no difference]" ) | ||
| stanzaIdx += 1 | ||
|
|
||
| print( "!! - Not recommended for your system" ) | ||
|
|
||
| idxSelection = int( input( "Select configuration [0-{stop}] (note !!) : ".format( stop=( stanzaIdx-1) ) ) ) | ||
| if idxSelection < 0 or idxSelection > stanzaIdx - 1 : | ||
| print( "Invalid configuration selection!" ) | ||
| exit(1) | ||
|
|
||
| additionalOptions = { | ||
| "WRF_CORE" : coreOption, | ||
| "WRF_NESTING" : nestingOption, | ||
| "WRF_CASE" : caseOption, | ||
| "USE_MPI" : "ON" if useMPI else "OFF", | ||
| "USE_OPENMP" : "ON" if useOpenMP else "OFF", | ||
| } | ||
| additionalOptions.update( subOptions ) | ||
| generateCMakeToolChainFile( cmakeTemplateFile, cmakeConfigFile, stanzas[idxSelection], additionalOptions ) | ||
|
|
||
|
|
||
|
|
||
|
|
||
| if __name__ == '__main__' : | ||
| main() | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This RE breaks on macOS, because it reads the (MACOS) comment from the
configure.defaultsfile. You could either make a special-case check here, or, updateconfigure.defaultswith something like this:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I follow. The
osAndArchregex properly catches the lines you mentioned in my tests when enabling (via changing the skip logic) cross-platform stanza selection. The last bit of the regex has a non-capture group for the(...)to deal with(MACOS)It would be nice though to not have to deal with special cases for all the inconsistent formatting in comments/descriptions of things in
configure.defaultsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my MacBook Pro, the script failed to find any stanzas until I manually added the architectures to the
configure.defaultsfile. Printing out theStanza.archs_variable is how I found that it was capturing the(MACOS)token. I did not try using the cross-platform flag.I also found that using the gfortran/clang stanza failed as well because the
-fallow-argument-mismatchflag was being passed to both gfortran and clang (where it's an invalid argument). Using gcc/gfortran worked fine after the edits to the configure file. I'll dig into that clang issue and post another comment when I determine the underlying issue.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I think I was focused on simply getting the regex to capture something, but that something is eventually compared to
platform.machine()in python. I think a change would be best.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried again but got the same result (no stanzas) when building on a M1 Mac -- as it turns out, macOS uses
arm64as an architecture identifier vsaarch64that Linux uses. My patch worked on a Intel Mac but not Arm-based. My apologies; I should have double-checked that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just double checking, adding
arm64to the list of archs in the line does properly show the modified stanza?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but I would change
aarch64toarm64for the Darwin stanzas vs. adding it. The macOS reports it only asarm64orx86_64from theuname()call (which is what Python is using under the hood).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, should be fixed now