diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..af0e68c90f433657dc3a69909e2fee7d497ee62e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.build/ +.build.*/ diff --git a/BUILD.md b/BUILD.md new file mode 100644 index 0000000000000000000000000000000000000000..dbd14f8bb3c8c4c30876cddafdaaa625dac2ca9a --- /dev/null +++ b/BUILD.md @@ -0,0 +1,106 @@ +# Build options for Lektor + +## Building a lektor distribution for windows (Cross Compilation) + +Windows 64 bit binaries are built from a linux system. Here we will assume you are using an arch +linux system because it's what I'm using. Install the packages `mingw-w64-gcc`, `mingw-w64-cmake` +(aur), `mingw-w64-make` (aur). You may also install the `mingw-w64-qt6-*` (aur) packages. For the +mpv library, install the packages in [utils/arch-pkgs]. Make sure that you have the windows +toolchain for 64 bit installed. Run the followinf commands: + + (cd utils/arch-pkgs/mingw-w64-shaderc && makepkg -si) + yay -Sy mingw-w64-gcc mingw-w64-cmake mingw-w64-make mingw-w64-dlfcn x86_64-w64-mingw32-ldd + yay -Sy mingw-w64-mpv # Be sure to install it after building shaderc from source + yay -Sy mingw-w64-qt6-* # You may specify the packages, you may doo the bootstrap thingy here + rustup target add x86_64-pc-windows-gnu # Add the windows target, here we build 64bit applications + MAKE=x86_64-w64-mingw32-make CMAKE=x86_64-w64-mingw32-cmake CXX=x86_64-w64-mingw32-g++ cargo build --target x86_64-pc-windows-gnu + +To produce the zip file for windows users, from the target folder run the following commands: + + mkdir -p lektor/platforms && cd lektor # Prepare folders + cp ../{lkt,amadeus,lektord}.exe . # Copy the produced executables + cp ../lektor_c.dll . # Copy the dll for lektord + + for F in $(WINEPATH=/usr/x86_64-w64-mingw32/bin x86_64-w64-mingw32-ldd lektor_c.dll | grep -v "not found" | awk '{print $3}') + do + cp "$F" . # Copy DLL files + done + chmod +x *.dll *.dll.* # Set DLL executable for linux, just in case + cp /usr/x86_64-w64-mingw32/lib/qt6/plugins/platforms/qwindows.dll platforms/ # Copy the windows platform dll for Qt + cp /usr/x86_64-w64-mingw32/lib/qt6/plugins/styles/qwindowsvistastyle.dll styles/ # Copy the style dll + (cd .. && zip lektor.zip lektor/* lektor/platforms/*) # Create the zip file + + # Now you can run lektord and distribute the zip file! + ./lektord.exe + +> Be sure to have the multilib repos and install the bootstrap `minwg-w64-*-bootstrap` packages +> first, to avoid the circular dependencies... And be sure to have a lot of time to waste. + +## Building a lektor distribution for linux (AppImage) + +Note that it is preferable to build AppImages from the older system that you want to support, see +the [official website](https://appimage.org/). Note that you can run AppImage from anywhere at the +condition that the target system has fuse2 installed and is newer that the system the AppImage was +build with. + +### Build on host system (ArchLinux) + +First you need the LinuxDeploy and AppImageTool binaries. You will need to have fuse2 installed on +your system. We will assume you are using an *x86_64* system. You can download it their repositories: +- https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous +- https://github.com/AppImage/AppImageKit/releases/tag/continuous + +As an alternative you can use the following commands and add the `$HOME/.local/bin` folder to you path. + + wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage + wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-static-x86_64.AppImage + mv appimagetool-x86_64.AppImage ~/.local/bin/appimagetool + mv linuxdeploy-static-x86_64.AppImage ~/.local/bin/linuxdeploy + chmod +x ~/.local/bin/appimagetool + chmod +x ~/.local/bin/linuxdeploy + +For the packages needed to build the lektor project, on arch you may install the following packages: +`qt6-multimedia-ffmpeg`, `qt6-translations`, `qt6-declarative`, `qt6-multimedia`, `qt6-wayland`, +`qt6-tools`, `qt6-base`, `qt6-svg`, `mpv`, `cmake`, `cmake-extra-modules`. The usual way of +installing rust is by executing their script: + + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + +After building the lektord executable and .so files, you can use the following commands from the +target folder (where the executable where generated). We will reference the root folder of the +lektord repository as `$ROOT`. + + mkdir Amadeus Lektord Lkt # Create one folder for each AppImage + + # Do the thing for Lkt + linuxdeploy --appdir Lkt --executable lkt --icon-file $ROOT/utils/desktop/lektor.png --desktop-file $ROOT/utils/desktop/lkt.desktop + appimagetool --comp xz --sign --sign-key $YOUR_SIGN_KEY Lkt + + # Do the thing for Lektord + linuxdeploy --appdir Lektord --executable lektord --icon-file $ROOT/utils/desktop/lektor.png --desktop-file $ROOT/utils/desktop/lektord.desktop + appimagetool --comp xz --sign --sign-key $YOUR_SIGN_KEY Lektord + + # Do the thing for Amadeus + linuxdeploy --appdir Amadeus --executable lektord --icon-file $ROOT/utils/desktop/amadeus.png --desktop-file $ROOT/utils/desktop/amadeus.desktop + appimagetool --comp xz --sign --sign-key $YOUR_SIGN_KEY Amadeus + +### Build in a container (Docker/Podman) + +As an alternative you can run the docker which will use debian 12 (bookworm) to try to build an +AppImage which is compatible with as many systems as possible, note that with Qt6 we won't be able +to support systems that are too old. + +You can use docker (must be configured) or podman, with podman you don't need a root daemon and +privileges, it will run as your current user. In the latter case your container registry config file +`/etc/containers/registries.conf` must contains the following content: + + [registries.search] + registries = ['docker.io'] + +When everything is configured you can run the following commands, using either docker or podman. +Note that you still need fuse2 on the host system. + + mkdir -p appimage + podman build --rm -v "$PWD/appimage":/usr/src/lektor/appimage --cap-add SYS_ADMIN --device /dev/fuse . + podman image prune -f + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7be0e00f520314345bed1bd2bc3814082c8e5f74..ecb0685fb1b0b85cb911d3b79fe4beeeaf13419f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,77 +1,69 @@ # Contributing to Lektor -Clone the [git repository](https://git.iiens.net/martin2018/lektor). Create a -branch from master with the `git checkout -b dev-${pseudal}` command. Please, -rebase regularly your branch on `master`. +Clone the [git repository](https://git.iiens.net/martin2018/lektor). Create a branch from master +with the `git checkout -b dev-${pseudal}` command. Please, rebase regularly your branch on `master`. -Please, add your name in the workspace's [Cargo.toml](Cargo.toml) file. The -format is `First name 'Pseudal' FAMILY NAME <email>`. +Please, add your name in the workspace's [Cargo.toml](Cargo.toml) file. The format is +`First name 'Pseudal' FAMILY NAME <email>`. ## License -See [LICENSE](LICENSE). +See [LICENSE]. ## Style and the code ### Rust - Prefer to not use unsafe code. -- Always place the used crates in the workspace's [Cargo.toml](Cargo.toml) - file, or for platform specific things in the [lektor_utils](Lektor) crate and - create a wrapper. All other crates must reuse crates defined in the - workspace's file. +- Always place the used crates in the workspace's [Cargo.toml](Cargo.toml) file, or for platform + specific things in the [lektor_utils](Lektor) crate and create a wrapper. All other crates must + reuse crates defined in the workspace's file. ### C/C++ code and style -For formating, use the `./utils/scripts/style.bash` from the root of the -project. You'll need `clang-format` for it to works. Please, keep the C/C++ -code amount to the minimum, prefer developping things in Rust. +For formating, use the `./utils/scripts/style.bash` from the root of the project. You'll need +`clang-format` for it to works. Please, keep the C/C++ code amount to the minimum, prefer +developping things in Rust. ### Scripts -Scripts goes to the [scripts](utils/scripts) folder. They must be written to be -launched from the root of the project. Include the language used in the name of -the script, for example: +Scripts goes to the [utils/scripts] folder. They must be written to be launched from the root of the +project. Include the language used in the name of the script, for example: - `astyle.bash`: written in bash (bourn shell again) - `hashire.sh`: written in sh (bourn shell) - `magic.rb`: written in ruby -Please, do not write scripts in too many different languages to reduce the -number of dependencies. If you are using binaries in your scripts (like astyle -or bc), include them in the binary dependencies in the [README](/README.md) -file. Also note that `bash` and `sh` are two different shells and things that -work in `bash` might not work with `sh`. As `bash` usually provide `sh`, it is -fine to use the two shells in different scripts without increasing the -dependency number. +Please, do not write scripts in too many different languages to reduce the number of dependencies. +If you are using binaries in your scripts (like astyle or bc), include them in the binary +dependencies in the [README.md] file. Also note that `bash` and `sh` are two different shells and +things that work in `bash` might not work with `sh`. As `bash` usually provide `sh`, it is fine to +use the two shells in different scripts without increasing the dependency number. -There is a strong possibility that your script will do similar things to what a -script already in this repo do. In that case, please work on the existing script -and enhance it with your changes. No need to duplicate things. +There is a strong possibility that your script will do similar things to what a script already in +this repo do. In that case, please work on the existing script and enhance it with your changes. No +need to duplicate things. ### Utilities -You can place utilities in the [utils](utils) folder. When downloading or -building tools not dirrectly distributed with lektor this folder will be used. +You can place utilities in the [utils] folder. When downloading or building tools not dirrectly +distributed with lektor this folder will be used. -See if we use [fontello](https://fontello.com/) to generate fonts with only the -needed icons or if we continue to use the thing from `iced_aw`. Also, see if we -can steel some ideas from https://youtu.be/gcBJ7cPSALo?si=LepvH3JO915AhI_7 +See if we use [fontello](https://fontello.com/) to generate fonts with only the needed icons or if +we continue to use the thing from `iced_aw`. Also, see if we can steel some ideas from +https://youtu.be/gcBJ7cPSALo?si=LepvH3JO915AhI_7 ## Merge request titles -Try to be as more descriptive as you can in your Merge Request title. Include -the issue number and the target OS if possible. +Try to be as more descriptive as you can in your Merge Request title. Include the issue number and +the target OS if possible. -- Branch from the master branch and, if needed, rebase to the current master - branch before submitting your merge request. If it doesn't merge cleanly with - master you may be asked to rebase your changes -- Commits should be as small as possible, while ensuring that each commit is - correct independently (i.e., each commit should compile and pass tests) -- Add tests relevant to the fixed bug or new feature. In general, add a way to - test lektor - -When adding new fetures or solving issues / bugs, please edit the -[CHANGELOG](CHANGELOG.md) file at the `# Next` section. This will help people -know what has been done since the last version. +- Branch from the master branch and, if needed, rebase to the current master branch before + submitting your merge request. If it doesn't merge cleanly with master you may be asked to rebase + your changes +- Commits should be as small as possible, while ensuring that each commit is correct independently + (i.e., each commit should compile and pass tests) +- Add tests relevant to the fixed bug or new feature. In general, add a way to test lektor +When adding new fetures or solving issues / bugs, please edit the [CHANGELOG.md] file at the +`# Next` section. This will help people know what has been done since the last version. diff --git a/Dockerfile b/Dockerfile index eba6d5f632354c966eb35aee27650aabf8ecf347..075be434c363643050273636180d81778fb8c13c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,48 @@ -FROM rust:1.73-bookworm +ARG VERSION=1.73 +FROM rust:${VERSION}-bookworm WORKDIR /usr/src/lektor COPY . . -RUN apt update && apt -y install make libmpv-dev cmake clang clang-format manpages man-db qt6-base-dev qt6-declarative-dev qt6-multimedia-dev \ - && wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O appimagetool && chmod +x appimagetool && mv appimagetool /bin/ \ - && wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-static-x86_64.AppImage -O linuxdeploy && chmod +x linuxdeploy && mv linuxdeploy /bin/ \ - && CXX=clang++ cargo build --release \ - && linuxdeploy --appdir appimage/Lkt --executable lkt --icon-file utils/desktop/lektor.png --desktop-file utils/desktop/lkt.desktop \ - && linuxdeploy --appdir appimage/Lektord --executable lektord --icon-file utils/desktop/lektor.png --desktop-file utils/desktop/lektord.desktop \ - && linuxdeploy --appdir appimage/Amadeus --executable lektord --icon-file utils/desktop/amadeus.png --desktop-file utils/desktop/amadeus.desktop \ - && appimagetool --comp xz appimage/Lkt && appimagetool --comp xz appimage/Lektord && appimagetool --comp xz appimage/Amadeus + +RUN apt update && apt -y install \ + make libmpv-dev cmake clang clang-format manpages man-db \ + qt6-base-dev qt6-declarative-dev qt6-multimedia-dev fuse + +RUN mkdir appimagetool \ + && wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage \ + -O appimagetool/appimage \ + && chmod +x appimagetool/appimage \ + && ./appimagetool/appimage --appimage-extract \ + && mv squashfs-root appimagetool/ + +RUN mkdir linuxdeploy \ + && wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage \ + -O linuxdeploy/appimage \ + && chmod +x linuxdeploy/appimage \ + && ./linuxdeploy/appimage --appimage-extract \ + && mv squashfs-root linuxdeploy/ + +RUN CXX=clang++ cargo build --release + +RUN ./linuxdeploy/squashfs-root/AppRun \ + -v1 --appdir appimage/Lkt \ + --executable target/release/lkt \ + --icon-file utils/desktop/lektor.png \ + --desktop-file utils/desktop/lkt.desktop \ + && ./appimagetool/squashfs-root/AppRun -v --comp xz appimage/Lkt \ + && mv Lkt-*.AppImage appimage/ && rm -rf appimage/Lkt/ + +RUN ./linuxdeploy/squashfs-root/AppRun \ + -v1 --appdir appimage/Lektord \ + --executable target/release/lektord \ + --icon-file utils/desktop/lektor.png \ + --desktop-file utils/desktop/lektord.desktop \ + && ./appimagetool/squashfs-root/AppRun -v --comp xz appimage/Lektord \ + && mv Lektord-*.AppImage appimage/ && rm -rf appimage/Lektord/ + +RUN ./linuxdeploy/squashfs-root/AppRun \ + -v1 --appdir appimage/Amadeus \ + --executable target/release/amadeus \ + --icon-file utils/desktop/amadeus.png \ + --desktop-file utils/desktop/amadeus.desktop \ + && ./appimagetool/squashfs-root/AppRun -v --comp xz appimage/Amadeus \ + && mv Amadeus-*.AppImage appimage/ && rm -rf appimage/Amadeus/ diff --git a/README.md b/README.md index 2fa6e51d7f6d4a1ff3bfa1f4c6287acb92dbe4be..51e9613b39aa128f22140235bd57cb66f43c4640 100644 --- a/README.md +++ b/README.md @@ -49,11 +49,13 @@ compiler: `CXX=clang++ cargo build --release`. By default the build artifacts fo placed in the `.build` folder at the root of the project. If you specify another compiler they will be placed in the `.build.$(basename "$CXX")` folder. -> **Important note**: Upgrading the database from version 2.4 to version 3 is not possible. You need -> to delete the database and re-dl all the karas from kurisu. +For more informations about builds options, see the [BUILD.md] file. ## How to use lektor +> **Important note**: Upgrading the database from version 2.4 to version 3 is not possible. You need +> to delete the database and re-dl all the karas from kurisu. + ### Launch instructions To run lektor, you can simply run the binary like: `./lektord`. Be sure to place the @@ -98,115 +100,7 @@ For `amadeus`, you can edit its configuration file in the settings section. ## Misc The lektord and related binaries and source code are under the MIT license. Please, refer to the -[CONTRIBUTING](CONTRIBUTING.md) file for any contributions. - -## Building a lektord distribution for windows (Cross Compilation) - -Windows 64 bit binaries are built from a linux system. Here we will assume you are using an arch -linux system because it's what I'm using. Install the packages `mingw-w64-gcc`, `mingw-w64-cmake` -(aur), `mingw-w64-make` (aur). You may also install the `mingw-w64-qt6-*` (aur) packages. For the -mpv library, install the packages in [utils/arch-pkgs]. Make sure that you have the windows -toolchain for 64 bit installed. Run the followinf commands: - - (cd utils/arch-pkgs/mingw-w64-shaderc && makepkg -si) - yay -Sy mingw-w64-gcc mingw-w64-cmake mingw-w64-make mingw-w64-dlfcn x86_64-w64-mingw32-ldd - yay -Sy mingw-w64-mpv # Be sure to install it after building shaderc from source - yay -Sy mingw-w64-qt6-* # You may specify the packages, you may doo the bootstrap thingy here - rustup target add x86_64-pc-windows-gnu # Add the windows target, here we build 64bit applications - MAKE=x86_64-w64-mingw32-make CMAKE=x86_64-w64-mingw32-cmake CXX=x86_64-w64-mingw32-g++ cargo build --target x86_64-pc-windows-gnu - -To produce the zip file for windows users, from the target folder run the following commands: - - mkdir -p lektor/platforms && cd lektor # Prepare folders - cp ../{lkt,amadeus,lektord}.exe . # Copy the produced executables - cp ../lektor_c.dll . # Copy the dll for lektord - - for F in $(WINEPATH=/usr/x86_64-w64-mingw32/bin x86_64-w64-mingw32-ldd lektor_c.dll | grep -v "not found" | awk '{print $3}') - do - cp "$F" . # Copy DLL files - done - chmod +x *.dll *.dll.* # Set DLL executable for linux, just in case - cp /usr/x86_64-w64-mingw32/lib/qt6/plugins/platforms/qwindows.dll platforms/ # Copy the windows platform dll for Qt - cp /usr/x86_64-w64-mingw32/lib/qt6/plugins/styles/qwindowsvistastyle.dll styles/ # Copy the style dll - (cd .. && zip lektor.zip lektor/* lektor/platforms/*) # Create the zip file - - # Now you can run lektord and distribute the zip file! - ./lektord.exe - -> Be sure to have the multilib repos and install the bootstrap `minwg-w64-*-bootstrap` packages -> first, to avoid the circular dependencies... And be sure to have a lot of time to waste. - -## Building a lektord distribution for linux (AppImage) - -Note that it is preferable to build AppImages from the older system that you want to support, see -the [official website](https://appimage.org/). - -### Build on host system (ArchLinux) - -First you need the LinuxDeploy and AppImageTool binaries. We will assume you are using an *x86_64* -system. You can download it their repositories: -- https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous -- https://github.com/AppImage/AppImageKit/releases/tag/continuous - -As an alternative you can use the following commands and add the `$HOME/.local/bin` folder to you path. - - wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage - wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-static-x86_64.AppImage - mv appimagetool-x86_64.AppImage ~/.local/bin/appimagetool - mv linuxdeploy-static-x86_64.AppImage ~/.local/bin/linuxdeploy - chmod +x ~/.local/bin/appimagetool - chmod +x ~/.local/bin/linuxdeploy - -For the packages needed to build the lektor project, on arch you may install the following packages: -`qt6-multimedia-ffmpeg`, `qt6-translations`, `qt6-declarative`, `qt6-multimedia`, `qt6-wayland`, -`qt6-tools`, `qt6-base`, `qt6-svg`, `mpv`, `cmake`, `cmake-extra-modules`. The usual way of -installing rust is by executing their script: - - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - -After building the lektord executable and .so files, you can use the following commands from the -target folder (where the executable where generated). We will reference the root folder of the -lektord repository as `$ROOT`. - - mkdir Amadeus Lektord Lkt # Create one folder for each AppImage - - # Do the thing for Lkt - linuxdeploy --appdir Lkt --executable lkt --icon-file $ROOT/utils/desktop/lektor.png --desktop-file $ROOT/utils/desktop/lkt.desktop - appimagetool --comp xz --sign --sign-key $YOUR_SIGN_KEY Lkt - - # Do the thing for Lektord - linuxdeploy --appdir Lektord --executable lektord --icon-file $ROOT/utils/desktop/lektor.png --desktop-file $ROOT/utils/desktop/lektord.desktop - appimagetool --comp xz --sign --sign-key $YOUR_SIGN_KEY Lektord - - # Do the thing for Amadeus - linuxdeploy --appdir Amadeus --executable lektord --icon-file $ROOT/utils/desktop/amadeus.png --desktop-file $ROOT/utils/desktop/amadeus.desktop - appimagetool --comp xz --sign --sign-key $YOUR_SIGN_KEY Amadeus - -### Build in a container (Docker/Podman) - -As an alternative you can run the docker which will use debian 12 (bookworm) to try to build an -AppImage which is compatible with as many systems as possible, note that with Qt6 we won't be able -to support systems that are too old. - -You can use docker (must be configured) or podman, with podman you don't need a root daemon and -privileges, it will run as your current user. In the latter case your container registry config file -`/etc/containers/registries.conf` must contains the following content: - - [registries.search] - registries = ['docker.io'] - -When everything is configured you can run the following commands, using either docker or podman: - - # Be sure that we have the target folder where the AppImages will be copied - mkdir -p appimage - - # Run Podman/Docker, "lbc" stands for Lektor Build Container - podman build --rm -v "$PWD/appimage":/usr/src/lektor/target/appimage -t lbc . - - # To clean up all the things left behind - podman system reset - ---- +[CONTRIBUTING.md] file for any contributions. # TODO List