mirror of
				https://github.com/Z3Prover/z3
				synced 2025-11-03 21:09:11 +00:00 
			
		
		
		
	Merge pull request #363 from delcypher/dotnet_configure_assembly_info
Refactor ``mk_all_assembly_infos()`` to use the ``configure_file()`` and misc fixes for dotnet bindings
This commit is contained in:
		
						commit
						fc5b9156cf
					
				
					 2 changed files with 28 additions and 45 deletions
				
			
		| 
						 | 
				
			
			@ -1535,7 +1535,7 @@ class DotNetDLLComponent(Component):
 | 
			
		|||
                           ]
 | 
			
		||||
                         )
 | 
			
		||||
        if DEBUG_MODE:
 | 
			
		||||
            cscCmdLine.extend( ['/define:DEBUG;TRACE',
 | 
			
		||||
            cscCmdLine.extend( ['"/define:DEBUG;TRACE"', # Needs to be quoted due to ``;`` being a shell command separator
 | 
			
		||||
                                '/debug+',
 | 
			
		||||
                                '/debug:full',
 | 
			
		||||
                                '/optimize-'
 | 
			
		||||
| 
						 | 
				
			
			@ -1916,7 +1916,7 @@ class DotNetExampleComponent(ExampleComponent):
 | 
			
		|||
        ExampleComponent.__init__(self, name, path)
 | 
			
		||||
 | 
			
		||||
    def is_example(self):
 | 
			
		||||
        return IS_WINDOWS
 | 
			
		||||
        return is_dotnet_enabled()
 | 
			
		||||
 | 
			
		||||
    def mk_makefile(self, out):
 | 
			
		||||
        if DOTNET_ENABLED:
 | 
			
		||||
| 
						 | 
				
			
			@ -1935,9 +1935,11 @@ class DotNetExampleComponent(ExampleComponent):
 | 
			
		|||
                out.write(' /platform:x86')
 | 
			
		||||
            for csfile in get_cs_files(self.ex_dir):
 | 
			
		||||
                out.write(' ')
 | 
			
		||||
                # HACK
 | 
			
		||||
                win_ex_dir = self.to_ex_dir.replace('/', '\\')
 | 
			
		||||
                out.write(os.path.join(win_ex_dir, csfile))
 | 
			
		||||
                # HACK: I'm not really sure why csc on Windows need to be
 | 
			
		||||
                # given Windows style paths (``\``) here. I thought Windows
 | 
			
		||||
                # supported using ``/`` as a path separator...
 | 
			
		||||
                relative_path = self.to_ex_dir.replace('/', os.path.sep)
 | 
			
		||||
                out.write(os.path.join(relative_path, csfile))
 | 
			
		||||
            out.write('\n')
 | 
			
		||||
            out.write('_ex_%s: %s\n\n' % (self.name, exefile))
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -2548,42 +2550,23 @@ def mk_version_dot_h(major, minor, build, revision):
 | 
			
		|||
    if VERBOSE:
 | 
			
		||||
        print("Generated '%s'" % os.path.join(c.src_dir, 'version.h'))
 | 
			
		||||
 | 
			
		||||
# Generate AssemblyInfo.cs files with the right version numbers by using AssemblyInfo files as a template
 | 
			
		||||
# Generate AssemblyInfo.cs files with the right version numbers by using ``AssemblyInfo.cs.in`` files as a template
 | 
			
		||||
def mk_all_assembly_infos(major, minor, build, revision):
 | 
			
		||||
    for c in get_components():
 | 
			
		||||
        if c.has_assembly_info():
 | 
			
		||||
            assembly = os.path.join(c.src_dir, c.assembly_info_dir, 'AssemblyInfo')
 | 
			
		||||
            if os.path.exists(assembly):
 | 
			
		||||
                # It is a CS file
 | 
			
		||||
                mk_assembly_info_version(assembly, major, minor, build, revision)
 | 
			
		||||
            assembly_info_template = os.path.join(c.src_dir, c.assembly_info_dir, 'AssemblyInfo.cs.in')
 | 
			
		||||
            assembly_info_output = assembly_info_template[:-3]
 | 
			
		||||
            assert assembly_info_output.endswith('.cs')
 | 
			
		||||
            if os.path.exists(assembly_info_template):
 | 
			
		||||
                configure_file(assembly_info_template, assembly_info_output,
 | 
			
		||||
                               { 'VER_MAJOR': str(major),
 | 
			
		||||
                                 'VER_MINOR': str(minor),
 | 
			
		||||
                                 'VER_BUILD': str(build),
 | 
			
		||||
                                 'VER_REVISION': str(revision),
 | 
			
		||||
                               }
 | 
			
		||||
                              )
 | 
			
		||||
            else:
 | 
			
		||||
                raise MKException("Failed to find assembly info file 'AssemblyInfo' at '%s'" % os.path.join(c.src_dir, c.assembly_info_dir))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Generate version number in the given 'AssemblyInfo.cs' file using 'AssemblyInfo' as a template.
 | 
			
		||||
def mk_assembly_info_version(assemblyinfo, major, minor, build, revision):
 | 
			
		||||
    ver_pat   = re.compile('[assembly: AssemblyVersion\("[\.\d]*"\) *')
 | 
			
		||||
    fver_pat  = re.compile('[assembly: AssemblyFileVersion\("[\.\d]*"\) *')
 | 
			
		||||
    fin  = open(assemblyinfo, 'r')
 | 
			
		||||
    tmp  = '%s.cs' % assemblyinfo
 | 
			
		||||
    fout = open(tmp, 'w')
 | 
			
		||||
    num_updates = 0
 | 
			
		||||
    for line in fin:
 | 
			
		||||
        if ver_pat.match(line):
 | 
			
		||||
            fout.write('[assembly: AssemblyVersion("%s.%s.%s.%s")]\n' % (major, minor, build, revision))
 | 
			
		||||
            num_updates = num_updates + 1
 | 
			
		||||
        elif fver_pat.match(line):
 | 
			
		||||
            fout.write('[assembly: AssemblyFileVersion("%s.%s.%s.%s")]\n' % (major, minor, build, revision))
 | 
			
		||||
            num_updates = num_updates + 1
 | 
			
		||||
        else:
 | 
			
		||||
            fout.write(line)
 | 
			
		||||
    # if VERBOSE:
 | 
			
		||||
    #    print("%s version numbers updated at '%s'" % (num_updates, assemblyinfo))
 | 
			
		||||
    assert num_updates == 2, "unexpected number of version number updates"
 | 
			
		||||
    fin.close()
 | 
			
		||||
    fout.close()
 | 
			
		||||
    if VERBOSE:
 | 
			
		||||
        print("Updated '%s'" % assemblyinfo)
 | 
			
		||||
                raise MKException("Failed to find assembly template info file '%s'" % assembly_info_template)
 | 
			
		||||
 | 
			
		||||
ADD_TACTIC_DATA=[]
 | 
			
		||||
ADD_PROBE_DATA=[]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue