Skip to content

Commit e0fe57e

Browse files
authored
Create installer for Windows (#377)
1 parent 35d888e commit e0fe57e

19 files changed

+820
-14
lines changed

.github/workflows/msbuild.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: MSBuild
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
build:
8+
runs-on: windows-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Add MSBuild to PATH
14+
uses: microsoft/setup-msbuild@v1.0.2
15+
16+
- name: Restore NuGet packages
17+
run: nuget restore ./win/
18+
19+
- name: Build
20+
run: msbuild /p:AdditionalIncludePaths=./:./cobj/:./win:./lib win/opensourcecobol4j.sln
21+
22+
- name: exec cobj
23+
run: |
24+
cd win/x64/Debug
25+
./cobj.exe --version

.github/workflows/pull-request.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,8 @@ jobs:
6767
javadoc:
6868
uses: ./.github/workflows/javadoc.yml
6969

70+
MSbuild:
71+
uses: ./.github/workflows/msbuild.yml
72+
7073
static-analysis:
7174
uses: ./.github/workflows/static-analysis.yml

.github/workflows/push.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,8 @@ jobs:
6666
javadoc:
6767
uses: ./.github/workflows/javadoc.yml
6868

69+
MSBuild:
70+
uses: ./.github/workflows/msbuild.yml
71+
6972
static-analysis:
7073
uses: ./.github/workflows/static-analysis.yml

cobj/cobj.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,8 +1363,8 @@ static char *cobc_temp_name(const char *ext) {
13631363
#ifdef _WIN32
13641364
char temp[MAX_PATH];
13651365

1366-
GetTempPath(MAX_PATH, temp);
1367-
GetTempFileName(temp, "cob", 0, buff);
1366+
GetTempPath2A(MAX_PATH, temp);
1367+
GetTempFileNameA(temp, "cob", 0, buff);
13681368
DeleteFile(buff);
13691369
strcpy(buff + strlen(buff) - 4, ext); /* replace ".tmp" by EXT */
13701370
#else

cobj/cobj.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,17 @@
2424

2525
#include <stdio.h>
2626

27-
#include "lib/gettext.h"
27+
#ifdef _WIN32
28+
#include <libcobj.h>
29+
#else
2830
#include "libcobj.h"
31+
#endif
32+
33+
#ifdef _WIN32
34+
#include <gettext.h>
35+
#else
36+
#include "lib/gettext.h"
37+
#endif
2938

3039
#if !defined(__i386__) && !defined(__x86_64__) && !defined(__powerpc__) && \
3140
!defined(__powerpc64__) && !defined(__ppc__) && !defined(__amd64__)

cobj/codegen.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
#define INITIALIZE_ONE 1
4545
#define INITIALIZE_DEFAULT 2
4646
#define INITIALIZE_COMPOUND 3
47+
#define EXECUTION_NORMAL 0
48+
#define EXECUTION_LAST 1
49+
#define EXECUTION_ERROR_HANDLER 2
50+
#define BUF_SIZE 1024
51+
#define MAX_LITERAL_SIZE 64
4752

4853
#ifndef __GNUC__
4954
static int inside_check = 0;
@@ -189,10 +194,6 @@ static void joutput_label_variable_name(char *s, int key,
189194
struct cb_label *section);
190195
static void joutput_label_variable_by_value(int value);
191196

192-
const int EXECUTION_NORMAL = 0;
193-
const int EXECUTION_LAST = 1;
194-
const int EXECUTION_ERROR_HANDLER = 2;
195-
196197
static char *get_java_identifier_field(struct cb_field *f) {
197198
char *buf = malloc(COB_SMALL_BUFF);
198199
if (cb_flag_serial_variable) {
@@ -627,13 +628,15 @@ static void joutput_edit_code_command(const char *target) {
627628
return;
628629
}
629630

630-
const int BUF_SIZE = 1024;
631-
632631
char command[BUF_SIZE];
633632
char buf[BUF_SIZE];
634633
sprintf(command, "%s --target=%s", edit_code_command, target);
635634

635+
#ifdef _WIN32
636+
FILE *fp = _popen(command, "r");
637+
#else
636638
FILE *fp = popen(command, "r");
639+
#endif
637640
if (fp == NULL) {
638641
return;
639642
}
@@ -642,8 +645,11 @@ static void joutput_edit_code_command(const char *target) {
642645
while (fgets(buf, BUF_SIZE, fp) != NULL) {
643646
joutput("%s", buf);
644647
}
645-
648+
#ifdef _WIN32
649+
_pclose(fp);
650+
#else
646651
pclose(fp);
652+
#endif
647653
}
648654

649655
/*
@@ -1188,7 +1194,6 @@ static struct literal_list *lookup_literal(cb_tree x) {
11881194
}
11891195

11901196
static void joutput_const_identifier(struct literal_list *l) {
1191-
const int MAX_LITERAL_SIZE = 64;
11921197
char s[MAX_LITERAL_SIZE + 1];
11931198
memset(s, 0, MAX_LITERAL_SIZE + 1);
11941199
int i = 0;

cobj/flag-help.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
* This file describes the options shown when executing cobj --help command
2424
*/
2525

26+
#ifdef _WIN32
27+
#include <gettext.h>
28+
#else
2629
#include "lib/gettext.h"
30+
#endif
2731

2832
CB_FLAG (cb_flag_trace, "trace",
2933
N_("Generate trace code (Executed SECTION/PARAGRAPH)"))

cobj/flag.def

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
* Boston, MA 02110-1301 USA
2020
*/
2121

22-
22+
#ifdef _WIN32
23+
#include <gettext.h>
24+
#else
2325
#include "lib/gettext.h"
26+
#endif
2427

2528
/* CB_FLAG (var, name, doc) */
2629

cobj/warning-help.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
* Boston, MA 02110-1301 USA
2020
*/
2121

22+
#ifdef _WIN32
23+
#include <gettext.h>
24+
#else
2225
#include "lib/gettext.h"
26+
#endif
2327

2428
/* CB_WARNDEF (var, name, wall, doc) */
2529

cobj/warning.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
* Boston, MA 02110-1301 USA
2020
*/
2121

22+
#ifdef _WIN32
23+
#include <gettext.h>
24+
#else
2225
#include "lib/gettext.h"
26+
#endif
2327

2428
/* CB_WARNDEF (var, name, wall, doc) */
2529

0 commit comments

Comments
 (0)