-
-
Notifications
You must be signed in to change notification settings - Fork 187
Add macOS nanoCLR host target scaffold #3256
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
Closed
Closed
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
906716d
Add macOS nanoCLR host target scaffold
asp2286 c47abfd
Fix macOS host scaffold review issues
asp2286 4b599cd
OSX: make bool timer single-shot and cancellable
asp2286 89e2425
CI: add macOS nanoCLR scaffold smoke job
asp2286 a2c0648
CI: align macOS job conditions with other targets
asp2286 ce4a0f8
CI: fix macOS job arch selection
asp2286 8e23fc2
Replace Windows-only native loader with cross-platform NativeNanoClrL…
asp2286 e4d1956
Merge branch 'main' into feature/osx-host-skeleton
asp2286 4d984d1
osx: remove ParseOptions_OSX — argument parsing is handled by C# CLI …
asp2286 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| name: osx-nanoclr | ||
|
|
||
| on: | ||
| push: | ||
| paths: | ||
| - "targets/osx/**" | ||
| - ".github/workflows/osx-nanoclr.yml" | ||
| pull_request: | ||
| paths: | ||
| - "targets/osx/**" | ||
| - ".github/workflows/osx-nanoclr.yml" | ||
|
|
||
| jobs: | ||
| build-osx-nanoclr: | ||
| runs-on: macos-14 | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Ninja (if missing) | ||
| run: | | ||
| if ! command -v ninja >/dev/null 2>&1; then | ||
| brew install ninja | ||
| fi | ||
|
|
||
| - name: Configure | ||
| run: | | ||
| cmake -S targets/osx -B build/osx -G Ninja \ | ||
| -DNANO_OSX_ARCH=arm64 \ | ||
| -DNANO_OSX_ENABLE_SMOKE=ON | ||
|
|
||
| - name: Build | ||
| run: cmake --build build/osx --verbose | ||
|
|
||
| - name: Smoke Run | ||
| run: | | ||
| set -euo pipefail | ||
| ./build/osx/bin/nanoFramework.nanoCLR --version | tee build/osx/smoke.log | ||
|
|
||
| - name: Upload Artifacts | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: osx-nanoclr | ||
| path: | | ||
| build/osx/bin/nanoFramework.nanoCLR | ||
| build/osx/smoke.log | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # | ||
| # Copyright (c) .NET Foundation and Contributors | ||
| # See LICENSE file in the project root for full license information. | ||
| # | ||
|
|
||
| cmake_minimum_required(VERSION 3.24) | ||
|
|
||
| project(nanoFramework_nanoCLR_osx VERSION 0.1.0 LANGUAGES C CXX) | ||
|
|
||
| if(NOT APPLE) | ||
| message(FATAL_ERROR "targets/osx can only be built on macOS.") | ||
| endif() | ||
|
|
||
| set(NANO_OSX_ARCH "arm64" CACHE STRING "Target architecture for macOS host build (arm64 or x86_64)") | ||
| set_property(CACHE NANO_OSX_ARCH PROPERTY STRINGS arm64 x86_64) | ||
|
|
||
| if(NOT NANO_OSX_ARCH STREQUAL "arm64" AND NOT NANO_OSX_ARCH STREQUAL "x86_64") | ||
| message(FATAL_ERROR "Invalid NANO_OSX_ARCH='${NANO_OSX_ARCH}'. Valid values: arm64, x86_64.") | ||
| endif() | ||
|
|
||
| set(CMAKE_OSX_ARCHITECTURES "${NANO_OSX_ARCH}" CACHE STRING "macOS architecture" FORCE) | ||
|
|
||
| option(NANO_OSX_ENABLE_SMOKE "Build smoke behavior (--help/--version/banner)." ON) | ||
|
|
||
| add_subdirectory(nanoCLR) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // | ||
| // Copyright (c) .NET Foundation and Contributors | ||
| // See LICENSE file in the project root for full license information. | ||
| // | ||
|
|
||
| #ifndef TARGET_HAL_SPI_H | ||
| #define TARGET_HAL_SPI_H | ||
|
|
||
| // # of buses | ||
| #define NUM_SPI_BUSES 0 | ||
|
|
||
| // Maximum number of devices per SPI bus | ||
| #define MAX_SPI_DEVICES 5 | ||
|
|
||
| #endif // TARGET_HAL_SPI_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // | ||
| // Copyright (c) .NET Foundation and Contributors | ||
| // See LICENSE file in the project root for full license information. | ||
| // | ||
|
|
||
| #ifndef NANOHAL_BOOT_H | ||
| #define NANOHAL_BOOT_H | ||
|
|
||
| #endif // NANOHAL_BOOT_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // | ||
| // Copyright (c) .NET Foundation and Contributors | ||
| // See LICENSE file in the project root for full license information. | ||
| // | ||
|
|
||
| #ifndef NANOHAL_CAPABILITIES_H | ||
| #define NANOHAL_CAPABILITIES_H | ||
|
|
||
| #endif // NANOHAL_CAPABILITIES_H | ||
|
asp2286 marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| // | ||
| // Copyright (c) .NET Foundation and Contributors | ||
| // See LICENSE file in the project root for full license information. | ||
| // | ||
|
|
||
| #ifndef TARGET_HAL_H | ||
| #define TARGET_HAL_H | ||
|
|
||
| #include <chrono> | ||
| #include <csignal> | ||
| #include <cstdint> | ||
| #include <thread> | ||
|
|
||
| // Keep the same macro shape used by other targets. | ||
| #define PLATFORM_DELAY(milliSecs) std::this_thread::sleep_for(std::chrono::milliseconds((milliSecs))) | ||
|
|
||
| // Start with the same minimum socket count used by win32 host. | ||
| #define PLATFORM_DEPENDENT__SOCKETS_MAX_COUNT 1 | ||
|
|
||
| #define NANOCLR_STOP() std::raise(SIGTRAP) | ||
|
|
||
| inline bool Target_ConfigUpdateRequiresErase() | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| inline bool Target_HasNanoBooter() | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| inline bool Target_CanChangeMacAddress() | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| inline bool Target_IFUCapable() | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| inline bool Target_HasProprietaryBooter() | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| inline uint32_t GetPlatformCapabilities() | ||
| { | ||
| return 0; | ||
| } | ||
|
|
||
| inline uint32_t GetTargetCapabilities() | ||
| { | ||
| return 0; | ||
| } | ||
|
|
||
| inline bool RequestToLaunchProprietaryBootloader() | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| inline bool RequestToLaunchNanoBooter(int32_t errorCode) | ||
| { | ||
| (void)errorCode; | ||
| return false; | ||
| } | ||
|
|
||
| inline uint32_t CPU_TicksPerSecond() | ||
| { | ||
| // 100ns ticks to align with nanoCLR time usage in virtual-device mode. | ||
| return 10000000U; | ||
| } | ||
|
|
||
| inline uint64_t CPU_MicrosecondsToTicks(uint64_t uSec) | ||
| { | ||
| return uSec * 10ULL; | ||
| } | ||
|
|
||
| inline uint64_t CPU_MillisecondsToTicks(uint64_t mSec) | ||
| { | ||
| return mSec * 10000ULL; | ||
| } | ||
|
|
||
| #endif // TARGET_HAL_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // | ||
| // Copyright (c) .NET Foundation and Contributors | ||
| // See LICENSE file in the project root for full license information. | ||
| // | ||
|
|
||
| #ifndef TARGET_HAL_POWER_H | ||
| #define TARGET_HAL_POWER_H | ||
|
|
||
| #include <cstdlib> | ||
|
|
||
| inline void CPU_Reset() | ||
| { | ||
| std::exit(0); | ||
| } | ||
|
|
||
| inline bool CPU_IsSoftRebootSupported() | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| #endif // TARGET_HAL_POWER_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // | ||
| // Copyright (c) .NET Foundation and Contributors | ||
| // See LICENSE file in the project root for full license information. | ||
| // | ||
|
|
||
| #ifndef TARGET_HAL_TIME_H | ||
| #define TARGET_HAL_TIME_H | ||
|
|
||
| #include <cstdint> | ||
|
|
||
| uint64_t HAL_Time_CurrentSysTicks(); | ||
| void HAL_Time_Sleep_MicroSeconds(unsigned int uSec); | ||
| void HAL_Time_Sleep_MicroSeconds_InterruptEnabled(unsigned int uSec); | ||
|
|
||
| #endif // TARGET_HAL_TIME_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // | ||
| // Copyright (c) .NET Foundation and Contributors | ||
| // See LICENSE file in the project root for full license information. | ||
| // | ||
|
|
||
| #ifndef TARGET_PAL_TIME_H | ||
| #define TARGET_PAL_TIME_H | ||
|
|
||
| #endif // TARGET_PAL_TIME_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // | ||
| // Copyright (c) .NET Foundation and Contributors | ||
| // See LICENSE file in the project root for full license information. | ||
| // | ||
|
|
||
| #ifndef TARGETPAL_BLOCKSTORAGE_H | ||
| #define TARGETPAL_BLOCKSTORAGE_H | ||
|
|
||
| // Start with the same value as win32 target profile. | ||
| #define TARGET_BLOCKSTORAGE_COUNT 1 | ||
|
|
||
| #endif // TARGETPAL_BLOCKSTORAGE_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // | ||
| // Copyright (c) .NET Foundation and Contributors | ||
| // See LICENSE file in the project root for full license information. | ||
| // | ||
|
|
||
| #ifndef TARGET_BOARD_H | ||
| #define TARGET_BOARD_H | ||
|
|
||
| #endif // TARGET_BOARD_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // | ||
| // Copyright (c) .NET Foundation and Contributors | ||
| // See LICENSE file in the project root for full license information. | ||
| // | ||
|
|
||
| #ifndef TARGET_COMMON_H | ||
| #define TARGET_COMMON_H | ||
|
|
||
| #define TARGETNAMESTRING "Virtual nanoDevice" | ||
| #define PLATFORMNAMESTRING "OSX" | ||
| #define TARGETINFOSTRING "CLR for OSX" | ||
| #define OEMSYSTEMINFOSTRING "nanoCLR running @ OSX" | ||
|
|
||
| #endif // TARGET_COMMON_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // | ||
| // Copyright (c) .NET Foundation and Contributors | ||
| // See LICENSE file in the project root for full license information. | ||
| // | ||
|
|
||
| #ifndef TARGET_OS_H | ||
| #define TARGET_OS_H | ||
|
|
||
| #define TARGET_HAS_NANOBOOTER 0 | ||
|
|
||
| #endif // TARGET_OS_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // | ||
| // Copyright (c) .NET Foundation and Contributors | ||
| // See LICENSE file in the project root for full license information. | ||
| // | ||
|
|
||
| #ifndef TARGET_PLATFORM_H | ||
| #define TARGET_PLATFORM_H | ||
|
|
||
| #endif // TARGET_PLATFORM_H | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.