@@ -13,6 +13,7 @@ use std::{env, io};
1313use crate :: args:: BuildSystem :: { CMake , Cargo , LFC } ;
1414use crate :: util:: errors:: { BuildResult , LingoError } ;
1515use git2:: Repository ;
16+ use tempfile:: tempdir;
1617use which:: which;
1718
1819fn is_valid_location_for_project ( path : & std:: path:: Path ) -> bool {
@@ -92,6 +93,7 @@ pub struct App {
9293impl App {
9394 pub fn build_system ( & self ) -> BuildSystem {
9495 match self . target {
96+ TargetLanguage :: C => LFC ,
9597 TargetLanguage :: Cpp => CMake ,
9698 TargetLanguage :: Rust => Cargo ,
9799 TargetLanguage :: TypeScript => {
@@ -118,16 +120,16 @@ impl App {
118120 }
119121}
120122
121- /// Simple or DetailedDependcy
123+ /// Simple or DetailedDependency
122124#[ derive( Clone , Deserialize , Serialize ) ]
123- pub enum FileDependcy {
125+ pub enum FileDependency {
124126 // the version string
125127 Simple ( String ) ,
126128 /// version string and source
127129 Advanced ( DetailedDependency ) ,
128130}
129131
130- /// Dependcy with source and version
132+ /// Dependency with source and version
131133#[ derive( Clone , Deserialize , Serialize ) ]
132134pub struct DetailedDependency {
133135 version : String ,
@@ -222,23 +224,32 @@ impl ConfigFile {
222224 Ok ( ( ) )
223225 }
224226
225- // Sets up a LF project with Zephyr as the target platform.
226- pub fn setup_zephyr ( & self ) -> BuildResult {
227- // Clone lf-west-template into a temporary directory
228- let tmp_path = Path :: new ( "zephyr_tmp" ) ;
229- if tmp_path. exists ( ) {
230- remove_dir_all ( tmp_path) ?;
231- }
232- let url = "https://github.com/lf-lang/lf-west-template" ;
227+ fn setup_template_repo ( & self , url : & str ) -> BuildResult {
228+ let dir = tempdir ( ) ?;
229+ let tmp_path = dir. path ( ) ;
233230 Repository :: clone ( url, tmp_path) ?;
234-
235231 // Copy the cloned template repo into the project directory
236232 copy_recursively ( tmp_path, Path :: new ( "." ) ) ?;
233+ // Remove temporary folder
234+ dir. close ( ) ?;
235+ Ok ( ( ) )
236+ }
237237
238- // Remove .git, .gitignore ad temporary folder
238+ // Sets up a LF project with Zephyr as the target platform.
239+ fn setup_zephyr ( & self ) -> BuildResult {
240+ let url = "https://github.com/lf-lang/lf-west-template" ;
241+ self . setup_template_repo ( url) ?;
239242 remove_file ( ".gitignore" ) ?;
240243 remove_dir_all ( Path :: new ( ".git" ) ) ?;
241- remove_dir_all ( tmp_path) ?;
244+ Ok ( ( ) )
245+ }
246+
247+ // Sets up a LF project with RP2040 MCU as the target platform.
248+ // Initializes a repo using the lf-pico-template
249+ fn setup_rp2040 ( & self ) -> BuildResult {
250+ let url = "https://github.com/lf-lang/lf-pico-template" ;
251+ // leave git artifacts
252+ self . setup_template_repo ( url) ?;
242253 Ok ( ( ) )
243254 }
244255
@@ -247,6 +258,7 @@ impl ConfigFile {
247258 match self . apps [ 0 ] . platform {
248259 Some ( Platform :: Native ) => self . setup_native ( ) ,
249260 Some ( Platform :: Zephyr ) => self . setup_zephyr ( ) ,
261+ Some ( Platform :: RP2040 ) => self . setup_rp2040 ( ) ,
250262 _ => Ok ( ( ) ) ,
251263 }
252264 } else {
0 commit comments