[edid-decode] build: add support for building with meson

Message ID 20240215120637.1559408-2-sebastian.wick@redhat.com (mailing list archive)
State Changes Requested
Delegated to: Hans Verkuil
Headers
Series [edid-decode] build: add support for building with meson |

Commit Message

Sebastian Wick Feb. 15, 2024, 12:06 p.m. UTC
  The immediate reason for adding support for meson is that this allows us
to include edid-decode as a subproject in libdisplay-info.

Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
---
 emscripten/wasm-crossfile.txt | 14 ++++++++
 meson.build                   | 61 +++++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 100644 emscripten/wasm-crossfile.txt
 create mode 100644 meson.build
  

Comments

Hans Verkuil March 5, 2024, 10:54 a.m. UTC | #1
Hi Sebastian,

On 15/02/2024 1:06 pm, Sebastian Wick wrote:
> The immediate reason for adding support for meson is that this allows us
> to include edid-decode as a subproject in libdisplay-info.

Thank you for your patch, and apologies for me taking so long to review it.

I think this patch needs a bit more work. Mainly since I want this to replace
the old Makefile since there is no point in maintaining two build systems.

That means that besides removing the Makefile you also need to update the
README. That should also explain how to build the emscripten part. To be
honest, I don't know what the magic meson incantation is for that, so
this documentation is really needed.

Also one minor nit: instead of writing '[edid-decode]' in the Subject line,
just write 'edid-decode:'.

Regards,

	Hans

> 
> Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
> ---
>  emscripten/wasm-crossfile.txt | 14 ++++++++
>  meson.build                   | 61 +++++++++++++++++++++++++++++++++++
>  2 files changed, 75 insertions(+)
>  create mode 100644 emscripten/wasm-crossfile.txt
>  create mode 100644 meson.build
> 
> diff --git a/emscripten/wasm-crossfile.txt b/emscripten/wasm-crossfile.txt
> new file mode 100644
> index 0000000..a41f46c
> --- /dev/null
> +++ b/emscripten/wasm-crossfile.txt
> @@ -0,0 +1,14 @@
> +[binaries]
> +c = '/usr/lib/emscripten/emcc'
> +cpp = '/usr/lib/emscripten/em++'
> +ar = '/usr/lib/emscripten/emar'
> +strip = '/usr/lib/emscripten/emstrip'
> +
> +[built-in options]
> +default_library = 'static'
> +
> +[host_machine]
> +system = 'emscripten'
> +cpu_family = 'wasm32'
> +cpu = 'wasm32'
> +endian = 'little'
> \ No newline at end of file
> diff --git a/meson.build b/meson.build
> new file mode 100644
> index 0000000..cda12de
> --- /dev/null
> +++ b/meson.build
> @@ -0,0 +1,61 @@
> +project(
> +	'edid-decode',
> +	'cpp',
> +)
> +
> +edid_decode_args = [
> +	'-Wno-missing-field-initializers',
> +	'-Wno-unused-parameter',
> +	'-Wimplicit-fallthrough',
> +]
> +edid_decode_link_args = []
> +
> +git = find_program('git', native: true, required: false)
> +if git.found()
> +	git_commit = run_command(
> +		[git, 'rev-parse', '--short=12', 'HEAD'],
> +		check: false,
> +	)
> +	git_date = run_command(
> +		[git, 'show', '--quiet', '--date=format-local:%F %T', '--format=%cd'],
> +		env: {'TZ': 'UTC'},
> +		check: false,
> +	)
> +
> +	if git_commit.returncode() == 0
> +		edid_decode_args += ['-DSHA=' + git_commit.stdout().strip()]
> +	endif
> +	if git_date.returncode() == 0
> +		edid_decode_args += ['-DDATE=' + git_date.stdout().strip()]
> +	endif
> +endif
> +
> +if target_machine.system() == 'emscripten'
> +	edid_decode_link_args += [
> +		'-sEXPORTED_FUNCTIONS=_parse_edid',
> +		'-sEXPORTED_RUNTIME_METHODS=ccall,cwrap'
> +	]
> +
> +	fs = import('fs')
> +	foreach filename : ['edid-decode.html', 'edid-decode.ico']
> +		fs.copyfile('emscripten' / filename)
> +	endforeach
> +endif
> +
> +executable(
> +	'edid-decode',
> +	'calc-gtf-cvt.cpp',
> +	'calc-ovt.cpp',
> +	'edid-decode.cpp',
> +	'parse-base-block.cpp',
> +	'parse-cta-block.cpp',
> +	'parse-di-ext-block.cpp',
> +	'parse-displayid-block.cpp',
> +	'parse-ls-ext-block.cpp',
> +	'parse-vtb-ext-block.cpp',
> +	cpp_args : edid_decode_args,
> +	link_args: edid_decode_link_args,
> +	install : true,
> +)
> +
> +install_man('edid-decode.1')
> \ No newline at end of file
  

Patch

diff --git a/emscripten/wasm-crossfile.txt b/emscripten/wasm-crossfile.txt
new file mode 100644
index 0000000..a41f46c
--- /dev/null
+++ b/emscripten/wasm-crossfile.txt
@@ -0,0 +1,14 @@ 
+[binaries]
+c = '/usr/lib/emscripten/emcc'
+cpp = '/usr/lib/emscripten/em++'
+ar = '/usr/lib/emscripten/emar'
+strip = '/usr/lib/emscripten/emstrip'
+
+[built-in options]
+default_library = 'static'
+
+[host_machine]
+system = 'emscripten'
+cpu_family = 'wasm32'
+cpu = 'wasm32'
+endian = 'little'
\ No newline at end of file
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..cda12de
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,61 @@ 
+project(
+	'edid-decode',
+	'cpp',
+)
+
+edid_decode_args = [
+	'-Wno-missing-field-initializers',
+	'-Wno-unused-parameter',
+	'-Wimplicit-fallthrough',
+]
+edid_decode_link_args = []
+
+git = find_program('git', native: true, required: false)
+if git.found()
+	git_commit = run_command(
+		[git, 'rev-parse', '--short=12', 'HEAD'],
+		check: false,
+	)
+	git_date = run_command(
+		[git, 'show', '--quiet', '--date=format-local:%F %T', '--format=%cd'],
+		env: {'TZ': 'UTC'},
+		check: false,
+	)
+
+	if git_commit.returncode() == 0
+		edid_decode_args += ['-DSHA=' + git_commit.stdout().strip()]
+	endif
+	if git_date.returncode() == 0
+		edid_decode_args += ['-DDATE=' + git_date.stdout().strip()]
+	endif
+endif
+
+if target_machine.system() == 'emscripten'
+	edid_decode_link_args += [
+		'-sEXPORTED_FUNCTIONS=_parse_edid',
+		'-sEXPORTED_RUNTIME_METHODS=ccall,cwrap'
+	]
+
+	fs = import('fs')
+	foreach filename : ['edid-decode.html', 'edid-decode.ico']
+		fs.copyfile('emscripten' / filename)
+	endforeach
+endif
+
+executable(
+	'edid-decode',
+	'calc-gtf-cvt.cpp',
+	'calc-ovt.cpp',
+	'edid-decode.cpp',
+	'parse-base-block.cpp',
+	'parse-cta-block.cpp',
+	'parse-di-ext-block.cpp',
+	'parse-displayid-block.cpp',
+	'parse-ls-ext-block.cpp',
+	'parse-vtb-ext-block.cpp',
+	cpp_args : edid_decode_args,
+	link_args: edid_decode_link_args,
+	install : true,
+)
+
+install_man('edid-decode.1')
\ No newline at end of file