Skip to content

Commit

Permalink
Add option to include the Ethernet driver task. (#15)
Browse files Browse the repository at this point in the history
Before, we included the Ethernet driver task in every example, which broke some of them. This change makes this optional and configurable through xtask.
  • Loading branch information
arctic-alpaca authored May 15, 2024
1 parent 8e232da commit b744331
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app-tc37x/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ cmake_path(SET pxros_utils_dir NORMALIZE $ENV{PXROS_UTILS})
cmake_path(SET illd_base NORMALIZE $ENV{ILLD_BASE})
cmake_path(SET illd_precompiled NORMALIZE $ENV{ILLD_PRECOMPILED})

# Whether to include the ethernet driver task.
if (DEFINED ENV{INCLUDE_ETHERNET_DRIVER_TASK})
add_compile_definitions(INCLUDE_ETHERNET_DRIVER_TASK)
endif()

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
Expand Down
4 changes: 4 additions & 0 deletions app-tc37x/pxros/tasks/taskDeployment.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@
/* Task Deployment Table
* Task configuration relying on Task default Memory Class and Object pool
*/
#ifdef INCLUDE_ETHERNET_DRIVER_TASK
const task_deployment_t taskTable[] = {
{ PxEthTaskCreate, GETH_DRIVER_PRIO, PXCORE_0},
};
#else
const task_deployment_t taskTable[] = {};
#endif

/* FUNTION: TaskDeploy
* Function calls Task Create function according their core assignment in the taskTable
Expand Down
19 changes: 17 additions & 2 deletions xtask/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ pub struct Options {
/// This is an expensive operation so it is disabled by default.
#[arg(long, required = false)]
pub build_illd: bool,

/// Include the Ethernet driver task into PXROS task list.
///
/// This is required if the Ethernet driver is used.
#[arg(long, required = false)]
pub include_ethernet_task: bool,
}

/// Tricore probe log level.
Expand Down Expand Up @@ -152,7 +158,7 @@ pub fn build(options: Options) -> anyhow::Result<()> {
env::set_current_dir(workspace_root_dir.join(options.app_folder))?;

let build_directory = build_directory.to_str().expect("Path should be valid UTF-8.");
let make_result = make_pxros(build_directory, options.jobs, options.build_illd);
let make_result = make_pxros(build_directory, options.jobs, options.build_illd, options.include_ethernet_task);

env::set_current_dir(current_directory)?;

Expand All @@ -173,7 +179,12 @@ fn to_os_path(path: &str) -> String {
///
/// This function is not inlined because we want to revert and go back to our
/// old folder even if we encounter an error.
fn make_pxros(build_dir: &str, make_job_count: usize, build_illd: bool) -> anyhow::Result<()> {
fn make_pxros(
build_dir: &str,
make_job_count: usize,
build_illd: bool,
include_ethernet_task: bool,
) -> anyhow::Result<()> {
let mut env_vars = vec![
("PXROS_ROOT_PATH", to_os_path(pxros_hr::TRI_8_2_1_EVAL_KERNEL)),
("PXROS_UTILS", to_os_path(pxros_hr::TRI_8_2_1_EVAL_UTILS)),
Expand All @@ -185,6 +196,10 @@ fn make_pxros(build_dir: &str, make_job_count: usize, build_illd: bool) -> anyho
env_vars.push(("BUILD_ILLD", "1".into()));
}

if include_ethernet_task {
env_vars.push(("INCLUDE_ETHERNET_DRIVER_TASK", "1".into()));
}

if !process::Command::new("cmake")
.args(["-B", build_dir, "--fresh", "-G", "Unix Makefiles"])
.envs(env_vars.clone())
Expand Down

0 comments on commit b744331

Please sign in to comment.