소스 검색

Allow defining PICOWOTA_WIFI_AP in the environment

This aligns the behavior of the build variables, providing a helper function to do the job.
Tomi 2 년 전
부모
커밋
aa6093b094
1개의 변경된 파일15개의 추가작업 그리고 8개의 파일을 삭제
  1. 15
    8
      CMakeLists.txt

+ 15
- 8
CMakeLists.txt 파일 보기

@@ -73,15 +73,22 @@ target_link_libraries(picowota
73 73
 	picowota_reboot
74 74
 )
75 75
 
76
-if (DEFINED ENV{PICOWOTA_WIFI_SSID} AND (NOT PICOWOTA_WIFI_SSID))
77
-	set(PICOWOTA_WIFI_SSID $ENV{PICOWOTA_WIFI_SSID})
78
-	message("Using PICOWOTA_WIFI_SSID from environment ('${PICOWOTA_WIFI_SSID}')")
79
-endif ()
76
+# Retrieves build variables from the environment if present
77
+function(picowota_retrieve_variable name hidden)
78
+	if (DEFINED ENV{${name}} AND (NOT ${name}))
79
+		set(${name} $ENV{${name}} PARENT_SCOPE)
80
+		if (hidden)
81
+			set(log_value "hidden")
82
+		else()
83
+			set(log_value "'$ENV{${name}}'")
84
+		endif()
85
+		message("Using ${name} from environment (${log_value})")
86
+	endif()
87
+endfunction()
80 88
 
81
-if (DEFINED ENV{PICOWOTA_WIFI_PASS} AND (NOT PICOWOTA_WIFI_PASS))
82
-	set(PICOWOTA_WIFI_PASS $ENV{PICOWOTA_WIFI_PASS})
83
-	message("Using PICOWOTA_WIFI_PASS from environment (hidden)")
84
-endif ()
89
+picowota_retrieve_variable(PICOWOTA_WIFI_SSID false)
90
+picowota_retrieve_variable(PICOWOTA_WIFI_PASS true)
91
+picowota_retrieve_variable(PICOWOTA_WIFI_AP false)
85 92
 
86 93
 if ((NOT PICOWOTA_WIFI_SSID) OR (NOT PICOWOTA_WIFI_PASS))
87 94
         message(FATAL_ERROR

Loading…
취소
저장