Skip to content

Commit 1c7c870

Browse files
committed
Mass attempt at windows portability
1 parent 0ee6d47 commit 1c7c870

22 files changed

Lines changed: 389 additions & 127 deletions

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ elseif (CMAKE_C_COMPILER_ID STREQUAL "MSVC")
2121
add_compile_options(${win_cflags})
2222
endif()
2323

24+
link_libraries(curl)
25+
if (WIN32)
26+
link_libraries(shlwapi)
27+
endif ()
2428
add_subdirectory(src)
2529

2630
set(SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SYSCONFDIR}")

examples/template/example.ini

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
1-
[meta]
2-
; (string) Mission type: hst, jwst
3-
mission =
4-
5-
; (string) Name of delivery
6-
name =
7-
8-
; (string) A codename is only used when mission is set to "hst"
9-
codename =
10-
11-
; (string) Version of the delivery
12-
version =
13-
14-
; (string) Release Candidate of delivery.
15-
; NOTE: Ignored when final is true.
16-
rc =
17-
18-
; (boolean) Enable delivery finalization routines
19-
final =
20-
21-
; (string) URL of Conda environment YAML
22-
; NOTE: Generally the final release of a older delivery
23-
based_on =
24-
25-
; (string) Target version of Python
26-
python =
27-
28-
[conda]
29-
installer_name = Miniforge3
30-
installer_version = 23.3.1-1
31-
installer_platform = ${OMC_CONDA_PLATFORM}
32-
installer_arch = ${OMC_CONDA_ARCH}
33-
installer_baseurl = https://github.com/conda-forge/miniforge/releases/latest/download
34-
35-
; (list) Conda packages to install
36-
conda_packages =
37-
38-
; (list) Python packages to install
39-
pip_packages =
40-
41-
[runtime]
42-
; (string) Environment variable key pairs
43-
; key=value
44-
45-
[test:name] ; where test:"name" denotes the package name
46-
; (string) Version of tested package
47-
version =
48-
49-
; (string) Git repository of tested package
50-
repository =
51-
52-
; (list) Commands to execute against tested package
53-
script =
1+
[meta]
2+
; (string) Mission type: hst, jwst
3+
mission =
4+
5+
; (string) Name of delivery
6+
name =
7+
8+
; (string) A codename is only used when mission is set to "hst"
9+
codename =
10+
11+
; (string) Version of the delivery
12+
version =
13+
14+
; (string) Release Candidate of delivery.
15+
; NOTE: Ignored when final is true.
16+
rc =
17+
18+
; (boolean) Enable delivery finalization routines
19+
final =
20+
21+
; (string) URL of Conda environment YAML
22+
; NOTE: Generally the final release of a older delivery
23+
based_on =
24+
25+
; (string) Target version of Python
26+
python =
27+
28+
[conda]
29+
installer_name = Miniforge3
30+
installer_version = 23.3.1-1
31+
installer_platform = ${OMC_CONDA_PLATFORM}
32+
installer_arch = ${OMC_CONDA_ARCH}
33+
installer_baseurl = https://github.com/conda-forge/miniforge/releases/latest/download
34+
35+
; (list) Conda packages to install
36+
conda_packages =
37+
38+
; (list) Python packages to install
39+
pip_packages =
40+
41+
[runtime]
42+
; (string) Environment variable key pairs
43+
; key=value
44+
45+
[test:name] ; where test:"name" denotes the package name
46+
; (string) Version of tested package
47+
version =
48+
49+
; (string) Git repository of tested package
50+
repository =
51+
52+
; (list) Commands to execute against tested package
53+
script =

include/config.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
77
#define OMC_OS_WINDOWS
8+
#include "os_windows.h"
89

910
#elif defined(__linux__)
1011
#define OMC_OS_LINUX

include/deliverable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <string.h>
77
#include <stdbool.h>
88
#include <unistd.h>
9-
#include <sys/utsname.h>
9+
1010
#include "omc.h"
1111

1212
#define DELIVERY_PLATFORM_MAX 4
@@ -139,7 +139,7 @@ struct Delivery {
139139
* \brief Global runtime variables
140140
*/
141141
struct Runtime {
142-
RuntimeEnv *environ; ///< Environment variables
142+
struct StrList *env; ///< Environment variables
143143
} runtime;
144144

145145
/*! \struct Test

include/environment.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <stdio.h>
88
#include <stdlib.h>
99
#include <dirent.h>
10-
#include "environment.h"
10+
#include "omc.h"
1111

1212
typedef struct StrList RuntimeEnv;
1313

@@ -20,4 +20,5 @@ char *runtime_expand_var(RuntimeEnv *env, char *input);
2020
void runtime_export(RuntimeEnv *env, char **keys);
2121
void runtime_apply(RuntimeEnv *env);
2222
void runtime_free(RuntimeEnv *env);
23+
2324
#endif //OMC_ENVIRONMENT_H

include/ini.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ struct INIFILE *ini_open(const char *filename);
101101
struct INISection *ini_section_search(struct INIFILE **ini, unsigned mode, char *value);
102102

103103
/**
104-
*
105-
* @param ini
106-
* @param section
107-
* @param key
108-
* @return
104+
*
105+
* @param ini
106+
* @param section
107+
* @param key
108+
* @return
109109
*/
110110
int ini_has_key(struct INIFILE *ini, const char *section, const char *key);
111111

include/omc.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,37 @@
88
#include <limits.h>
99
#include <unistd.h>
1010
#include <time.h>
11-
#include <sys/statvfs.h>
11+
#include "config.h"
1212

1313
#define SYSERROR(MSG, ...) do { \
1414
fprintf(stderr, "%s:%s:%d:%s - ", path_basename(__FILE__), __FUNCTION__, __LINE__, strerror(errno) ? "info" : strerror(errno)); \
1515
fprintf(stderr, MSG LINE_SEP, __VA_ARGS__); \
1616
} while (0)
17+
1718
#define OMC_BUFSIZ 8192
1819
#define OMC_NAME_MAX 255
1920
#define OMC_DIRSTACK_MAX 1024
2021
#define OMC_TIME_STR_MAX 128
2122
#define HTTP_ERROR(X) X >= 400
2223

23-
#include "config.h"
2424
#include "template.h"
2525

26+
#include "strlist.h"
27+
#include "str.h"
28+
#include "environment.h"
2629
#include "utils.h"
2730
#include "copy.h"
2831
#include "ini.h"
2932
#include "conda.h"
30-
#include "environment.h"
3133
#include "artifactory.h"
3234
#include "docker.h"
33-
#include "deliverable.h"
34-
#include "str.h"
35-
#include "strlist.h"
3635
#include "system.h"
3736
#include "download.h"
3837
#include "recipe.h"
3938
#include "relocation.h"
4039
#include "wheel.h"
4140
#include "junitxml.h"
41+
#include "deliverable.h"
4242

4343
#define guard_runtime_free(X) do { if (X) { runtime_free(X); X = NULL; } } while (0)
4444
#define guard_strlist_free(X) do { if ((*X)) { strlist_free(X); (*X) = NULL; } } while (0)

include/os_darwin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define OMC_OS_DARWIN_H
33

44
#include <sys/mount.h>
5+
#include <sys/utsname.h>
56

67
#ifndef __DARWIN_64_BIT_INO_T
78
#define statvfs statfs

include/os_linux.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#define OMC_OS_LINUX_H
33

44
#include <limits.h>
5+
#include <sys/statvfs.h>
6+
#include <sys/utsname.h>
57

68
#ifndef PATH_MAX
79
#include <linux/limits.h>

include/os_windows.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// Created by jhunk on 5/19/2024.
3+
//
4+
5+
#ifndef OMC_OS_WINDOWS_H
6+
#define OMC_OS_WINDOWS_H
7+
8+
9+
#include <winsock2.h>
10+
#include <windows.h>
11+
#include <direct.h>
12+
#define lstat stat
13+
#define NAME_MAX 256
14+
#define MAXNAMLEN 256
15+
#define __environ _environ
16+
#undef mkdir
17+
#define mkdir(X, Y) _mkdir(X)
18+
19+
int setenv(const char *key, const char *value, int overwrite);
20+
char *realpath(const char *path, char **dest);
21+
22+
#endif //OMC_OS_WINDOWS_H

0 commit comments

Comments
 (0)