Permalink
Browse files

feat(extract): add template extraction tool

Uses the Clang bindings to parse native headers and extract generator
templates.
  • Loading branch information...
Spasi committed Nov 25, 2018
1 parent d07c441 commit af03dd99910061977cc4bccc82a0ed68ed7f2f4d

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="kotlin-language" name="Kotlin">
<configuration version="3" platform="JVM 1.8" useProjectSettings="false">
<compilerSettings>
<option name="additionalArguments" value="-version -progressive -Xuse-experimental=kotlin.Experimental -Xuse-experimental=kotlin.contracts.ExperimentalContracts" />
</compilerSettings>
<compilerArguments>
<option name="jvmTarget" value="1.8" />
</compilerArguments>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/../../bin/classes/extract" />
<output-test url="file://$MODULE_DIR$/../../bin/classes/extract" />
<exclude-output />
<content url="file://$MODULE_DIR$/../../modules/extract">
<sourceFolder url="file://$MODULE_DIR$/../../modules/extract/src/main/kotlin" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="KotlinRuntime" level="project" />
<orderEntry type="module-library" scope="RUNTIME">
<library>
<CLASSES>
<root url="file://$MODULE_DIR$/../../modules/samples/src/test/resources" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module" module-name="core" />
<orderEntry type="module" module-name="llvm" />
</component>
</module>
@@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Template Extraction Tool" type="JetRunConfigurationType" factoryName="Kotlin">
<module name="extract" />
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="VM_PARAMETERS" value="-Djava.library.path=bin/libs -Dorg.lwjgl.llvm.clang.libname=D:/CLONES/llvm/build/Release/bin/libclang.dll -Dfile.encoding=UTF8" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="MAIN_CLASS_NAME" value="org.lwjgl.extract.MainKt" />
<option name="WORKING_DIRECTORY" value="" />
<method v="2">
<option name="Make" enabled="true" />
<option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/build.xml" target="touch-extract" />
</method>
</configuration>
</component>
@@ -421,6 +421,64 @@
<antcall target="compile-native-platform"/>
</target>

<target name="-compile-extract">
<local name="extract-uptodate"/>
<uptodate targetfile="${bin.extract}/touch.txt" property="extract-uptodate">
<srcfiles dir="${src.extract}/kotlin" includes="**"/>
</uptodate>

<echo message="Compiling LWJGL Template Extraction Tool..." level="info" taskname="extract compilation" unless:set="extract-uptodate"/>
<mkdir dir="${bin.extract}"/>
<kotlinc moduleName="extract" output="${bin.extract}" printVersion="true" unless:set="extract-uptodate">
<classpath>
<pathelement path="${bin.lwjgl}/core/META-INF/versions/9" if:set="core.java9"/>
<pathelement path="${bin.lwjgl}/core/META-INF/versions/10" if:set="core.java10"/>
<pathelement path="${module.classpath}"/>
<pathelement path="${kotlinc}/lib/kotlin-stdlib.jar"/>
<pathelement path="${kotlinc}/lib/kotlin-stdlib-jdk7.jar"/>
</classpath>

<compilerarg line="-jvm-target 1.8"/>
<compilerarg value="-Xno-call-assertions"/>
<compilerarg value="-Xno-param-assertions"/>
<compilerarg value="-Xreport-perf"/>
<compilerarg value="-progressive"/>
<compilerarg value="-Xuse-experimental=kotlin.Experimental"/>
<compilerarg value="-Xuse-experimental=kotlin.contracts.ExperimentalContracts"/>

<src path="${src.extract}/kotlin"/>
</kotlinc>
<touch file="${bin.extract}/touch.txt" unless:set="extract-uptodate"/>
</target>

<target name="touch-extract" description="Used for touching from an IDE">
<touch file="${bin.extract}/touch.txt"/>
</target>

<target name="extract" description="Runs the LWJGL Template Extraction tool" depends="compile-native, -compile-extract">
<fail message="Please specify the Clang shared library path with -Dclang=&lt;path&gt;">
<condition>
<not><isset property="clang"/></not>
</condition>
</fail>
<java classname="org.lwjgl.extract.MainKt" fork="true" spawn="true" taskname="LWJGL Template Extraction Tool">
<classpath>
<pathelement path="${bin.lwjgl}/core/META-INF/versions/9" if:set="core.java9"/>
<pathelement path="${bin.lwjgl}/core/META-INF/versions/10" if:set="core.java10"/>
<pathelement path="${module.classpath}"/>
<pathelement path="${bin.extract}"/>
<pathelement path="${test.resources}"/>
<pathelement path="${kotlinc}/lib/kotlin-stdlib.jar"/>
<pathelement path="${kotlinc}/lib/kotlin-stdlib-jdk7.jar"/>
</classpath>

<jvmarg value="-Djava.library.path=${lib}"/>
<jvmarg value="-Dorg.lwjgl.llvm.clang.libname=${clang}"/>
<jvmarg line="${jvmargs}" if:set="jvmargs"/>
<arg line="${args}" if:set="args"/>
</java>
</target>

<target name="compile-tests" description="Compiles the LWJGL test suite" depends="compile">
<mkdir dir="${bin.test}"/>
<forEachModule>
@@ -51,10 +51,12 @@ This script is included in /build.xml and /config/update-dependencies.xml.

<property name="module.lwjgl" location="modules/lwjgl" relative="true"/>

<property name="src.extract" location="modules/extract/src/main" relative="true"/>
<property name="src.generator" location="modules/generator/src/main" relative="true"/>

<property name="test.resources" location="modules/samples/src/test/resources" relative="true"/>

<property name="bin.extract" location="bin/classes/extract" relative="true"/>
<property name="bin.generator" location="bin/classes/generator" relative="true"/>
<property name="bin.javadoc" location="bin/javadoc" relative="true"/>
<property name="bin.lwjgl" location="bin/classes/lwjgl" relative="true"/>
@@ -45,6 +45,13 @@ The source code Generator and related tools.
Module dependencies: n/a
Compile dependencies: Kotlin runtime, JDK tools

### Extract
A tool that extracts generator templates from native headers.
* `modules/extract/src/main/kotlin`

Module dependencies: the core & llvm modules
Compile dependencies: Kotlin runtime

# INSTALLATION
Requirements:
* JDK 8 or newer
@@ -1,5 +1,9 @@
# LWJGL Project Modules

### extract

A tool that extracts generator templates from native headers. (experimental)

### generator

The source code Generator and related tools. Used only for building
Oops, something went wrong.

0 comments on commit af03dd9

Please sign in to comment.