Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/cocoatouch/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build/
/src/main/robopods/META-INF/robovm/ios/libs/RvmCocoaTouch.xcframework
37 changes: 37 additions & 0 deletions compiler/cocoatouch/build-natives.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

rm -rf build
rm -rf src/main/robopods/META-INF/robovm/ios/libs/RvmCocoaTouch.xcframework

# ios device
cmake -S src/main/native -B build/ios-arm64 \
-DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_OSX_SYSROOT=iphoneos \
-DCMAKE_OSX_DEPLOYMENT_TARGET=8.0
cmake --build build/ios-arm64 --config Release

# ios simulator
cmake -S src/main/native -B build/ios-sim \
-DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" \
-DCMAKE_OSX_SYSROOT=iphonesimulator \
-DCMAKE_OSX_DEPLOYMENT_TARGET=8.0
cmake --build build/ios-sim --config Release


# macos
cmake -S src/main/native -B build/macos \
-DCMAKE_SYSTEM_NAME=Darwin \
-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" \
-DCMAKE_OSX_SYSROOT=macosx \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.12
cmake --build build/macos --config Release


# pack to xcframework
xcodebuild -create-xcframework \
-library build/ios-arm64/librvmcocoatouch.a \
-library build/ios-sim/librvmcocoatouch.a \
-library build/macos/librvmcocoatouch.a \
-output src/main/robopods/META-INF/robovm/ios/libs/RvmCocoaTouch.xcframework
25 changes: 25 additions & 0 deletions compiler/cocoatouch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
</dependencies>

<build>
<!-- adds META-INF/robovm.xml where available -->
<resources>
<resource>
<directory>src/main/robopods</directory>
</resource>
</resources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -66,6 +73,24 @@
<detectJavaApiLink>false</detectJavaApiLink>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>build-binaries</id>
<phase>process-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<workingDirectory>${project.basedir}</workingDirectory>
<executable>${project.basedir}/build-natives.sh</executable>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>

Expand Down
70 changes: 70 additions & 0 deletions compiler/cocoatouch/src/main/bro-gen/oslog2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# OS log api from os/log.h
package: org.robovm.apple.oslog
include: [foundation]
header: /usr/include/os/log.h
path_match: ^.*/usr/include/os/log.*$
clang_args: ['-x', 'objective-c']

typedefs:
os_log_s: OSLog

enums:
os_log_type_t: { name: Type } # will me moved manually inside OSLog!

categories:

classes:

protocols:
OS_os_log:
name: OSLog
class: true
protocols: []
annotations: ['@NativeClass("NSObject")']
visibility: 'public final'
skip_adapter: true

functions:
os_log_create:
name: create
class: OSLog
parameters:
0:
marshaler: StringMarshalers.AsAsciiZMarshaler
type: String
1:
marshaler: StringMarshalers.AsAsciiZMarshaler
type: String
os_log_type_enabled:
name: isEnabled
class: OSLog
os_log_is_enabled:
exclude: true # deprecated !
os_log_is_debug_enabled:
exclude: true # deprecated !

# Make sure we don't miss any functions if new ones are introduced in a later version
(os_.*):
class: FIXME
name: 'Function__#{g[0]}'

values:
RVM_OS_LOG_DISABLED:
name: DISABLED
class: OSLog
readonly: true
RVM_OS_LOG_DEFAULT:
name: DEFAULT
class: OSLog
readonly: true

# Make sure we don't miss any values if new ones are introduced in a later version
(os_.*):
class: FIXME
name: 'Value__#{g[0]}'

constants:
# Make sure we don't miss any constants if new ones are introduced in a later version
(os_.*):
class: FIXME
name: 'Constant__#{g[0]}'
164 changes: 164 additions & 0 deletions compiler/cocoatouch/src/main/java/org/robovm/apple/oslog/OSLog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
/*
* Copyright (C) 2013-2015 RoboVM AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.robovm.apple.oslog;


/*<imports>*/

import java.io.*;
import java.nio.*;
import java.util.*;

import org.robovm.objc.*;
import org.robovm.objc.annotation.*;
import org.robovm.objc.block.*;
import org.robovm.rt.*;
import org.robovm.rt.annotation.*;
import org.robovm.rt.bro.*;
import org.robovm.rt.bro.annotation.*;
import org.robovm.rt.bro.ptr.*;
import org.robovm.apple.foundation.*;
/*</imports>*/

/*<javadoc>*/

/*</javadoc>*/
/*<annotations>*/
@Library(Library.INTERNAL)
@NativeClass("NSObject")/*</annotations>*/
/*<visibility>*/ public final/*</visibility>*/ class /*<name>*/OSLog/*</name>*/
extends /*<extends>*/NSObject/*</extends>*/
/*<implements>*//*</implements>*/ {

/*<ptr>*/public static class OSLogPtr extends Ptr<OSLog, OSLogPtr> {
}/*</ptr>*/

/*<bind>*/static {
ObjCRuntime.bind(OSLog.class);
}/*</bind>*/
/*<constants>*//*</constants>*/
/*<constructors>*/

/*</constructors>*/
/*<properties>*/

/*</properties>*/
/*<members>*//*</members>*/
/*<methods>*/

/**
* @since Available in iOS 10.0 and later.
*/
@Bridge(symbol = "os_log_create", optional = true)
public static native OSLog create(@org.robovm.rt.bro.annotation.Marshaler(StringMarshalers.AsAsciiZMarshaler.class) String subsystem, @org.robovm.rt.bro.annotation.Marshaler(StringMarshalers.AsAsciiZMarshaler.class) String category);

/**
* @since Available in iOS 10.0 and later.
*/
@Bridge(symbol = "os_log_type_enabled", optional = true)
public native boolean isEnabled(Type type);


/*</methods>*/

///
/// dkimitsa: manually added code bellow
///
@org.robovm.rt.bro.annotation.Marshaler(ValuedEnum.AsUnsignedByteMarshaler.class)
public enum Type implements ValuedEnum {
DEFAULT(0L),
INFO(1L),
DEBUG(2L),
ERROR(16L),
FAULT(17L);
private final long n;

Type(long n) {
this.n = n;
}

public long value() {
return n;
}

public static Type valueOf(long n) {
for (Type v : values()) {
if (v.n == n) {
return v;
}
}
throw new IllegalArgumentException("No constant with value " + n + " found in "
+ Type.class.getName());
}
}

///
/// Bindings for rvm_oslog.m
///

/// TODO: fixme, static XCFrameworks doesn't support "forced" parameter
/// and symbols are got dead-stripped, using ObjC wrapper to make
/// API available
@NativeClass
private final static class RvmOSLog extends NSObject {
static { ObjCRuntime.bind(RvmOSLog.class); }

@Method(selector = "DISABLED")
static native OSLog DISABLED();

@Method(selector = "DEFAULT")
static native OSLog DEFAULT();

@Method(selector = "logPublic:withType:message:")
static native void publicLog(OSLog log, Type type, @org.robovm.rt.bro.annotation.Marshaler(StringMarshalers.AsAsciiZMarshaler.class) String msg);

@Method(selector= "logPrivate:withType:message:")
static native void privateLog(OSLog log, Type type, @org.robovm.rt.bro.annotation.Marshaler(StringMarshalers.AsAsciiZMarshaler.class) String msg);
}


///
/// macro implementations
///
public static OSLog DISABLED() {
return RvmOSLog.DISABLED();
}

public static OSLog DEFAULT() {
return RvmOSLog.DEFAULT();
}

public void publicLog(Type type, String msg) {
RvmOSLog.publicLog(this, type, msg);
}

public void privateLog(OSLog log, Type type, String msg) {
RvmOSLog.privateLog(this, type, msg);
}

/**
* public log to default logger
*/
public static void log(String msg) {
RvmOSLog.publicLog(DEFAULT(), Type.DEFAULT, msg);
}

public static void log(boolean isPrivate, String msg) {
OSLog log = DEFAULT();
if (isPrivate) RvmOSLog.privateLog(log, Type.DEFAULT, msg);
else RvmOSLog.publicLog(log, Type.DEFAULT, msg);
}
}
Loading
Loading