Skip to content

Commit

Permalink
Consolidate to one version code throughout the build.
Browse files Browse the repository at this point in the history
Normal builds without special setup will read the version from VERSION,
which would generally be expected to be a SNAPSHOT version. Release
builds (those generated by CI with tags on GitHub) get the tag name as
the version. This version is propagated to the Windows installer, the
app, and the Mac plist file.

dist/gen_packages.lua still has a hard-coded reference; this will be
handled separately.

This commit also fixes a bug in xword.pkgmgr.is_newer, which seems to
have been passing an escaped "." character to pl.stringx.split when a
non-escaped character was expected. We also extend is_newer to support
-SNAPSHOT builds by considering them to be older than the non-SNAPSHOT
build of the same version, but newer than any previous version.

See mrichards42#40
  • Loading branch information
jpd236 committed Feb 10, 2020
1 parent 6ae002b commit 61fce6a
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 14 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ env:
before_install:
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get -qq update && sudo apt-get install libgtk-3-dev; fi

# Build and install wxWidgets, with our custom tweaks patch
install:
# For tagged builds, use the tag name as the version.
# Otherwise, read the version from the VERSION file.
- if [ "$TRAVIS_TAG" != "" ]; then export XWORD_VERSION=$TRAVIS_TAG; else export XWORD_VERSION=$(cat VERSION); fi
# Build and install wxWidgets, with our custom tweaks patch
- ./build-wxwidgets.sh $WX_VERSION $CONFIGURATION

# Cache the compiled wxWidgets so it can be in with future builds
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.7.0-SNAPSHOT
5 changes: 4 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ environment:
PYTHON: "C:\\Python38"
WX_VERSION: 3.1.3

# Build and install markdown and wxWidgets, with our custom tweaks patch
install:
# For tagged builds, use the tag name as the version.
# Otherwise, read the version from the VERSION file.
- IF "%APPVEYOR_REPO_TAG%"=="true" (SET XWORD_VERSION=%APPVEYOR_REPO_TAG_NAME%) ELSE (SET /P XWORD_VERSION=< VERSION)
# Build and install markdown and wxWidgets, with our custom tweaks patch
- SET PATH=%PYTHON%;%PATH%
- IF %CONFIGURATION%==Release python -m pip install markdown
- call "%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
Expand Down
2 changes: 1 addition & 1 deletion dist/XWord.nsi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "XWord"
!define PRODUCT_VERSION "0.6.1"
!define PRODUCT_VERSION "$%XWORD_VERSION%"
!define PRODUCT_WEB_SITE "http://sourceforge.net/projects/wx-xword/"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\XWord.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
Expand Down
19 changes: 16 additions & 3 deletions scripts/xword/pkgmgr/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,14 @@ end

function P.is_newer(v1, v2)
local split = require 'pl.stringx'.split
-- Split by '-' to determine if either version is a SNAPSHOT build.
local v1 = split(tostring(v1) or '', '-')
local v1_is_snapshot = v1[#v1] == 'SNAPSHOT'
local v2 = split(tostring(v2) or '', '-')
local v2_is_snapshot = v2[#v2] == 'SNAPSHOT'
-- Split by '.'
local v1 = split(tostring(v1) or '', '%.')
local v2 = split(tostring(v2) or '', '%.')
local v1 = split(v1[1], '.')
local v2 = split(v2[1], '.')
-- Compare successive revision numbers
for i = 1, #v1 do
local cmp = (tonumber(v1[i]) or 0) - (tonumber(v2[i]) or 0)
Expand All @@ -149,7 +154,15 @@ function P.is_newer(v1, v2)
return false
end
end
return #v1 > #v2
if #v1 ~= #v2 then
return #v1 > #v2
end
-- Versions are equal, except potentially for a -SNAPSHOT at the end of
-- one of them. SNAPSHOT builds should be considered older.
if v1_is_snapshot ~= v2_is_snapshot then
return v2_is_snapshot
end
return false
end

function P.get_all_scripts()
Expand Down
2 changes: 0 additions & 2 deletions src/App.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ extern wxPageSetupDialogData* g_pageSetupData;

// Global misc
#define XWORD_APP_NAME _T("XWord")
// Make sure this is made up of only numbers (for lua)
#define XWORD_VERSION_STRING _T("0.6.1")
#define XWORD_COPYRIGHT_STRING _T("(C) 2013 Mike Richards <mrichards42@gmx.com>")

class MyApp : public wxApp
Expand Down
6 changes: 3 additions & 3 deletions src/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.5.4</string>
<string>{XWORD_VERSION}</string>
<key>CFBundleVersion</key>
<string>0.5.4</string>
<string>{XWORD_VERSION}</string>
<key>CFBundleIdentifier</key>
<string>com.github.mrichards42.xword</string>
<key>NSHumanReadableCopyright</key>
<string>XWord 0.5.4 © 2009-2012 Mike Richards</string>
<string>XWord {XWORD_VERSION} © 2009-2012 Mike Richards</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
Expand Down
4 changes: 2 additions & 2 deletions src/MyFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2570,7 +2570,7 @@ MyFrame::OnAbout(wxCommandEvent & WXUNUSED(evt))
wxAboutDialogInfo info;
info.SetName(XWORD_APP_NAME);

info.SetVersion(XWORD_VERSION_STRING _T(" (") __TDATE__ _T(")"));
info.SetVersion(_T(XWORD_VERSION_STRING) _T(" (") __TDATE__ _T(")"));

info.SetCopyright(XWORD_COPYRIGHT_STRING);

Expand All @@ -2582,7 +2582,7 @@ void
MyFrame::OnLicense(wxCommandEvent & WXUNUSED(evt))
{
const wxString licenseText(
XWORD_APP_NAME _T(" ") XWORD_VERSION_STRING _T("\n")
XWORD_APP_NAME _T(" ") _T(XWORD_VERSION_STRING) _T("\n")
_T("Copyright ") XWORD_COPYRIGHT_STRING _T("\n")
_T("\n")
_T("This program is free software; you can redistribute it and/or ")
Expand Down
15 changes: 14 additions & 1 deletion src/premake4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ project "XWord"

files { "**.hpp", "**.cpp", "**.h" }

local xword_version
if os.getenv("XWORD_VERSION") ~= "" then
xword_version = os.getenv("XWORD_VERSION")
else
local version_file = assert(io.open("../VERSION", "r"))
local version = version_file:read("*all")
version_file:close()
xword_version = string.gsub(version, '%s+', '')
end

configuration {}
defines { [[XWORD_VERSION_STRING="]]..xword_version..[["]] }

configuration "windows"
-- Use WinMain() instead of main() for windows apps
entrypoint "WinMainCRTStartup"
Expand Down Expand Up @@ -140,7 +153,7 @@ project "XWord"
"mkdir -p $UNLOCALIZED_RESOURCES_FOLDER_PATH",
"ln -sFh ../../../../../images $UNLOCALIZED_RESOURCES_FOLDER_PATH/images",
-- Copy Info.plist, xword.icns, and default_config.ini
"cp ../../src/Info.plist $INFOPLIST_PATH",
"sed 's/{XWORD_VERSION}/"..xword_version.."/' ../../src/Info.plist > $INFOPLIST_PATH",
"cp ../../images/xword.icns $UNLOCALIZED_RESOURCES_FOLDER_PATH",
"cp ../../default_config.ini $UNLOCALIZED_RESOURCES_FOLDER_PATH",
}
Expand Down

0 comments on commit 61fce6a

Please sign in to comment.