diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-12-30 18:44:52 +0100 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-12-30 18:44:52 +0100 |
commit | 8beb57f19d5abd9ec9356abfc67a4da094e94b14 (patch) | |
tree | 0c041715fc5bb365729f5daff31a29bdac45d866 | |
parent | feat(treewide): Migrate the Unicode handling to a custom c program, that work... (diff) | |
download | qmk_layout-8beb57f19d5abd9ec9356abfc67a4da094e94b14.zip |
fix(qmk_unicode_type): Package
-rw-r--r-- | flake.nix | 6 | ||||
-rw-r--r-- | rust/qmk-hid-com/src_c/meson.build | 16 | ||||
-rw-r--r-- | rust/qmk-hid-com/src_c/package.nix | 63 |
3 files changed, 70 insertions, 15 deletions
diff --git a/flake.nix b/flake.nix index 4e472d3..3880f37 100644 --- a/flake.nix +++ b/flake.nix @@ -46,8 +46,12 @@ package = pkgs.callPackage ./package.nix {}; format_layer = pkgs.callPackage ./rust/format/package.nix {}; + qmk_unicode_type = pkgs.callPackage ./rust/qmk-hid-com/src_c/package.nix {}; in { - packages.default = package; + packages = { + default = package; + inherit qmk_unicode_type; + }; checks = { formatting = treefmtEval.config.build.check self; }; diff --git a/rust/qmk-hid-com/src_c/meson.build b/rust/qmk-hid-com/src_c/meson.build index 9e8357f..20388b8 100644 --- a/rust/qmk-hid-com/src_c/meson.build +++ b/rust/qmk-hid-com/src_c/meson.build @@ -4,22 +4,9 @@ project( 'qmk-unicode-type', 'c', version: '0.1', license: 'GPL-3.0-or-later', - default_options : [ - 'buildtype=release', - 'default_library=static' - ], ) -git = find_program('git', native: true, required: false) - -if not git.found() - add_project_arguments('-DVERSION="@0@"'.format(meson.project_version()), language: 'c') -else - git_commit_hash = run_command([git.full_path(), 'describe', '--always', '--tags'], check: true).stdout().strip() - git_branch = run_command([git.full_path(), 'rev-parse', '--abbrev-ref', 'HEAD'], check: true).stdout().strip() - version = '"@0@ (" __DATE__ ", branch \'@1@\')"'.format(git_commit_hash, git_branch) - add_project_arguments('-DVERSION=@0@'.format(version), language: 'c') -endif +add_project_arguments('-DVERSION="@0@"'.format(meson.project_version()), language: 'c') cc = meson.get_compiler('c') @@ -47,5 +34,6 @@ executable( libhid, rt, ], + install: true ) diff --git a/rust/qmk-hid-com/src_c/package.nix b/rust/qmk-hid-com/src_c/package.nix new file mode 100644 index 0000000..17f84db --- /dev/null +++ b/rust/qmk-hid-com/src_c/package.nix @@ -0,0 +1,63 @@ +{ + stdenv, + lib, + # deps + meson, + pkg-config, + ninja, + wayland-scanner, + wayland, + hidapi, +}: +stdenv.mkDerivation { + pname = "qmk-unicode-type"; + version = "1.0.0"; + + src = lib.cleanSourceWith { + src = lib.cleanSource ./.; + filter = name: type: + (type == "directory") + || (builtins.elem (builtins.baseNameOf name) [ + "virtual-keyboard-unstable-v1.xml" + ]) + || (lib.strings.hasSuffix ".c" (builtins.baseNameOf name)) + || (lib.strings.hasSuffix ".h" (builtins.baseNameOf name)) + || (lib.strings.hasSuffix ".build" (builtins.baseNameOf name)); + }; + + env = { + }; + mesonFlags = lib.mapAttrsToList lib.mesonOption { + debug = "false"; + optimization = "3"; + strip = "true"; + warning_level = "everything"; + werror = "true"; + b_lundef = "true"; + b_lto = "true"; + b_ndebug = "false"; + b_pgo = "generate"; + b_staticpic = "true"; + b_pie = "false"; + c_std = "gnu2x"; + }; + # ar with gcc plugins for lto objects + preConfigure = '' + CC="gcc"; + AR="gcc-ar"; + RANLIB="gcc-ranlib" ; + export CC AR RANLIB + ''; + + strictDeps = true; + nativeBuildInputs = [ + meson + pkg-config + ninja + wayland-scanner + ]; + buildInputs = [ + wayland + hidapi + ]; +} |