summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Heijligen <thomas.heijligen@secunet.com>2023-05-15 21:48:38 +0200
committerAnastasia Klimchuk <aklm@chromium.org>2023-07-13 09:29:14 +0000
commit81c3f31f90b33c993c106d4c0addabd4d2fdfe7a (patch)
tree022ef1e3b3af7d3b3f83ca2decefbde39080f39f
parent7538b74a11a81afb352b78a829badf4673afd4ae (diff)
downloadflashrom-81c3f31f90b33c993c106d4c0addabd4d2fdfe7a.tar.gz
flashrom-81c3f31f90b33c993c106d4c0addabd4d2fdfe7a.tar.bz2
flashrom-81c3f31f90b33c993c106d4c0addabd4d2fdfe7a.zip
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>
-rw-r--r--meson.build34
-rw-r--r--meson_options.txt4
-rw-r--r--ni845x_spi.c7
3 files changed, 44 insertions, 1 deletions
diff --git a/meson.build b/meson.build
index 18359db9a..9428e08ef 100644
--- a/meson.build
+++ b/meson.build
@@ -12,6 +12,8 @@ project('flashromutils', 'c',
],
)
+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 @@ libusb1 = dependency('libusb-1.0', required : group_usb)
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 @@ programmer = {
'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 732d8d52e..e62deb6ee 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -13,10 +13,12 @@ option('programmer', type : 'array', value : ['auto'], choices : [
'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 d4ae294c1..6e7bb769c 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>