From 55128d4949327c595bfe28f26cf01105fbdc2695 Mon Sep 17 00:00:00 2001 From: lmp Date: Wed, 26 Jul 2023 22:39:51 +0200 Subject: [PATCH 1/5] docs: add example with auto detection of SDL2 version --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 74626ecf..b44dbaeb 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,16 @@ v install sdl If you want to use another version of SDL2 you will, currently, have to install it via `git` or by manual download. +An example of installing the system provided version of SDL2 via `git`: +```bash +git clone https://github.com/vlang/sdl.git ~/.vmodules +cd ~/.vmodules/sdl +sdl_version=$(sdl2-config --version); git checkout "${sdl_version%.*}.0" +``` + +Should `sdl2-config` be absent on your system you can try the following instead, +by providing the version manually: + An example of installing SDL2 `v2.0.12` via `git`: ```bash git clone https://github.com/vlang/sdl.git ~/.vmodules From 954a060499885515bb989609b2cc945e91642c78 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 27 Jul 2023 00:10:32 +0300 Subject: [PATCH 2/5] add setup.vsh, to make matching the installed SDL version easier for users Add a script to ease the post installation setup of SDL for end users. --- setup.vsh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 setup.vsh diff --git a/setup.vsh b/setup.vsh new file mode 100644 index 00000000..1bfa8234 --- /dev/null +++ b/setup.vsh @@ -0,0 +1,29 @@ +import os + +os.chdir(os.dir(os.executable()))! + +res := os.execute('sdl2-config --version') +if res.exit_code != 0 { + println('sdl2-config is missing') + exit(1) +} +system_version := res.output.trim_space() +println('Your version is ${system_version}') + +remotes := os.execute('git branch -r --list') +if remotes.exit_code != 0 { + println('git is missing') + exit(1) +} +supported_versions := remotes.output.split_into_lines().map(it.trim_space()).filter(it.starts_with('origin/2')).map(it.all_after('origin/')) +println('The SDL module officially supports these versions of SDL:\n ${supported_versions}') + +if system_version in supported_versions { + println('Setting up the repository to branch ${system_version} that exactly matches your system SDL version') + os.system('git checkout ${system_version}') + exit(0) +} + +base_version := '${system_version.all_before_last('.')}.0' +println('Setting up the repository to branch ${base_version}, that best matches the system SDL version: ${system_version} ...') +os.system('git checkout ${base_version}') From e01e91c25bb7a2cde5a46455a89aa0d367910ac8 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 27 Jul 2023 00:13:33 +0300 Subject: [PATCH 3/5] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index b44dbaeb..98333a48 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,7 @@ it via `git` or by manual download. An example of installing the system provided version of SDL2 via `git`: ```bash git clone https://github.com/vlang/sdl.git ~/.vmodules -cd ~/.vmodules/sdl -sdl_version=$(sdl2-config --version); git checkout "${sdl_version%.*}.0" +v ~/.vmodules/sdl/setup.vsh ``` Should `sdl2-config` be absent on your system you can try the following instead, From 4118075eb5c6194207c3582fe1bfdcec7e0f2f06 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 27 Jul 2023 00:24:31 +0300 Subject: [PATCH 4/5] insert 2.0.8 master at the start of supported_versions --- setup.vsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.vsh b/setup.vsh index 1bfa8234..0a81583e 100644 --- a/setup.vsh +++ b/setup.vsh @@ -15,7 +15,8 @@ if remotes.exit_code != 0 { println('git is missing') exit(1) } -supported_versions := remotes.output.split_into_lines().map(it.trim_space()).filter(it.starts_with('origin/2')).map(it.all_after('origin/')) +mut supported_versions := remotes.output.split_into_lines().map(it.trim_space()).filter(it.starts_with('origin/2')).map(it.all_after('origin/')) +supported_versions.insert(0, '2.0.8') // master println('The SDL module officially supports these versions of SDL:\n ${supported_versions}') if system_version in supported_versions { From 81322c6b463495488ab8c4d96c33ceac2aecabe8 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 27 Jul 2023 00:29:16 +0300 Subject: [PATCH 5/5] Update setup.vsh --- setup.vsh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/setup.vsh b/setup.vsh index 0a81583e..06e80346 100644 --- a/setup.vsh +++ b/setup.vsh @@ -19,6 +19,12 @@ mut supported_versions := remotes.output.split_into_lines().map(it.trim_space()) supported_versions.insert(0, '2.0.8') // master println('The SDL module officially supports these versions of SDL:\n ${supported_versions}') +if system_version == '2.0.8' { + println('Setting up the repository to branch master, that exactly matches your system SDL version 2.0.8') + os.system('git checkout master') + exit(0) +} + if system_version in supported_versions { println('Setting up the repository to branch ${system_version} that exactly matches your system SDL version') os.system('git checkout ${system_version}')