summaryrefslogtreecommitdiff
path: root/modules/mono/SCsub
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mono/SCsub')
-rw-r--r--modules/mono/SCsub45
1 files changed, 29 insertions, 16 deletions
diff --git a/modules/mono/SCsub b/modules/mono/SCsub
index f3cf4c9c5d..1d5c145027 100644
--- a/modules/mono/SCsub
+++ b/modules/mono/SCsub
@@ -7,21 +7,24 @@ env_mono = env_modules.Clone()
# TODO move functions to their own modules
-def make_cs_files_header(src, dst):
+def make_cs_files_header(src, dst, version_dst):
from compat import byte_to_str
with open(dst, 'w') as header:
- header.write('/* This is an automatically generated file; DO NOT EDIT! OK THX */\n')
- header.write('#ifndef _CS_FILES_DATA_H\n')
- header.write('#define _CS_FILES_DATA_H\n\n')
- header.write('#include "map.h"\n')
- header.write('#include "ustring.h"\n')
+ header.write('/* THIS FILE IS GENERATED DO NOT EDIT */\n')
+ header.write('#ifndef CS_COMPRESSED_H\n')
+ header.write('#define CS_COMPRESSED_H\n\n')
+ header.write('#ifdef TOOLS_ENABLED\n\n')
+ header.write('#include "core/map.h"\n')
+ header.write('#include "core/ustring.h"\n')
inserted_files = ''
import os
latest_mtime = 0
+ cs_file_count = 0
for root, _, files in os.walk(src):
files = [f for f in files if f.endswith('.cs')]
for file in files:
+ cs_file_count += 1
filepath = os.path.join(root, file)
filepath_src_rel = os.path.relpath(filepath, src)
mtime = os.path.getmtime(filepath)
@@ -31,8 +34,10 @@ def make_cs_files_header(src, dst):
decomp_size = len(buf)
import zlib
buf = zlib.compress(buf)
- name = os.path.splitext(os.path.normpath(filepath_src_rel))[0].strip(os.sep).replace(os.sep, '_').replace('.', '_dotto_')
- header.write('\nstatic const int _cs_' + name + '_compressed_size = ' + str(len(buf)) + ';\n')
+ name = str(cs_file_count)
+ header.write('\n')
+ header.write('// ' + filepath_src_rel + '\n')
+ header.write('static const int _cs_' + name + '_compressed_size = ' + str(len(buf)) + ';\n')
header.write('static const int _cs_' + name + '_uncompressed_size = ' + str(decomp_size) + ';\n')
header.write('static const unsigned char _cs_' + name + '_compressed[] = { ')
for i, buf_idx in enumerate(range(len(buf))):
@@ -44,8 +49,6 @@ def make_cs_files_header(src, dst):
'_cs_' + name + '_uncompressed_size, ' \
'_cs_' + name + '_compressed));\n'
header.write(' };\n')
- glue_version = int(latest_mtime) # The latest modified time will do for now
- header.write('\n#define CS_GLUE_VERSION UINT32_C(' + str(glue_version) + ')\n')
header.write('\nstruct CompressedFile\n' '{\n'
'\tint compressed_size;\n' '\tint uncompressed_size;\n' '\tconst unsigned char* data;\n'
'\n\tCompressedFile(int p_comp_size, int p_uncomp_size, const unsigned char* p_data)\n'
@@ -53,17 +56,28 @@ def make_cs_files_header(src, dst):
'\t\tdata = p_data;\n' '\t}\n' '\n\tCompressedFile() {}\n' '};\n'
'\nvoid get_compressed_files(Map<String, CompressedFile>& r_files)\n' '{\n' + inserted_files + '}\n'
)
- header.write('#endif // _CS_FILES_DATA_H')
+ header.write('\n#endif // TOOLS_ENABLED\n')
+ header.write('\n#endif // CS_COMPRESSED_H\n')
+
+ glue_version = int(latest_mtime) # The latest modified time will do for now
+
+ with open(version_dst, 'w') as version_header:
+ version_header.write('/* THIS FILE IS GENERATED DO NOT EDIT */\n')
+ version_header.write('#ifndef CS_GLUE_VERSION_H\n')
+ version_header.write('#define CS_GLUE_VERSION_H\n\n')
+ version_header.write('#define CS_GLUE_VERSION UINT32_C(' + str(glue_version) + ')\n')
+ version_header.write('\n#endif // CS_GLUE_VERSION_H\n')
env_mono.add_source_files(env.modules_sources, '*.cpp')
+env_mono.add_source_files(env.modules_sources, 'glue/*.cpp')
env_mono.add_source_files(env.modules_sources, 'mono_gd/*.cpp')
env_mono.add_source_files(env.modules_sources, 'utils/*.cpp')
if env['tools']:
env_mono.add_source_files(env.modules_sources, 'editor/*.cpp')
- # NOTE: It is safe to generate this file here, since this is still execute serially
- make_cs_files_header('glue/cs_files', 'glue/cs_compressed.gen.h')
+ # NOTE: It is safe to generate this file here, since this is still executed serially
+ make_cs_files_header('glue/Managed/Files', 'glue/cs_compressed.gen.h', 'glue/cs_glue_version.gen.h')
vars = Variables()
vars.Add(BoolVariable('mono_glue', 'Build with the mono glue sources', True))
@@ -72,9 +86,7 @@ vars.Update(env_mono)
# Glue sources
if env_mono['mono_glue']:
- env_mono.add_source_files(env.modules_sources, 'glue/*.cpp')
-else:
- env_mono.Append(CPPDEFINES=['MONO_GLUE_DISABLED'])
+ env_mono.Append(CPPDEFINES=['MONO_GLUE_ENABLED'])
if ARGUMENTS.get('yolo_copy', False):
env_mono.Append(CPPDEFINES=['YOLO_COPY'])
@@ -122,6 +134,7 @@ def find_msbuild_unix(filename):
def find_msbuild_windows():
import mono_reg_utils as monoreg
+ mono_root = ''
bits = env['bits']
if bits == '32':