Skip to content

Commit

Permalink
Implement version check
Browse files Browse the repository at this point in the history
  • Loading branch information
psiberx committed Dec 24, 2022
1 parent 9f0cac7 commit 3a9c82d
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/App/Facade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ void App::Facade::Reload()
Core::Resolve<ExtensionService>()->Configure();
}

bool App::Facade::Require(Red::CString& aVersion)
{
const auto requirement = semver::from_string_noexcept(aVersion.c_str());
return requirement.has_value() ? Project::Version >= requirement.value() : false;
}

Red::CString App::Facade::GetVersion()
{
return Project::Version.to_string().c_str();
Expand All @@ -22,5 +28,6 @@ void App::Facade::OnRegister(Descriptor* aType)
void App::Facade::OnDescribe(Descriptor* aType)
{
aType->AddFunction<&Reload>("Reload");
aType->AddFunction<&Require>("Require");
aType->AddFunction<&GetVersion>("Version");
}
1 change: 1 addition & 0 deletions src/App/Facade.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Facade : public Red::Rtti::Class<Facade>
{
public:
static void Reload();
static bool Require(Red::CString& aVersion);
static Red::CString GetVersion();

private:
Expand Down
2 changes: 1 addition & 1 deletion src/App/Project.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ constexpr auto Author = "psiberx";
constexpr auto NameW = L"ArchiveXL";
constexpr auto AuthorW = L"psiberx";

constexpr auto Version = semver::from_string_noexcept("1.3.2").value();
constexpr auto Version = semver::from_string_noexcept("1.3.4").value();
}
8 changes: 4 additions & 4 deletions src/App/Version.rc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#define VER_PRODUCTVERSION 1,3,2,0
#define VER_FILEVERSION 1,3,2,2212160642
#define VER_PRODUCTVERSION 1,3,4,0
#define VER_FILEVERSION 1,3,4,2212241000

#define VER_PRODUCTNAME_STR "ArchiveXL\0"
#define VER_PRODUCTVERSION_STR "1.3.2\0"
#define VER_FILEVERSION_STR "1.3.2.2212160642\0"
#define VER_PRODUCTVERSION_STR "1.3.4\0"
#define VER_FILEVERSION_STR "1.3.4.2212241000\0"

1 VERSIONINFO
FILEVERSION VER_FILEVERSION
Expand Down
5 changes: 5 additions & 0 deletions support/redscript/ArchiveXL.reds
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

public abstract native class ArchiveXL {
public static native func Require(version: String) -> Bool
public static native func Version() -> String
}
1 change: 1 addition & 0 deletions tools/dist/install-asi.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ param ($GameDir, $ReleaseBin, $ProjectName = "ArchiveXL")
$StageDir = "build/package"

& $($PSScriptRoot + "\steps\compose-plugin-asi.ps1") -StageDir ${StageDir} -ProjectName ${ProjectName} -ReleaseBin ${ReleaseBin}
& $($PSScriptRoot + "\steps\compose-redscripts.ps1") -StageDir ${StageDir} -ProjectName ${ProjectName}
& $($PSScriptRoot + "\steps\install-from-stage.ps1") -StageDir ${StageDir} -GameDir ${GameDir}

Remove-Item -Recurse ${StageDir}
1 change: 1 addition & 0 deletions tools/dist/install-red4ext.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ param ($GameDir, $ReleaseBin, $ProjectName = "ArchiveXL")
$StageDir = "build/package"

& $($PSScriptRoot + "\steps\compose-plugin-red4ext.ps1") -StageDir ${StageDir} -ProjectName ${ProjectName} -ReleaseBin ${ReleaseBin}
& $($PSScriptRoot + "\steps\compose-redscripts.ps1") -StageDir ${StageDir} -ProjectName ${ProjectName}
& $($PSScriptRoot + "\steps\install-from-stage.ps1") -StageDir ${StageDir} -GameDir ${GameDir}

Remove-Item -Recurse ${StageDir}
1 change: 1 addition & 0 deletions tools/dist/package-asi.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $StageDir = "build/package"
$DistDir = "build/dist"

& $($PSScriptRoot + "\steps\compose-plugin-asi.ps1") -StageDir ${StageDir} -ProjectName ${ProjectName} -ReleaseBin ${ReleaseBin}
& $($PSScriptRoot + "\steps\compose-redscripts.ps1") -StageDir ${StageDir} -ProjectName ${ProjectName}
& $($PSScriptRoot + "\steps\create-zip-from-stage.ps1") -StageDir ${StageDir} -ProjectName ${ProjectName} -DistDir ${DistDir} -Suffix "-asi"

Remove-Item -Recurse ${StageDir}
1 change: 1 addition & 0 deletions tools/dist/package-red4ext.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $StageDir = "build/package"
$DistDir = "build/dist"

& $($PSScriptRoot + "\steps\compose-plugin-red4ext.ps1") -StageDir ${StageDir} -ProjectName ${ProjectName} -ReleaseBin ${ReleaseBin}
& $($PSScriptRoot + "\steps\compose-redscripts.ps1") -StageDir ${StageDir} -ProjectName ${ProjectName}
& $($PSScriptRoot + "\steps\create-zip-from-stage.ps1") -StageDir ${StageDir} -ProjectName ${ProjectName} -DistDir ${DistDir}

Remove-Item -Recurse ${StageDir}
6 changes: 6 additions & 0 deletions tools/dist/steps/compose-redscripts.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
param ($StageDir, $ProjectName)

$ScriptsDir = "${StageDir}/r6/scripts/${ProjectName}"

New-Item -ItemType directory -Force -Path ${ScriptsDir} | Out-Null
Get-Content "support/redscript/*.reds" | Out-File -Encoding ascii "${ScriptsDir}/${ProjectName}.reds"
2 changes: 1 addition & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set_xmakever("2.5.9")

set_project("ArchiveXL")
set_version("1.3.2", {build = "%y%m%d%H%M"})
set_version("1.3.4", {build = "%y%m%d%H%M"})

set_arch("x64")
set_languages("cxx20", "cxx2a")
Expand Down

0 comments on commit 3a9c82d

Please sign in to comment.