+++ /dev/null
-/*
- * Copyright © 2015 Collabora, Ltd.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial
- * portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/*
- * Avoid executable stack.
- * from: https://wiki.gentoo.org/wiki/Hardened/GNU_stack_quickstart
- */
-#if defined(__linux__) && defined(__ELF__)
-.section .note.GNU-stack,"",%progbits
-#endif
-
-/* from: http://www.linuxjournal.com/content/embedding-file-executable-aka-hello-world-version-5967#comment-348129 */
-
-.macro binfile name file
- .p2align 2
- .globl \name\()_begin
-\name\()_begin:
- .incbin "\file"
-\name\()_end:
- .byte 0
- .p2align 2
- .globl \name\()_len
-\name\()_len:
- .int (\name\()_end - \name\()_begin)
-.endm
-
-.section .rodata
-binfile DTD_DATA src/wayland.dtd.embed
--- /dev/null
+#!/usr/bin/env python3
+
+"""
+Simple C data embedder
+
+License: MIT
+
+Copyright (c) 2020 Simon Ser
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+"""
+
+import sys
+
+if len(sys.argv) != 3:
+ print('usage: ' + sys.argv[0] + ' <filename> <ident>', file=sys.stderr)
+ sys.exit(1)
+
+filename = sys.argv[1]
+ident = sys.argv[2]
+
+with open(filename, 'rb') as f:
+ buf = f.read()
+
+print('static const char ' + ident + '[] = {\n\t', end='')
+for i in range(len(buf)):
+ ch = buf[i:i+1]
+ print('0x' + ch.hex() + ', ', end='')
+print('\n};')
scanner_args += '-DHAVE_LIBXML=1'
endif
- configure_file(
+ prog_embed = find_program('embed.py', native: true)
+
+ embed_dtd = custom_target(
+ 'wayland.dtd.h',
input: '../protocol/wayland.dtd',
- output: 'wayland.dtd.embed',
- copy: true
+ output: 'wayland.dtd.h',
+ command: [ prog_embed, '@INPUT@', 'wayland_dtd' ],
+ capture: true
)
- wayland_scanner_sources = [ 'scanner.c', 'dtddata.S' ]
+ wayland_scanner_sources = [ 'scanner.c', embed_dtd ]
wayland_scanner_includes = [ root_inc, protocol_inc ]
wayland_scanner = executable(
#if HAVE_LIBXML
#include <libxml/parser.h>
-/* Embedded wayland.dtd file, see dtddata.S */
-extern char DTD_DATA_begin;
-extern int DTD_DATA_len;
+/* Embedded wayland.dtd file */
+/* static const char wayland_dtd[]; wayland.dtd */
+#include "wayland.dtd.h"
#endif
/* Expat must be included after libxml as both want to declare XMLCALL; see
if (!ctx || !dtdctx)
abort();
- buffer = xmlParserInputBufferCreateMem(&DTD_DATA_begin,
- DTD_DATA_len,
+ buffer = xmlParserInputBufferCreateMem(wayland_dtd,
+ sizeof(wayland_dtd),
XML_CHAR_ENCODING_UTF8);
if (!buffer) {
fprintf(stderr, "Failed to init buffer for DTD.\n");