Skip to content

Swap over to cmake #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -24,8 +24,9 @@ jobs:
- name: Compile and Package
shell: bash
run: |
make clean all
7z a ./build/mdloader-${RUNNER_OS}.zip ./build/mdloader*
cmake -S . -B build -G"Unix Makefiles"
cd build && cmake --build .
7z a ./mdloader-${RUNNER_OS}.zip mdloader*

- uses: actions/upload-artifact@v2
with:
27 changes: 27 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 3.10)

# set the project name and version
project("Massdrop Loader" VERSION 1.7)

configure_file(config.h.in config.h)
include_directories("${PROJECT_BINARY_DIR}")

file(COPY applet-mdflash.bin DESTINATION "${CMAKE_BINARY_DIR}")

SET(SOURCES
mdloader_common.c
mdloader_parser.c
)

if (WIN32)
SET(SOURCES ${SOURCES}
mdloader_win32.c
)
else()
SET(SOURCES ${SOURCES}
mdloader_unix.c
)
endif()

add_executable(mdloader ${SOURCES})
install(TARGETS mdloader DESTINATION bin)
36 changes: 0 additions & 36 deletions Makefile

This file was deleted.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -55,10 +55,11 @@ Massdrop keyboard's featuring Microchip's SAM-BA bootloader.

## Building

Enter mdloader directory where Makefile is located and execute:
Enter mdloader directory where `CMakeLists.txt` is located and execute:

```
make
cmake -B build
cmake --build build
```

This will create a `build` directory with the compiled executable. Run `./build/mdloader` to test.
6 changes: 6 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#define PROJECT_NAME "@PROJECT_NAME@"
#define PROJECT_VER "@PROJECT_VERSION@"
#define PROJECT_VER_MAJOR "@PROJECT_VERSION_MAJOR@"
#define PROJECT_VER_MINOR "@PROJECT_VERSION_MINOR@"
4 changes: 2 additions & 2 deletions mdloader_common.c
Original file line number Diff line number Diff line change
@@ -601,14 +601,14 @@ int set_terminal_mode(void)
//Display program version
void display_version(void)
{
printf(PROGRAM_NAME " %i.%02i\n", VERSION_MAJOR, VERSION_MINOR);
printf(PROJECT_NAME " " PROJECT_VER "\n");
printf("\n");
}

//Display program copyright
void display_copyright(void)
{
printf(PROGRAM_NAME " Copyright (C) 2018-2022 Massdrop Inc.\n");
printf(PROJECT_NAME " Copyright (C) 2018-2022 Massdrop Inc.\n");
printf("This program is Free Software and has ABSOLUTELY NO WARRANTY\n");
printf("\n");
}
4 changes: 1 addition & 3 deletions mdloader_common.h
Original file line number Diff line number Diff line change
@@ -20,9 +20,7 @@
#ifndef _MDLOADER_COMMON_H
#define _MDLOADER_COMMON_H

#define PROGRAM_NAME "Massdrop Loader"
#define VERSION_MAJOR 1
#define VERSION_MINOR 7 //0-99
#include "config.h"

#ifdef _WIN32
#define INITGUID
2 changes: 1 addition & 1 deletion mdloader_win32.c
Original file line number Diff line number Diff line change
@@ -469,7 +469,7 @@ int close_port(char silent)
//Return 1 on sucess, 0 on failure
int config_port(void)
{
DCB dcb = {};
DCB dcb = {0};

if (verbose) printf("Configuring port... \n");