JSON packaging is slightly improved - no injection every time; Build incompressible JSON library

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
Ian Bell
2014-06-05 11:14:31 +02:00
parent eba0b9c0f0
commit 81cea06746
4 changed files with 38 additions and 13 deletions

View File

@@ -13,6 +13,7 @@ import generate_headers
# 2: Name of variable
values = [
('all_fluids.json','all_fluids_JSON.h','all_fluids_JSON'),
('all_incompressibles.json','all_incompressibles_JSON.h','all_incompressibles_JSON'),
('mixtures/mixture_excess_term.json', 'mixture_excess_term_JSON.h', 'mixture_excess_term_JSON'),
('mixtures/mixture_reducing_parameters.json', 'mixture_reducing_parameters_JSON.h', 'mixture_reducing_parameters_JSON')
]
@@ -28,7 +29,7 @@ def TO_CPP(root_dir, hashes):
# First we package up the JSON files
import package_json
package_json.package_json(root_dir)
package_json.combine_json(root_dir)
for infile,outfile,variable in values:
@@ -68,7 +69,7 @@ def TO_CPP(root_dir, hashes):
# Store the hash of the data that was written to file (not including the header)
hashes[variable] = generate_headers.get_hash(hex_string)
else:
print(outfile + 'is up to date')
print(outfile + ' is up to date')
if __name__=='__main__':
parser = argparse.ArgumentParser(

View File

@@ -10,21 +10,22 @@
<Option output="bin/Debug/coolprop" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Option compiler="clang" />
<Compiler>
<Add option="-g" />
<Add option="-DENABLE_CATCH" />
<Add directory="../../../include" />
<Add directory="../../include" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/coolprop" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Option compiler="clang" />
<Compiler>
<Add option="-O2" />
<Add directory="../../../include" />
<Add option="-O4" />
<Add option="-DENABLE_CATCH" />
<Add directory="../../include" />
</Compiler>
<Linker>
<Add option="-s" />

View File

@@ -105,6 +105,7 @@ if __name__=='__main__':
version_to_file(root_dir = path)
gitrev_to_file(root_dir = path)
import JSON_to_CPP
JSON_to_CPP.TO_CPP(root_dir = path, hashes = hashes)

View File

@@ -241,13 +241,14 @@ def inject_ancillaries(root_dir):
fp = open(os.path.join(root_dir,'dev','fluids', fluid_name+'.json'),'w')
fp.write(json.dumps(fluid, **json_options))
def package_json(root_dir):
master = []
def inject(root_dir):
inject_ancillaries(root_dir)
inject_surface_tension(root_dir)
inject_environmental_data(root_dir)
def combine_json(root_dir):
master = []
print('*** Combining fluid JSON files in JSON format in dev folder...')
for file in glob.glob(os.path.join(root_dir,'dev','fluids','*.json')):
@@ -256,7 +257,7 @@ def package_json(root_dir):
fluid_name = file_name.split('.')[0]
# Load the fluid file
fluid = json.load(open(os.path.join(root_dir,'dev','fluids', fluid_name+'.json'), 'r'))
fluid = json.load(open(file, 'r'))
master += [fluid]
@@ -268,5 +269,26 @@ def package_json(root_dir):
fp.write(json.dumps(master))
fp.close()
master = []
print('*** Combining incompressible JSON files in JSON format in dev folder...')
for file in glob.glob(os.path.join(root_dir,'dev','IncompressibleLiquids','*.json')):
path, file_name = os.path.split(file)
fluid_name = file_name.split('.')[0]
# Load the fluid file
fluid = json.load(open(file, 'r'))
master += [fluid]
fp = open(os.path.join(root_dir,'dev','all_incompressibles_verbose.json'),'w')
fp.write(json.dumps(master, **json_options))
fp.close()
fp = open(os.path.join(root_dir,'dev','all_incompressibles.json'),'w')
fp.write(json.dumps(master))
fp.close()
if __name__=='__main__':
package_json(root_dir = '..')
combine_json(root_dir = '..')