Anastasia Klimchuk submitted this change.
meson: Add support for ni845x_spi on Windows
TEST=On MSYS32 MINGW32 with ni845x library installed:
meson setup -Dprogrammer=ni845x_spi build
meson compile -C build
./build/flashrom.exe lists the ni845x_spi as choice.
Without ni845x library installed but ni845x_spi disabled,
build succeeds on all platforms.
Change-Id: I2d32f11852ac1a5184af8e8683ca1914a6e72973
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Signed-off-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/75236
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
---
M meson.build
M meson_options.txt
M ni845x_spi.c
3 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
index 18359db..9428e08 100644
--- a/meson.build
+++ b/meson.build
@@ -12,6 +12,8 @@
],
)
+fs = import('fs')
+
if get_option('classic_cli').enabled() and get_option('default_library') == 'shared'
error('''
Cannot build cli_classic with shared libflashrom. Use \'-Dclassic_cli=disabled\' to disable the cli,
@@ -149,6 +151,30 @@
libftdi1 = dependency('libftdi1', required : group_ftdi)
libjaylink = dependency('libjaylink', required : group_jlink, version : '>=0.3.0')
+if host_machine.system() == 'windows'
+ # Specifying an include_path that doesn't exist is an error,
+ # but we only use this if the library is found in the same directory.
+ ni845x_search_path = get_option('ni845x_search_path')
+ if fs.is_dir(ni845x_search_path)
+ ni845x_include_path = [ni845x_search_path]
+ else
+ ni845x_include_path = []
+ endif
+
+ libni845x = declare_dependency(
+ dependencies : [
+ cc.find_library(
+ 'ni845x',
+ dirs : get_option('ni845x_search_path'),
+ required : get_option('programmer').contains('ni845x_spi')
+ ),
+ ],
+ include_directories : ni845x_include_path,
+ )
+else
+ libni845x = dependency('', required : false)
+endif
+
subdir('platform')
if systems_hwaccess.contains(host_machine.system())
@@ -369,6 +395,14 @@
'flags' : [ '-DCONFIG_MSTARDDC_SPI=1' ],
'default' : false
},
+ 'ni845x_spi' : {
+ 'systems' : [ 'windows' ],
+ 'cpu_families' : [ 'x86' ], # The required ni845x library is 32-bit only
+ 'deps' : [ libni845x ],
+ 'srcs' : files('ni845x_spi.c'),
+ 'flags' : [ '-DCONFIG_NI845X_SPI=1' ],
+ 'default' : false,
+ },
'nic3com' : {
'systems' : systems_hwaccess,
'cpu_families' : cpus_port_io,
diff --git a/meson_options.txt b/meson_options.txt
index 732d8d52..e62deb6 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -13,10 +13,12 @@
'asm106x', 'atahpt', 'atapromise', 'atavia', 'buspirate_spi', 'ch341a_spi', 'ch347_spi','dediprog',
'developerbox_spi', 'digilent_spi', 'dirtyjtag_spi', 'drkaiser', 'dummy', 'ft2232_spi',
'gfxnvidia', 'internal', 'it8212', 'jlink_spi', 'linux_mtd', 'linux_spi', 'mediatek_i2c_spi',
- 'mstarddc_spi', 'nic3com', 'nicintel', 'nicintel_eeprom', 'nicintel_spi', 'nicnatsemi',
+ 'mstarddc_spi', 'ni845x_spi', 'nic3com', 'nicintel', 'nicintel_eeprom', 'nicintel_spi', 'nicnatsemi',
'nicrealtek', 'ogp_spi', 'parade_lspcon', 'pickit2_spi', 'pony_spi', 'raiden_debug_spi',
'rayer_spi', 'realtek_mst_i2c_spi', 'satamv', 'satasii', 'serprog', 'stlinkv3_spi', 'usbblaster_spi',
], description: 'Active programmers')
option('llvm_cov', type : 'feature', value : 'disabled', description : 'build for llvm code coverage')
option('man-pages', type : 'feature', value : 'auto', description : 'build the man-page for classic_cli')
option('documentation', type : 'feature', value : 'auto', description : 'build the html documentation')
+option('ni845x_search_path', type : 'string', value : 'C:\Program Files (x86)\National Instruments\Ni-845x\MS Visual C',
+ description : 'Path to search for the proprietary ni845x library and header (32-bit Windows only)')
diff --git a/ni845x_spi.c b/ni845x_spi.c
index d4ae294..6e7bb76 100644
--- a/ni845x_spi.c
+++ b/ni845x_spi.c
@@ -15,6 +15,13 @@
*
*/
+/* The ni845x header does need the WIN32 symbol to be defined and meson does not do it.
+ * Define it just here, since this driver will only work on 32-bit Windows.
+ */
+#ifndef WIN32
+#define WIN32
+#endif
+
#include <ctype.h>
#include <inttypes.h>
#include <string.h>
To view, visit change 75236. To unsubscribe, or for help writing mail filters, visit settings.