Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/bootstrap #48

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fbcc1da
echo gcc version
jamesadevine Jan 30, 2020
9171e30
Update comments in merge_hex.py
jamesadevine Mar 13, 2020
6d66102
Update uf2conv.py to python3 version
mmoskal May 14, 2020
13110e9
Allow for additional "libraries": [] in codal.json
mmoskal Aug 13, 2020
7cf09a3
Merge pull request #39 from lancaster-university/codal_json_libraries2
jamesadevine Aug 13, 2020
e9e2035
add codal-microbit-v2 to targets.json
jamesadevine Nov 18, 2020
18aa65b
echo version to fix CI
jamesadevine Nov 18, 2020
595b27a
add makeable target
jamesadevine Mar 26, 2021
a18ad20
update codal-makeable branch name
jamesadevine Mar 26, 2021
4186802
Account for main being used instead of master in lock code
jamesadevine Apr 28, 2021
0b2a37c
Merge pull request #43 from lancaster-university/lock-code-fixup
jamesadevine Apr 28, 2021
c5326cb
Add pre-process task
jamesadevine Jul 13, 2021
17017b5
remove debug
jamesadevine Jul 13, 2021
aa9ba2a
cleanup more debug
jamesadevine Jul 13, 2021
c389db2
Move to new cmake and update call_cmake
jamesadevine Jul 13, 2021
e1bb097
Merge pull request #44 from lancaster-university/rp2040-build
finneyj Jul 23, 2021
f52b597
Updated targets.json path to be correct for bootstrapping mode
JohnVidler Feb 11, 2022
eea9c76
Added a CORE_PATH variable to track/set the library path for boostrap…
JohnVidler Feb 11, 2022
b75a1c6
Added -b flag to --status calls, to get the branch as well as the fil…
JohnVidler Feb 16, 2022
8854606
Removed bogus os.environ call, which did nothing
JohnVidler Feb 24, 2022
be95816
Added the M1 fix to the upstream codal toolchains
JohnVidler May 13, 2022
ce7b501
Removed old build files, moved to bootstrap toolchain
JohnVidler Jun 7, 2022
db75902
Pulling sources forward to match with master
JohnVidler Feb 5, 2023
90812ba
Moved to a codal.py based build, merging bootstrap directly into codal
JohnVidler Feb 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 45 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
cmake_minimum_required(VERSION 3.3)

# include additional cmake
include(utils/cmake/JSONParser.cmake)
include(utils/cmake/util.cmake)
include(utils/cmake/colours.cmake)
set( CORE_PATH "libraries/codal" )
include(${CORE_PATH}/utils/cmake/JSONParser.cmake)
include(${CORE_PATH}/utils/cmake/util.cmake)
include(${CORE_PATH}/utils/cmake/colours.cmake)

if (NOT "${BUILD_TOOL}" STRGREATER "")
set(BUILD_TOOL "CODAL")
Expand Down Expand Up @@ -95,7 +96,7 @@ endif()
####################

SET(TOOLCHAIN ${device.toolchain})
SET(TOOLCHAIN_FOLDER "./utils/cmake/toolchains/${device.toolchain}")
SET(TOOLCHAIN_FOLDER "${CMAKE_CURRENT_LIST_DIR}/${CORE_PATH}/utils/cmake/toolchains/${device.toolchain}")

# include toolchain file
set(CMAKE_TOOLCHAIN_FILE "${TOOLCHAIN_FOLDER}/toolchain.cmake" CACHE PATH "toolchain file")
Expand All @@ -106,7 +107,7 @@ enable_language(ASM)

# include compiler flags overrides
include(${TOOLCHAIN_FOLDER}/compiler-flags.cmake)
set(PLATFORM_INCLUDES_PATH "${PROJECT_SOURCE_DIR}/utils/cmake/toolchains/${device.toolchain}")
set(PLATFORM_INCLUDES_PATH "${PROJECT_SOURCE_DIR}/${CORE_PATH}/utils/cmake/toolchains/${device.toolchain}")

file(MAKE_DIRECTORY "${PROJECT_SOURCE_DIR}/build")

Expand All @@ -132,7 +133,7 @@ foreach(var ${device})
string(REGEX MATCH "[^device\.cmake_definitions\.]([A-Z,a-z,0-9,_,]+)" CODAL_CMAKE_DEFINITION "${var}")

set(${CODAL_CMAKE_DEFINITION} ${${var}})
endforeach()
endforeach()

#define any additional symbols specified by the target.
if("${device.definitions}" STRGREATER "")
Expand Down Expand Up @@ -182,18 +183,18 @@ if("${CODAL_DEFINITIONS}" STRGREATER "")
file(WRITE "${EXTRA_INCLUDES_NEW_PATH}" ${CODAL_DEFINITIONS})
configure_file(${EXTRA_INCLUDES_NEW_PATH} ${EXTRA_INCLUDES_PATH} COPYONLY)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -include \"${EXTRA_INCLUDES_PATH}\"")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include \"${EXTRA_INCLUDES_PATH}\"")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -include ${EXTRA_INCLUDES_PATH}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include ${EXTRA_INCLUDES_PATH}")
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I\"${PLATFORM_INCLUDES_PATH}\"")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I\"${PLATFORM_INCLUDES_PATH}\"")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${PLATFORM_INCLUDES_PATH}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${PLATFORM_INCLUDES_PATH}")
Comment on lines 185 to +191
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is undoing PR #10


# a define for cmake if statements to detect if within the CODAL build environment
set(CODAL_BUILD_SYSTEM TRUE)

# a define specificying common utils used in codal
set(CODAL_UTILS_LOCATION "${PROJECT_SOURCE_DIR}/utils/cmake/util.cmake")
set(CODAL_UTILS_LOCATION "${PROJECT_SOURCE_DIR}/${CORE_PATH}/utils/cmake/util.cmake")

# this variable is used in the linking step of the final binary.
set(LIB_FOLDERS "")
Expand All @@ -204,7 +205,7 @@ include_directories(${PROJECT_SOURCE_DIR}/${LIB_DEST})

#add_subdirectory("${PROJECT_SOURCE_DIR}/${LIB_DEST}/${dep}")

# "import" and add any specified libraries to the build list
# "import" and add any libraries from target.json to the build list
if("${device.libraries}" STRGREATER "")
message("Installing dependencies...")
set(DEVICE_LIBS ${device.libraries})
Expand All @@ -220,16 +221,41 @@ if("${device.libraries}" STRGREATER "")
MESSAGE (STATUS "Override branch: ${BRANCH}")
endif()

INSTALL_DEPENDENCY(${LIB_DEST} ${device.libraries_${i}.name} ${URL} ${BRANCH} ${device.libraries_${i}.type})
list(APPEND CODAL_DEPS "${device.libraries_${i}.name}")
if( NOT "${device.libraries_${i}.name}" STREQUAL "codal" )
INSTALL_DEPENDENCY(${LIB_DEST} ${device.libraries_${i}.name} ${URL} ${BRANCH} ${device.libraries_${i}.type})
list(APPEND CODAL_DEPS "${device.libraries_${i}.name}")
endif()
endforeach()
endif()

# and also from codal.json
if("${codal.libraries}" STRGREATER "")
message("Installing app dependencies...")
set(CODAL_LIBS ${codal.libraries})

foreach(i ${CODAL_LIBS})
SET(BRANCH "NONE")
SET(URL "${codal.libraries_${i}.url}")
if("${codal.libraries_${i}.branch}" STRGREATER "")
SET(BRANCH "${codal.libraries_${i}.branch}")
endif()
if("${codal.target.branches.${URL}}" STRGREATER "")
SET(BRANCH "${codal.target.branches.${URL}}")
MESSAGE (STATUS "Override branch: ${BRANCH}")
endif()

foreach(dep ${CODAL_DEPS})
message("${BoldGreen}Using library: ${dep}${ColourReset}")
add_subdirectory("${PROJECT_SOURCE_DIR}/${LIB_DEST}/${dep}")
if( NOT "${codal.libraries_${i}.name}" STREQUAL "codal" )
INSTALL_DEPENDENCY(${LIB_DEST} ${codal.libraries_${i}.name} ${URL} ${BRANCH} ${codal.libraries_${i}.type})
list(APPEND CODAL_DEPS "${codal.libraries_${i}.name}")
endif()
endforeach()
endif()

foreach(dep ${CODAL_DEPS})
message("${BoldGreen}Using library: ${dep}${ColourReset}")
add_subdirectory("${PROJECT_SOURCE_DIR}/${LIB_DEST}/${dep}")
endforeach()

#finally, find sources and includes of the application, and create a target.
RECURSIVE_FIND_DIR(INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/${CODAL_APP_SOURCE_DIR}" "*.h")
# *.c?? only catches .cpp, not .c, so let's be precise
Expand All @@ -247,12 +273,12 @@ endif()
if ("${BUILD_TOOL}" STRGREATER "")
string(COMPARE EQUAL "${BUILD_TOOL}" "YOTTA" YOTTA_BUILD)
if (${YOTTA_BUILD})
include("${PROJECT_SOURCE_DIR}/utils/cmake/buildtools/yotta.cmake")
include("${PROJECT_SOURCE_DIR}/${CORE_PATH}/utils/cmake/buildtools/yotta.cmake")
endif ()

string(COMPARE EQUAL "${BUILD_TOOL}" "CODAL" CODAL_BUILD)
if (${CODAL_BUILD})
include("${PROJECT_SOURCE_DIR}/utils/cmake/buildtools/codal.cmake")
include("${PROJECT_SOURCE_DIR}/${CORE_PATH}/utils/cmake/buildtools/codal.cmake")
endif()
endif()

Expand Down
169 changes: 0 additions & 169 deletions build.py

This file was deleted.

21 changes: 18 additions & 3 deletions codal.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,27 @@
"test_ignore": true,
"dev": true
},
"config":{
"libraries": [
{
"name": "codal",
"url": "https://github.com/lancaster-university/codal",
"branch": "feature/bootstrap-refactor",
"type": "git"
},
{
"url": "https://github.com/JohnVidler/codal-field-testing.git",
"name": "codal-field-testing",
"branch": "Master",
"type": "git"
}
],
"config": {
"DEVICE_DMESG": 1,
"DMESG_SERIAL_DEBUG": 1,
"CODAL_DEBUG": 1,
"MICROBIT_BLE_ENABLED" : 0,
"DEVICE_BLE": 0,
"MICROBIT_BLE_ENABLED": 0,
"MICROBIT_BLE_PAIRING_MODE": 0,
"CONFIG_MICROBIT_ERASE_USER_DATA_ON_REFLASH": 1
}
}
}
50 changes: 50 additions & 0 deletions codal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env python3

# The MIT License (MIT)

# Copyright (c) 2022 Lancaster University.

# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

import os
import sys

from importlib import import_module
from genericpath import exists

BOOTSTRAP_TAG = "feature/bootstrap-refactor"
TARGET_LIST = [
"https://raw.githubusercontent.com/lancaster-university/codal/master/utils/targets.json"
]
BASE_ROOT = os.getcwd()
CODAL_ROOT = os.path.join( BASE_ROOT, 'libraries', 'codal' )

# Minimum folder structure:
if not exists( os.path.join( BASE_ROOT, 'libraries' ) ):
os.mkdir( os.path.join( BASE_ROOT, 'libraries' ) );

# Grab the latest library
if not exists( os.path.join( BASE_ROOT, 'libraries', 'codal' ) ):
print( "Downloading codal-bootstrap..." )
if not exists( os.path.join( CODAL_ROOT, '.git' ) ):
os.system( f'git clone --recurse-submodules --branch "{BOOTSTRAP_TAG}" "https://github.com/lancaster-university/codal.git" "{CODAL_ROOT}"' )

# Jump into the current upstream code
sys.path.append( CODAL_ROOT )
import_module( f'libraries.codal.codal' )
Empty file removed utils/__init__.py
Empty file.
Loading