diff --git a/utils/scripts/build/linux-build.sh b/utils/scripts/build/linux-build.sh index 7780c0004..3c0b30e3a 100755 --- a/utils/scripts/build/linux-build.sh +++ b/utils/scripts/build/linux-build.sh @@ -7,6 +7,8 @@ sudo chown eqemu:eqemu /home/eqemu/.ccache/ * -R git submodule init && git submodule update +perl utils/scripts/build/tag-version.pl + mkdir -p build && cd build && cmake -DEQEMU_BUILD_TESTS=ON -DEQEMU_BUILD_LOGIN=ON -DEQEMU_BUILD_LUA=ON -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="-Os" -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -G 'Unix Makefiles' .. && make -j$((`nproc`-4)) curl https://raw.githubusercontent.com/Akkadius/eqemu-install-v2/master/eqemu_config.json --output eqemu_config.json diff --git a/utils/scripts/build/tag-version.pl b/utils/scripts/build/tag-version.pl new file mode 100644 index 000000000..803b4f608 --- /dev/null +++ b/utils/scripts/build/tag-version.pl @@ -0,0 +1,61 @@ +#!/usr/bin/perl +use strict; +use warnings FATAL => 'all'; + +open my $fh, '<', './package.json' or die "Can't open file $!"; +my $package_json = do { + local $/; + <$fh> +}; + +my $version = ""; +sub trim($) +{ + my $string = shift; + $string =~ s/^\s+//; + $string =~ s/\s+$//; + return $string; +} + +# manually parse because we can't guarantee json module is available +# it's jank but it's quick and dirty +# this is only used in the build pipeline +foreach my $line (split("\n", $package_json)) { + if ($line =~ /version/i) { + $version = $line; + $version =~ s/version//g; + $version =~ s/://g; + $version =~ s/"//g; + $version =~ s/,//g; + $version = trim($version); + } +} + +print "Version is [" . $version . "]\n"; + +# server version file +my $version_file_name = "./common/version.h"; +open my $vfh, '<', $version_file_name or die "Can't open file $!"; +my $version_file = do { + local $/; + <$vfh> +}; + +# write new version +my $new_version_file = ""; +foreach my $line (split("\n", $version_file)) { + if ($line =~ /CURRENT_VERSION/i) { + my @s = split("\"", $line); + if ($#s == 2) { + $line =~ s/$s[1]/$version/g; + } + } + + $new_version_file .= $line . "\n"; +} + +open(my $wfh, '>', $version_file_name) or die "Could not open file '$version_file_name' $!"; +print $wfh $new_version_file; +close $wfh; + +print $new_version_file; diff --git a/utils/scripts/build/windows-build.ps1 b/utils/scripts/build/windows-build.ps1 index f4306c27d..95270bf5d 100644 --- a/utils/scripts/build/windows-build.ps1 +++ b/utils/scripts/build/windows-build.ps1 @@ -13,6 +13,8 @@ try New-Item -Path "$cwd\win-build-x64" -ItemType Directory } + perl .\utils\scripts\build\tag-version.pl + Write-Information -MessageData "Creating build x64" -InformationAction Continue Set-Location -Path "$cwd\win-build-x64" cmake -Wno-dev -G "Visual Studio 17 2022" -A x64 -DEQEMU_BUILD_TESTS=ON -DEQEMU_BUILD_LOGIN=ON -DEQEMU_BUILD_ZLIB=ON "$cwd"