Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add setup for INCLUDE environment variable to properly run with default setup (target = host OS) #81

Merged
merged 1 commit into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
This action sets up watcom for use in actions by:

- downloading a watcom release.
- eventually setting the PATH and WATCOM environment variables.
- set default Open Watcom environment variables (WATCOM + INCLUDE + PATH).
- failing if the specific version of Open Watcom is not available for download.

# Usage
Expand All @@ -21,7 +21,7 @@ steps:
with:
version: "2.0"
- run: |
wcl386 -zq -d+ ${{ env.WATCOM }}/h -w3 -bt=dos -d2 -fomain.c.obj -c -cc main.c
wcl386 -zq -d+ -i"${{ env.WATCOM }}/h" -w3 -bt=dos -d2 -fomain.c.obj -c -cc main.c
wlink option quiet name hello.exe opt map system dos4g debug all file main.c.obj
- run: |
cmake -S . -B build -G "Watcom WMake" -D CMAKE_SYSTEM_NAME=DOS
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ inputs:
required: false
default: ''
location:
description: 'Location where Open Watcom should be extracted to (default=/opt/watcom or C:\\watcom)'
description: 'Location where Open Watcom should be extracted to (default=/opt/watcom or C:\\WATCOM)'
required: false
default: ''
environment:
description: 'Set environment variables (WATCOM + PATH)'
description: 'Set default Open Watcom environment variables (WATCOM + INCLUDE + PATH)'
required: false
default: true
runs:
Expand Down
10 changes: 8 additions & 2 deletions src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,21 @@ export interface ISetupWatcomSettings {
location: string;

/**
* Set WATCOM environment variable + add to PATH
* Set Open Watcom default environment variable (WATCOM + INCLUDE) and add
* native binaries subdir to PATH
*/
environment: boolean;

/**
* Watcom subdir containing the native binaries
* Watcom subdir containing the native binaries (for host OS)
*/
path_subdir: string;

/**
* List of Watcom subdirs containing the default header files (for host OS)
*/
inc_subdirs: string[];

/**
* Need mode bits fix-up
*/
Expand Down
22 changes: 19 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ function getInputs(): ISetupWatcomSettings {

let default_location: string;
let p_path_subdir: string;
let p_inc_subdirs: string[];
if (process.platform === "win32") {
default_location = "C:\\watcom";
default_location = "C:\\WATCOM";
if (p_version == "2.0-64") {
p_path_subdir = "binnt64";
p_path_subdir = "BINNT64";
} else {
p_path_subdir = "binnt";
p_path_subdir = "BINNT";
}
p_inc_subdirs = ["H", "H\\NT", "H\\NT\\DIRECTX", "H\\NT\\DDK"];
} else if (process.platform === "darwin") {
throw new Error("Unsupported platform");
} else {
Expand All @@ -68,6 +70,7 @@ function getInputs(): ISetupWatcomSettings {
} else {
p_path_subdir = "binl";
}
p_inc_subdirs = ["lh"];
}

let p_location = core.getInput("location");
Expand All @@ -84,6 +87,7 @@ function getInputs(): ISetupWatcomSettings {
location: p_location,
environment: p_environment,
path_subdir: p_path_subdir,
inc_subdirs: p_inc_subdirs,
needs_chmod: p_needs_chmod,
};
}
Expand All @@ -98,6 +102,7 @@ async function run(): Promise<void> {
core.info(`location: ${settings.location}`);
core.info(`environment: ${settings.environment}`);
core.info(`path_subdir: ${settings.path_subdir}`);
core.info(`inc_subdirs: ${settings.inc_subdirs}`);
core.endGroup();
if (settings.archive_type == "tar" && process.platform == "win32") {
core.startGroup("Install GNU tar (MSYS).");
Expand Down Expand Up @@ -168,6 +173,17 @@ async function run(): Promise<void> {
const bin_path = path.join(watcom_path, settings.path_subdir);
core.addPath(bin_path);
core.info(`PATH appended with ${bin_path}.`);
const originalInclude = process.env["INCLUDE"];
const sep = (process.platform == "win32") ? ";" : ":";
let inc_path = "";
for (var x of settings.inc_subdirs) {
inc_path = inc_path + path.join(watcom_path, x) + sep;
}
if (originalInclude) {
inc_path = inc_path + originalInclude;
}
core.exportVariable("INCLUDE", inc_path);
core.info(`Setted INCLUDE=${inc_path}`);
core.endGroup();
}
} catch (error) {
Expand Down