Skip to content

Commit

Permalink
Release 0.3 (#56)
Browse files Browse the repository at this point in the history
* Advance to version 0.2

* Remove explicit root project name.

* Add a prerelease identifier.

* Set linker to clang++.

* Update link.

* Discover target host (#42)

* Update to Gradle 8.4 final

* Advance version to 0.3

* Improve external cmake project sample.

* Discover host target.

Closes #34.

* Test host target discovery.

* Conventional archive adds a test application (#43)

* Update to Gradle 8.4 final

* Advance version to 0.3

* Improve external cmake project sample.

* Discover host target.

Closes #34.

* Test host target discovery.

* Conventional archive adds a test application.

* When configuring ixx includes, configure also commands task (#44)

* Update to Gradle 8.4 final

* Advance version to 0.3

* Improve external cmake project sample.

* Discover host target.

Closes #34.

* Test host target discovery.

* Conventional archive adds a test application.

* When configuring ixx includes, configure also the commands task.

* Test compile option inheritance.

* Expose locateTool (#47)

* Update CI; add LLVM 17. (#48)

* Get path from providers.

* Add a run task for conventional application components.

* Wire the main module to the test module.

* Don't apply cpp plugin

* Require JDK 17

* Shorten notation of test files.

* API for conventional archive and executable file names (#50)

* Don't apply cpp plugin

* Require JDK 17

* Shorten notation of test files.

* API for conventional archive and executable file names.

Closes #33.

* API to define includables etc. as public or private. (#51)

* API to define includables etc. as public or private.

Closes #46.

* API to define includables etc. as public or private.

Closes #46.

* Add MetalService::getHost and MetalService::getTarget.

* Remove getLinkables, use SourceTask::source.

* Wire run-test to test to check.

* API for set of enabled targets (#53)

Provide API for restricting the set of targets where the source set or component is enabled.

The empty set has the special meaning of permitting everything.

* Avoid linking empty source set. (#55)

Closes #52.

* Add javadoc.

* Update to 0.3-next

* Update samples.

* Ignore sample external src.

* Locate tools with metal extension.

* Update version string.

* Fix runTask onlyIf targets is empty i.e. default.

* Add onlyIf reason.

* Advance version to 0.3-rc-1

* Fix typo.

* Document published plugins.

* Set version to 0.3.
  • Loading branch information
pedrolamarao authored Oct 18, 2023
1 parent 008ac7e commit f20fc7a
Show file tree
Hide file tree
Showing 94 changed files with 2,038 additions and 532 deletions.
30 changes: 27 additions & 3 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,35 @@ jobs:
java-version: "17"
distribution: "temurin"
- name: "Install LLVM 16"
uses: KyleMayes/install-llvm-action@v1.8.3
uses: KyleMayes/install-llvm-action@v1
with:
ubuntu-version: 22.04
version: 16.0.4
- name: "Build with Gradle"
uses: gradle/gradle-build-action@v2.8.0
uses: gradle/gradle-build-action@v2
with:
arguments: build
arguments: build
build-llvm-17:
name: "build with llvm 17"
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: "Validate Gradle Wrapper"
uses: gradle/wrapper-validation-action@v1
- name: "Set up JDK 17"
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "temurin"
- name: "Install LLVM 16"
uses: KyleMayes/install-llvm-action@v1
with:
force-version: true
ubuntu-version: 22.04
version: 17.0.2
- name: "Build with Gradle"
uses: gradle/gradle-build-action@v2
with:
arguments: build
44 changes: 24 additions & 20 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
:author: Pedro Lamarão <pedro.lamarao@gmail.com>

Gradle Metal is a suite of Gradle plugins supporting development for the bare metal,
primarily design to support project link:https://github.com/pedrolamarao/psys[Metal].
primarily designed to support project link:https://github.com/pedrolamarao/metal[Metal].

Features:

* multiple languages (assembler, c and c++)
* multiple components (static archives, shared libraries and executables)
* compile commands database (for clang-check, CLion etc.)
* dependency on included (sub)project, included build and external prebuilt components
* compile assembler, c and c++ (including c++ module interfaces)
* assemble archives and executables
* build target support (e.g. `x86_64-elf`)
* generate compilation commands database
* source dependency on included project
* binary dependency on prebuilt external project
* LLVM tools
[WARNING]
Expand All @@ -23,33 +25,35 @@ Current requirements:
* JDK 17 or newer
* LLVM 16 or newer (with clang, clang-scan-deps, lld, llvm-ar etc.)
Plugins are published to Gradle's Plugin Portal. To apply using the plugins DSL:
Plugins are published to Gradles Plugin Portal. To apply using the plugins DSL:

[source,kotlin]
[source]
----
plugins {
id("br.dev.pedrolamarao.metal.base") version("0.1-rc-0")
id("br.dev.pedrolamarao.metal.base") version("0.3")
}
----

Check the link:samples[] for a variety of use-cases.

Plugins:

* `br.dev.pedrolamarao.metal.base`: adds the `metal` extension
* `br.dev.pedrolamarao.metal.application`: creates a conventional "main" application with tasks
* `br.dev.pedrolamarao.metal.archive`: creates a conventional "main" archive with tasks
* `br.dev.pedrolamarao.metal.asm`: adds assembler sources to "main" component (at `src/main/asm`) with tasks
* `br.dev.pedrolamarao.metal.c`: adds C sources to "main" component (at `src/main/c`) with tasks
* `br.dev.pedrolamarao.metal.cpp`: adds CPP sources to "main" component (at `src/main/cxx`) with tasks
* `br.dev.pedrolamarao.metal.cxx`: adds C++ module implementation sources to "main" component (at `src/main/cxx`) with tasks
* `br.dev.pedrolamarao.metal.ixx`: adds C++ module interface sources to "main" component (at `src/main/cxx`) with tasks
* `br.dev.pedrolamarao.metal.base`: adds the Gradle Metal service and extension
* `br.dev.pedrolamarao.metal.application`: conventional application project
* `br.dev.pedrolamarao.metal.archive`: conventional archive project
* `br.dev.pedrolamarao.metal.asm`: adds assembler source sets
* `br.dev.pedrolamarao.metal.c`: adds C sources sets
* `br.dev.pedrolamarao.metal.cpp`: adds C preprocessor source sets
* `br.dev.pedrolamarao.metal.cxx`: adds C++ module implementation source sets
* `br.dev.pedrolamarao.metal.ixx`: adds C++ module interface source sets
Under construction:

* dependencies on external cmake project, maven repository
* GCC and MSVC tools
* variant flavours (release, debug)
* variant target machines (any "triple")
* build flavour support (e.g. `debug`, `release`)
* shared library component
* source dependencies on cmake project
* binary dependencies on maven repository
* GCC tools
* MSVC tools
For development status, see Github issues at link:https://github.com/pedrolamarao/gradle-metal/issues[].
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "br.dev.pedrolamarao.gradle.metal"
version = "0.2"
version = "0.3"

subprojects {
group = rootProject.group
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package br.dev.pedrolamarao.gradle.metal;

import org.gradle.testkit.runner.GradleRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import java.nio.file.Files;
import java.nio.file.Path;

public class MultiProjectFunctionalTest
{
@TempDir
Path projectDir;

/**
* There are two archive projects, foo and bar, with main C++ sources.
* Both foo and bar test source set is empty.
* Bar depends on foo.
* Running <code>check</code> must not try to run nonexistent test applications.
* @see <a href="https://github.com/pedrolamarao/gradle-metal/issues/52">https://github.com/pedrolamarao/gradle-metal/issues/52</a>
*/
@Test
void issue52 () throws Exception
{
final var fooDir = projectDir.resolve("foo");
Files.createDirectories(fooDir);
Files.writeString(fooDir.resolve("build.gradle.kts"),
"""
plugins {
id("br.dev.pedrolamarao.metal.archive")
id("br.dev.pedrolamarao.metal.cpp")
id("br.dev.pedrolamarao.metal.cxx")
}
metal {
cpp {
main {
public = true
}
}
}
""");

final var barDir = projectDir.resolve("bar");
Files.createDirectories(barDir);
Files.writeString(barDir.resolve("build.gradle.kts"),
"""
plugins {
id("br.dev.pedrolamarao.metal.archive")
id("br.dev.pedrolamarao.metal.cxx")
}
dependencies {
implementation(project(":foo"))
}
""");

final var fooCppDir = fooDir.resolve("src/main/cpp");
Files.createDirectories(fooCppDir);
Files.writeString(fooCppDir.resolve("foo.h"),
"""
#pragma once
int foo (int argc, char * argv[]);
""");

final var fooCxxDir = fooDir.resolve("src/main/cxx");
Files.createDirectories(fooCxxDir);
Files.writeString(fooCxxDir.resolve("foo.cxx"),
"""
#include <foo.h>
int foo (int argc, char * argv[])
{
return 0;
}
""");

final var barCxxDir = projectDir.resolve("bar/main/cxx");
Files.createDirectories(barCxxDir);
Files.writeString(barCxxDir.resolve("bar.cxx"),
"""
#include <foo.h>
int bar (int argc, char * argv[])
{
return foo(argc,argv);
}
""");

Files.writeString(projectDir.resolve("build.gradle.kts"),
"""
plugins {
id("base")
}
""");

Files.writeString(projectDir.resolve("settings.gradle.kts"),
"""
include("bar")
include("foo")
""");

GradleRunner.create()
.withPluginClasspath()
.withProjectDir(projectDir.toFile())
.withArguments("check")
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void apply () throws IOException
metal {
applications {
named("main") {
main {
linkOptions = listOf()
}
}
Expand All @@ -36,7 +36,6 @@ public void apply () throws IOException
GradleRunner.create()
.withPluginClasspath()
.withProjectDir(projectDir.toFile())
.withDebug(true)
.build();
}

Expand All @@ -53,12 +52,12 @@ public void language (String language) throws IOException
metal {
%s {
named("main") {
main {
compileOptions = listOf()
}
}
applications {
named("main") {
main {
archiveOptions = listOf()
}
}
Expand All @@ -69,7 +68,68 @@ public void language (String language) throws IOException
GradleRunner.create()
.withPluginClasspath()
.withProjectDir(projectDir.toFile())
.withDebug(true)
.build();
}

@Test
public void languageC () throws IOException
{
final var languageDir = projectDir.resolve("src/main/c");

Files.createDirectories(languageDir);

Files.writeString(languageDir.resolve("main.c"),
"""
int main (int argc, char * argv[])
{
return 0;
}
""");

Files.writeString(projectDir.resolve("build.gradle.kts"),
"""
plugins {
id("br.dev.pedrolamarao.metal.application")
id("br.dev.pedrolamarao.metal.c")
}
"""
);

GradleRunner.create()
.withPluginClasspath()
.withProjectDir(projectDir.toFile())
.withArguments("run-main")
.build();
}

@Test
public void languageCxx () throws IOException
{
final var languageDir = projectDir.resolve("src/main/cxx");

Files.createDirectories(languageDir);

Files.writeString(languageDir.resolve("main.cxx"),
"""
int main (int argc, char * argv[])
{
return 0;
}
""");

Files.writeString(projectDir.resolve("build.gradle.kts"),
"""
plugins {
id("br.dev.pedrolamarao.metal.application")
id("br.dev.pedrolamarao.metal.cxx")
}
"""
);

GradleRunner.create()
.withPluginClasspath()
.withProjectDir(projectDir.toFile())
.withArguments("run-main")
.build();
}
}
Loading

0 comments on commit f20fc7a

Please sign in to comment.