<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
		 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<parent>
		<groupId>org.cryptomator</groupId>
		<artifactId>jfuse</artifactId>
		<version>0.1.0-beta1</version>
	</parent>
	<modelVersion>4.0.0</modelVersion>
	<artifactId>jfuse-win-amd64</artifactId>
	<name>jFUSE Windows x86_64</name>
	<description>Java FUSE bindings for Windows x86_64</description>
	<url>https://github.com/cryptomator/jfuse/tree/develop/jfuse-win-amd64</url>

	<properties>
		<maven.deploy.skip>false</maven.deploy.skip>
		<win.ucrtHeaderPath>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt</win.ucrtHeaderPath>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.cryptomator</groupId>
			<artifactId>jfuse-api</artifactId>
			<version>${project.version}</version>
		</dependency>
	</dependencies>

	<profiles>
		<profile>
			<id>jextract</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-enforcer-plugin</artifactId>
						<executions>
							<execution>
								<id>check-preconditions</id>
								<goals>
									<goal>enforce</goal>
								</goals>
								<configuration>
									<rules>
										<requireOS>
											<family>windows</family>
											<message>This build configuration requires Windows.</message>
										</requireOS>
										<requireFilesExist>
											<files>
												<file>${win.ucrtHeaderPath}</file>
											</files>
											<message>Windows UCRT headers not found.</message>
										</requireFilesExist>
									</rules>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<artifactId>maven-clean-plugin</artifactId>
						<configuration>
							<filesets>
								<fileset>
									<directory>${project.build.sourceDirectory}/org/cryptomator/jfuse/win/amd64/extr</directory>
									<includes>
										<include>*.java</include>
									</includes>
									<followSymlinks>false</followSymlinks>
								</fileset>
							</filesets>
						</configuration>
					</plugin>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>jextract-fuse</id>
								<goals>
									<goal>exec</goal>
								</goals>
								<phase>generate-sources</phase>
								<configuration>
									<executable>${java.home}/bin/jextract</executable>
									<workingDirectory>${project.basedir}</workingDirectory>
									<arguments>
										<argument>--source</argument>
										<argument>-l</argument>
										<argument>fuse</argument>
										<argument>-d</argument>
										<argument>${project.build.sourceDirectory}</argument>
										<argument>-t</argument>
										<argument>org.cryptomator.jfuse.win.amd64.extr</argument>
										<argument>-I</argument>
										<argument>${win.ucrtHeaderPath}</argument>
										<!-- structs: -->
										<argument>--include-struct</argument>
										<argument>fuse_operations</argument>
										<argument>--include-struct</argument>
										<argument>fuse_file_info</argument>
										<argument>--include-struct</argument>
										<argument>fuse_context</argument>
										<argument>--include-struct</argument>
										<argument>fuse_conn_info</argument>
										<!-- typedefs: -->
										<argument>--include-typedef</argument>
										<argument>fuse_fill_dir_t</argument>
										<!-- functions: -->
										<argument>--include-function</argument>
										<argument>fuse_main_real</argument>
										<argument>--include-function</argument>
										<argument>fuse_get_context</argument>
										<argument>--include-function</argument>
										<argument>fuse_exit</argument>
										<!-- extract fuse.h header: -->
										<argument>${project.parent.basedir}/winfsp/inc/fuse/fuse.h</argument>
									</arguments>
								</configuration>
							</execution>
							<execution>
								<id>jextract-winfsp-fuse</id>
								<goals>
									<goal>exec</goal>
								</goals>
								<phase>generate-sources</phase>
								<configuration>
									<executable>${java.home}/bin/jextract</executable>
									<workingDirectory>${project.basedir}</workingDirectory>
									<arguments>
										<argument>--source</argument>
										<argument>-l</argument>
										<argument>fuse</argument>
										<argument>-d</argument>
										<argument>${project.build.sourceDirectory}</argument>
										<argument>-t</argument>
										<argument>org.cryptomator.jfuse.win.amd64.extr</argument>
										<argument>-I</argument>
										<argument>${win.ucrtHeaderPath}</argument>
										<!-- structs -->
										<argument>--include-struct</argument>
										<argument>fuse_stat</argument>
										<argument>--include-struct</argument>
										<argument>fuse_statvfs</argument>
										<argument>--include-struct</argument>
										<argument>fuse_timespec</argument>
										<!-- extract winfsp_fuse.h header: -->
										<argument>${project.parent.basedir}/winfsp/inc/fuse/winfsp_fuse.h</argument>
									</arguments>
								</configuration>
							</execution>
							<execution>
								<id>jextract-errno</id>
								<goals>
									<goal>exec</goal>
								</goals>
								<phase>generate-sources</phase>
								<configuration>
									<executable>${java.home}/bin/jextract</executable>
									<workingDirectory>${project.basedir}</workingDirectory>
									<arguments>
										<argument>--source</argument>
										<argument>-d</argument>
										<argument>${project.build.sourceDirectory}</argument>
										<argument>-t</argument>
										<argument>org.cryptomator.jfuse.win.amd64.extr</argument>
										<argument>-I</argument>
										<argument>${win.ucrtHeaderPath}</argument>
										<!-- constants -->
										<argument>--include-macro</argument>
										<argument>ENOENT</argument>
										<argument>--include-macro</argument>
										<argument>ENOSYS</argument>
										<argument>--include-macro</argument>
										<argument>ENOMEM</argument>
										<argument>--include-macro</argument>
										<argument>EACCES</argument>
										<argument>--include-macro</argument>
										<argument>EIO</argument>
										<argument>--include-macro</argument>
										<argument>EROFS</argument>
										<argument>--include-macro</argument>
										<argument>EBADF</argument>
										<argument>--include-macro</argument>
										<argument>EEXIST</argument>
										<argument>--include-macro</argument>
										<argument>ENOTDIR</argument>
										<argument>--include-macro</argument>
										<argument>EISDIR</argument>
										<argument>--include-macro</argument>
										<argument>ENOTEMPTY</argument>
										<argument>--include-macro</argument>
										<argument>EINVAL</argument>
										<!-- extract errno.h header: -->
										<argument>${win.ucrtHeaderPath}\errno.h</argument>
									</arguments>
								</configuration>
							</execution>
							<execution>
								<id>jextract-fcntl</id>
								<goals>
									<goal>exec</goal>
								</goals>
								<phase>generate-sources</phase>
								<configuration>
									<executable>${java.home}/bin/jextract</executable>
									<workingDirectory>${project.basedir}</workingDirectory>
									<arguments>
										<argument>--source</argument>
										<argument>-d</argument>
										<argument>${project.build.sourceDirectory}</argument>
										<argument>-t</argument>
										<argument>org.cryptomator.jfuse.win.amd64.extr</argument>
										<argument>-I</argument>
										<argument>${win.ucrtHeaderPath}</argument>
										<!-- open flags -->
										<argument>--include-macro</argument>
										<argument>O_RDONLY</argument>
										<argument>--include-macro</argument>
										<argument>O_WRONLY</argument>
										<argument>--include-macro</argument>
										<argument>O_RDWR</argument>
										<argument>--include-macro</argument>
										<argument>O_APPEND</argument>
										<argument>--include-macro</argument>
										<argument>O_CREAT</argument>
										<argument>--include-macro</argument>
										<argument>O_TRUNC</argument>
										<argument>--include-macro</argument>
										<argument>O_EXCL</argument>
										<!-- extract fcntl.h header: -->
										<argument>${win.ucrtHeaderPath}\fcntl.h</argument>
									</arguments>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

</project>