Skip to content

Commit

Permalink
Move version info (#709)
Browse files Browse the repository at this point in the history
* move version information

* update scripts and makefiles

* add version.h to main.h

* fix bugs on windows and linux

* move version.h to pros folder

* update header comments
  • Loading branch information
Rocky14683 authored Nov 9, 2024
1 parent 575dc38 commit 58e23bf
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 14 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ EXTRA_LIB_DEPS=$(INCDIR)/api.h $(PATCHED_SDK)
########## Nothing below this line should be edited by typical users ###########
-include ./common.mk

.PHONY: $(INCDIR)/api.h patch_sdk_headers clean
$(INCDIR)/api.h: version.py
.PHONY: $(INCDIR)/pros/version.h patch_sdk_headers clean
$(INCDIR)/pros/version.h: version.py
$(VV)python version.py

patch_sdk_headers: patch_headers.py
@echo "Patching SDK headers"
$(VV)python patch_headers.py

# Override clean, necessary to remove patched sdk on clean
clean:
clean::
@echo "Cleaning patched SDK"
@rm -f $(PATCHED_SDK)
@rm -rf $(EXTRA_INCDIR)
Expand Down
4 changes: 2 additions & 2 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ quick: $(DEFAULT_BIN)

all: clean $(DEFAULT_BIN)

clean:
clean::
@echo Cleaning project
-$Drm -rf $(BINDIR)
-$Drm -rf $(DEPDIR)
Expand Down Expand Up @@ -262,7 +262,7 @@ $(foreach asmext,$(ASMEXTS),$(eval $(call asm_rule,$(asmext))))

define c_rule
$(BINDIR)/%.$1.o: $(SRCDIR)/%.$1
$(BINDIR)/%.$1.o: $(SRCDIR)/%.$1 $(DEPDIR)/$(basename $1).d
$(BINDIR)/%.$1.o: $(SRCDIR)/%.$1 $(DEPDIR)/$(basename %).d
$(VV)mkdir -p $$(dir $$@)
$(MAKEDEPFOLDER)
$$(call test_output_2,Compiled $$< ,$(CC) -c $(INCLUDE) -iquote"$(INCDIR)/$$(dir $$*)" $(CFLAGS) $(EXTRA_CFLAGS) $(DEPFLAGS) -o $$@ $$<,$(OK_STRING))
Expand Down
7 changes: 0 additions & 7 deletions include/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@
#include <unistd.h>
#endif /* __cplusplus */

#define PROS_VERSION_MAJOR 4
#define PROS_VERSION_MINOR 1

#define PROS_VERSION_PATCH 0
#define PROS_VERSION_STRING "4.1.0"


#include "pros/adi.h"
#include "pros/colors.h"
#include "pros/device.h"
Expand Down
23 changes: 23 additions & 0 deletions include/pros/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* \file version.h
*
* PROS Version Information
*
* Contains PROS kernel version information
*
*
* \copyright Copyright (c) 2017-2023, Purdue University ACM SIGBots.
* All rights reserved.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#pragma once

#define PROS_VERSION_MAJOR 4
#define PROS_VERSION_MINOR 1

#define PROS_VERSION_PATCH 0
#define PROS_VERSION_STRING "4.1.0"
1 change: 1 addition & 0 deletions src/system/dev/ser_daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <errno.h>

#include "kapi.h"
#include "pros/version.h"
#include "system/dev/banners.h"
#include "system/hot.h"
#include "system/optimizers.h"
Expand Down
4 changes: 2 additions & 2 deletions version.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
assert semver.count('.') >= 2
major, minor, patch = semver.split('.', 2)
patch = patch.split('-', 1)[0]
with io.open('include/api.h', 'r', encoding='ascii') as file:
with io.open('include/pros/version.h', 'r', encoding='ascii') as file:
data = file.readlines()
for i, line in enumerate(data):
if '#define PROS_VERSION_MAJOR' in line:
Expand All @@ -39,7 +39,7 @@
data[i] = u'#define PROS_VERSION_PATCH {}\n'.format(patch)
if '#define PROS_VERSION_STRING ' in line:
data[i] = u'#define PROS_VERSION_STRING "{}"\n'.format(semver)
with io.open('include/api.h', 'w', newline='\n', encoding='ascii') as file:
with io.open('include/pros/version.h', 'w', newline='\n', encoding='ascii') as file:
file.writelines(data)

except subprocess.CalledProcessError as e:
Expand Down

0 comments on commit 58e23bf

Please sign in to comment.