@@ -34,14 +34,13 @@ def local_path(path):
3434 return os .path .abspath (os .path .join (current , path ))
3535
3636
37- WOLFSSL_GIT_ADDR = "https://github.com/wolfssl/wolfssl.git"
38- WOLFSSL_SRC_PATH = local_path ("lib/wolfssl/src" )
37+ WOLFSSL_SRC_PATH = local_path ("lib/wolfssl" )
3938
4039
4140def wolfssl_inc_path ():
4241 wolfssl_path = os .environ .get ("USE_LOCAL_WOLFSSL" )
4342 if wolfssl_path is None :
44- return local_path ("lib/wolfssl/src " )
43+ return local_path ("lib/wolfssl" )
4544 else :
4645 if os .path .isdir (wolfssl_path ) and os .path .exists (wolfssl_path ):
4746 return wolfssl_path + "/include"
@@ -86,20 +85,17 @@ def chdir(new_path, mkdir=False):
8685 os .chdir (old_path )
8786
8887
89- def clone_wolfssl (ref ):
90- """ Clone wolfSSL C library repository
91- """
92- call ("git clone --depth=1 --branch={} {} {}" .format (
93- ref , WOLFSSL_GIT_ADDR , WOLFSSL_SRC_PATH ))
94-
95-
9688def checkout_ref (ref ):
9789 """ Ensure that we have the right version
9890 """
9991 with chdir (WOLFSSL_SRC_PATH ):
100- current = subprocess .check_output (
101- ["git" , "describe" , "--all" , "--exact-match" ]
102- ).strip ().decode ().split ('/' )[- 1 ]
92+ current = ""
93+ try :
94+ current = subprocess .check_output (
95+ ["git" , "describe" , "--all" , "--exact-match" ]
96+ ).strip ().decode ().split ('/' )[- 1 ]
97+ except :
98+ pass
10399
104100 if current != ref :
105101 tags = subprocess .check_output (
@@ -119,9 +115,13 @@ def checkout_ref(ref):
119115def ensure_wolfssl_src (ref ):
120116 """ Ensure that wolfssl sources are presents and up-to-date
121117 """
122- if not os .path .isdir (WOLFSSL_SRC_PATH ):
123- clone_wolfssl (ref )
124- return True
118+ if not os .path .isdir ("lib" ):
119+ os .mkdir ("lib" )
120+ with chdir ("lib" ):
121+ subprocess .run (["git" , "clone" , "--depth=1" , "https://github.com/wolfssl/wolfssl" ])
122+
123+ if not os .path .isdir (os .path .join (WOLFSSL_SRC_PATH , "wolfssl" )):
124+ subprocess .run (["git" , "submodule" , "update" , "--init" , "--depth=1" ])
125125
126126 return checkout_ref (ref )
127127
0 commit comments