Files
robovm/compiler/vm/MergeStaticLibObjectFiles.cmake
Justin Shapcott 3d1e6eccf9 Initial commit. Here's what I did:
- Figured out which OSS RoboVM repositories are needed for libGDX
- Put them into a single repository, much easier to maintain, but
  history got destroyed in the process. Can look up history in
  original repository if necessary
- Set the groupId of all artifacts to my domain com.mobidevelop
  so I can publish to Maven Central
- Set the version to 2.0.0-SNAPSHOT so there's zero chance of
  a collision with the original RoboVM releases
- Couldn't get native bits to compile, so updated minimum iOS
  and Mac OS X versions for toolchain in vm/CMakeFileList.txt
  and OS.java until it worked.
- Apps wouldn't link due to some missing c++ symbols. Removed linking
  to libstdc++ in IOSTarget.java. Not sure if that has any detrimental
  effects but it fixed linking.
- When opening a run configuration via the IDEA plugin, it would
  crash in DeviceType.java:113. It seems that the output of some
  command line tool is being parsed, and that returns error
  messages together with the data we need. Fixed via ugly
  hack.
- Updated to the latest commit of https://github.com/robovm/bwdgc.git
  Probably fixed some GC crashes since the release in October.
- Pulled in the IDE plugins for Eclipse and IDEA, the Gradle plugin
  and the templates project. We don't need the Maven plugin and junit
  stuff for libGDX. Everything's in the plugin/ directory
- Templates: removed the templates that i couldn't get to work, namely
  the ones relying on storyboards. Seems like the OSS RoboVM couldn't
  deal with those at all.
- IDEA plugin: removed the bridge to the interface builder functionality
  otherwise the plugin would crash since we miss the artifacts for that
- IDEA plugin: removed the whole setup stuff for Android and license
  checks. The former didn't work for me at all, and the latter would crash
  because it's missing the actual code.
- IDEA plugin: removed the templates in RoboVMTemplateFactory that aren't
  working.
- IDEA plugin: The RoboVmCompileTask doesn't seem to work with that as it can't find
  the robovm.xml file needed for compilation. Fixed in RoboVmPlugin.java
  with a very ugly hack.
- IDEA plugin: there was a huge memory leak in the compiler code of the
  plugin. It retained the AppCompiler instance, which was huge. Fixed
  by nulling that out at the appropriate time
- IDEA plugin: fixed template_build.gradle to use the new groupId
- Gradle plugin: it seems the Gradle plugin was kept up-to-date with
  the latest closed source RoboVM. Had to remove a bunch of stuff, like
  TvOS functionality, as we don't have to sources for that.
- Eclipse plugin: just fixed up the poms, don't know if it works.
2016-04-20 13:15:45 -07:00

77 lines
3.3 KiB
CMake
Executable File

# Copyright (C) 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.
# Merges the object files in a sttaic lib into a single object file and
# overwrites the static lib with a new static lib only containing this single
# object file. Will not do anything if CMAKE_BUILD_TYPE is 'debug' as it
# destroys the debug info. Only the specified symbols will be externally
# visible in the resulting static lib.
# Usage: merge_static_lib_object_files(lib sym1 sym2 ... symn)
function(merge_static_lib_object_files lib)
if (NOT CMAKE_BUILD_TYPE STREQUAL "debug")
set(exported_symbols ${ARGV})
list(REMOVE_AT exported_symbols 0)
if (APPLE)
foreach(sym ${exported_symbols})
list(APPEND exported_symbols_args "-exported_symbol")
list(APPEND exported_symbols_args "_${sym}")
endforeach()
string(REPLACE ";" ", " exported_symbols_joined "${exported_symbols}")
string(REPLACE ";" " " exported_symbols_args_joined "${exported_symbols_args}")
add_custom_command(TARGET ${lib}
COMMAND echo Merging object files in $<TARGET_FILE:${lib}> with exported symbols: ${exported_symbols_joined}
COMMAND echo ld -arch ${CARCH} -r ${exported_symbols_args_joined} -all_load $<TARGET_FILE:${lib}> -o ${CMAKE_CURRENT_BINARY_DIR}/merged.o
COMMAND ld -arch ${CARCH} -r ${exported_symbols_args} -all_load $<TARGET_FILE:${lib}> -o ${CMAKE_CURRENT_BINARY_DIR}/merged.o
COMMAND rm -f $<TARGET_FILE:${lib}>
COMMAND ar rcs $<TARGET_FILE:${lib}> ${CMAKE_CURRENT_BINARY_DIR}/merged.o
)
else()
# Linux
set(EMULATION_MODE elf_i386)
if(64_BIT)
set(EMULATION_MODE elf_x86_64)
endif()
message(STATUS "Format ${FORMAT}")
foreach(sym ${exported_symbols})
list(APPEND exported_symbols_args "-G")
list(APPEND exported_symbols_args "${sym}")
endforeach()
string(REPLACE ";" ", " exported_symbols_joined "${exported_symbols}")
string(REPLACE ";" " " exported_symbols_args_joined "${exported_symbols_args}")
add_custom_command(TARGET ${lib}
COMMAND echo Merging object files in $<TARGET_FILE:${lib}> with exported symbols: ${exported_symbols_joined}
COMMAND echo ld -m ${EMULATION_MODE} -r --whole-archive $<TARGET_FILE:${lib}> -o ${CMAKE_CURRENT_BINARY_DIR}/tmp.o
COMMAND ld -m ${EMULATION_MODE} -r --whole-archive $<TARGET_FILE:${lib}> -o ${CMAKE_CURRENT_BINARY_DIR}/tmp.o
COMMAND echo objcopy -w ${exported_symbols_args} ${CMAKE_CURRENT_BINARY_DIR}/tmp.o ${CMAKE_CURRENT_BINARY_DIR}/merged.o
COMMAND objcopy -w ${exported_symbols_args} ${CMAKE_CURRENT_BINARY_DIR}/tmp.o ${CMAKE_CURRENT_BINARY_DIR}/merged.o
COMMAND rm -f $<TARGET_FILE:${lib}>
COMMAND ar rcs $<TARGET_FILE:${lib}> ${CMAKE_CURRENT_BINARY_DIR}/merged.o
)
endif()
endif()
endfunction()