From 539651609cf82ab8e05cac636aee997e831b4d29 Mon Sep 17 00:00:00 2001
From: "William D. Jones" <thor0505@comcast.net>
Date: Sat, 27 Jun 2020 17:08:11 -0400
Subject: Update machxo2 backend with minimal build system changes so nextpnr
 compiles again.

---
 machxo2/facade_import.py |  5 +++++
 machxo2/family.cmake     | 11 ++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/machxo2/facade_import.py b/machxo2/facade_import.py
index dd21a698..d21557ae 100644
--- a/machxo2/facade_import.py
+++ b/machxo2/facade_import.py
@@ -70,9 +70,14 @@ def main():
 
     pytrellis.load_database(database.get_db_root())
 
+    # Dummy
+    dev_name = "1200"
+
     bba = BinaryBlobAssembler()
     bba.pre('#include "nextpnr.h"')
+    bba.pre('#include "embed.h"')
     bba.pre('NEXTPNR_NAMESPACE_BEGIN')
+    bba.post('EmbeddedFile chipdb_file_%s("machxo2/chipdb-%s.bin", chipdb_blob_%s);' % (dev_name, dev_name, dev_name))
     bba.post('NEXTPNR_NAMESPACE_END')
     bba.push("chipdb_blob_%s" % args.device)
     bba.u8(0, None)
diff --git a/machxo2/family.cmake b/machxo2/family.cmake
index 0c829d55..f19ebc70 100644
--- a/machxo2/family.cmake
+++ b/machxo2/family.cmake
@@ -33,9 +33,14 @@ foreach(device ${MACHXO2_DEVICES})
     endif()
 endforeach()
 if(WIN32)
-    list(APPEND chipdb_sources
-        ${CMAKE_CURRENT_SOURCE_DIR}/${family}/resource/embed.cc
-        ${CMAKE_CURRENT_SOURCE_DIR}/${family}/resource/chipdb.rc)
+    set(chipdb_rc ${CMAKE_CURRENT_BINARY_DIR}/${family}/resource/chipdb.rc)
+    list(APPEND chipdb_sources ${chipdb_rc})
+
+    file(WRITE ${chipdb_rc})
+    foreach(device ${MACHXO2_DEVICES})
+        file(APPEND ${chipdb_rc}
+             "${family}/chipdb-${device}.bin RCDATA \"${CMAKE_CURRENT_BINARY_DIR}/${family}/chipdb/chipdb-${device}.bin\"")
+    endforeach()
 endif()
 
 add_custom_target(chipdb-${family}-bins DEPENDS ${chipdb_sources} ${chipdb_binaries})
-- 
cgit v1.2.3