mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 22:20:24 +00:00
Merge branch 'misc-meson-fixes' into 'master'
Reduce useless relinking on configure and fix check for buildtype arguments See merge request GNOME/gtk!1614
This commit is contained in:
commit
da6faf321c
@ -1,21 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import argparse
|
||||
import sys
|
||||
import filecmp
|
||||
|
||||
def replace_if_changed(new, old):
|
||||
'''
|
||||
Compare contents and only replace if changed to avoid triggering a rebuild.
|
||||
'''
|
||||
try:
|
||||
changed = not filecmp.cmp(new, old, shallow=False)
|
||||
except FileNotFoundError:
|
||||
changed = True
|
||||
if changed:
|
||||
os.replace(new, old)
|
||||
else:
|
||||
os.remove(new)
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--array-name', help='The name of the array variable')
|
||||
parser.add_argument('--output', metavar='FILE', help='Output file',
|
||||
type=argparse.FileType('w'),
|
||||
default=sys.stdout)
|
||||
parser.add_argument('--output', metavar='STRING', help='Output filename',
|
||||
default=None)
|
||||
parser.add_argument('input', metavar='FILE', help='The input file',
|
||||
type=argparse.FileType('r'))
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
args.output.write('static const char {}[] = {{\n'.format(args.array_name))
|
||||
for line in args.input:
|
||||
for ch in line:
|
||||
args.output.write(' 0x{:02x},\n'.format(ord(ch)))
|
||||
if args.output is None:
|
||||
output = sys.stdout
|
||||
else:
|
||||
output = args.output + '~'
|
||||
|
||||
args.output.write('};')
|
||||
with open(output, 'w') as f:
|
||||
f.write('static const char {}[] = {{\n'.format(args.array_name))
|
||||
for line in args.input:
|
||||
for ch in line:
|
||||
f.write(' 0x{:02x},\n'.format(ord(ch)))
|
||||
f.write('};')
|
||||
|
||||
if args.output is not None:
|
||||
replace_if_changed(output, args.output)
|
||||
|
@ -5,6 +5,20 @@
|
||||
# Usage: gen-gdk-gresources-xml SRCDIR_GDK [OUTPUT-FILE]
|
||||
|
||||
import os, sys
|
||||
import filecmp
|
||||
|
||||
def replace_if_changed(new, old):
|
||||
'''
|
||||
Compare contents and only replace if changed to avoid triggering a rebuild.
|
||||
'''
|
||||
try:
|
||||
changed = not filecmp.cmp(new, old, shallow=False)
|
||||
except FileNotFoundError:
|
||||
changed = True
|
||||
if changed:
|
||||
os.replace(new, old)
|
||||
else:
|
||||
os.remove(new)
|
||||
|
||||
srcdir = sys.argv[1]
|
||||
|
||||
@ -26,8 +40,9 @@ xml += '''
|
||||
|
||||
if len(sys.argv) > 2:
|
||||
outfile = sys.argv[2]
|
||||
f = open(outfile, 'w')
|
||||
f.write(xml)
|
||||
f.close()
|
||||
tmpfile = outfile + '~'
|
||||
with open(tmpfile, 'w') as f:
|
||||
f.write(xml)
|
||||
replace_if_changed(tmpfile, outfile)
|
||||
else:
|
||||
print(xml)
|
||||
|
@ -5,6 +5,20 @@
|
||||
# Usage: gen-gsk-gresources-xml OUTPUT-FILE [INPUT-FILE1] [INPUT-FILE2] ...
|
||||
|
||||
import os, sys
|
||||
import filecmp
|
||||
|
||||
def replace_if_changed(new, old):
|
||||
'''
|
||||
Compare contents and only replace if changed to avoid triggering a rebuild.
|
||||
'''
|
||||
try:
|
||||
changed = not filecmp.cmp(new, old, shallow=False)
|
||||
except FileNotFoundError:
|
||||
changed = True
|
||||
if changed:
|
||||
os.replace(new, old)
|
||||
else:
|
||||
os.remove(new)
|
||||
|
||||
source_shaders = []
|
||||
vulkan_compiled_shaders = []
|
||||
@ -45,8 +59,9 @@ xml += '''
|
||||
|
||||
if len(sys.argv) > 1 and sys.argv[1] != '-':
|
||||
outfile = sys.argv[1]
|
||||
f = open(outfile, 'w')
|
||||
f.write(xml)
|
||||
f.close()
|
||||
tmpfile = outfile + '~'
|
||||
with open(tmpfile, 'w') as f:
|
||||
f.write(xml)
|
||||
replace_if_changed(tmpfile, outfile)
|
||||
else:
|
||||
print(xml)
|
||||
|
@ -5,6 +5,20 @@
|
||||
# Usage: gen-gtk-gresources-xml SRCDIR_GTK [OUTPUT-FILE]
|
||||
|
||||
import os, sys
|
||||
import filecmp
|
||||
|
||||
def replace_if_changed(new, old):
|
||||
'''
|
||||
Compare contents and only replace if changed to avoid triggering a rebuild.
|
||||
'''
|
||||
try:
|
||||
changed = not filecmp.cmp(new, old, shallow=False)
|
||||
except FileNotFoundError:
|
||||
changed = True
|
||||
if changed:
|
||||
os.replace(new, old)
|
||||
else:
|
||||
os.remove(new)
|
||||
|
||||
srcdir = sys.argv[1]
|
||||
|
||||
@ -78,8 +92,9 @@ xml += '''
|
||||
|
||||
if len(sys.argv) > 2:
|
||||
outfile = sys.argv[2]
|
||||
f = open(outfile, 'w')
|
||||
f.write(xml)
|
||||
f.close()
|
||||
tmpfile = outfile + '~'
|
||||
with open(tmpfile, 'w') as f:
|
||||
f.write(xml)
|
||||
replace_if_changed(tmpfile, outfile)
|
||||
else:
|
||||
print(xml)
|
||||
|
@ -4,6 +4,20 @@
|
||||
import sys
|
||||
import re
|
||||
import os
|
||||
import filecmp
|
||||
|
||||
def replace_if_changed(new, old):
|
||||
'''
|
||||
Compare contents and only replace if changed to avoid triggering a rebuild.
|
||||
'''
|
||||
try:
|
||||
changed = not filecmp.cmp(new, old, shallow=False)
|
||||
except FileNotFoundError:
|
||||
changed = True
|
||||
if changed:
|
||||
os.replace(new, old)
|
||||
else:
|
||||
os.remove(new)
|
||||
|
||||
debug = os.getenv('GTK_GENTYPEFUNCS_DEBUG') is not None
|
||||
|
||||
@ -50,6 +64,7 @@ for f in funcs:
|
||||
|
||||
if debug: print (len(funcs), 'functions')
|
||||
|
||||
ofile = open(out_file, "w")
|
||||
ofile.write(file_output)
|
||||
ofile.close()
|
||||
tmp_file = out_file + '~'
|
||||
with open(tmp_file, 'w') as f:
|
||||
f.write(file_output)
|
||||
replace_if_changed(tmp_file, out_file)
|
||||
|
11
meson.build
11
meson.build
@ -60,14 +60,17 @@ add_project_arguments('-DGTK_VERSION="@0@"'.format(meson.project_version()), lan
|
||||
|
||||
add_project_arguments('-D_GNU_SOURCE', language: 'c')
|
||||
|
||||
# Use debug/optimization flags to determine whether to enable debug or disable
|
||||
# cast checks
|
||||
gtk_debug_cflags = []
|
||||
buildtype = get_option('buildtype')
|
||||
if buildtype.startswith('debug')
|
||||
debug = get_option('debug')
|
||||
optimization = get_option('optimization')
|
||||
if debug
|
||||
gtk_debug_cflags += '-DG_ENABLE_DEBUG'
|
||||
if buildtype == 'debug'
|
||||
if optimization in ['0', 'g']
|
||||
gtk_debug_cflags += '-DG_ENABLE_CONSISTENCY_CHECKS'
|
||||
endif
|
||||
elif buildtype == 'release'
|
||||
elif optimization in ['2', '3', 's']
|
||||
gtk_debug_cflags += '-DG_DISABLE_CAST_CHECKS'
|
||||
endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user