Skip to content

Commit ebd5583

Browse files
authored
Merge pull request #48 from chausner/msvc-fixes
2 parents 294e2dd + 963b22c commit ebd5583

File tree

7 files changed

+87
-34
lines changed

7 files changed

+87
-34
lines changed

.github/workflows/ccpp.yml

Lines changed: 57 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,20 @@ jobs:
2424
run: |
2525
echo ${{ steps.tag.outputs.new_tag }} > tag.txt
2626
- name: upload new tag artifact
27-
uses: actions/upload-artifact@v1
27+
uses: actions/upload-artifact@v4
2828
with:
29-
name: uploads
29+
name: tag-txt
3030
path: tag.txt
3131
build-linux:
3232
runs-on: ubuntu-latest
3333
needs: [bump-tag-dry]
3434
steps:
3535
- uses: actions/checkout@v4
3636
- name: download artifacts
37-
uses: actions/download-artifact@v1
37+
uses: actions/download-artifact@v4
3838
with:
39-
name: uploads
39+
name: tag-txt
40+
path: uploads
4041

4142
- uses: actions/setup-node@v4
4243
with:
@@ -48,47 +49,73 @@ jobs:
4849
export DUPLO_VERSION=`cat ./uploads/tag.txt`
4950
mkdir -p build
5051
pushd build
51-
cmake .. -DDUPLO_VERSION=\"$DUPLO_VERSION\"
52+
cmake .. -DDUPLO_VERSION=\"$DUPLO_VERSION\" -DCMAKE_BUILD_TYPE=Release
5253
make
5354
popd
5455
zip --junk-paths duplo-linux build/duplo
5556
- name: upload linux artifact
56-
uses: actions/upload-artifact@v1
57+
uses: actions/upload-artifact@v4
5758
with:
58-
name: uploads
59+
name: linux-build
5960
path: duplo-linux.zip
6061
build-macos:
6162
runs-on: macos-latest
6263
needs: [bump-tag-dry]
6364
steps:
6465
- uses: actions/checkout@v4
6566
- name: download artifacts
66-
uses: actions/download-artifact@v1
67+
uses: actions/download-artifact@v4
6768
with:
68-
name: uploads
69+
name: tag-txt
70+
path: uploads
6971
- name: build
7072
run: |
7173
brew install bats-core
7274
export DUPLO_VERSION=`cat ./uploads/tag.txt`
7375
mkdir -p build
7476
pushd build
75-
cmake .. -DDUPLO_VERSION=\"$DUPLO_VERSION\"
77+
cmake .. -DDUPLO_VERSION=\"$DUPLO_VERSION\" -DCMAKE_BUILD_TYPE=Release
7678
make
7779
popd
7880
zip --junk-paths duplo-macos build/duplo
7981
- name: upload macos artifact
80-
uses: actions/upload-artifact@v1
82+
uses: actions/upload-artifact@v4
8183
with:
82-
name: uploads
84+
name: macos-build
8385
path: duplo-macos.zip
86+
build-windows:
87+
runs-on: windows-latest
88+
needs: [bump-tag-dry]
89+
steps:
90+
- uses: actions/checkout@v4
91+
- name: download artifacts
92+
uses: actions/download-artifact@v4
93+
with:
94+
name: tag-txt
95+
path: uploads
96+
- name: build
97+
run: |
98+
$duploVersion = Get-Content .\uploads\tag.txt
99+
mkdir build | Out-Null
100+
pushd build
101+
cmake .. "-DDUPLO_VERSION=`"$duploVersion`"" -G "Visual Studio 17 2022" -A x64
102+
cmake --build . --config Release
103+
popd
104+
Compress-Archive -Path build\Release\duplo.exe -DestinationPath duplo-windows.zip
105+
- name: upload windows artifact
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: windows-build
109+
path: duplo-windows.zip
84110
push-docker-image:
85111
runs-on: ubuntu-latest
86112
needs: [bump-tag-dry]
87113
steps:
88114
- name: download artifacts
89-
uses: actions/download-artifact@v1
115+
uses: actions/download-artifact@v4
90116
with:
91-
name: uploads
117+
name: tag-txt
118+
path: uploads
92119

93120
- name: set version
94121
id: version
@@ -133,7 +160,7 @@ jobs:
133160
upload-release:
134161
if: success()
135162
runs-on: ubuntu-latest
136-
needs: [build-linux, build-macos]
163+
needs: [build-linux, build-macos, build-windows]
137164
steps:
138165
- uses: actions/checkout@v4
139166
with:
@@ -156,17 +183,17 @@ jobs:
156183
draft: false
157184
prerelease: false
158185
- name: download artifacts
159-
uses: actions/download-artifact@v1
186+
uses: actions/download-artifact@v4
160187
with:
161-
name: uploads
188+
path: uploads
162189
- name: upload macos
163190
id: upload-macos
164191
uses: actions/[email protected]
165192
env:
166193
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
167194
with:
168195
upload_url: ${{ steps.create_release.outputs.upload_url }}
169-
asset_path: ./uploads/duplo-macos.zip
196+
asset_path: ./uploads/macos-build/duplo-macos.zip
170197
asset_name: duplo-macos.zip
171198
asset_content_type: application/zip
172199
- name: upload linux
@@ -176,6 +203,17 @@ jobs:
176203
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
177204
with:
178205
upload_url: ${{ steps.create_release.outputs.upload_url }}
179-
asset_path: ./uploads/duplo-linux.zip
206+
asset_path: ./uploads/linux-build/duplo-linux.zip
180207
asset_name: duplo-linux.zip
181208
asset_content_type: application/zip
209+
- name: upload windows
210+
id: upload-windows
211+
uses: actions/[email protected]
212+
env:
213+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
214+
with:
215+
upload_url: ${{ steps.create_release.outputs.upload_url }}
216+
asset_path: ./uploads/windows-build/duplo-windows.zip
217+
asset_name: duplo-windows.zip
218+
asset_content_type: application/zip
219+

CMakeLists.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@ file(GLOB SOURCES src/*.cpp)
44

55
SET(DUPLO_VERSION "\"v1.0.1\"" CACHE STRING "Duplo version")
66

7-
if(MSVC)
8-
else()
9-
add_compile_options(-O3 -Wall -Werror -std=c++17)
10-
add_compile_definitions(DUPLO_VERSION=${DUPLO_VERSION})
11-
endif()
127
add_executable(duplo ${SOURCES})
8+
9+
set_target_properties(duplo PROPERTIES
10+
CXX_STANDARD 17
11+
CXX_STANDARD_REQUIRED ON
12+
)
13+
14+
target_compile_definitions(duplo PRIVATE DUPLO_VERSION=${DUPLO_VERSION})
15+
16+
if(NOT MSVC)
17+
target_compile_options(duplo PRIVATE -Wall -Werror)
18+
endif()
19+
20+

Duplo.vcxproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
2020
<ConfigurationType>Application</ConfigurationType>
2121
<CharacterSet>MultiByte</CharacterSet>
22-
<PlatformToolset>v142</PlatformToolset>
22+
<PlatformToolset>v143</PlatformToolset>
2323
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
2424
</PropertyGroup>
2525
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
2626
<ConfigurationType>Application</ConfigurationType>
2727
<CharacterSet>MultiByte</CharacterSet>
28-
<PlatformToolset>v142</PlatformToolset>
28+
<PlatformToolset>v143</PlatformToolset>
2929
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
3030
</PropertyGroup>
3131
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -108,8 +108,10 @@
108108
<ClCompile Include="src\Duplo.cpp" />
109109
<ClCompile Include="src\FileTypeBase.cpp" />
110110
<ClCompile Include="src\FileTypeFactory.cpp" />
111+
<ClCompile Include="src\FileType_Ada.cpp" />
111112
<ClCompile Include="src\FileType_C.cpp" />
112113
<ClCompile Include="src\FileType_CS.cpp" />
114+
<ClCompile Include="src\FileType_Java.cpp" />
113115
<ClCompile Include="src\FileType_S.cpp" />
114116
<ClCompile Include="src\FileType_Unknown.cpp" />
115117
<ClCompile Include="src\FileType_VB.cpp" />
@@ -129,8 +131,10 @@
129131
<ClInclude Include="src\Duplo.h" />
130132
<ClInclude Include="src\FileTypeBase.h" />
131133
<ClInclude Include="src\FileTypeFactory.h" />
134+
<ClInclude Include="src\FileType_Ada.h" />
132135
<ClInclude Include="src\FileType_C.h" />
133136
<ClInclude Include="src\FileType_CS.h" />
137+
<ClInclude Include="src\FileType_Java.h" />
134138
<ClInclude Include="src\FileType_S.h" />
135139
<ClInclude Include="src\FileType_Unknown.h" />
136140
<ClInclude Include="src\FileType_VB.h" />

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,11 @@ filenames into this command. A complete commandline sample will be shown below.
101101

102102
### 4.2. Pre-built binaries
103103

104-
Duplo is also available as a pre-built binary for (alpine) linux and macos. Grab
105-
the executable from the [releases](https://github.com/dlidstrom/Duplo/releases)
106-
page.
104+
Duplo is also available as a pre-built binary for (Alpine) Linux, macOS and
105+
Windows. Grab the executable from the
106+
[releases](https://github.com/dlidstrom/Duplo/releases) page.
107107

108-
You can of course build from source as well, and you'll have to do so to get a
109-
binary for Windows.
108+
You can of course build from source as well.
110109

111110
## 5. Usage
112111

@@ -240,7 +239,7 @@ build/> popd
240239
241240
### 8.2. Windows
242241
243-
Use Visual Studio 2019 to open the included solution file (or try `CMake`).
242+
Use Visual Studio 2022 to open the included solution file (or try `CMake`).
244243
245244
### 8.3. Additional Language Support
246245

src/Duplo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
#include <iostream>
88
#include <vector>
99

10+
#ifdef DUPLO_VERSION
1011
const std::string VERSION = DUPLO_VERSION;
12+
#else
13+
const std::string VERSION = "";
14+
#endif
1115

1216
namespace Duplo {
1317
void Run(const Options& options);

src/FileTypeBase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ std::vector<SourceLine> FileTypeBase::GetCleanedSourceLines(const std::vector<st
3838
for (std::vector<std::string>::size_type i = 0; i < lines.size(); i++) {
3939
auto filteredLine = GetCleanLine(lineFilter->ProcessSourceLine(lines[i]));
4040
if (IsSourceLine(filteredLine)) {
41-
filteredLines.emplace_back(filteredLine, i);
41+
filteredLines.emplace_back(filteredLine, static_cast<int>(i));
4242
}
4343
}
4444

src/StringUtil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int StringUtil::Split(const std::string& input, const std::string& delimiter, st
5959
}
6060

6161
// At the beginning is always a marker
62-
std::vector<int> positions(1, -sizeDelim);
62+
std::vector<int> positions(1, -static_cast<int>(sizeDelim));
6363
auto pos = input.find(delimiter);
6464
while (pos != std::string::npos) {
6565
positions.push_back(pos);

0 commit comments

Comments
 (0)