diff --git a/.appveyor.yml b/.appveyor.yml
deleted file mode 100644
index 7d86882..0000000
--- a/.appveyor.yml
+++ /dev/null
@@ -1,42 +0,0 @@
-image: Visual Studio 2017
-
-configuration: Default
-
-platform:
- - x64
- - Win32
-
-before_build:
- - cmd: |
- git clone --depth 1 https://chromium.googlesource.com/external/gyp
- gyp\gyp rcedit.gyp --depth .
-
-build:
- project: rcedit.sln
- parallel: true
- verbosity: minimal
-
-after_build:
- - cmd: if %PLATFORM%==Win32 (move Default\rcedit.exe Default\rcedit-x86.exe)
- - cmd: if %PLATFORM%==x64 (move Default\rcedit.exe Default\rcedit-x64.exe)
-
-branches:
- only:
- - master
-
-artifacts:
- - path: Default\*.exe
-
-deploy:
- - provider: GitHub
- release: Rcedit $(APPVEYOR_REPO_TAG_NAME)
- tag: $(APPVEYOR_REPO_TAG_NAME)
- description: '(placeholder)'
- auth_token:
- secure: lVaYho+MDDKAQH4aImQub/L5ORlENgZ4utufxWAetovWnIsWiwFCkgFRIcIRMWz5
- artifact: /.*\.exe/
- draft: true
- force_update: true
- prerelease: false
- on:
- appveyor_repo_tag: true
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..37ec512
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,81 @@
+name: Continuous Integration
+
+on:
+ push:
+ branches:
+ - master
+ pull_request:
+ branches:
+ - master
+
+permissions:
+ contents: read
+
+jobs:
+ build:
+ name: Build
+ runs-on: windows-2022
+ steps:
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+ with:
+ fetch-depth: 1
+ - name: Build
+ run: |
+ cmake -E make_directory build/x64
+ cmake -E make_directory build/Win32
+ cd build/x64
+ cmake -A x64 ../../
+ cmake --build . --config RelWithDebInfo
+ cd ../../build/Win32
+ cmake -A Win32 ../../
+ cmake --build . --config RelWithDebInfo
+ - name: Copy to dist
+ run: |
+ cmake -E make_directory dist
+ cmake -E copy build/x64/RelWithDebInfo/rcedit.exe dist/rcedit-x64.exe
+ cmake -E copy build/Win32/RelWithDebInfo/rcedit.exe dist/rcedit-x86.exe
+ - name: Upload artifacts
+ uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
+ with:
+ name: dist
+ path: dist/
+
+ release:
+ name: Release
+ runs-on: windows-2022
+ needs: build
+ if: github.ref == 'refs/heads/master'
+ permissions:
+ contents: write
+ steps:
+ - name: Checkout
+ id: checkout
+ uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+ - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
+ with:
+ name: dist
+ path: dist/
+ - name: Print help
+ run: |
+ dist/rcedit-x86.exe -h
+ dist/rcedit-x64.exe -h
+ - run: npm install -g semantic-release@22.0.6 semantic-release-export-data@v1.0.1
+ - run: npx semantic-release@22.0.6 --dry-run
+ id: get-next-version
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ - name: Stamp version
+ if: steps.get-next-version.outputs.new-release-published == 'true'
+ run: |
+ set -eo pipefail
+ dist/rcedit-x64.exe dist/rcedit-x86.exe --set-product-version $VERSION --set-file-version $VERSION
+ dist/rcedit-x86.exe -h | grep -q Rcedit v$VERSION
+ dist/rcedit-x86.exe dist/rcedit-x64.exe --set-product-version $VERSION --set-file-version $VERSION
+ dist/rcedit-x64.exe -h | grep -q Rcedit v$VERSION
+ env:
+ VERSION: ${{ steps.get-next-version.outputs.new-release-version }}
+ - name: Run semantic release
+ run: npx semantic-release@22.0.6 --dry-run
+ if: steps.get-next-version.outputs.new-release-published == 'true'
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.gitignore b/.gitignore
index dceecf0..7fa43b2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
Default/
ipch/
+build/
*.swp
*.sdf
diff --git a/.releaserc.json b/.releaserc.json
new file mode 100644
index 0000000..85926dc
--- /dev/null
+++ b/.releaserc.json
@@ -0,0 +1,18 @@
+{
+ "plugins": [
+ "semantic-release-export-data",
+ "@semantic-release/commit-analyzer",
+ "@semantic-release/release-notes-generator",
+ [
+ "@semantic-release/github",
+ {
+ "assets": [
+ { "path": "dist/rcedit-x64.exe" },
+ { "path": "dist/rcedit-x86.exe" }
+ ],
+ "draftRelease": true
+ }
+ ]
+ ],
+ "branches": [ "master" ]
+}
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..439d838
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,12 @@
+cmake_minimum_required(VERSION 3.15)
+
+set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
+
+# /Ox, full optimization
+# /Os, favour small code
+add_compile_options(/Ox /Os)
+
+project(rcedit)
+
+add_executable(rcedit src/main.cc src/rescle.cc src/rcedit.rc)
+target_link_libraries(rcedit version.lib)
diff --git a/README.md b/README.md
index a96e485..c4957a6 100644
--- a/README.md
+++ b/README.md
@@ -1,24 +1,22 @@
-# rcedit [![Build status](https://ci.appveyor.com/api/projects/status/99eokln2emhidcej?svg=true)](https://ci.appveyor.com/project/zcbenz/rcedit/branch/master)
+# rcedit
+
+[![Continuous Integration](https://github.com/electron/rcedit/actions/workflows/ci.yml/badge.svg)](https://github.com/electron/rcedit/actions/workflows/ci.yml)
Command line tool to edit resources of exe file on Windows.
## Executables
-Prebuilt binaries can be found in the artifacts of appveyor jobs.
+Prebuilt binaries can be found in the releases.
## Building
-1. Clone the repository
-2. Open `rcedit.sln` with Visual Studio 2015 or above
-3. Build
-
-## Generate solution files
+To build you need CMake 3.15+ and Visual Studio 2015 or above.
-If you have modified the gyp files, you should regenerate the solution files:
-
-1. Make sure you have gyp configured on your system. If not, clone gyp from
- https://chromium.googlesource.com/external/gyp
-2. Run `gyp rcedit.gyp --depth .`
+1. Clone the repository
+2. Create a build directory: `cmake -E make_directory build`
+3. Change to the build directory: `cd build`
+4. Make the CMake project: `cmake ..`
+5. Build: `cmake --build .`
## Docs
diff --git a/rcedit.gyp b/rcedit.gyp
deleted file mode 100644
index 49e03be..0000000
--- a/rcedit.gyp
+++ /dev/null
@@ -1,40 +0,0 @@
-{
- 'targets': [
- {
- 'target_name': 'rcedit',
- 'type': 'executable',
- 'sources': [
- 'src/main.cc',
- 'src/rescle.cc',
- 'src/rescle.h',
- 'src/rcedit.rc',
- 'src/version.h',
- ],
- 'msvs_settings': {
- 'VCLinkerTool': {
- 'SubSystem': 1, # console executable
- },
- 'VCCLCompilerTool': {
- 'Optimization': 3, # /Ox, full optimization
- 'FavorSizeOrSpeed': 1, # /Os, favour small code
- 'RuntimeLibrary': 0, # /MT, for statically linked runtime
- },
- },
- 'conditions': [
- ['MSVS_VERSION=="2015"', {
- 'msbuild_toolset': 'v140_xp',
- }],
- ['MSVS_VERSION=="2017"', {
- 'msbuild_toolset': 'v141_xp',
- }],
- ],
- 'configurations': {
- 'Default': {
- },
- 'Default_x64': {
- 'msvs_configuration_platform': 'x64',
- },
- }
- },
- ],
-}
diff --git a/rcedit.sln b/rcedit.sln
deleted file mode 100644
index 3de061f..0000000
--- a/rcedit.sln
+++ /dev/null
@@ -1,19 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2015
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rcedit", "rcedit.vcxproj", "{3609DBE4-DFE6-667B-C659-D6913E25C767}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Default|x64 = Default|x64
- Default|Win32 = Default|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {3609DBE4-DFE6-667B-C659-D6913E25C767}.Default|x64.ActiveCfg = Default|x64
- {3609DBE4-DFE6-667B-C659-D6913E25C767}.Default|x64.Build.0 = Default|x64
- {3609DBE4-DFE6-667B-C659-D6913E25C767}.Default|Win32.ActiveCfg = Default|Win32
- {3609DBE4-DFE6-667B-C659-D6913E25C767}.Default|Win32.Build.0 = Default|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/rcedit.vcxproj b/rcedit.vcxproj
deleted file mode 100644
index aabf1b3..0000000
--- a/rcedit.vcxproj
+++ /dev/null
@@ -1,82 +0,0 @@
-
-
-
-
- Default
- Win32
-
-
- Default
- x64
-
-
-
- {3609DBE4-DFE6-667B-C659-D6913E25C767}
- Win32Proj
- rcedit
- true
-
-
-
- Application
-
-
- v140_xp
-
-
-
-
-
-
-
-
- $(ExecutablePath);$(MSBuildProjectDirectory)\.\bin\;$(MSBuildProjectDirectory)\.\bin\
- $(Configuration)\obj\$(ProjectName)\
- $(SolutionDir)$(Configuration)\
- $(ProjectName)
- $(OutDir)\$(ProjectName)$(TargetExt)
-
-
-
- false
- Speed
- Full
- NotUsing
- MultiThreaded
-
-
-
- $(OutDir)$(ProjectName)$(TargetExt)
- Console
-
-
-
-
- false
- Speed
- Full
- NotUsing
- MultiThreaded
-
-
-
- $(OutDir)$(ProjectName)$(TargetExt)
- Console
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/rcedit.vcxproj.filters b/rcedit.vcxproj.filters
deleted file mode 100644
index bc7aacb..0000000
--- a/rcedit.vcxproj.filters
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
- {8CDEE807-BC53-E450-C8B8-4DEBB66742D4}
-
-
- {8CDEE807-BC53-E450-C8B8-4DEBB66742D4}
-
-
- {8CDEE807-BC53-E450-C8B8-4DEBB66742D4}
-
-
- {8CDEE807-BC53-E450-C8B8-4DEBB66742D4}
-
-
-
-
- src
-
-
- src
-
-
- src
-
-
- src
-
-
-
-
diff --git a/src/main.cc b/src/main.cc
index c7763b8..108d97a 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -4,14 +4,53 @@
#include
+#include
+#include
+
#include "rescle.h"
-#include "version.h"
namespace {
-void print_help() {
+LPVOID get_file_version_info() {
+ DWORD zero = 0;
+ DWORD filename_buffer_size = MAX_PATH;
+ LPWSTR filename = nullptr;
+ SetLastError(ERROR_SUCCESS);
+
+ do {
+ filename = new wchar_t[filename_buffer_size];
+
+ GetModuleFileNameW(NULL, filename, filename_buffer_size);
+
+ // Double the buffer size in case the path is longer
+ filename_buffer_size *= 2;
+ } while (GetLastError() == ERROR_INSUFFICIENT_BUFFER);
+
+ if (GetLastError() != ERROR_SUCCESS) {
+ return nullptr;
+ }
+
+ DWORD file_ver_info_size = GetFileVersionInfoSizeW(filename, &zero);
+ if (file_ver_info_size == 0) {
+ free(filename);
+ return nullptr;
+ }
+
+ LPVOID file_ver_info = operator new(file_ver_info_size);
+ if (!GetFileVersionInfoW(filename, NULL, file_ver_info_size, file_ver_info)) {
+ free(file_ver_info);
+ free(filename);
+ return nullptr;
+ }
+
+ free(filename);
+
+ return file_ver_info;
+}
+
+void print_help(VS_FIXEDFILEINFO* file_info) {
fprintf(stdout,
-"Rcedit " RCEDIT_VERSION ": Edit resources of exe.\n\n"
+"Rcedit %d.%d.%d: Edit resources of exe.\n\n"
"Usage: rcedit [options...]\n\n"
"Options:\n"
" -h, --help Show this message\n"
@@ -24,7 +63,10 @@ void print_help() {
" --application-manifest Set manifest file\n"
" --set-resource-string Set resource string\n"
" --get-resource-string Get resource string\n"
-" --set-rcdata Replace RCDATA by integer id\n");
+" --set-rcdata Replace RCDATA by integer id\n",
+(file_info->dwProductVersionMS >> 16) & 0xff,
+(file_info->dwProductVersionMS >> 0) & 0xff,
+(file_info->dwProductVersionLS >> 16) & 0xff);
}
bool print_error(const char* message) {
@@ -54,7 +96,17 @@ int wmain(int argc, const wchar_t* argv[]) {
if (argc == 1 ||
(argc == 2 && wcscmp(argv[1], L"-h") == 0) ||
(argc == 2 && wcscmp(argv[1], L"--help") == 0)) {
- print_help();
+ UINT ignored = 0;
+ VS_FIXEDFILEINFO* file_info = nullptr;
+ LPVOID file_version_info = get_file_version_info();
+
+ if (file_version_info == nullptr || !VerQueryValueW(file_version_info, L"\\", (LPVOID*) &file_info, &ignored)) {
+ free(file_version_info);
+ return print_error("Could not determine version of rcedit");
+ }
+
+ print_help(file_info);
+ free(file_version_info);
return 0;
}
diff --git a/src/rcedit.rc b/src/rcedit.rc
index 84920c8..79ca01d 100644
--- a/src/rcedit.rc
+++ b/src/rcedit.rc
@@ -20,8 +20,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,1,1,0
- PRODUCTVERSION 1,1,1,0
+ FILEVERSION 0,0,0,0
+ PRODUCTVERSION 0,0,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -38,10 +38,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "GitHub, Inc"
VALUE "FileDescription", "Edit resources of exe"
- VALUE "FileVersion", "1.1.1"
+ VALUE "FileVersion", "0.0.0"
VALUE "LegalCopyright", "Copyright (C) 2013 GitHub, Inc. All rights reserved."
VALUE "ProductName", "rcedit"
- VALUE "ProductVersion", "1.1.1"
+ VALUE "ProductVersion", "0.0.0"
END
END
BLOCK "VarFileInfo"
diff --git a/src/version.h b/src/version.h
deleted file mode 100644
index 474585c..0000000
--- a/src/version.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) 2017 GitHub, Inc. All rights reserved.
-// Use of this source code is governed by MIT license that can be found in the
-// LICENSE file.
-
-#ifndef SRC_VERSION_H_
-#define SRC_VERSION_H_
-
-#define RCEDIT_MAJOR_VERSION 1
-#define RCEDIT_MINOR_VERSION 1
-#define RCEDIT_PATCH_VERSION 1
-
-#ifndef RCEDIT_TAG
-# define RCEDIT_TAG ""
-#endif
-
-#ifndef RCEDIT_STRINGIFY
-#define RCEDIT_STRINGIFY(n) RCEDIT_STRINGIFY_HELPER(n)
-#define RCEDIT_STRINGIFY_HELPER(n) #n
-#endif
-
-#define RCEDIT_VERSION_STRING RCEDIT_STRINGIFY(RCEDIT_MAJOR_VERSION) "." \
- RCEDIT_STRINGIFY(RCEDIT_MINOR_VERSION) "." \
- RCEDIT_STRINGIFY(RCEDIT_PATCH_VERSION) \
- RCEDIT_TAG
-
-#define RCEDIT_VERSION "v" RCEDIT_VERSION_STRING
-
-#endif // SRC_VERSION_H_