diff --git a/.gitignore b/.gitignore index 3960c723d..a4ef9adc4 100644 --- a/.gitignore +++ b/.gitignore @@ -73,4 +73,5 @@ go.mod go.sum /.pio -__pycache__ \ No newline at end of file +__pycache__ +/targets \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index db3c07fb1..000000000 --- a/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "targets"] - path = targets - url = https://github.com/BossHobby/Targets.git - branch = targets diff --git a/platformio.ini b/platformio.ini index 8348bed7b..23e3a58ef 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,7 +12,7 @@ include_dir = src build_cache_dir = .pio/cache extra_configs = - targets/_index.ini + targets/*.ini [common] diff --git a/script/pre_script.py b/script/pre_script.py index 258b4e669..80c6f60ff 100644 --- a/script/pre_script.py +++ b/script/pre_script.py @@ -63,3 +63,25 @@ def rewrite_source(localenv, node): env.AddBuildMiddleware(rewrite_source) + + +def touch(fname, times=None): + with open(fname, "a"): + os.utime(fname, times) + + +target_remote = "https://github.com/BossHobby/Targets.git" +target_dir = os.path.join(env["PROJECT_DIR"], "targets") + +if not os.path.exists(target_dir): + porcelain.clone(target_remote, target=target_dir, branch="targets") + touch(os.path.join(env["PROJECT_DIR"], "platformio.ini")) +else: + target_repo = porcelain.open_repo(target_dir) + target_ref_before = porcelain.describe(target_repo) + porcelain.fetch(target_repo) + porcelain.checkout_branch(target_repo, "targets") + target_ref_after = porcelain.describe(target_repo) + + if target_ref_before != target_ref_after: + touch(os.path.join(env["PROJECT_DIR"], "platformio.ini")) diff --git a/targets b/targets deleted file mode 160000 index 2718ce075..000000000 --- a/targets +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2718ce075cbaa6b73c9f6f71507fb671a877ac16