diff --git a/build/jam/FileRules b/build/jam/FileRules index ce7c32693a..89dcf20b85 100644 --- a/build/jam/FileRules +++ b/build/jam/FileRules @@ -217,3 +217,35 @@ rule ObjectReferences } } +rule CopySetHaikuRevision target : source +{ + # CopySetHaikuRevision : + # + # Copy to , writing the SVN revision of the working root + # directory into the haiku revision section of . + # + # - Output file target. Gristed and located target. + # - ELF object to be copied. Gristed and located target. + + # If existent, make the target depend on the .svn/entries file in the + # root directory, so it gets updated when the revision changes due to + # "svn up". + if [ Glob [ FDirName $(HAIKU_TOP) .svn ] : entries ] { + local svnEntries = entries ; + SEARCH on $(svnEntries) = [ FDirName $(HAIKU_TOP) .svn ] ; + Depends $(target) : $(svnEntries) ; + } + + Depends $(target) : copyattr set_haiku_revision $(source) ; + CopySetHaikuRevision1 $(target) + : copyattr set_haiku_revision $(source) ; +} + +actions CopySetHaikuRevision1 +{ + $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) + revision=`(svn info $(HAIKU_TOP) 2> /dev/null || echo Revision: 0) | + grep Revision | awk '{printf $2}'` + $(2[1]) --data $(2[3]) $(1) && + $(2[2]) $(1) ${revision} +} diff --git a/build/jam/HaikuImage b/build/jam/HaikuImage index 3d60a2c4ce..0e01c4935a 100644 --- a/build/jam/HaikuImage +++ b/build/jam/HaikuImage @@ -48,8 +48,8 @@ BEOS_DEMOS = BitmapDrawing Chart $(X86_ONLY)GLTeapot PictureTest Playground BEOS_SYSTEM_LIB = libbe.so $(HAIKU_LIBSTDC++) libmedia.so libtracker.so libtranslation.so libnetwork.so libdebug.so libbsd.so libmail.so libtextencoding.so libz.so libfreetype.so libpng.so libmidi.so libmidi2.so - libdevice.so libgame.so libscreensaver.so libroot.so $(X86_ONLY)libGL.so - libfluidsynth.so libqoca.so + libdevice.so libgame.so libscreensaver.so libroot.so + $(X86_ONLY)libGL.so libfluidsynth.so libqoca.so ; BEOS_SYSTEM_SERVERS = registrar debug_server syslog_daemon media_server net_server media_addon_server input_server app_server fake_app_server midi_server print_server diff --git a/src/apps/abouthaiku/AboutHaiku.cpp b/src/apps/abouthaiku/AboutHaiku.cpp index b8349101de..604b3dea08 100644 --- a/src/apps/abouthaiku/AboutHaiku.cpp +++ b/src/apps/abouthaiku/AboutHaiku.cpp @@ -31,6 +31,7 @@ #include #include +#include #define SCROLL_CREDITS_VIEW 'mviv' @@ -178,18 +179,17 @@ AboutView::AboutView(const BRect &rect) strcpy(string, versionInfo.short_info); } - // Add revision from resources - BResources* resources = be_app->AppResources(); - char version[32]; - size_t size; - const char* versionResource = (const char *)resources->LoadResource( - B_STRING_TYPE, "SVN:REVISION", &size); - if (versionResource != NULL) - strlcpy(version, versionResource, min_c(size + 1, sizeof(version))); - if (versionResource != NULL && strcmp(version, "unknown") != 0) { - strlcat(string, " (Revision ", sizeof(string)); - strlcat(string, version, sizeof(string)); - strlcat(string, ")", sizeof(string)); + // Add revision from uname() info + utsname unameInfo; + if (uname(&unameInfo) == 0) { + long revision; + if (sscanf(unameInfo.version, "r%ld", &revision) == 1) { + char version[16]; + snprintf(version, sizeof(version), "%ld", revision); + strlcat(string, " (Revision ", sizeof(string)); + strlcat(string, version, sizeof(string)); + strlcat(string, ")", sizeof(string)); + } } stringView = new BStringView(r, "ostext", string); diff --git a/src/apps/abouthaiku/Jamfile b/src/apps/abouthaiku/Jamfile index e65ffb647e..efb18b284d 100644 --- a/src/apps/abouthaiku/Jamfile +++ b/src/apps/abouthaiku/Jamfile @@ -6,25 +6,6 @@ if $(TARGET_PLATFORM) = r5 { SubDirC++Flags -DR5_COMPATIBLE ; } -rule GenerateRevisionFile -{ - MakeLocateCommonPlatform $(1) ; - Always $(1) ; - # we want to rebuild the resources everytime AboutHaiku - # is built to keep them up-to-date -} - -actions GenerateRevisionFile -{ - (svn info $(HAIKU_TOP) 2> /dev/null || echo Revision: unknown) | - grep Revision | awk '{printf $2}' > $(1) -} - -local revisionFile = [ FGristFiles haiku-revision ] ; -GenerateRevisionFile $(revisionFile) ; - -AddFileDataResource AboutHaiku : CSTR:201:SVN:REVISION : $(revisionFile) ; - Application AboutHaiku : AboutHaiku.cpp : libbe.so libtranslation.so libroot.so diff --git a/src/system/libroot/Jamfile b/src/system/libroot/Jamfile index f169fddca9..fd6d94295b 100644 --- a/src/system/libroot/Jamfile +++ b/src/system/libroot/Jamfile @@ -48,5 +48,16 @@ SharedLibrary libroot.so $(librootObjects:G=nogrist) ; + +# Copy libroot.so and update the copy's revision section. We link everything +# against the original, but the copy will end up on the disk image (this way +# we avoid unnecessary dependencies). The copy will be located in a subdirectory. +if $(TARGET_PLATFORM) = haiku { + MakeLocate libroot.so + : [ FDirName $(TARGET_DEBUG_$(DEBUG)_LOCATE_TARGET) revisioned ] ; + CopySetHaikuRevision libroot.so : libroot.so ; +} + + SubInclude HAIKU_TOP src system libroot os ; SubInclude HAIKU_TOP src system libroot posix ; diff --git a/src/system/libroot/posix/sys/uname.c b/src/system/libroot/posix/sys/uname.c index 03fe729b3b..449eb87a0a 100644 --- a/src/system/libroot/posix/sys/uname.c +++ b/src/system/libroot/posix/sys/uname.c @@ -12,6 +12,12 @@ #include +// Haiku SVN revision. Will be set when copying libroot.so to the image. +// Lives in a separate section so that it can easily be found. +extern uint32 _gHaikuRevision __attribute__((section("_haiku_revision"))); +uint32 _gHaikuRevision = 0; + + int uname(struct utsname *info) { @@ -28,13 +34,15 @@ uname(struct utsname *info) strlcpy(info->sysname, "Haiku", sizeof(info->sysname)); info->version[0] = '\0'; -#ifdef HAIKU_REVISION - snprintf(info->version, sizeof(info->version), "r%d ", HAIKU_REVISION); -#endif + if (_gHaikuRevision) { + snprintf(info->version, sizeof(info->version), "r%ld ", + _gHaikuRevision); + } strlcat(info->version, systemInfo.kernel_build_date, sizeof(info->version)); strlcat(info->version, " ", sizeof(info->version)); strlcat(info->version, systemInfo.kernel_build_time, sizeof(info->version)); - snprintf(info->release, sizeof(info->release), "%lld", systemInfo.kernel_version); + snprintf(info->release, sizeof(info->release), "%lld", + systemInfo.kernel_version); // TODO: make this better switch (systemInfo.platform_type) {