Skip to content
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

Build: Use git tag for the file version on windows #5355

Merged
merged 2 commits into from
Jan 20, 2022

Conversation

TheLastRar
Copy link
Contributor

@TheLastRar TheLastRar commented Jan 18, 2022

Description of Changes

Uses the Git tag for the file version (And anything else that uses PCSX2_VersionHi/Mid/Lo)

image

Rationale behind Changes

Have the Git tag visible in the file details pane on Windows

Suggested Testing Steps

Hope nothing breaks

pcsx2/SysForwardDefs.h Outdated Show resolved Hide resolved
Also update the copyright year of SysForwardDefs.h
@refractionpcsx2 refractionpcsx2 merged commit 38a5431 into PCSX2:master Jan 20, 2022
@AaronBPaden
Copy link

Heads up, this seems to break building on Linux for me

In file included from /build/pcsx2-git/src/pcsx2/pcsx2/System.h:18,
                 from /build/pcsx2-git/src/pcsx2/pcsx2/Common.h:25,
                 from /build/pcsx2-git/src/pcsx2/pcsx2/PINE.cpp:39:
/build/pcsx2-git/src/pcsx2/pcsx2/PINE.cpp: In member function ‘PINEServer::IPCBuffer PINEServer::ParseCommand(char*, char*, u32)’:
/build/pcsx2-git/src/pcsx2/pcsx2/SysForwardDefs.h:22:26: error: ‘GIT_TAG_HI’ was not declared in this scope; did you mean ‘GIT_TAG’?
   22 | #define PCSX2_VersionHi  GIT_TAG_HI
      |                          ^~~~~~~~~~
/build/pcsx2-git/src/pcsx2/pcsx2/SysForwardDefs.h:22:26: note: in definition of macro ‘PCSX2_VersionHi’
   22 | #define PCSX2_VersionHi  GIT_TAG_HI
      |                          ^~~~~~~~~~
/build/pcsx2-git/src/pcsx2/pcsx2/SysForwardDefs.h:23:26: error: ‘GIT_TAG_MID’ was not declared in this scope; did you mean ‘GIT_TAG’?
   23 | #define PCSX2_VersionMid GIT_TAG_MID
      |                          ^~~~~~~~~~~
/build/pcsx2-git/src/pcsx2/pcsx2/SysForwardDefs.h:23:26: note: in definition of macro ‘PCSX2_VersionMid’
   23 | #define PCSX2_VersionMid GIT_TAG_MID
      |                          ^~~~~~~~~~~
/build/pcsx2-git/src/pcsx2/pcsx2/SysForwardDefs.h:24:26: error: ‘GIT_TAG_LO’ was not declared in this scope; did you mean ‘GIT_TAG’?
   24 | #define PCSX2_VersionLo  GIT_TAG_LO
      |                          ^~~~~~~~~~
/build/pcsx2-git/src/pcsx2/pcsx2/SysForwardDefs.h:24:26: note: in definition of macro ‘PCSX2_VersionLo’
   24 | #define PCSX2_VersionLo  GIT_TAG_LO
      |                          ^~~~~~~~~~

@F0bes
Copy link
Member

F0bes commented Jan 21, 2022

Yup, aware of it.

@TellowKrinkle
Copy link
Member

I reverted the commit for now

For the future, here's a cmake function to put in Pcsx2Utils.cmake

function(write_svnrev_h)
	if(PCSX2_GIT_TAG)
		if ("${PCSX2_GIT_TAG}" MATCHES "^v([0-9]+)\\.([0-9]+)\\.([0-9]+)$")
			file(WRITE ${CMAKE_BINARY_DIR}/common/include/svnrev.h
				"#define SVN_REV ${PCSX2_WC_TIME}ll\n"
				"#define GIT_TAG \"${PCSX2_GIT_TAG}\"\n"
				"#define GIT_TAGGED_COMMIT 1\n"
				"#define GIT_TAG_HI  ${CMAKE_MATCH_1}\n"
				"#define GIT_TAG_MID ${CMAKE_MATCH_2}\n"
				"#define GIT_TAG_LO  ${CMAKE_MATCH_3}\n"
				"#define GIT_REV \"\"\n"
			)
		else()
			file(WRITE ${CMAKE_BINARY_DIR}/common/include/svnrev.h
				"#define SVN_REV ${PCSX2_WC_TIME}ll\n"
				"#define GIT_TAG \"${PCSX2_GIT_TAG}\"\n"
				"#define GIT_TAGGED_COMMIT 1\n"
				"#define GIT_REV \"\"\n"
			)
		endif()
	else()
		file(WRITE ${CMAKE_BINARY_DIR}/common/include/svnrev.h 
			"#define SVN_REV ${PCSX2_WC_TIME}ll\n"
			"#define GIT_TAG \"${PCSX2_GIT_TAG}\"\n"
			"#define GIT_TAGGED_COMMIT 0\n"
			"#define GIT_REV \"${PCSX2_GIT_REV}\"\n"
		)
	endif()
endfunction()

Check for GIT_TAG_LO > 0 instead of GIT_TAGGED_COMMIT to filter out any tags that aren't in the v#.#.# format

But more importantly, do not include svnrev.h in a file that's widely included across the emulator or you'll mess up all our incremental builds and caching

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants