Skip to content

Commit f1b654c

Browse files
Merge pull request #15 from github-enactor/Mac-OS-ARM/x86-Support
Mac OS ARM and x86 platform support and code sign is added
2 parents 3c7a335 + 94b5fb1 commit f1b654c

2 files changed

Lines changed: 217 additions & 6 deletions

File tree

native/CMakeLists.txt

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,28 @@ if(OS_MAC)
283283
# Avoid CMP0042 policy errors.
284284
set(CMAKE_MACOSX_RPATH 1)
285285

286+
287+
if(NOT DEFINED PROJECT_ARCH)
288+
message(STATUS "PROJECT_ARCH not defined. Detecting machine architecture.")
289+
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
290+
set(PROJECT_ARCH arm64)
291+
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64")
292+
set(PROJECT_ARCH x86_64)
293+
else()
294+
message(FATAL_ERROR "Unsupported machine architecture: ${CMAKE_SYSTEM_PROCESSOR}. Please specify the target architecture using -DPROJECT_ARCH=<arch>")
295+
endif()
296+
endif()
297+
298+
message(STATUS "Building for architecture: ${PROJECT_ARCH}")
299+
300+
if(PROJECT_ARCH STREQUAL "x86_64")
301+
set(CMAKE_OSX_ARCHITECTURES x86_64)
302+
elseif(PROJECT_ARCH STREQUAL "arm64")
303+
set(CMAKE_OSX_ARCHITECTURES arm64)
304+
else()
305+
message(FATAL_ERROR "Unsupported architecture: ${PROJECT_ARCH}")
306+
endif()
307+
286308
# Avoid CMP0068 policy errors.
287309
if(POLICY CMP0068)
288310
cmake_policy(SET CMP0068 NEW)
@@ -370,7 +392,20 @@ if(OS_MAC)
370392
MACOSX_BUNDLE_INFO_PLIST ${_helper_info_plist}
371393
OUTPUT_NAME ${_helper_output_name}
372394
)
373-
395+
set_target_properties(${JCEF_TARGET} PROPERTIES
396+
# XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO"
397+
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ${ENACTOR_CODE_SIGN_IDENTITY}
398+
XCODE_ATTRIBUTE_DEVELOPMENT_TEAM ${ENACTOR_DEVELOPMENT_TEAM}
399+
# XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME "YES"
400+
# XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "--deep"
401+
)
402+
set_target_properties(${JCEF_HELPER_TARGET} PROPERTIES
403+
# XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO"
404+
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ${ENACTOR_CODE_SIGN_IDENTITY}
405+
XCODE_ATTRIBUTE_DEVELOPMENT_TEAM ${ENACTOR_DEVELOPMENT_TEAM}
406+
# XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME "YES"
407+
# XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "--deep"
408+
)
374409
if(USE_SANDBOX)
375410
target_link_libraries(${_helper_target} cef_sandbox_lib)
376411
endif()

pom.xml

Lines changed: 181 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -722,12 +722,12 @@
722722
</plugins>
723723
</build>
724724
</profile>
725-
726725
<profile>
727-
<id>generate-mac</id>
726+
<id>generate-mac-amd64</id>
728727
<activation>
729728
<os>
730729
<family>mac</family>
730+
<arch>x86_64</arch>
731731
</os>
732732
</activation>
733733
<properties>
@@ -753,11 +753,14 @@
753753
<environmentVariables>
754754
</environmentVariables>
755755
<options>
756+
<option>-DPROJECT_ARCH=x86_64</option>
756757
<option>-DCMAKE_BUILD_TYPE=Release</option>
757758
<option>-DJCEF_VERSION=${project.version}</option>
758759
<option>-DJCEF_COMMIT_NUMBER=${git.total.commit.count}</option>
759760
<option>-DJCEF_COMMIT_HASH=${git.commit.id}</option>
760-
</options>
761+
<option>-DENACTOR_CODE_SIGN_IDENTITY=${enactor.code.sign.identity}</option>
762+
<option>-DENACTOR_DEVELOPMENT_TEAM=${enactor.development.team}</option>
763+
</options>
761764
</configuration>
762765
</execution>
763766
<execution>
@@ -839,7 +842,7 @@
839842
</execution>
840843
</executions>
841844
<configuration>
842-
<finalName>chromium-binaries-mac</finalName>
845+
<finalName>chromium-binaries-${distribution.arch}</finalName>
843846
<descriptors>
844847
<descriptor>assemble-mac-os.xml</descriptor>
845848
</descriptors>
@@ -876,7 +879,7 @@
876879
<goal>deploy-file</goal>
877880
</goals>
878881
<configuration>
879-
<file>${basedir}/target/chromium-binaries-mac.zip</file>
882+
<file>${basedir}/target/chromium-binaries-${distribution.arch}.zip</file>
880883
<repositoryId>${repository.id}</repositoryId>
881884
<url>${repository.url}</url>
882885
<groupId>com.enactor.chromium</groupId>
@@ -890,6 +893,179 @@
890893
</plugins>
891894
</build>
892895
</profile>
896+
<profile>
897+
<id>generate-mac-arm64</id>
898+
<activation>
899+
<os>
900+
<family>mac</family>
901+
<arch>arm64</arch>
902+
</os>
903+
</activation>
904+
<properties>
905+
<distribution.folder>macosx64</distribution.folder>
906+
<distribution.arch>macos-arm64</distribution.arch>
907+
</properties>
908+
<build>
909+
<plugins>
910+
<plugin>
911+
<groupId>com.googlecode.cmake-maven-project</groupId>
912+
<artifactId>cmake-maven-plugin</artifactId>
913+
<executions>
914+
<execution>
915+
<id>cmake-generate-mac</id>
916+
<goals>
917+
<goal>generate</goal>
918+
</goals>
919+
<configuration>
920+
<sourcePath>${basedir}</sourcePath>
921+
<targetPath>${basedir}/jcef_build</targetPath>
922+
<generator>Xcode</generator>
923+
<classifier>mac-x86_64</classifier>
924+
<environmentVariables>
925+
</environmentVariables>
926+
<options>
927+
<option>-DPROJECT_ARCH=arm64</option>
928+
<option>-DCMAKE_BUILD_TYPE=Release</option>
929+
<option>-DJCEF_VERSION=${project.version}</option>
930+
<option>-DJCEF_COMMIT_NUMBER=${git.total.commit.count}</option>
931+
<option>-DJCEF_COMMIT_HASH=${git.commit.id}</option>
932+
<option>-DENACTOR_CODE_SIGN_IDENTITY=${enactor.code.sign.identity}</option>
933+
<option>-DENACTOR_DEVELOPMENT_TEAM=${enactor.development.team}</option>
934+
</options>
935+
</configuration>
936+
</execution>
937+
<execution>
938+
<id>cmake-compile-mac</id>
939+
<goals>
940+
<goal>compile</goal>
941+
</goals>
942+
<configuration>
943+
<config>Release</config>
944+
<projectDirectory>${basedir}/jcef_build</projectDirectory>
945+
<classifier>mac-x86_64</classifier>
946+
<environmentVariables>
947+
</environmentVariables>
948+
</configuration>
949+
</execution>
950+
</executions>
951+
</plugin>
952+
<plugin>
953+
<artifactId>maven-antrun-plugin</artifactId>
954+
<executions>
955+
<execution>
956+
<id>package</id>
957+
<phase>package</phase>
958+
<goals>
959+
<goal>run</goal>
960+
</goals>
961+
<configuration>
962+
<tasks>
963+
<exec dir="${basedir}/tools" executable="/bin/bash">
964+
<arg value="make_distrib.sh" />
965+
<arg value="macosx64" />
966+
</exec>
967+
</tasks>
968+
</configuration>
969+
</execution>
970+
</executions>
971+
</plugin>
972+
<plugin>
973+
<artifactId>maven-install-plugin</artifactId>
974+
<executions>
975+
<execution>
976+
<id>deploy-jcef</id>
977+
<phase>install</phase>
978+
<goals>
979+
<goal>install-file</goal>
980+
</goals>
981+
<configuration>
982+
<file>${basedir}/jcef_build/native/Release/jcef.jar/</file>
983+
<groupId>com.enactor.core</groupId>
984+
<artifactId>jcef</artifactId>
985+
<version>${project.version}</version>
986+
<packaging>jar</packaging>
987+
</configuration>
988+
</execution>
989+
<execution>
990+
<id>deploy-jcef-test</id>
991+
<phase>install</phase>
992+
<goals>
993+
<goal>install-file</goal>
994+
</goals>
995+
<configuration>
996+
<file>${basedir}/jcef_build/native/Release/jcef-tests.jar/</file>
997+
<groupId>com.enactor.core</groupId>
998+
<artifactId>jcef-tests</artifactId>
999+
<version>${project.version}</version>
1000+
<packaging>jar</packaging>
1001+
</configuration>
1002+
</execution>
1003+
</executions>
1004+
</plugin>
1005+
<plugin>
1006+
<artifactId>maven-assembly-plugin</artifactId>
1007+
<executions>
1008+
<execution>
1009+
<phase>package</phase>
1010+
<goals>
1011+
<goal>single</goal>
1012+
</goals>
1013+
</execution>
1014+
</executions>
1015+
<configuration>
1016+
<finalName>chromium-binaries-${distribution.arch}</finalName>
1017+
<descriptors>
1018+
<descriptor>assemble-mac-os.xml</descriptor>
1019+
</descriptors>
1020+
<appendAssemblyId>false</appendAssemblyId>
1021+
</configuration>
1022+
</plugin>
1023+
<plugin>
1024+
<groupId>org.apache.maven.plugins</groupId>
1025+
<artifactId>maven-deploy-plugin</artifactId>
1026+
<configuration>
1027+
<skip>${skip.deploy}</skip>
1028+
</configuration>
1029+
<executions>
1030+
<execution>
1031+
<id>deploy-jcef</id>
1032+
<phase>deploy</phase>
1033+
<goals>
1034+
<goal>deploy-file</goal>
1035+
</goals>
1036+
<configuration>
1037+
<file>${basedir}/jcef_build/native/Release/jcef.jar</file>
1038+
<repositoryId>${repository.id}</repositoryId>
1039+
<url>${repository.url}</url>
1040+
<groupId>com.enactor.core</groupId>
1041+
<artifactId>jcef</artifactId>
1042+
<version>${project.version}</version>
1043+
<packaging>jar</packaging>
1044+
</configuration>
1045+
</execution>
1046+
<execution>
1047+
<id>deploy-native-binaries</id>
1048+
<phase>deploy</phase>
1049+
<goals>
1050+
<goal>deploy-file</goal>
1051+
</goals>
1052+
<configuration>
1053+
<file>${basedir}/target/chromium-binaries-${distribution.arch}.zip</file>
1054+
<repositoryId>${repository.id}</repositoryId>
1055+
<url>${repository.url}</url>
1056+
<groupId>com.enactor.chromium</groupId>
1057+
<artifactId>mac-binaries</artifactId>
1058+
<version>${project.version}</version>
1059+
<packaging>zip</packaging>
1060+
</configuration>
1061+
</execution>
1062+
</executions>
1063+
</plugin>
1064+
</plugins>
1065+
</build>
1066+
</profile>
1067+
1068+
8931069
</profiles>
8941070
<dependencies>
8951071
<dependency>

0 commit comments

Comments
 (0)