-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [EXAMPLES] better examples * [EXAMPLES] fix tools
- Loading branch information
Showing
14 changed files
with
142 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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,3 @@ | ||
# Examples | ||
|
||
These examples can be used to understand the different features of this toolchain |
This file contains 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,27 @@ | ||
# project/BUILD.bazel | ||
|
||
load("@rules_cc//cc:defs.bzl", "cc_binary") | ||
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup") | ||
|
||
cc_binary( | ||
name = "binary", | ||
srcs = ["main.c"], | ||
linkopts = [ | ||
"-Wl,-entry=main", | ||
], | ||
target_compatible_with = [ | ||
"@platforms//os:none", | ||
], | ||
) | ||
|
||
platform_transition_filegroup( | ||
name = "cortex_m3_elf", | ||
srcs = [":binary"], | ||
target_platform = "//examples/custom/platform:cortex_m3", | ||
) | ||
|
||
platform_transition_filegroup( | ||
name = "cortex_m4_elf", | ||
srcs = [":binary"], | ||
target_platform = "//examples/custom/platform:cortex_m4", | ||
) |
This file contains 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,5 @@ | ||
# Custom toolchain example | ||
|
||
This example shows how to create a custom toolchain with different CPUs based | ||
on custom constraint values. The toolchain has different flags for each CPU and | ||
is applied to all dependencies. |
This file contains 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 @@ | ||
constraint_setting( | ||
name = "arm_none_eabi_cpu", | ||
) | ||
|
||
constraint_value( | ||
name = "cortex_m3", | ||
constraint_setting = "arm_none_eabi_cpu", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
constraint_value( | ||
name = "cortex_m4", | ||
constraint_setting = "arm_none_eabi_cpu", | ||
visibility = ["//visibility:public"], | ||
) |
This file contains 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 @@ | ||
// The simplest possible main function | ||
|
||
int main() | ||
{ | ||
return 0; | ||
} | ||
|
||
extern void _start() | ||
{ | ||
main(); | ||
} |
This file contains 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,18 @@ | ||
|
||
platform( | ||
name = "cortex_m4", | ||
constraint_values = [ | ||
"@platforms//os:none", | ||
"//examples/custom/cpu:cortex_m4" | ||
], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
platform( | ||
name = "cortex_m3", | ||
constraint_values = [ | ||
"@platforms//os:none", | ||
"//examples/custom/cpu:cortex_m3" | ||
], | ||
visibility = ["//visibility:public"], | ||
) |
This file contains 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,43 @@ | ||
load("@arm_none_eabi//toolchain:toolchain.bzl", "arm_none_eabi_toolchain") | ||
|
||
arm_none_eabi_toolchain( | ||
name = "cortex_m3_toolchain", | ||
target_compatible_with = [ | ||
"@platforms//os:none", | ||
"//examples/custom/cpu:cortex_m3" | ||
], | ||
copts = [ | ||
"-mcpu=cortex-m3", | ||
"-mthumb", | ||
"-mfloat-abi=hard", | ||
"-mfpu=fpv4-sp-d16", | ||
], | ||
linkopts = [ | ||
"-mcpu=cortex-m3", | ||
"-mthumb", | ||
"-mfloat-abi=hard", | ||
"-mfpu=fpv4-sp-d16", | ||
"-nostartfiles", | ||
], | ||
) | ||
|
||
arm_none_eabi_toolchain( | ||
name = "cortex_m4_toolchain", | ||
target_compatible_with = [ | ||
"@platforms//os:none", | ||
"//examples/custom/cpu:cortex_m4" | ||
], | ||
copts = [ | ||
"-mcpu=cortex-m4", | ||
"-mthumb", | ||
"-mfloat-abi=hard", | ||
"-mfpu=fpv4-sp-d16", | ||
], | ||
linkopts = [ | ||
"-mcpu=cortex-m4", | ||
"-mthumb", | ||
"-mfloat-abi=hard", | ||
"-mfpu=fpv4-sp-d16", | ||
"-nostartfiles", | ||
], | ||
) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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
Empty file.