Skip to content

Commit

Permalink
Initial structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
tzarc committed Nov 22, 2023
0 parents commit 92d62d0
Show file tree
Hide file tree
Showing 12 changed files with 506 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
BasedOnStyle: Google
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'true'
AlignOperands: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: Empty
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: 'false'
BinPackArguments: 'true'
BinPackParameters: 'true'
ColumnLimit: '1000'
IndentCaseLabels: 'true'
IndentPPDirectives: AfterHash
IndentWidth: '4'
MaxEmptyLinesToKeep: '1'
PointerAlignment: Right
SortIncludes: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: 'false'
SpacesBeforeTrailingComments: 1
TabWidth: '4'
UseTab: Never

...
4 changes: 4 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CompileFlags:
Add: [-Wno-unknown-attributes, -Wno-maybe-uninitialized, -Wno-unknown-warning-option]
Remove: [-W*, -mcall-prologues]
Compiler: clang
32 changes: 32 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 4

# We recommend you to keep these unchanged
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
indent_size = 4

[{qmk,*.py}]
charset = utf-8
max_line_length = 200

# Make these match what we have in .gitattributes
[*.mk]
end_of_line = lf
indent_style = tab

[Makefile]
end_of_line = lf
indent_style = tab

[*.sh]
end_of_line = lf
20 changes: 20 additions & 0 deletions .github/workflows/build_binaries.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Build QMK firmware

on: [push, workflow_dispatch]

permissions:
contents: write

jobs:
build:
name: 'QMK Userspace Build'
uses: qmk/.github/.github/workflows/qmk_userspace_build.yml@qmk-userspace
with:
qmk_repo: qmk/qmk_firmware
qmk_ref: master

publish:
name: 'QMK Userspace Publish'
uses: qmk/.github/.github/workflows/qmk_userspace_publish.yml@qmk-userspace
if: always() && !cancelled()
needs: build
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.hex
*.bin
*.uf2
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.SILENT:

MAKEFLAGS += --no-print-directory

QMK_USERSPACE := $(patsubst %/,%,$(dir $(shell realpath "$(lastword $(MAKEFILE_LIST))")))
ifeq ($(QMK_USERSPACE),)
QMK_USERSPACE := $(shell pwd)
endif

QMK_FIRMWARE_ROOT = $(shell qmk config -ro user.qmk_home | cut -d= -f2 | sed -e 's@^None$$@@g')
ifeq ($(QMK_FIRMWARE_ROOT),)
$(error Cannot determine qmk_firmware location. `qmk config -ro user.qmk_home` is not set)
endif

%:
+$(MAKE) -C $(QMK_FIRMWARE_ROOT) $(MAKECMDGOALS) QMK_USERSPACE=$(QMK_USERSPACE)
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# QMK Userspace

This is a template repository which allows for an external set of QMK keymaps to be defined and compiled. This is useful for users who want to maintain their own keymaps without having to fork the main QMK repository.

## Howto configure your build targets

1. Run the normal `qmk setup` procedure if you haven't already done so -- see [QMK Docs](https://docs.qmk.fm/#/newbs) for details.
1. Fork this repository
1. Clone your fork to your local machine
1. Add a new keymap for your board using `qmk new-keymap`
* This will create a new keymap in the `keyboards` directory, in the same location that would normally be used in the main QMK repository. For example, if you wanted to add a keymap for the Planck, it will be created in `keyboards/planck/keymaps/<your keymap name>`
* You can also create a new keymap using `qmk new-keymap -kb <your_keyboard> -km <your_keymap>`
* Alternatively, add your keymap manually by placing it in the location specified above.
* `layouts/<layout name>/<your keymap name>/keymap.*` is also supported if you prefer the layout system
1. Add your keymap(s) to the build by running `qmk userspace-add -kb <your_keyboard> -km <your_keymap>`
* This will automatically update your `qmk.json` file
* Corresponding `qmk userspace-remove -kb <your_keyboard> -km <your_keymap>` will delete it
* Listing the build targets can be done with with `qmk userspace-list`
1. Commit your changes

## Howto build with GitHub

1. In the GitHub Actions tab, enable workflows
1. Push your changes above to your forked GitHub repository
1. Look at the GitHub Actions for a new actions run
1. Wait for the actions run to complete
1. Inspect the Releases tab on your repository for the latest firmware build

## Howto build locally

1. Run the normal `qmk setup` procedure if you haven't already done so -- see [QMK Docs](https://docs.qmk.fm/#/newbs) for details.
1. Fork this repository
1. Clone your fork to your local machine
1. `cd` into this repository's clone directory
1. Set global userspace path: `qmk config user.overlay_dir="$(realpath .)"` -- you MUST be located in the cloned userspace location for this to work correctly
* This will be automatically detected if you've `cd`ed into your userspace repository, but the above makes your userspace available regardless of your shell location.
1. Compile normally: `qmk compile -kb your_keyboard -km your_keymap` or `make your_keyboard:your_keymap`

Alternatively, if you configured your build targets above, you can use `qmk userspace-compile` to build all of your userspace targets at once.

## Extra info

If you wish to point GitHub actions to a different repository, a different branch, or even a different keymap name, you can modify `.github/workflows/build_binaries.yml` to suit your needs.

To override the `build` job, you can change the following parameters to use a different QMK repository or branch:
```
with:
qmk_repo: qmk/qmk_firmware
qmk_ref: master
```

If you wish to manually manage `qmk_firmware` using git within the userspace repository, you can add `qmk_firmware` as a submodule in the userspace directory instead. GitHub Actions will automatically use the submodule at the pinned revision if it exists, otherwise it will use the default latest revision of `qmk_firmware` from the main repository.

This can also be used to control which fork is used, though only upstream `qmk_firmware` will have support for external userspace until other manufacturers update their forks.

1. (First time only) `git submodule add https://github.com/qmk/qmk_firmware.git`
1. (To update) `git submodule update --init --recursive`
1. Commit your changes to your userspace repository
Empty file added keyboards/.keep
Empty file.
Empty file added layouts/.keep
Empty file.
4 changes: 4 additions & 0 deletions qmk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"userspace_version": "1.0",
"build_targets": []
}
Empty file added users/.keep
Empty file.

0 comments on commit 92d62d0

Please sign in to comment.