diff --git a/README.adoc b/README.adoc index bb72d18..738b356 100644 --- a/README.adoc +++ b/README.adoc @@ -46,7 +46,9 @@ Plugins: * `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.cxx`: adds C++ sources to "main" component (at `src/main/cxx`) 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 Under construction: diff --git a/plugins/build.gradle.kts b/plugins/build.gradle.kts index 279fefe..dca00ed 100644 --- a/plugins/build.gradle.kts +++ b/plugins/build.gradle.kts @@ -30,7 +30,7 @@ gradlePlugin { } create("commands") { id = "br.dev.pedrolamarao.metal.commands" - implementationClass = "br.dev.pedrolamarao.gradle.metal.base.MetalRootPlugin" + implementationClass = "br.dev.pedrolamarao.gradle.metal.base.MetalCommandsPlugin" } create("cpp") { id = "br.dev.pedrolamarao.metal.cpp" @@ -44,6 +44,10 @@ gradlePlugin { id = "br.dev.pedrolamarao.metal.prebuilt" implementationClass = "br.dev.pedrolamarao.gradle.metal.base.MetalPrebuiltPlugin" } + create("ixx") { + id = "br.dev.pedrolamarao.metal.ixx" + implementationClass = "br.dev.pedrolamarao.gradle.metal.ixx.MetalIxxPlugin" + } } } diff --git a/plugins/src/functionalTest/java/br/dev/pedrolamarao/gradle/metal/cxx/CxxFunctionalTest.java b/plugins/src/functionalTest/java/br/dev/pedrolamarao/gradle/metal/cxx/CxxFunctionalTest.java index 0c29452..be0fc94 100644 --- a/plugins/src/functionalTest/java/br/dev/pedrolamarao/gradle/metal/cxx/CxxFunctionalTest.java +++ b/plugins/src/functionalTest/java/br/dev/pedrolamarao/gradle/metal/cxx/CxxFunctionalTest.java @@ -99,7 +99,7 @@ int greet (int argc, char * argv[]) final var buildGradleKts = """ plugins { - id("br.dev.pedrolamarao.metal.cxx") + id("br.dev.pedrolamarao.metal.ixx") } metal { @@ -162,6 +162,7 @@ int greet (int argc, char * argv[]) """ plugins { id("br.dev.pedrolamarao.metal.cxx") + id("br.dev.pedrolamarao.metal.ixx") } metal { diff --git a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/asm/MetalAsmCommandsTask.java b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/asm/MetalAsmCommandsTask.java index 0b64c50..cda8e9a 100644 --- a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/asm/MetalAsmCommandsTask.java +++ b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/asm/MetalAsmCommandsTask.java @@ -2,27 +2,23 @@ package br.dev.pedrolamarao.gradle.metal.asm; -import org.gradle.api.file.RegularFileProperty; import org.gradle.api.provider.Property; import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.OutputFile; import org.gradle.api.tasks.TaskAction; import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.ArrayList; import java.util.stream.Collectors; +import static java.nio.charset.StandardCharsets.UTF_8; + public abstract class MetalAsmCommandsTask extends MetalAsmCompileBaseTask { @Input public abstract Property getObjectDirectory (); - @OutputFile - public abstract RegularFileProperty getOutputFile (); - static final String template = """ { @@ -64,7 +60,8 @@ public void generate () throws IOException }); // aggregate fields - try (var writer = Files.newBufferedWriter(getOutputFile().get().getAsFile().toPath(),StandardCharsets.UTF_8)) { + final var output = getTargetDirectory().map(it -> it.file("compile_commands.json")).get(); + try (var writer = Files.newBufferedWriter(output.getAsFile().toPath(),UTF_8)) { writer.write("[\n"); writer.write( String.join(",\n",list) ); writer.write("]"); diff --git a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/asm/MetalAsmCompileTask.java b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/asm/MetalAsmCompileTask.java index 5ad038c..235b43c 100644 --- a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/asm/MetalAsmCompileTask.java +++ b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/asm/MetalAsmCompileTask.java @@ -2,18 +2,13 @@ package br.dev.pedrolamarao.gradle.metal.asm; -import org.gradle.api.file.Directory; import org.gradle.api.file.DirectoryProperty; import org.gradle.api.file.RegularFileProperty; import org.gradle.api.provider.ListProperty; -import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.Internal; -import org.gradle.api.tasks.OutputDirectory; import org.gradle.api.tasks.TaskAction; import org.gradle.process.ExecOperations; import org.gradle.workers.WorkAction; import org.gradle.workers.WorkParameters; -import org.gradle.workers.WorkerExecutor; import javax.inject.Inject; import java.io.File; @@ -23,23 +18,6 @@ public abstract class MetalAsmCompileTask extends MetalAsmCompileBaseTask { - final WorkerExecutor workerExecutor; - - @OutputDirectory - public abstract DirectoryProperty getOutputDirectory (); - - @Internal - Provider getOutputTargetDirectory () - { - return getOutputDirectory().flatMap(it -> it.dir(getTarget().orElse("default"))); - } - - @Inject - public MetalAsmCompileTask (WorkerExecutor workerExecutor) - { - this.workerExecutor = workerExecutor; - } - public interface CompileParameters extends WorkParameters { DirectoryProperty getBaseDirectory (); @@ -53,13 +31,8 @@ public interface CompileParameters extends WorkParameters public static abstract class CompileAction implements WorkAction { - final ExecOperations execOperations; - @Inject - public CompileAction (ExecOperations execOperations) - { - this.execOperations = execOperations; - } + public abstract ExecOperations getExec (); @Override public void execute () @@ -80,7 +53,7 @@ public void execute () try { Files.createDirectories(outputPath.getParent()); - execOperations.exec(it -> it.commandLine(compileArgs)); + getExec().exec(it -> it.commandLine(compileArgs)); } catch (IOException e) { throw new RuntimeException(e); } } @@ -90,8 +63,8 @@ public void execute () public void compile () { final var baseDirectory = getProject().getProjectDir(); - final var outputDirectory = getOutputTargetDirectory(); - final var workers = workerExecutor.noIsolation(); + final var outputDirectory = getTargetDirectory(); + final var workers = getWorkers().noIsolation(); // prepare arguments final var compileArgs = toCompileArguments(File::toString); diff --git a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/asm/MetalAsmPlugin.java b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/asm/MetalAsmPlugin.java index 73066c0..862c258 100644 --- a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/asm/MetalAsmPlugin.java +++ b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/asm/MetalAsmPlugin.java @@ -31,22 +31,26 @@ static MetalAsmSources createSources (Project project, String name) final var objects = project.getObjects(); final var tasks = project.getTasks(); + // prepare configuration + final var commandsDirectory = layout.getBuildDirectory().dir("db/%s/asm".formatted(name)); final var compileOptions = objects.listProperty(String.class); final var includables = configurations.named(INCLUDABLE_DEPENDENCIES); final var sources = objects.sourceDirectorySet(name,name); sources.srcDir(layout.getProjectDirectory().dir("src/%s/asm".formatted(name))); final var objectDirectory = layout.getBuildDirectory().dir("obj/%s/asm".formatted(name)); + // register commands database task final var commandsTask = tasks.register("commands-%s-asm".formatted(name), MetalAsmCommandsTask.class, task -> { task.getCompileOptions().set(compileOptions); task.getIncludables().from(includables); task.getObjectDirectory().set(objectDirectory.map(Directory::getAsFile)); - task.getOutputFile().set(layout.getBuildDirectory().file("db/%s/asm/compile_commands.json".formatted(name))); + task.getOutputDirectory().set(commandsDirectory); task.setSource(sources); }); configurations.named(COMMANDS_ELEMENTS).configure(it -> it.getOutgoing().artifact(commandsTask)); + // register compile task final var compileTask = tasks.register("compile-%s-asm".formatted(name), MetalAsmCompileTask.class, task -> { task.getCompileOptions().set(compileOptions); diff --git a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalBasePlugin.java b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalBasePlugin.java index 7efcf02..fba28f6 100644 --- a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalBasePlugin.java +++ b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalBasePlugin.java @@ -43,6 +43,24 @@ public void apply (Project project) configuration.setVisible(false); }); + project.getConfigurations().resolvable(IMPORTABLE_DEPENDENCIES, configuration -> { + configuration.attributes(it -> it.attribute(MetalCapability.ATTRIBUTE, MetalCapability.IMPORTABLE)); + configuration.extendsFrom(nativeImplementation.get()); + }); + + project.getConfigurations().consumable(MetalBasePlugin.IMPORTABLE_ELEMENTS, configuration -> { + configuration.attributes(it -> it.attribute(MetalCapability.ATTRIBUTE, MetalCapability.IMPORTABLE)); + }); + + project.getConfigurations().resolvable(MetalBasePlugin.INCLUDABLE_DEPENDENCIES, configuration -> { + configuration.attributes(it -> it.attribute(MetalCapability.ATTRIBUTE, MetalCapability.INCLUDABLE)); + configuration.extendsFrom(nativeImplementation.get()); + }); + + project.getConfigurations().consumable(MetalBasePlugin.INCLUDABLE_ELEMENTS, configuration -> { + configuration.attributes(it -> it.attribute(MetalCapability.ATTRIBUTE, MetalCapability.INCLUDABLE)); + }); + configurations.resolvable(LINKABLE_DEPENDENCIES, configuration -> { configuration.attributes(it -> it.attribute(MetalCapability.ATTRIBUTE, MetalCapability.LINKABLE)); configuration.extendsFrom(nativeImplementation.get()); diff --git a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalRootPlugin.java b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalCommandsPlugin.java similarity index 92% rename from plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalRootPlugin.java rename to plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalCommandsPlugin.java index f6f995e..8bcd042 100644 --- a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalRootPlugin.java +++ b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalCommandsPlugin.java @@ -8,7 +8,7 @@ import java.util.ArrayList; import java.util.List; -public class MetalRootPlugin implements Plugin +public class MetalCommandsPlugin implements Plugin { @Override public void apply (Project project) @@ -32,7 +32,7 @@ public void apply (Project project) } final var list = new ArrayList<>(); - commandsDependencies.forEach(file -> { + commandsDependencies.getAsFileTree().forEach(file -> { final var parsed = (List) new groovy.json.JsonSlurper().parse(file); list.addAll(parsed); }); diff --git a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalCompileTask.java b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalCompileTask.java index 0689d5d..68e5518 100644 --- a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalCompileTask.java +++ b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalCompileTask.java @@ -1,8 +1,15 @@ package br.dev.pedrolamarao.gradle.metal.base; +import org.gradle.api.file.Directory; +import org.gradle.api.file.DirectoryProperty; import org.gradle.api.provider.ListProperty; +import org.gradle.api.provider.Provider; import org.gradle.api.tasks.Input; +import org.gradle.api.tasks.Internal; +import org.gradle.api.tasks.OutputDirectory; +import org.gradle.workers.WorkerExecutor; +import javax.inject.Inject; import java.nio.file.Path; public abstract class MetalCompileTask extends MetalSourceTask @@ -10,6 +17,18 @@ public abstract class MetalCompileTask extends MetalSourceTask @Input public abstract ListProperty getCompileOptions (); + @Internal + public abstract DirectoryProperty getOutputDirectory (); + + @OutputDirectory + public Provider getTargetDirectory () + { + return getOutputDirectory().flatMap(it -> it.dir(getTarget().orElse("default"))); + } + + @Inject + public abstract WorkerExecutor getWorkers (); + protected static Path toOutputPath (Path base, Path source, Path output, String extension) { final var hash = hash(base.relativize(source)); diff --git a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalComponentPlugin.java b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalComponentPlugin.java index 5bd2e9c..60fce6c 100644 --- a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalComponentPlugin.java +++ b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalComponentPlugin.java @@ -16,6 +16,8 @@ protected void configure (Project project, MetalComponent component) project.getLogger().info("gradle-metal: creating main component: {}",component); + // if cpp plugin then create cpp sources + plugins.withPlugin("br.dev.pedrolamarao.metal.cpp",plugin -> { final var metal = project.getExtensions().getByType(MetalExtension.class); @@ -24,6 +26,8 @@ protected void configure (Project project, MetalComponent component) project.getLogger().info("gradle-metal: creating main sources: {}",sources); }); + // if asm plugin then create asm sources + plugins.withPlugin("br.dev.pedrolamarao.metal.asm",plugin -> { final var metal = project.getExtensions().getByType(MetalExtension.class); @@ -33,6 +37,8 @@ protected void configure (Project project, MetalComponent component) project.getLogger().info("gradle-metal: creating main sources: {}",sources); }); + // if c plugin then create c sources + plugins.withPlugin("br.dev.pedrolamarao.metal.c",plugin -> { final var metal = project.getExtensions().getByType(MetalExtension.class); @@ -42,19 +48,29 @@ protected void configure (Project project, MetalComponent component) project.getLogger().info("gradle-metal: creating main sources: {}",sources); }); + // if cxx plugin then create cxx sources + plugins.withPlugin("br.dev.pedrolamarao.metal.cxx",plugin -> { final var metal = project.getExtensions().getByType(MetalExtension.class); - final var ixx = (NamedDomainObjectContainer) metal.getExtensions().getByName("ixx"); - final var ixxSources = (MetalIxxSources) ixx.create("main"); final var cxx = (NamedDomainObjectContainer) metal.getExtensions().getByName("cxx"); - final var cxxSources = (MetalCxxSources) cxx.create("main"); - cxxSources.importable(ixxSources.getOutputDirectory()); - cxxSources.source(ixxSources.getOutputs()); - component.source(cxxSources.getOutputs()); - project.getLogger().info("gradle-metal: creating main sources: {}",cxxSources); + final var sources = (MetalCxxSources) cxx.create("main"); + component.source(sources.getOutputs()); + project.getLogger().info("gradle-metal: creating main sources: {}",sources); }); + // if ixx plugin then create ixx sources + + plugins.withPlugin("br.dev.pedrolamarao.metal.ixx",plugin -> + { + final var metal = project.getExtensions().getByType(MetalExtension.class); + final var ixx = (NamedDomainObjectContainer) metal.getExtensions().getByName("ixx"); + final var sources = (MetalIxxSources) ixx.create("main"); + project.getLogger().info("gradle-metal: creating main sources: {}",sources); + }); + + // if cpp sources then wire to other sources' includables + project.afterEvaluate(it -> { final var metal = it.getExtensions().getByType(MetalExtension.class); @@ -83,6 +99,32 @@ protected void configure (Project project, MetalComponent component) cxx.includable( cpp.getSources().getSourceDirectories() ); project.getLogger().info("gradle-metal: wiring sources: {} -> {}",cpp,cxx); } + + final var ixxContainer = (NamedDomainObjectContainer) metal.getExtensions().findByName("ixx"); + if (ixxContainer != null) { + final var ixx = (MetalIxxSources) ixxContainer.getByName("main"); + ixx.includable( cpp.getSources().getSourceDirectories() ); + project.getLogger().info("gradle-metal: wiring sources: {} -> {}",cpp,ixx); + } + }); + + // if ixx sources then wire to other sources' importables + + project.afterEvaluate(it -> + { + final var metal = it.getExtensions().getByType(MetalExtension.class); + + final var ixxContainer = (NamedDomainObjectContainer) metal.getExtensions().findByName("ixx"); + if (ixxContainer == null) return; + final var ixx = (MetalIxxSources) ixxContainer.getByName("main"); + + final var cxxContainer = (NamedDomainObjectContainer) metal.getExtensions().findByName("cxx"); + if (cxxContainer != null) { + final var cxx = (MetalCxxSources) cxxContainer.getByName("main"); + cxx.importable( ixx.getOutputDirectory() ); + cxx.source( ixx.getOutputs() ); + project.getLogger().info("gradle-metal: wiring sources: {} -> {}",ixx,cxx); + } }); } } diff --git a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalLinkTask.java b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalLinkTask.java index a5acb22..3b32f36 100644 --- a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalLinkTask.java +++ b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/base/MetalLinkTask.java @@ -26,7 +26,7 @@ public Provider getOutput () { final var target = getTarget().orElse("default").get(); final var name = getProject().getName(); - return getOutputDirectory().map(it -> it.file("%s/%s.lib".formatted(target,name))); + return getOutputDirectory().map(it -> it.file("%s/%s.exe".formatted(target,name))); } @Internal diff --git a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/c/MetalCCommandsTask.java b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/c/MetalCCommandsTask.java index 9d6e354..e1e2a65 100644 --- a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/c/MetalCCommandsTask.java +++ b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/c/MetalCCommandsTask.java @@ -2,27 +2,23 @@ package br.dev.pedrolamarao.gradle.metal.c; -import org.gradle.api.file.RegularFileProperty; import org.gradle.api.provider.Property; import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.OutputFile; import org.gradle.api.tasks.TaskAction; import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.ArrayList; import java.util.stream.Collectors; +import static java.nio.charset.StandardCharsets.UTF_8; + public abstract class MetalCCommandsTask extends MetalCCompileBaseTask { @Input public abstract Property getObjectDirectory (); - @OutputFile - public abstract RegularFileProperty getOutputFile (); - static final String template = """ { @@ -64,7 +60,8 @@ public void generate () throws IOException }); // aggregate fields - try (var writer = Files.newBufferedWriter(getOutputFile().get().getAsFile().toPath(),StandardCharsets.UTF_8)) { + final var output = getTargetDirectory().map(it -> it.file("compile_commands.json")).get(); + try (var writer = Files.newBufferedWriter(output.getAsFile().toPath(),UTF_8)) { writer.write("[\n"); writer.write( String.join(",\n",list) ); writer.write("]"); diff --git a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/c/MetalCCompileTask.java b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/c/MetalCCompileTask.java index 9586591..b1eb1eb 100644 --- a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/c/MetalCCompileTask.java +++ b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/c/MetalCCompileTask.java @@ -2,18 +2,13 @@ package br.dev.pedrolamarao.gradle.metal.c; -import org.gradle.api.file.Directory; import org.gradle.api.file.DirectoryProperty; import org.gradle.api.file.RegularFileProperty; import org.gradle.api.provider.ListProperty; -import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.Internal; -import org.gradle.api.tasks.OutputDirectory; import org.gradle.api.tasks.TaskAction; import org.gradle.process.ExecOperations; import org.gradle.workers.WorkAction; import org.gradle.workers.WorkParameters; -import org.gradle.workers.WorkerExecutor; import javax.inject.Inject; import java.io.File; @@ -23,23 +18,6 @@ public abstract class MetalCCompileTask extends MetalCCompileBaseTask { - final WorkerExecutor workerExecutor; - - @OutputDirectory - public abstract DirectoryProperty getOutputDirectory (); - - @Internal - Provider getOutputTargetDirectory () - { - return getOutputDirectory().flatMap(it -> it.dir(getTarget().orElse("default"))); - } - - @Inject - public MetalCCompileTask (WorkerExecutor workerExecutor) - { - this.workerExecutor = workerExecutor; - } - public interface CompileParameters extends WorkParameters { DirectoryProperty getBaseDirectory (); @@ -53,13 +31,8 @@ public interface CompileParameters extends WorkParameters public static abstract class CompileAction implements WorkAction { - final ExecOperations execOperations; - @Inject - public CompileAction (ExecOperations execOperations) - { - this.execOperations = execOperations; - } + public abstract ExecOperations getExec (); @Override public void execute () @@ -80,7 +53,7 @@ public void execute () try { Files.createDirectories(outputPath.getParent()); - execOperations.exec(it -> it.commandLine(compileArgs)); + getExec().exec(it -> it.commandLine(compileArgs)); } catch (IOException e) { throw new RuntimeException(e); } } @@ -90,8 +63,8 @@ public void execute () public void compile () { final var baseDirectory = getProject().getProjectDir(); - final var outputDirectory = getOutputTargetDirectory(); - final var workers = workerExecutor.noIsolation(); + final var outputDirectory = getTargetDirectory(); + final var workers = getWorkers().noIsolation(); // prepare compile args final var compileArgs = toCompileArguments(File::toString); diff --git a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/c/MetalCPlugin.java b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/c/MetalCPlugin.java index 6337a9d..99fa4c0 100644 --- a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/c/MetalCPlugin.java +++ b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/c/MetalCPlugin.java @@ -31,6 +31,7 @@ static MetalCSources createSources (Project project, String name) final var objects = project.getObjects(); final var tasks = project.getTasks(); + final var commandsDirectory = layout.getBuildDirectory().dir("db/%s/c".formatted(name)); final var compileOptions = objects.listProperty(String.class); final var includables = configurations.named(INCLUDABLE_DEPENDENCIES); final var sources = objects.sourceDirectorySet(name,name); @@ -42,7 +43,7 @@ static MetalCSources createSources (Project project, String name) task.getCompileOptions().set(compileOptions); task.getIncludables().from(includables); task.getObjectDirectory().set(objectDirectory.map(Directory::getAsFile)); - task.getOutputFile().set(layout.getBuildDirectory().file("db/%s/c/compile_commands.json".formatted(name))); + task.getOutputDirectory().set(commandsDirectory); task.setSource(sources); }); configurations.named(COMMANDS_ELEMENTS).configure(it -> it.getOutgoing().artifact(commandsTask)); diff --git a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/cpp/MetalCppPlugin.java b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/cpp/MetalCppPlugin.java index 21548a0..06b88a7 100644 --- a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/cpp/MetalCppPlugin.java +++ b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/cpp/MetalCppPlugin.java @@ -1,7 +1,6 @@ package br.dev.pedrolamarao.gradle.metal.cpp; import br.dev.pedrolamarao.gradle.metal.base.MetalBasePlugin; -import br.dev.pedrolamarao.gradle.metal.base.MetalCapability; import br.dev.pedrolamarao.gradle.metal.base.MetalExtension; import org.gradle.api.Plugin; import org.gradle.api.Project; @@ -17,21 +16,6 @@ public void apply (Project project) final var cpp = project.getObjects().domainObjectContainer(MetalCppSources.class, name -> createCppSources(project,name)); metal.getExtensions().add("cpp", cpp); - - final var nativeImplementation = project.getConfigurations().named("nativeImplementation"); - - project.getConfigurations().create(MetalBasePlugin.INCLUDABLE_DEPENDENCIES, configuration -> { - configuration.setCanBeConsumed(false); - configuration.setCanBeResolved(true); - configuration.attributes(it -> it.attribute(MetalCapability.ATTRIBUTE, MetalCapability.INCLUDABLE)); - configuration.extendsFrom(nativeImplementation.get()); - }); - - project.getConfigurations().create(MetalBasePlugin.INCLUDABLE_ELEMENTS, configuration -> { - configuration.setCanBeConsumed(true); - configuration.setCanBeResolved(false); - configuration.attributes(it -> it.attribute(MetalCapability.ATTRIBUTE, MetalCapability.INCLUDABLE)); - }); } static MetalCppSources createCppSources (Project project, String name) @@ -44,8 +28,7 @@ static MetalCppSources createCppSources (Project project, String name) final var sources = objects.sourceDirectorySet(name,name); sources.srcDir( layout.getProjectDirectory().dir("src/%s/cpp".formatted(name)) ); - configurations.named(MetalBasePlugin.INCLUDABLE_ELEMENTS).configure(configuration -> - { + configurations.named(MetalBasePlugin.INCLUDABLE_ELEMENTS).configure(configuration -> { configuration.getOutgoing().artifacts(providers.provider(sources::getSourceDirectories)); }); diff --git a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/cxx/MetalCxxCommandsTask.java b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/cxx/MetalCxxCommandsTask.java index 8674410..7a74400 100644 --- a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/cxx/MetalCxxCommandsTask.java +++ b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/cxx/MetalCxxCommandsTask.java @@ -2,27 +2,23 @@ package br.dev.pedrolamarao.gradle.metal.cxx; -import org.gradle.api.file.RegularFileProperty; import org.gradle.api.provider.Property; import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.OutputFile; import org.gradle.api.tasks.TaskAction; import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.ArrayList; import java.util.stream.Collectors; +import static java.nio.charset.StandardCharsets.UTF_8; + public abstract class MetalCxxCommandsTask extends MetalCxxCompileBaseTask { @Input public abstract Property getObjectDirectory (); - @OutputFile - public abstract RegularFileProperty getOutputFile (); - static final String template = """ { @@ -64,7 +60,8 @@ public void generate () throws IOException }); // aggregate fields - try (var writer = Files.newBufferedWriter(getOutputFile().get().getAsFile().toPath(),StandardCharsets.UTF_8)) { + final var output = getTargetDirectory().map(it -> it.file("compile_commands.json")).get(); + try (var writer = Files.newBufferedWriter(output.getAsFile().toPath(),UTF_8)) { writer.write("[\n"); writer.write( String.join(",\n",list) ); writer.write("]"); diff --git a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/cxx/MetalCxxCompileTask.java b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/cxx/MetalCxxCompileTask.java index 7ab0af2..24f726f 100644 --- a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/cxx/MetalCxxCompileTask.java +++ b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/cxx/MetalCxxCompileTask.java @@ -2,18 +2,13 @@ package br.dev.pedrolamarao.gradle.metal.cxx; -import org.gradle.api.file.Directory; import org.gradle.api.file.DirectoryProperty; import org.gradle.api.file.RegularFileProperty; import org.gradle.api.provider.ListProperty; -import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.Internal; -import org.gradle.api.tasks.OutputDirectory; import org.gradle.api.tasks.TaskAction; import org.gradle.process.ExecOperations; import org.gradle.workers.WorkAction; import org.gradle.workers.WorkParameters; -import org.gradle.workers.WorkerExecutor; import javax.inject.Inject; import java.io.File; @@ -23,23 +18,6 @@ public abstract class MetalCxxCompileTask extends MetalCxxCompileBaseTask { - final WorkerExecutor workerExecutor; - - @OutputDirectory - public abstract DirectoryProperty getOutputDirectory (); - - @Internal - Provider getOutputTargetDirectory () - { - return getOutputDirectory().flatMap(it -> it.dir(getTarget().orElse("default"))); - } - - @Inject - public MetalCxxCompileTask (WorkerExecutor workerExecutor) - { - this.workerExecutor = workerExecutor; - } - public interface CompileParameters extends WorkParameters { DirectoryProperty getBaseDirectory (); @@ -53,13 +31,8 @@ public interface CompileParameters extends WorkParameters public static abstract class CompileAction implements WorkAction { - final ExecOperations execOperations; - @Inject - public CompileAction (ExecOperations execOperations) - { - this.execOperations = execOperations; - } + public abstract ExecOperations getExec (); @Override public void execute () @@ -80,7 +53,7 @@ public void execute () try { Files.createDirectories(outputPath.getParent()); - execOperations.exec(it -> it.commandLine(compileArgs)); + getExec().exec(it -> it.commandLine(compileArgs)); } catch (IOException e) { throw new RuntimeException(e); } } @@ -90,8 +63,8 @@ public void execute () public void compile () { final var baseDirectory = getProject().getProjectDir(); - final var outputDirectory = getOutputTargetDirectory(); - final var queue = workerExecutor.noIsolation(); + final var outputDirectory = getTargetDirectory(); + final var queue = getWorkers().noIsolation(); // prepare arguments final var compileArgs = toCompileArguments(File::toString); diff --git a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/cxx/MetalCxxPlugin.java b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/cxx/MetalCxxPlugin.java index 6e0be9b..460e4ef 100644 --- a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/cxx/MetalCxxPlugin.java +++ b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/cxx/MetalCxxPlugin.java @@ -1,12 +1,8 @@ package br.dev.pedrolamarao.gradle.metal.cxx; import br.dev.pedrolamarao.gradle.metal.base.MetalBasePlugin; -import br.dev.pedrolamarao.gradle.metal.base.MetalCapability; import br.dev.pedrolamarao.gradle.metal.base.MetalExtension; import br.dev.pedrolamarao.gradle.metal.cpp.MetalCppPlugin; -import br.dev.pedrolamarao.gradle.metal.ixx.MetalIxxCommandsTask; -import br.dev.pedrolamarao.gradle.metal.ixx.MetalIxxCompileTask; -import br.dev.pedrolamarao.gradle.metal.ixx.MetalIxxSources; import org.gradle.api.Plugin; import org.gradle.api.Project; import org.gradle.api.file.Directory; @@ -23,35 +19,18 @@ public void apply (Project project) final var metal = project.getExtensions().getByType(MetalExtension.class); - final var cxx = project.getObjects().domainObjectContainer(MetalCxxSources.class, name -> createCxxSources(project,name)); + final var cxx = project.getObjects().domainObjectContainer(MetalCxxSources.class, name -> createSources(project,name)); metal.getExtensions().add("cxx", cxx); - - final var ixx = project.getObjects().domainObjectContainer(MetalIxxSources.class, name -> createIxxSources(project,name)); - metal.getExtensions().add("ixx", ixx); - - final var nativeImplementation = project.getConfigurations().named("nativeImplementation"); - - project.getConfigurations().create(IMPORTABLE_DEPENDENCIES, configuration -> { - configuration.setCanBeConsumed(false); - configuration.setCanBeResolved(true); - configuration.attributes(it -> it.attribute(MetalCapability.ATTRIBUTE, MetalCapability.IMPORTABLE)); - configuration.extendsFrom(nativeImplementation.get()); - }); - - project.getConfigurations().create(MetalBasePlugin.IMPORTABLE_ELEMENTS, configuration -> { - configuration.setCanBeConsumed(true); - configuration.setCanBeResolved(false); - configuration.attributes(it -> it.attribute(MetalCapability.ATTRIBUTE, MetalCapability.IMPORTABLE)); - }); } - static MetalCxxSources createCxxSources (Project project, String name) + static MetalCxxSources createSources (Project project, String name) { final var configurations = project.getConfigurations(); final var layout = project.getLayout(); final var objects = project.getObjects(); final var tasks = project.getTasks(); + final var commandsDirectory = layout.getBuildDirectory().dir("db/%s/cxx".formatted(name)); final var compileOptions = objects.listProperty(String.class); final var includables = configurations.named(INCLUDABLE_DEPENDENCIES); final var importables = configurations.named(IMPORTABLE_DEPENDENCIES); @@ -65,7 +44,7 @@ static MetalCxxSources createCxxSources (Project project, String name) task.getImportables().from(importables); task.getIncludables().from(includables); task.getObjectDirectory().set(objectDirectory.map(Directory::getAsFile)); - task.getOutputFile().set(layout.getBuildDirectory().file("db/%s/cxx/compile_commands.json".formatted(name))); + task.getOutputDirectory().set(commandsDirectory); task.setSource(sources); }); configurations.named(COMMANDS_ELEMENTS).configure(it -> it.getOutgoing().artifact(commandsTask)); @@ -82,44 +61,4 @@ static MetalCxxSources createCxxSources (Project project, String name) return new MetalCxxSources(commandsTask, compileOptions, compileTask, name); } - - static MetalIxxSources createIxxSources (Project project, String name) - { - final var configurations = project.getConfigurations(); - final var layout = project.getLayout(); - final var objects = project.getObjects(); - final var tasks = project.getTasks(); - - final var compileOptions = objects.listProperty(String.class); - final var importables = configurations.named(IMPORTABLE_DEPENDENCIES); - final var includables = configurations.named(INCLUDABLE_DEPENDENCIES); - final var sources = objects.sourceDirectorySet(name,name); - sources.srcDir(layout.getProjectDirectory().dir("src/%s/ixx".formatted(name))); - final var objectDirectory = layout.getBuildDirectory().dir("bmi/%s/ixx".formatted(name)); - - final var commandsTask = tasks.register("commands-%s-ixx".formatted(name), MetalIxxCommandsTask.class, task -> - { - task.getCompileOptions().set(compileOptions); - task.getIncludables().from(includables); - task.getImportables().from(importables); - task.getObjectDirectory().set(objectDirectory.map(Directory::getAsFile)); - task.getOutputFile().set(layout.getBuildDirectory().file("db/%s/ixx/compile_commands.json".formatted(name))); - task.setSource(sources); - }); - configurations.named(COMMANDS_ELEMENTS).configure(it -> it.getOutgoing().artifact(commandsTask)); - - final var compileTask = tasks.register("compile-%s-ixx".formatted(name), MetalIxxCompileTask.class, task -> - { - task.getCompileOptions().set(compileOptions); - task.getIncludables().from(includables); - task.getImportables().from(importables); - task.getOutputDirectory().set(objectDirectory); - task.setSource(sources); - }); - configurations.named(MetalBasePlugin.IMPORTABLE_ELEMENTS).configure(configuration -> { - configuration.getOutgoing().artifact(compileTask.map(MetalIxxCompileTask::getOutputDirectory), it -> it.builtBy(compileTask)); - }); - - return new MetalIxxSources(compileOptions, compileTask, name); - } } diff --git a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/ixx/MetalIxxCommandsTask.java b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/ixx/MetalIxxCommandsTask.java index da9b57d..840791e 100644 --- a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/ixx/MetalIxxCommandsTask.java +++ b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/ixx/MetalIxxCommandsTask.java @@ -3,26 +3,22 @@ package br.dev.pedrolamarao.gradle.metal.ixx; import br.dev.pedrolamarao.gradle.metal.cxx.MetalCxxCompileBaseTask; -import org.gradle.api.file.RegularFileProperty; import org.gradle.api.provider.Property; import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.OutputFile; import org.gradle.api.tasks.TaskAction; import java.io.File; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.ArrayList; import java.util.stream.Collectors; +import static java.nio.charset.StandardCharsets.UTF_8; + public abstract class MetalIxxCommandsTask extends MetalIxxCompileBaseTask { @Input public abstract Property getObjectDirectory (); - @OutputFile - public abstract RegularFileProperty getOutputFile (); - static final String template = """ { @@ -73,7 +69,8 @@ public void generate () throws Exception }); // aggregate fields - try (var writer = Files.newBufferedWriter(getOutputFile().get().getAsFile().toPath(),StandardCharsets.UTF_8)) { + final var output = getTargetDirectory().map(it -> it.file("compile_commands.json")).get(); + try (var writer = Files.newBufferedWriter(output.getAsFile().toPath(),UTF_8)) { writer.write("[\n"); writer.write( String.join(",\n", commandList) ); writer.write("]"); diff --git a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/ixx/MetalIxxCompileTask.java b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/ixx/MetalIxxCompileTask.java index 755c583..acb3faa 100644 --- a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/ixx/MetalIxxCompileTask.java +++ b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/ixx/MetalIxxCompileTask.java @@ -2,46 +2,14 @@ package br.dev.pedrolamarao.gradle.metal.ixx; -import org.gradle.api.file.Directory; -import org.gradle.api.file.DirectoryProperty; -import org.gradle.api.model.ObjectFactory; -import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.Internal; -import org.gradle.api.tasks.OutputDirectory; import org.gradle.api.tasks.TaskAction; -import org.gradle.process.ExecOperations; -import org.gradle.workers.WorkerExecutor; -import javax.inject.Inject; import java.io.IOException; import java.nio.file.Files; import java.util.ArrayList; public abstract class MetalIxxCompileTask extends MetalIxxCompileBaseTask { - final ExecOperations exec; - - final ObjectFactory objects; - - final WorkerExecutor workers; - - @Internal - public abstract DirectoryProperty getOutputDirectory (); - - @OutputDirectory - public Provider getOutputTargetDirectory () - { - return getOutputDirectory().flatMap(it -> it.dir(getTarget().orElse("default"))); - } - - @Inject - public MetalIxxCompileTask (ExecOperations exec, ObjectFactory objects, WorkerExecutor workers) - { - this.exec = exec; - this.objects = objects; - this.workers = workers; - } - @TaskAction public void compile () throws ClassNotFoundException, IOException { @@ -60,7 +28,7 @@ public void compile () throws ClassNotFoundException, IOException baseArgs.add("--language=c++-module"); // remove old objects - final var outputDirectory = getOutputTargetDirectory().get().getAsFile().toPath(); + final var outputDirectory = getTargetDirectory().get().getAsFile().toPath(); getProject().delete(outputDirectory); // compile objects from sources @@ -75,7 +43,7 @@ public void compile () throws ClassNotFoundException, IOException compileArgs.add("--output=%s".formatted(outputPath)); compileArgs.add(module.source().toString()); - exec.exec(it -> { + getProject().exec(it -> { it.commandLine(compileArgs); }); } diff --git a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/ixx/MetalIxxPlugin.java b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/ixx/MetalIxxPlugin.java new file mode 100644 index 0000000..d1f46b2 --- /dev/null +++ b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/ixx/MetalIxxPlugin.java @@ -0,0 +1,66 @@ +package br.dev.pedrolamarao.gradle.metal.ixx; + +import br.dev.pedrolamarao.gradle.metal.base.MetalBasePlugin; +import br.dev.pedrolamarao.gradle.metal.base.MetalExtension; +import br.dev.pedrolamarao.gradle.metal.cpp.MetalCppPlugin; +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.file.Directory; + +import static br.dev.pedrolamarao.gradle.metal.base.MetalBasePlugin.*; + +public class MetalIxxPlugin implements Plugin +{ + @Override + public void apply (Project project) + { + project.getPluginManager().apply(MetalBasePlugin.class); + project.getPluginManager().apply(MetalCppPlugin.class); + + final var metal = project.getExtensions().getByType(MetalExtension.class); + + final var ixx = project.getObjects().domainObjectContainer(MetalIxxSources.class, name -> createSources(project,name)); + metal.getExtensions().add("ixx", ixx); + } + + static MetalIxxSources createSources (Project project, String name) + { + final var configurations = project.getConfigurations(); + final var layout = project.getLayout(); + final var objects = project.getObjects(); + final var tasks = project.getTasks(); + + final var commandsDirectory = layout.getBuildDirectory().dir("db/%s/ixx".formatted(name)); + final var compileOptions = objects.listProperty(String.class); + final var importables = configurations.named(IMPORTABLE_DEPENDENCIES); + final var includables = configurations.named(INCLUDABLE_DEPENDENCIES); + final var sources = objects.sourceDirectorySet(name,name); + sources.srcDir(layout.getProjectDirectory().dir("src/%s/ixx".formatted(name))); + final var objectDirectory = layout.getBuildDirectory().dir("bmi/%s/ixx".formatted(name)); + + final var commandsTask = tasks.register("commands-%s-ixx".formatted(name), MetalIxxCommandsTask.class, task -> + { + task.getCompileOptions().set(compileOptions); + task.getIncludables().from(includables); + task.getImportables().from(importables); + task.getObjectDirectory().set(objectDirectory.map(Directory::getAsFile)); + task.getOutputDirectory().set(commandsDirectory); + task.setSource(sources); + }); + configurations.named(COMMANDS_ELEMENTS).configure(it -> it.getOutgoing().artifact(commandsTask)); + + final var compileTask = tasks.register("compile-%s-ixx".formatted(name), MetalIxxCompileTask.class, task -> + { + task.getCompileOptions().set(compileOptions); + task.getIncludables().from(includables); + task.getImportables().from(importables); + task.getOutputDirectory().set(objectDirectory); + task.setSource(sources); + }); + configurations.named(MetalBasePlugin.IMPORTABLE_ELEMENTS).configure(configuration -> { + configuration.getOutgoing().artifact(compileTask.map(MetalIxxCompileTask::getTargetDirectory), it -> it.builtBy(compileTask)); + }); + + return new MetalIxxSources(compileOptions, compileTask, name); + } +} diff --git a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/ixx/MetalIxxSources.java b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/ixx/MetalIxxSources.java index ec1d82e..56d785e 100644 --- a/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/ixx/MetalIxxSources.java +++ b/plugins/src/main/java/br/dev/pedrolamarao/gradle/metal/ixx/MetalIxxSources.java @@ -40,7 +40,7 @@ public String getName () public Provider getOutputDirectory () { - return compileTask.flatMap(MetalIxxCompileTask::getOutputTargetDirectory); + return compileTask.flatMap(MetalIxxCompileTask::getTargetDirectory); } public Provider getOutputs () @@ -48,6 +48,11 @@ public Provider getOutputs () return compileTask.map(MetalIxxCompileTask::getOutputs); } + public void includable (Object... sources) + { + compileTask.configure(it -> it.getIncludables().from(sources)); + } + public void importable (Object... sources) { compileTask.configure(it -> it.getImportables().from(sources)); diff --git a/samples/dependency-on-subproject-modules/archive/build.gradle.kts b/samples/dependency-on-subproject-modules/archive/build.gradle.kts index 76c644f..4746659 100644 --- a/samples/dependency-on-subproject-modules/archive/build.gradle.kts +++ b/samples/dependency-on-subproject-modules/archive/build.gradle.kts @@ -1,6 +1,7 @@ plugins { id("br.dev.pedrolamarao.metal.archive") id("br.dev.pedrolamarao.metal.cxx") + id("br.dev.pedrolamarao.metal.ixx") } metal { diff --git a/samples/dependency-on-subproject-modules/settings.gradle.kts b/samples/dependency-on-subproject-modules/settings.gradle.kts index e017119..76a52be 100644 --- a/samples/dependency-on-subproject-modules/settings.gradle.kts +++ b/samples/dependency-on-subproject-modules/settings.gradle.kts @@ -3,6 +3,7 @@ pluginManagement { id("br.dev.pedrolamarao.metal.application") version("1.0-SNAPSHOT") id("br.dev.pedrolamarao.metal.archive") version("1.0-SNAPSHOT") id("br.dev.pedrolamarao.metal.cxx") version("1.0-SNAPSHOT") + id("br.dev.pedrolamarao.metal.ixx") version("1.0-SNAPSHOT") } repositories { mavenLocal() @@ -10,5 +11,6 @@ pluginManagement { } rootProject.name = "sample" + include("application") include("archive") \ No newline at end of file diff --git a/samples/unconventional-project/README.adoc b/samples/unconventional-project/README.adoc index 11dce35..52d9880 100644 --- a/samples/unconventional-project/README.adoc +++ b/samples/unconventional-project/README.adoc @@ -1,11 +1,9 @@ = unconventional project This sample demonstrates a project with source directories in a style different from gradle-metal convention. -An archive is generated from C sources in `lib`. -An application is generated from C++ sources in `tool`, with an include dependency on CPP headers in `lib` and a link dependency on the archive. -Object files are expected in `obj`, archives and executables in `bin`. -The various tasks are registered explicitly. +There is a limit to how flexible we can be: we accept the user's source layout, but partially impose our build layout. +The users configures object output to `obj` and assembled outputs to `bin`, but the inner layout is ours. To build this sample inside a `gradle-metal` source tree, run: `../../gradlew --include-build=../.. build` -Look for the executable file in `application/build/exe`. \ No newline at end of file +Look for the executable file in `bin`. \ No newline at end of file diff --git a/samples/unconventional-project/build.gradle.kts b/samples/unconventional-project/build.gradle.kts index e36ab08..c3c4bce 100644 --- a/samples/unconventional-project/build.gradle.kts +++ b/samples/unconventional-project/build.gradle.kts @@ -22,13 +22,13 @@ val compileTool = tasks.register("compile-tool") { // register archive task for lib val archiveLib = tasks.register("archive-lib") { - output = layout.projectDirectory.file("bin/greet.lib") + outputDirectory = layout.projectDirectory.dir("bin") source( compileLib ) } // register link task for lib val linkTool = tasks.register("link-tool") { - output = layout.projectDirectory.file("bin/greet.exe") + outputDirectory = layout.projectDirectory.dir("bin") source( compileTool, archiveLib ) }