Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/release_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,55 @@ name: Release Windows

on:
workflow_dispatch:
release:
types: published

env:
PACKAGE: ${{ github.event.repository.name }}

jobs:
run:

runs-on: ubuntu-latest

steps:
- name: Chekout
uses: actions/checkout@v4

- name: 'Dependencies: Nix'
uses: cachix/install-nix-action@v26
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: Setup Nix cache
uses: DeterminateSystems/magic-nix-cache-action@v4

- name: Build
env:
NIXPKGS_ALLOW_BROKEN: 1
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM: 1
run: nix build -L --no-update-lock-file --show-trace --impure .#${{ env.PACKAGE }}Mingw64Zip

- name: Extract informations
id: extract
shell: bash
run: |
echo "upload_url=$(curl -sL ${{ github.api_url }}/repos/${{ github.repository }}/releases/tags/${{ github.ref_name }}} | jq -r '.upload_url')" >> $GITHUB_OUTPUT

- name: Deploy .zip on Github
if: ${{ github.event_name == 'release' }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.extract.outputs.upload_url }}
asset_path: result/${{ env.PACKAGE }}-x86_64-w64-mingw32-${{ github.ref_name }}.zip
asset_name: ${{ env.PACKAGE }}-${{ github.ref_name }}-x86_64-w64-mingw32.zip
asset_content_type: application/zip

- name: Fail
if: ${{ github.event_name != 'release' }}
uses: actions/github-script@v7
with:
script: |
core.setFailed("Trigger event: ${{ github.event_name }} (should be release), Git ref: ${{ github.ref_name }}")
31 changes: 16 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,8 @@ if( NOT CMAKE_BUILD_TYPE )
endif()
message( STATUS "Build type: ${CMAKE_BUILD_TYPE}" )

#[[
set( CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
OWNER_READ
OWNER_WRITE
OWNER_EXECUTE
GROUP_READ
GROUP_EXECUTE
WORLD_READ
WORLD_EXECUTE
)
#]]

option( CPM_DISABLE "Don't use CPM to retrieve dependencies" "$ENV{CPM_DISABLE}" )
option( OEMSH_PORTABILITY_TWEAKS "Enable some portability tweaks" OFF )

if( NOT CPM_DISABLE )
message( STATUS "Downloading dependencies with CPM" )
Expand All @@ -53,7 +42,7 @@ if( NOT CPM_DISABLE )
CPMAddPackage(
NAME pugixml
GITHUB_REPOSITORY zeux/pugixml
VERSION 1.12.1
VERSION 1.15
OPTIONS
"BUILD_SHARED_LIBS ON"
)
Expand All @@ -63,7 +52,7 @@ if( NOT CPM_DISABLE )
CPMAddPackage(
NAME CLI11
GITHUB_REPOSITORY CLIUtils/CLI11
VERSION 2.3.1
VERSION 2.5.0
)

set( CLI11_DIR "${CLI11_BINARY_DIR}" )
Expand All @@ -81,7 +70,7 @@ if( pugixml_FOUND )
message( STATUS "Found pugixml: ${pugixml_DIR} ${PUGIXML_VERSION}" )
endif()

find_package( CLI11 REQUIRED )
find_package( CLI11 2.4.0 REQUIRED )
if( CLI11_FOUND )
message( STATUS "Found CLI11: ${CLI11_DIR} ${CLI11_VERSION}" )
endif()
Expand Down Expand Up @@ -109,6 +98,18 @@ if( CMakeUtils_FOUND )
include( CMakeUtils )
endif()

include( GNUInstallDirs )

set( CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
OWNER_READ
OWNER_WRITE
OWNER_EXECUTE
GROUP_READ
GROUP_EXECUTE
WORLD_READ
WORLD_EXECUTE
)

add_subdirectory( "${CMAKE_SOURCE_DIR}/src" )
add_subdirectory( "${CMAKE_SOURCE_DIR}/test" )
add_subdirectory( "${CMAKE_SOURCE_DIR}/icon" )
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
[![SonarCloud quality gate](https://sonarcloud.io/api/project_badges/measure?project=Open-RFlab_openemsh&metric=alert_status)](https://sonarcloud.io/dashboard?id=Open-RFlab_openemsh)
[![SonarCloud coverage](https://sonarcloud.io/api/project_badges/measure?project=Open-RFlab_openemsh&metric=coverage)](https://sonarcloud.io/dashboard?id=Open-RFlab_openemsh)

[![Package Windows](https://img.shields.io/github/actions/workflow/status/Open-RFlab/openemsh/release_windows.yml?label=package&logo=mingww64)](https://github.com/Open-RFlab/openemsh/releases)

# OpenEMSH : OpenEMS Mesher [WIP]

_This project is under heavy development and not yet usable, for now the best way to contribute is to give a symbolic tip. :)_
Expand Down
18 changes: 12 additions & 6 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{ lib
, pkgs ? import <nixpkgs> {}
, stdenv ? pkgs.stdenv
, stdenv
, cmake
, cmake-utils
, git
Expand All @@ -9,12 +8,11 @@
, pugixml
, qtbase
, wrapQtAppsHook
, withPortabilityTweaks ? false
}:

with pkgs;

stdenv.mkDerivation {
name = "openemsh";
pname = "openemsh";
version = "0.0.0";

src = lib.nix-filter {
Expand Down Expand Up @@ -47,14 +45,22 @@ stdenv.mkDerivation {
];

cmakeFlags = [
"-DCPM_DISABLE=ON"
(lib.cmakeBool "CPM_DISABLE" true)
(lib.cmakeBool "OEMSH_PORTABILITY_TWEAKS" withPortabilityTweaks)
];

shellHook = ''
unset NIX_HARDENING_ENABLE
export CPM_DISABLE=ON
'';

postInstall = lib.optionals stdenv.hostPlatform.isWindows ''
mkdir -p $out/bin/platforms
ln -t $out/bin/platforms -s ${qtbase}/lib/qt-6/plugins/platforms/qwindows.dll
'';

dontWrapQtApps = stdenv.hostPlatform.isWindows;

QT_XCB_GL_INTEGRATION = "none";

meta = {
Expand Down
37 changes: 27 additions & 10 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 55 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";

# Known to work version, nixpkgs is often broken for cross compilation.
nixpkgs-mingw.url = "github:NixOS/nixpkgs/58a1abdbae3217ca6b702f03d3b35125d88a2994";

nix-filter.url = "github:numtide/nix-filter";

flake-utils.url = "github:numtide/flake-utils";
Expand All @@ -25,6 +28,7 @@

outputs = { self
, nixpkgs
, nixpkgs-mingw
, nix-filter
, cmake-utils
, flake-utils
Expand All @@ -41,6 +45,48 @@
self.overlays.pkgs
];

pkgs-mingw = nixpkgs-mingw.legacyPackages.${system}.appendOverlays [
(final: prev: { inherit (pkgs) cli11; })
cmake-utils.overlays.pkgs
self.overlays.pkgs
];

wineWrapper = package: pkgs.stdenvNoCC.mkDerivation {
inherit (package) pname version meta;
doCheck = false;
dontUnpack = true;
dontBuild = true;
installPhase =
let
script = ''
#!/bin/sh
exec ${pkgs.wine64}/bin/wine64 ${package}/bin/${package.pname}.exe "$@"
'';
in ''
mkdir -p $out/bin
printf '${script}' > $out/bin/${package.pname}
chmod +x $out/bin/${package.pname}
# mkdir -p $out/share
# ${pkgs.xorg.lndir}/bin/lndir -silent ${package}/share $out/share
'';
};

zipWrapper = package: pkgs.stdenvNoCC.mkDerivation {
inherit (package) pname version meta;
doCheck = false;
dontUnpack = true;
nativeBuildInputs = [ pkgs.zip ];
buildPhase = ''
cp -rL ${package} ${package.name}
chmod -R ug+w ${package.name}
zip -r ${package.name}.zip ${package.name}/*
'';
installPhase = ''
mkdir -p $out
mv ${package.name}.zip $out/
'';
};

in {
devShells = {
default = pkgs.mkShell {
Expand Down Expand Up @@ -77,16 +123,23 @@
packages = {
default = pkgs.openemsh;
openemsh = pkgs.openemsh;
openemshMingw64 = pkgs-mingw.openemshMingw64;
openemshMingw64Zip = zipWrapper pkgs-mingw.openemshMingw64;
openemshWine64 = wineWrapper (pkgs-mingw.openemshMingw64.override { withPortabilityTweaks = true; });
};
}) // {
overlays = {
pkgs = final: prev: {
openemsh = prev.qt6.callPackage ./default.nix {
inherit lib;
stdenv = prev.llvmPackages_13.stdenv;
};

inherit (prev.python310Packages) cairosvg;
openemshMingw64 = prev.pkgsCross.mingwW64.qt6.callPackage ./default.nix {
inherit lib;
inherit (final) texlive;
};

inherit (prev.python3Packages) cairosvg;

csxcad = (prev.csxcad.overrideAttrs (new: old: {
version = "0.6.3";
Expand Down
Loading
Loading