Skip to content

Commit

Permalink
Merge pull request #355 from SingingBush/ci/github-actions
Browse files Browse the repository at this point in the history
add CI using GitHub Actions
  • Loading branch information
MikeWey authored Feb 26, 2024
2 parents 17d7dc2 + 292de45 commit e9f99f6
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/dlang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
name: ${{ matrix.compiler }} on ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ] # Windows and MacOS are only with latest compilers
compiler:
- dmd-latest
- ldc-latest
- dmd-2.106.1 # (released in 2024)
- dmd-2.105.3 # (released in 2023)
- dmd-2.104.2 # (released in 2023)
- dmd-2.103.1 # (released in 2023)
- dmd-2.102.2 # (released in 2023)
- dmd-2.101.2 # (released in 2023)
- dmd-2.100.2 # (released in 2022)
- dmd-2.099.1 # (released in 2022)
- dmd-2.098.1 # (released in 2021)
- dmd-2.097.2 # (released in 2021)
- ldc-1.35.0 # eq to dmd v2.105.2
- ldc-1.34.0 # eq to dmd v2.104.2
- ldc-1.33.0 # eq to dmd v2.103.1
- ldc-1.28.1 # eq to dmd v2.098.1
- ldc-1.27.1 # eq to dmd v2.097.2

include:
- { os: windows-latest, compiler: dmd-latest } # Windows Server 2022
- { os: windows-latest, compiler: ldc-latest } # Windows Server 2022
- { os: macos-latest, compiler: dmd-latest } # macOS 12
- { os: macos-latest, compiler: ldc-latest } # macOS 12

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Install D ${{ matrix.compiler }}
uses: dlang-community/setup-dlang@v1
with:
compiler: ${{ matrix.compiler }}

- name: Build All With make (unix)
if: runner.os != 'Windows'
run: make all

- name: Build All With rdmd (windows)
if: startsWith(matrix.os, 'windows')
run: rdmd Build.d all
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
*.o
*.a
*.so
*.so.*
.hg
.hgignore
.svn
.dub

TestWindow
27 changes: 27 additions & 0 deletions Build.d
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ int main(string[] args)

void build(string dir, string lib)
{
writefln("Building: %s...", lib);

version(DMD32)
{
if (lib == "gtkd")
Expand All @@ -136,6 +138,8 @@ void build(string dir, string lib)
objects ~= directory ~".obj ";
objects ~= "gtk1.obj gtk2.obj gtk3.obj gtk4.obj";

writeln("Execute dmd in shell...");

executeShell(format("dmd -lib %s %s%s.lib %s", ldflags, OUTPUT, lib, objects));

foreach(string obj; objects.split())
Expand All @@ -144,17 +148,30 @@ void build(string dir, string lib)
else
{
buildObj(dFiles(dir), lib);

writeln("Execute dmd in shell...");

executeShell(format("dmd -lib %s %s%s.lib %s.obj", ldflags, OUTPUT, lib, lib));
std.file.remove(lib ~".obj");
}
}
else
{
std.file.write("build.rf", format("%s -c -lib %s %s %s -Igenerated/gtkd %s%s.lib %s", PLATFORM, dcflags, ldflags, DEBUG, OUTPUT ,lib, dFiles(dir)));

writefln("Spawning process: %s @build.rf", DC);

auto pid = spawnProcess([DC, "@build.rf"]);

if ( wait(pid) != 0 )
{
writefln("%s failed", DC);
exit(1);
}
else
{
writeln("process complete");
}
}

version(LDC)std.file.rmdirRecurse("objects");
Expand All @@ -164,9 +181,19 @@ void build(string dir, string lib)
void buildObj(string files, string objName)
{
std.file.write("build.rf", format("-c %s %s -Igenerated/gtkd %s%s.obj %s", dcflags, DEBUG, OUTPUT, objName, files));

writeln("Spawning process: dmd @build.rf");

auto pid = spawnProcess(["dmd", "@build.rf"]);
if ( wait(pid) != 0 )
{
writeln("dmd failed");
exit(1);
}
else
{
writeln("process complete");
}
}

string dFiles(string sourceDir)
Expand Down

0 comments on commit e9f99f6

Please sign in to comment.