Add script to help porting from nordic sdk releases
The required file list is maintained in required_files.txt which is parsed to find a list of filenames. The script searches for these filenames in the sdk folder, and copy then into the yotta module with folder structure intact. extraIncludes is automatically added to module.json
This commit is contained in:
parent
e68b1f8c39
commit
c557bae00b
2 changed files with 222 additions and 0 deletions
105
script/pick_nrf51_files.py
Executable file
105
script/pick_nrf51_files.py
Executable file
|
@ -0,0 +1,105 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os, shutil, json, pprint, sys
|
||||
from collections import OrderedDict
|
||||
|
||||
help_text = "Usage: python {} <full-noridc-sdk-path> <nrf51-sdk-yotta-module-path>".format(os.path.basename(__file__))
|
||||
|
||||
# exclude path to avoid confusion over files of the same name
|
||||
exclude_path = ["examples", "SVD", "s110", "s120", "s210", "nrf_soc_nosd", "serialization/connectivity",
|
||||
'components/libraries/hci/config', 'components/libraries/bootloader_dfu/ble_transport']
|
||||
|
||||
if __name__ == "__main__":
|
||||
# define source and destination of copy
|
||||
arg_valid = True
|
||||
if len(sys.argv) != 3:
|
||||
arg_valid = False
|
||||
else:
|
||||
src_folder = sys.argv[1]
|
||||
yt_module_dir = sys.argv[2]
|
||||
|
||||
for d in [src_folder, yt_module_dir]:
|
||||
if not os.path.isdir(d):
|
||||
arg_valid = False
|
||||
print src_folder, "is not a folder"
|
||||
|
||||
if not arg_valid:
|
||||
print help_text
|
||||
sys.exit(1)
|
||||
|
||||
dst_folder = os.path.join(yt_module_dir, "source/nordic_sdk")
|
||||
|
||||
# build a file_list from required_files.txt
|
||||
file_list = []
|
||||
with open("required_files.txt", "r") as fd:
|
||||
for line in fd:
|
||||
if not line.strip().startswith("#") and line.strip() != '':
|
||||
file_list.append(os.path.basename(line).strip())
|
||||
|
||||
def find(name, path):
|
||||
paths = []
|
||||
for root, dirs, files in os.walk(path):
|
||||
if True not in [x in root for x in exclude_path]:
|
||||
if isinstance(name, list):
|
||||
for nm in [x for x in name if x in files]:
|
||||
paths.append(os.path.join(root, nm))
|
||||
elif name in files:
|
||||
paths.append(os.path.join(root, name))
|
||||
|
||||
if len(paths) == 0:
|
||||
print "-"*30
|
||||
print "Warning! No {} found!!!!".format(name)
|
||||
print "-"*30
|
||||
return None
|
||||
elif len(paths) > 1:
|
||||
print "-"*30
|
||||
print "Warning! More than one {} found!!!!".format(name)
|
||||
print paths
|
||||
print "-"*30
|
||||
return None
|
||||
else:
|
||||
return paths[0]
|
||||
|
||||
# remove everything from the destination folder
|
||||
if os.path.exists(dst_folder):
|
||||
shutil.rmtree(dst_folder)
|
||||
|
||||
# find files and copy them
|
||||
extra_includes = []
|
||||
for fn in file_list:
|
||||
src = find(fn, src_folder)
|
||||
if src:
|
||||
rel_dst = os.path.relpath(src, src_folder)
|
||||
dst = os.path.join(dst_folder, rel_dst)
|
||||
print src, "->", dst
|
||||
#print dst
|
||||
directory = os.path.dirname(dst)
|
||||
if not os.path.exists(directory):
|
||||
os.makedirs(directory)
|
||||
if not os.path.isfile(dst):
|
||||
pass
|
||||
shutil.copyfile(src, dst)
|
||||
|
||||
# build a list of extra includes to be added to module.json
|
||||
if dst.endswith(".h"):
|
||||
inc_rel_path = os.path.relpath(dst, yt_module_dir)
|
||||
inc_dir_path = os.path.dirname(inc_rel_path)
|
||||
if inc_dir_path not in extra_includes:
|
||||
extra_includes.append(inc_dir_path)
|
||||
|
||||
# write extraIncludes in the module.json file
|
||||
mod_json = os.path.join(yt_module_dir, "module.json")
|
||||
print "-"*30
|
||||
print "Writing extra_includes to {}".format(mod_json)
|
||||
print "-"*30
|
||||
for n in sorted(extra_includes):
|
||||
print n
|
||||
|
||||
with open(mod_json, 'r+') as fd:
|
||||
jobj = json.loads(fd.read(), object_pairs_hook=OrderedDict)
|
||||
jobj['extraIncludes'] = sorted(extra_includes)
|
||||
jdump = json.dumps(jobj, indent=2, separators=(',', ': '))
|
||||
fd.seek(0)
|
||||
fd.write(jdump)
|
||||
fd.write("\n")
|
||||
fd.truncate()
|
117
script/required_files.txt
Normal file
117
script/required_files.txt
Normal file
|
@ -0,0 +1,117 @@
|
|||
# from cmsis-core-nrf51822:
|
||||
cmsis-core-nrf51822/compiler_abstraction.h
|
||||
cmsis-core-nrf51822/nrf.h
|
||||
cmsis-core-nrf51822/nrf51.h
|
||||
cmsis-core-nrf51822/nrf51_bitfields.h
|
||||
cmsis-core-nrf51822/nrf_delay.h
|
||||
cmsis-core-nrf51822/system_nrf51.h
|
||||
source/system_nrf51.c
|
||||
|
||||
# from ble-nrf51822
|
||||
source/nordic-sdk/components/ble/ble_radio_notification/ble_radio_notification.c
|
||||
source/nordic-sdk/components/ble/ble_radio_notification/ble_radio_notification.h
|
||||
source/nordic-sdk/components/ble/ble_services/ble_dfu/ble_dfu.c
|
||||
source/nordic-sdk/components/ble/ble_services/ble_dfu/ble_dfu.h
|
||||
source/nordic-sdk/components/ble/common/ble_advdata.c
|
||||
source/nordic-sdk/components/ble/common/ble_advdata.h
|
||||
source/nordic-sdk/components/ble/common/ble_advdata_parser.c
|
||||
source/nordic-sdk/components/ble/common/ble_advdata_parser.h
|
||||
# source/nordic-sdk/components/ble/common/ble_conn_params.cpp the file is called
|
||||
source/nordic-sdk/components/ble/common/ble_conn_params.c
|
||||
source/nordic-sdk/components/ble/common/ble_conn_params.h
|
||||
source/nordic-sdk/components/ble/common/ble_date_time.h
|
||||
source/nordic-sdk/components/ble/common/ble_sensor_location.h
|
||||
source/nordic-sdk/components/ble/common/ble_srv_common.c
|
||||
source/nordic-sdk/components/ble/common/ble_srv_common.h
|
||||
source/nordic-sdk/components/ble/device_manager/config/device_manager_cnfg.h
|
||||
source/nordic-sdk/components/ble/device_manager/device_manager.h
|
||||
source/nordic-sdk/components/ble/device_manager/device_manager_peripheral.c
|
||||
source/nordic-sdk/components/drivers_nrf/ble_flash/ble_flash.c
|
||||
source/nordic-sdk/components/drivers_nrf/ble_flash/ble_flash.h
|
||||
source/nordic-sdk/components/drivers_nrf/hal/compiler_abstraction.h
|
||||
source/nordic-sdk/components/drivers_nrf/hal/nrf.h
|
||||
source/nordic-sdk/components/drivers_nrf/hal/nrf51.h
|
||||
source/nordic-sdk/components/drivers_nrf/hal/nrf51_bitfields.h
|
||||
source/nordic-sdk/components/drivers_nrf/hal/nrf51_deprecated.h
|
||||
source/nordic-sdk/components/drivers_nrf/hal/nrf_delay.c
|
||||
source/nordic-sdk/components/drivers_nrf/hal/nrf_ecb.c
|
||||
source/nordic-sdk/components/drivers_nrf/hal/nrf_ecb.h
|
||||
source/nordic-sdk/components/drivers_nrf/hal/nrf_gpio.h
|
||||
source/nordic-sdk/components/drivers_nrf/hal/nrf_gpiote.h
|
||||
source/nordic-sdk/components/drivers_nrf/hal/nrf_nvmc.c
|
||||
source/nordic-sdk/components/drivers_nrf/hal/nrf_nvmc.h
|
||||
source/nordic-sdk/components/drivers_nrf/hal/nrf_temp.h
|
||||
source/nordic-sdk/components/drivers_nrf/pstorage/config/pstorage_platform.h
|
||||
source/nordic-sdk/components/drivers_nrf/pstorage/pstorage.c
|
||||
source/nordic-sdk/components/drivers_nrf/pstorage/pstorage.h
|
||||
source/nordic-sdk/components/libraries/bootloader_dfu/bootloader.h
|
||||
source/nordic-sdk/components/libraries/bootloader_dfu/bootloader_types.h
|
||||
source/nordic-sdk/components/libraries/bootloader_dfu/bootloader_util.h
|
||||
# source/nordic-sdk/components/libraries/bootloader_dfu/bootloader_util_arm.c new file is called:
|
||||
source/nordic-sdk/components/libraries/bootloader_dfu/bootloader_util.c
|
||||
source/nordic-sdk/components/libraries/bootloader_dfu/dfu.h
|
||||
source/nordic-sdk/components/libraries/bootloader_dfu/dfu_bank_internal.h
|
||||
source/nordic-sdk/components/libraries/bootloader_dfu/dfu_ble_svc.h
|
||||
source/nordic-sdk/components/libraries/bootloader_dfu/dfu_ble_svc_internal.h
|
||||
source/nordic-sdk/components/libraries/bootloader_dfu/dfu_init.h
|
||||
source/nordic-sdk/components/libraries/bootloader_dfu/dfu_init_template.c
|
||||
source/nordic-sdk/components/libraries/bootloader_dfu/dfu_transport.h
|
||||
source/nordic-sdk/components/libraries/bootloader_dfu/dfu_types.h
|
||||
source/nordic-sdk/components/libraries/bootloader_dfu/experimental/dfu_app_handler.c
|
||||
source/nordic-sdk/components/libraries/bootloader_dfu/experimental/dfu_app_handler.h
|
||||
source/nordic-sdk/components/libraries/bootloader_dfu/hci_transport/hci_mem_pool_internal.h
|
||||
source/nordic-sdk/components/libraries/crc16/crc16.c
|
||||
source/nordic-sdk/components/libraries/hci/hci_mem_pool.c
|
||||
source/nordic-sdk/components/libraries/hci/hci_mem_pool.h
|
||||
source/nordic-sdk/components/libraries/scheduler/app_scheduler.c
|
||||
source/nordic-sdk/components/libraries/util/app_error.c
|
||||
source/nordic-sdk/components/libraries/util/app_util_platform.c
|
||||
source/nordic-sdk/components/libraries/util/app_util_platform.h
|
||||
source/nordic-sdk/components/libraries/util/common.h
|
||||
source/nordic-sdk/components/libraries/util/nordic_common.h
|
||||
source/nordic-sdk/components/libraries/util/nrf_assert.c
|
||||
source/nordic-sdk/components/libraries/util/nrf_assert.h
|
||||
source/nordic-sdk/components/libraries/util/sdk_common.h
|
||||
source/nordic-sdk/components/libraries/util/sdk_errors.h
|
||||
source/nordic-sdk/components/libraries/util/sdk_os.h
|
||||
source/nordic-sdk/components/softdevice/common/softdevice_handler/ant_stack_handler_types.h
|
||||
source/nordic-sdk/components/softdevice/common/softdevice_handler/ble_stack_handler_types.h
|
||||
source/nordic-sdk/components/softdevice/common/softdevice_handler/softdevice_handler.c
|
||||
source/nordic-sdk/components/softdevice/common/softdevice_handler/softdevice_handler.h
|
||||
source/nordic-sdk/components/softdevice/common/softdevice_handler/softdevice_handler_appsh.c
|
||||
source/nordic-sdk/components/softdevice/common/softdevice_handler/softdevice_handler_appsh.h
|
||||
# source/nordic-sdk/components/softdevice/s130/doc/ble_api.dox uncertain of the origin of this file
|
||||
source/nordic-sdk/components/softdevice/s130/include/ble.h
|
||||
source/nordic-sdk/components/softdevice/s130/include/ble_err.h
|
||||
source/nordic-sdk/components/softdevice/s130/include/ble_gap.h
|
||||
source/nordic-sdk/components/softdevice/s130/include/ble_gatt.h
|
||||
source/nordic-sdk/components/softdevice/s130/include/ble_gattc.h
|
||||
source/nordic-sdk/components/softdevice/s130/include/ble_gatts.h
|
||||
source/nordic-sdk/components/softdevice/s130/include/ble_hci.h
|
||||
source/nordic-sdk/components/softdevice/s130/include/ble_l2cap.h
|
||||
source/nordic-sdk/components/softdevice/s130/include/ble_ranges.h
|
||||
source/nordic-sdk/components/softdevice/s130/include/ble_types.h
|
||||
source/nordic-sdk/components/softdevice/s130/include/nrf_error.h
|
||||
source/nordic-sdk/components/softdevice/s130/include/nrf_error_sdm.h
|
||||
source/nordic-sdk/components/softdevice/s130/include/nrf_error_soc.h
|
||||
source/nordic-sdk/components/softdevice/s130/include/nrf_mbr.h
|
||||
source/nordic-sdk/components/softdevice/s130/include/nrf_sdm.h
|
||||
source/nordic-sdk/components/softdevice/s130/include/nrf_soc.h
|
||||
source/nordic-sdk/components/softdevice/s130/include/nrf_svc.h
|
||||
source/nordic-sdk/components/softdevice/s130/include/softdevice_assert.h
|
||||
|
||||
|
||||
# from mbed-hal-nrf51822-mcu
|
||||
mbed-hal-nrf51822-mcu/lib/nordic_sdk/components/libraries/crc16/crc16.h
|
||||
mbed-hal-nrf51822-mcu/lib/nordic_sdk/components/libraries/scheduler/app_scheduler.h
|
||||
mbed-hal-nrf51822-mcu/lib/nordic_sdk/components/libraries/util/app_error.h
|
||||
mbed-hal-nrf51822-mcu/lib/nordic_sdk/components/libraries/util/app_util.h
|
||||
|
||||
# included from ble_conn_params.c
|
||||
app_timer.h
|
||||
|
||||
# included from device_manager_peripheral.c
|
||||
app_trace.h
|
||||
|
||||
# included from nrf51.h
|
||||
core_cm0.h
|
Loading…
Reference in a new issue