Crude dust-off for building on OSX Sonoma 14.4 with Python 3 and Xcode 15.3

This commit is contained in:
Tony Garnock-Jones 2024-04-14 16:20:54 +02:00
parent 183c0241ef
commit e32f0485e6
4 changed files with 148 additions and 148 deletions

View File

@ -241,6 +241,7 @@
GCC_PREFIX_HEADER = hopOsx_Prefix.pch;
INFOPLIST_FILE = "hopOsx-Info.plist";
INSTALL_PATH = "$(HOME)/Applications";
MACOSX_DEPLOYMENT_TARGET = 10.13;
PRODUCT_NAME = "Hop Server";
};
name = Debug;
@ -255,6 +256,7 @@
GCC_PREFIX_HEADER = hopOsx_Prefix.pch;
INFOPLIST_FILE = "hopOsx-Info.plist";
INSTALL_PATH = "$(HOME)/Applications";
MACOSX_DEPLOYMENT_TARGET = 10.13;
PRODUCT_NAME = "Hop Server";
};
name = Release;
@ -262,26 +264,28 @@
C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
ARCHS = "$(ARCHS_STANDARD)";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
SDKROOT = macosx10.6;
SDKROOT = macosx14.4;
};
name = Debug;
};
C01FCF5008A954540054247B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
ARCHS = "$(ARCHS_STANDARD)";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
PREBINDING = NO;
SDKROOT = macosx10.6;
SDKROOT = macosx14.4;
};
name = Release;
};

View File

@ -20,10 +20,10 @@ web/%.html: web/bootstrap/templates/%.xml web/bootstrap/template.xsl web/bootstr
xsltproc web/bootstrap/template.xsl $< > $@
message.ml: ../protocol/messages.json codegen.py
python codegen.py > $@
python3 codegen.py > $@
amqp_spec.ml: amqp0-9-1.stripped.xml amqp_codegen.py
python amqp_codegen.py > $@
python3 amqp_codegen.py > $@
webclean:
rm -f $(HTML)

View File

@ -15,8 +15,6 @@
## You should have received a copy of the GNU General Public License
## along with Hop. If not, see <http://www.gnu.org/licenses/>.
##
from __future__ import with_statement
copyright_stmt = '''(* Copyright 2012 Tony Garnock-Jones <tonygarnockjones@gmail.com>. *)
(* This file is part of Hop. *)
@ -197,90 +195,90 @@ class BitAccumulator:
def flush(self):
if self.acc:
print ' write_octet output_buf (%s);' % (' lor '.join(self.acc),)
print(' write_octet output_buf (%s);' % (' lor '.join(self.acc),))
self.acc = []
def print_codec():
print copyright_stmt
print '(* WARNING: Autogenerated code. Do not edit by hand! *)'
print
print 'open Amqp_wireformat'
print 'open Sexp'
print
print 'let version = (%d, %d, %d)' % (major, minor, revision)
print 'let port = %d' % (port,)
print
print(copyright_stmt)
print('(* WARNING: Autogenerated code. Do not edit by hand! *)')
print()
print('open Amqp_wireformat')
print('open Sexp')
print()
print('let version = (%d, %d, %d)' % (major, minor, revision))
print('let port = %d' % (port,))
print()
for (n, v) in constants():
print 'let %s = %s' % (mlify(n), v)
print
print('let %s = %s' % (mlify(n), v))
print()
for c in classes:
print 'let %s_class_id = %d' % (mlify(c.name), c.index)
print
print 'type method_t ='
print('let %s_class_id = %d' % (mlify(c.name), c.index))
print()
print('type method_t =')
for m in methods:
print ' | ' + m.pattern(True)
print
print 'let has_content m = match m with '
print(' | ' + m.pattern(True))
print()
print('let has_content m = match m with ')
for m in methods:
if m.has_content:
print m.match_clause + ' true'
print ' | _ -> false'
print
print 'type properties_t ='
print(m.match_clause + ' true')
print(' | _ -> false')
print()
print('type properties_t =')
for c in classes:
if c.fields:
print ' | ' + c.pattern(True, True)
print
print 'let is_synchronous m = match m with '
print(' | ' + c.pattern(True, True))
print()
print('let is_synchronous m = match m with ')
for m in methods:
if not m.synchronous:
print m.match_clause + ' false'
print ' | _ -> true'
print
print 'let sexp_of_method m = match m with '
print(m.match_clause + ' false')
print(' | _ -> true')
print()
print('let sexp_of_method m = match m with ')
for m in methods:
print m.match_clause
print(m.match_clause)
if m.accessible_fields:
print ' Arr [litstr "%s"; litstr "%s"' % (m.class_name, m.name)
print(' Arr [litstr "%s"; litstr "%s"' % (m.class_name, m.name))
for f in m.accessible_fields:
print ' ; Arr [litstr "%s"; sexp_of_%s(%s)]' % \
(f.name, mlify(f.type), mlify(f.name))
print ' ]'
print(' ; Arr [litstr "%s"; sexp_of_%s(%s)]' %
(f.name, mlify(f.type), mlify(f.name)))
print(' ]')
else:
print ' Arr [litstr "%s"; litstr "%s"]' % (m.class_name, m.name)
print
print 'let method_name class_index method_index = match (class_index, method_index) with'
print(' Arr [litstr "%s"; litstr "%s"]' % (m.class_name, m.name))
print()
print('let method_name class_index method_index = match (class_index, method_index) with')
for m in methods:
print ' | (%d, %d) -> "%s"' % (m.class_index, m.index, ctor(m.full_name))
print ' | _ -> Printf.sprintf "unknown(%d/%d)" class_index method_index'
print
print 'let read_method class_index method_index input_buf = match (class_index, method_index) with'
print(' | (%d, %d) -> "%s"' % (m.class_index, m.index, ctor(m.full_name)))
print(' | _ -> Printf.sprintf "unknown(%d/%d)" class_index method_index')
print()
print('let read_method class_index method_index input_buf = match (class_index, method_index) with')
for m in methods:
print ' | (%d, %d) ->' % (m.class_index, m.index)
print(' | (%d, %d) ->' % (m.class_index, m.index))
bits_remaining = 0
for f in m.fields:
target = '_' if f.reserved else mlify(f.name)
if f.type == 'bit':
if bits_remaining < 1:
print ' let bit_buffer = read_octet input_buf in'
print(' let bit_buffer = read_octet input_buf in')
bits_remaining = 8
print ' let %s = (bit_buffer land %d) <> 0 in' % \
(target, 1 << (8 - bits_remaining))
print(' let %s = (bit_buffer land %d) <> 0 in' %
(target, 1 << (8 - bits_remaining)))
bits_remaining = bits_remaining - 1
else:
print ' let %s = read_%s input_buf in' % (target, mlify(f.type))
print ' Lwt.return (' + m.pattern() + ')'
print ' | _ -> raise_lwt (Amqp_exception (frame_error,'
print ' Printf.sprintf "Unknown method number %d/%d"'
print ' class_index method_index))'
print
print 'let method_index m = match m with'
print(' let %s = read_%s input_buf in' % (target, mlify(f.type)))
print(' Lwt.return (' + m.pattern() + ')')
print(' | _ -> raise_lwt (Amqp_exception (frame_error,')
print(' Printf.sprintf "Unknown method number %d/%d"')
print(' class_index method_index))')
print()
print('let method_index m = match m with')
for m in methods:
print m.match_clause + ' (%d, %d)' % (m.class_index, m.index)
print
print 'let write_method m output_buf = match m with'
print(m.match_clause + ' (%d, %d)' % (m.class_index, m.index))
print()
print('let write_method m output_buf = match m with')
for m in methods:
print m.match_clause
print(m.match_clause)
acc = BitAccumulator()
for f in m.fields:
source = 'reserved_value_'+mlify(f.type) if f.reserved else mlify(f.name)
@ -290,90 +288,90 @@ def print_codec():
acc.add('(if %s then %d else 0)' % (source, 1 << acc.count))
else:
acc.flush()
print ' write_%s output_buf %s;' % (mlify(f.type), source)
print(' write_%s output_buf %s;' % (mlify(f.type), source))
acc.flush()
print ' ()'
print
print 'let sexp_of_properties p = match p with '
print(' ()')
print()
print('let sexp_of_properties p = match p with ')
for c in classes:
if c.fields:
print c.match_clause
print ' let fields__ = [] in'
print(c.match_clause)
print(' let fields__ = [] in')
for f in reversed(c.accessible_fields):
print ' let fields__ = (match %s with Some v -> Arr [litstr "%s"; sexp_of_%s(v)] :: fields__ | None -> fields__) in' % \
(mlify(f.name), f.name, mlify(f.type))
print ' Arr fields__'
print
print 'let read_properties class_index input_buf = match class_index with'
print(' let fields__ = (match %s with Some v -> Arr [litstr "%s"; sexp_of_%s(v)] :: fields__ | None -> fields__) in' %
(mlify(f.name), f.name, mlify(f.type)))
print(' Arr fields__')
print()
print('let read_properties class_index input_buf = match class_index with')
for c in classes:
if c.fields:
print ' | %d ->' % (c.index,)
print ' let flags__ = read_short input_buf in'
print(' | %d ->' % (c.index,))
print(' let flags__ = read_short input_buf in')
property_bit = 15
for f in c.fields:
target = '_' if f.reserved else mlify(f.name)
if f.type == 'bit':
print ' let %s = if (flags__ land %d) <> 0 in' % \
(target, 1 << property_bit)
print(' let %s = if (flags__ land %d) <> 0 in' %
(target, 1 << property_bit))
else:
print (' let %s = if (flags__ land %d) <> 0 then '+
'Some (read_%s input_buf) else None in') % \
(target, 1 << property_bit, mlify(f.type))
print((' let %s = if (flags__ land %d) <> 0 then ' +
'Some (read_%s input_buf) else None in') %
(target, 1 << property_bit, mlify(f.type)))
property_bit = property_bit - 1
print ' Lwt.return (' + c.pattern() + ')'
print ' | _ -> raise_lwt (Amqp_exception (frame_error, Printf.sprintf "Unknown class number %d"'
print ' class_index))'
print
print 'let class_index p = match p with'
print(' Lwt.return (' + c.pattern() + ')')
print(' | _ -> raise_lwt (Amqp_exception (frame_error, Printf.sprintf "Unknown class number %d"')
print(' class_index))')
print()
print('let class_index p = match p with')
for c in classes:
if c.fields:
print c.match_clause + ' ' + str(c.index)
print
print 'let properties_of_sexp class_id ps_sexp = match class_id with'
print(c.match_clause + ' ' + str(c.index))
print()
print('let properties_of_sexp class_id ps_sexp = match class_id with')
for c in classes:
if c.fields:
print ' | %d ->' % (c.index,)
print(' | %d ->' % (c.index,))
for f in c.accessible_fields:
print ' let %s = ref None in' % (mlify(f.name),)
print ' (match ps_sexp with'
print ' | Arr ps ->'
print ' List.iter (fun (p) -> match p with'
print(' let %s = ref None in' % (mlify(f.name),))
print(' (match ps_sexp with')
print(' | Arr ps ->')
print(' List.iter (fun (p) -> match p with')
for f in c.accessible_fields:
print ' | Arr [Str k; v] when k = Bytes.of_string "%s" -> %s := Some (%s_of_sexp v)' % \
(f.name, mlify(f.name), mlify(f.type))
print ' | _ -> ()) ps'
print ' | _ -> ());'
print ' %s (%s)' % \
(ctor(c.full_name),
', '.join(('reserved_value_'+mlify(f.type) if f.reserved else '!'+mlify(f.name)
for f in c.fields)))
print ' | _ -> die internal_error (Printf.sprintf "Bad content class %d" class_id)'
print
print 'let write_properties p output_buf = match p with'
print(' | Arr [Str k; v] when k = Bytes.of_string "%s" -> %s := Some (%s_of_sexp v)' %
(f.name, mlify(f.name), mlify(f.type)))
print(' | _ -> ()) ps')
print(' | _ -> ());')
print(' %s (%s)' %
(ctor(c.full_name),
', '.join(('reserved_value_'+mlify(f.type) if f.reserved else '!'+mlify(f.name)
for f in c.fields))))
print(' | _ -> die internal_error (Printf.sprintf "Bad content class %d" class_id)')
print()
print('let write_properties p output_buf = match p with')
for c in classes:
if c.fields:
print c.match_clause
print ' let flags__ = 0'
print(c.match_clause)
print(' let flags__ = 0')
property_bit = 15
for f in c.fields:
if not f.reserved:
if f.type == 'bit':
print ' lor (if %s then %d else 0)' % \
(mlify(f.name), 1 << property_bit)
print(' lor (if %s then %d else 0)' %
(mlify(f.name), 1 << property_bit))
else:
print ' lor (match %s with Some _ -> %d | None -> 0)' % \
(mlify(f.name), 1 << property_bit)
print(' lor (match %s with Some _ -> %d | None -> 0)' %
(mlify(f.name), 1 << property_bit))
property_bit = property_bit - 1
print ' in'
print ' write_short output_buf flags__;'
print(' in')
print(' write_short output_buf flags__;')
for f in c.fields:
source = 'reserved_value_%s' if f.reserved else mlify(f.name)
if f.type != 'bit':
print (' (match %s with Some v_ -> write_%s output_buf v_'+
' | None -> ());') % \
(source, mlify(f.type))
print ' ()'
print
print((' (match %s with Some v_ -> write_%s output_buf v_' +
' | None -> ());') %
(source, mlify(f.type)))
print(' ()')
print()
if __name__ == '__main__':
print_codec()

View File

@ -15,8 +15,6 @@
## You should have received a copy of the GNU General Public License
## along with Hop. If not, see <http://www.gnu.org/licenses/>.
##
from __future__ import with_statement
import sys
try:
import json
@ -34,17 +32,17 @@ class MessageType:
self.selector = mlify(self.wire_selector)
self.constructor = self.selector.capitalize()
self.wire_argnames = j['args']
self.argnames = map(mlify, self.wire_argnames)
self.argnames = list(map(mlify, self.wire_argnames))
def format_args(self, template, separator = ', '):
return separator.join([template % (x,) for x in self.argnames])
with file("../protocol/messages.json") as f:
with open("../protocol/messages.json") as f:
raw_spec = json.load(f)
copyright_stmt = '(* %s *)' % (raw_spec['copyright'])
license = '\n'.join((('(* %s *)' % (x,) if x else '') for x in raw_spec['license']))
spec = map(MessageType, raw_spec['definitions'])
spec = list(map(MessageType, raw_spec['definitions']))
def print_list(o, xs, sep, c):
sys.stdout.write(o)
@ -58,47 +56,47 @@ def print_list(o, xs, sep, c):
sys.stdout.write(c)
def print_codec():
print copyright_stmt
print
print license
print
print '(* WARNING: Autogenerated code. Do not edit by hand! *)'
print
print 'open Sexp'
print
print 'type t ='
print(copyright_stmt)
print()
print(license)
print()
print('(* WARNING: Autogenerated code. Do not edit by hand! *)')
print()
print('open Sexp')
print()
print('type t =')
for t in spec:
if t.argnames:
print ' | %s of ' % (t.constructor),
print(' | %s of ' % (t.constructor),)
print_list('(', ['Sexp.t' for n in t.argnames], ' * ', ')\n')
else:
print ' | %s' % t.constructor
print ' | UNKNOWN of Sexp.t'
print
print 'let sexp_of_message m = match m with'
print(' | %s' % t.constructor)
print(' | UNKNOWN of Sexp.t')
print()
print('let sexp_of_message m = match m with')
for t in spec:
sys.stdout.write(' | %s' % t.constructor)
if t.argnames:
print_list(' (', [n for n in t.argnames], ', ', ')')
print ' ->'
print(' ->')
sys.stdout.write(' Arr [Sexp.litstr "%s"' % t.wire_selector)
if t.argnames:
print_list('; ', t.argnames, '; ', '')
print ']'
print ' | UNKNOWN s -> s'
print
print 'let message_of_sexp s = match s with'
print(']')
print(' | UNKNOWN s -> s')
print()
print('let message_of_sexp s = match s with')
for t in spec:
sys.stdout.write(' | Arr [Str label_bs')
if t.argnames:
print_list('; ', t.argnames, '; ', '')
print ('] when label_bs = Bytes.of_string "%s" ->' % t.wire_selector)
print(('] when label_bs = Bytes.of_string "%s" ->' % t.wire_selector))
sys.stdout.write(' %s' % t.constructor)
if t.argnames:
print_list(' (', [n for n in t.argnames], ', ', ')')
print
print ' | _ -> UNKNOWN s'
print
print()
print(' | _ -> UNKNOWN s')
print()
for t in spec:
sys.stdout.write('let %s' % t.selector)
if t.argnames:
@ -107,7 +105,7 @@ def print_codec():
if t.argnames:
print_list(' (', t.argnames, ', ', ')')
sys.stdout.write(')\n')
print
print()
if __name__ == '__main__':
print_codec()