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; GCC_PREFIX_HEADER = hopOsx_Prefix.pch;
INFOPLIST_FILE = "hopOsx-Info.plist"; INFOPLIST_FILE = "hopOsx-Info.plist";
INSTALL_PATH = "$(HOME)/Applications"; INSTALL_PATH = "$(HOME)/Applications";
MACOSX_DEPLOYMENT_TARGET = 10.13;
PRODUCT_NAME = "Hop Server"; PRODUCT_NAME = "Hop Server";
}; };
name = Debug; name = Debug;
@ -255,6 +256,7 @@
GCC_PREFIX_HEADER = hopOsx_Prefix.pch; GCC_PREFIX_HEADER = hopOsx_Prefix.pch;
INFOPLIST_FILE = "hopOsx-Info.plist"; INFOPLIST_FILE = "hopOsx-Info.plist";
INSTALL_PATH = "$(HOME)/Applications"; INSTALL_PATH = "$(HOME)/Applications";
MACOSX_DEPLOYMENT_TARGET = 10.13;
PRODUCT_NAME = "Hop Server"; PRODUCT_NAME = "Hop Server";
}; };
name = Release; name = Release;
@ -262,26 +264,28 @@
C01FCF4F08A954540054247B /* Debug */ = { C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; ARCHS = "$(ARCHS_STANDARD)";
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO; PREBINDING = NO;
SDKROOT = macosx10.6; SDKROOT = macosx14.4;
}; };
name = Debug; name = Debug;
}; };
C01FCF5008A954540054247B /* Release */ = { C01FCF5008A954540054247B /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; ARCHS = "$(ARCHS_STANDARD)";
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
PREBINDING = NO; PREBINDING = NO;
SDKROOT = macosx10.6; SDKROOT = macosx14.4;
}; };
name = Release; 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 $< > $@ xsltproc web/bootstrap/template.xsl $< > $@
message.ml: ../protocol/messages.json codegen.py message.ml: ../protocol/messages.json codegen.py
python codegen.py > $@ python3 codegen.py > $@
amqp_spec.ml: amqp0-9-1.stripped.xml amqp_codegen.py amqp_spec.ml: amqp0-9-1.stripped.xml amqp_codegen.py
python amqp_codegen.py > $@ python3 amqp_codegen.py > $@
webclean: webclean:
rm -f $(HTML) rm -f $(HTML)

View File

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

View File

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