xmake.lua 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. package("tao_idl")
  2. set_kind("binary")
  3. set_homepage("https://www.dre.vanderbilt.edu/~schmidt/TAO.html")
  4. set_description("tao_idl is TAO's Interface Description Language (IDL) compiler, based on Sun Microsystems' OMG IDL Compiler Front End (CFE) version 1.3, implements most IDL v3 & some IDL v4 features.")
  5. set_license("DOC")
  6. add_urls("https://github.com/DOCGroup/ACE_TAO/releases/download/$(version).tar.gz", {version = function (version)
  7. return "ACE%2BTAO-" .. version:gsub("%.", "_") .. "/ACE%2BTAO-" .. version
  8. end})
  9. add_versions("8.0.3", "b9130369be615f75042504d1e22ae6bcba20f0068de31787182f46381ec85340")
  10. add_deps("ace", {configs = {shared = true}})
  11. on_load(function (package)
  12. package:addenv("PATH", "bin")
  13. end)
  14. on_install("linux", "macosx", "iphoneos", function(package)
  15. import("package.tools.make")
  16. local envs = make.buildenvs(package)
  17. if package:is_plat("linux") then
  18. io.writefile("ace/config.h", [[#include "ace/config-linux.h"]])
  19. io.writefile("include/makeinclude/platform_macros.GNU", [[include $(ACE_ROOT)/include/makeinclude/platform_linux_common.GNU]])
  20. elseif package:is_plat("macosx") then
  21. io.writefile("ace/config.h", [[#include "ace/config-macosx.h"]])
  22. io.writefile("include/makeinclude/platform_macros.GNU", [[include $(ACE_ROOT)/include/makeinclude/platform_macosx.GNU]])
  23. elseif package:is_plat("iphoneos") then
  24. io.writefile("ace/config.h", [[#include "ace/config-macosx-iOS.h"]])
  25. io.writefile("include/makeinclude/platform_macros.GNU", [[include $(ACE_ROOT)/include/makeinclude/platform_macosx_iOS.GNU]])
  26. envs.IPHONE_TARGET = "HARDWARE"
  27. io.replace("include/makeinclude/platform_macosx_iOS.GNU", "CCFLAGS += -DACE_HAS_IOS", "CCFLAGS += -DACE_HAS_IOS -std=c++17", {plain = true})
  28. end
  29. envs.LIBCHECK = "1"
  30. envs.ACE_ROOT = os.curdir()
  31. envs.TAO_ROOT = path.join(os.curdir(), "TAO")
  32. envs.INSTALL_PREFIX = package:installdir()
  33. local ace_libdir
  34. local lib_paths = {}
  35. local packagedep = package:dep("ace")
  36. if packagedep then
  37. local fetchinfo = packagedep:fetch()
  38. if fetchinfo then
  39. for _, linkdir in ipairs(fetchinfo.linkdirs) do
  40. table.insert(lib_paths, linkdir)
  41. end
  42. end
  43. end
  44. ace_libdir = table.concat(lib_paths, " -L")
  45. ace_libdir = "-L" .. ace_libdir
  46. os.cd("apps/gperf/src")
  47. io.replace("GNUmakefile.gperf", [[-L../../../lib]], ace_libdir, {plain = true})
  48. make.build(package, {"all"}, {envs = envs})
  49. make.make(package, {"install"}, {envs = envs})
  50. os.cd("../../../TAO/TAO_IDL")
  51. io.replace("GNUmakefile.TAO_IDL_ACE",
  52. [[depend: ACE-depend gperf-depend TAO_IDL_FE-depend TAO_IDL_BE-depend TAO_IDL_BE_VIS_A-depend TAO_IDL_BE_VIS_C-depend TAO_IDL_BE_VIS_E-depend TAO_IDL_BE_VIS_I-depend TAO_IDL_BE_VIS_O-depend TAO_IDL_BE_VIS_S-depend TAO_IDL_BE_VIS_U-depend TAO_IDL_BE_VIS_V-depend TAO_IDL_EXE-depend]],
  53. [[depend: gperf-depend TAO_IDL_FE-depend TAO_IDL_BE-depend TAO_IDL_BE_VIS_A-depend TAO_IDL_BE_VIS_C-depend TAO_IDL_BE_VIS_E-depend TAO_IDL_BE_VIS_I-depend TAO_IDL_BE_VIS_O-depend TAO_IDL_BE_VIS_S-depend TAO_IDL_BE_VIS_U-depend TAO_IDL_BE_VIS_V-depend TAO_IDL_EXE-depend]],
  54. {plain = true})
  55. io.replace("GNUmakefile.TAO_IDL_ACE",
  56. [[all: ACE gperf TAO_IDL_FE TAO_IDL_BE TAO_IDL_BE_VIS_A TAO_IDL_BE_VIS_C TAO_IDL_BE_VIS_E TAO_IDL_BE_VIS_I TAO_IDL_BE_VIS_O TAO_IDL_BE_VIS_S TAO_IDL_BE_VIS_U TAO_IDL_BE_VIS_V TAO_IDL_EXE]],
  57. [[all: gperf TAO_IDL_FE TAO_IDL_BE TAO_IDL_BE_VIS_A TAO_IDL_BE_VIS_C TAO_IDL_BE_VIS_E TAO_IDL_BE_VIS_I TAO_IDL_BE_VIS_O TAO_IDL_BE_VIS_S TAO_IDL_BE_VIS_U TAO_IDL_BE_VIS_V TAO_IDL_EXE]],
  58. {plain = true})
  59. io.replace("GNUmakefile.TAO_IDL_ACE", [[$(KEEP_GOING)@cd ../../ace && $(MAKE) -f GNUmakefile.ACE $(@)]], [[]], {plain = true})
  60. for _, GNUmakefile in ipairs(os.files("GNUmakefile.*")) do
  61. io.replace(GNUmakefile, [[-L../../lib]], ace_libdir, {plain = true})
  62. end
  63. make.build(package, {"all"}, {envs = envs})
  64. make.make(package, {"install"}, {envs = envs})
  65. os.tryrm(path.join(package:installdir(), "share"))
  66. end)
  67. on_install("windows", function(package)
  68. import("package.tools.msbuild")
  69. local include_paths = {"..", "include", "be_include", "fe"}
  70. local lib_paths = {"../../lib"}
  71. -- Fetch *ace* dependency
  72. local packagedep = package:dep("ace")
  73. if packagedep then
  74. local fetchinfo = packagedep:fetch()
  75. if fetchinfo then
  76. for _, includedir in ipairs(fetchinfo.includedirs or fetchinfo.sysincludedirs) do
  77. table.insert(include_paths, includedir)
  78. end
  79. for _, linkdir in ipairs(fetchinfo.linkdirs) do
  80. table.insert(lib_paths, linkdir)
  81. end
  82. end
  83. end
  84. os.cd("TAO/TAO_IDL")
  85. -- Prepare .vcxproj using config & de-bundle ace dependency
  86. for _, vcxproj in ipairs({
  87. "../../apps/gperf/src/gperf_vs2022.vcxproj",
  88. "TAO_IDL_FE_vs2022.vcxproj",
  89. "TAO_IDL_BE_vs2022.vcxproj",
  90. "TAO_IDL_BE_VIS_A_vs2022.vcxproj",
  91. "TAO_IDL_BE_VIS_C_vs2022.vcxproj",
  92. "TAO_IDL_BE_VIS_E_vs2022.vcxproj",
  93. "TAO_IDL_BE_VIS_I_vs2022.vcxproj",
  94. "TAO_IDL_BE_VIS_O_vs2022.vcxproj",
  95. "TAO_IDL_BE_VIS_S_vs2022.vcxproj",
  96. "TAO_IDL_BE_VIS_U_vs2022.vcxproj",
  97. "TAO_IDL_BE_VIS_V_vs2022.vcxproj",
  98. "TAO_IDL_EXE_vs2022.vcxproj"
  99. }) do
  100. io.replace(vcxproj,
  101. "<AdditionalIncludeDirectories>.-</AdditionalIncludeDirectories>",
  102. "<AdditionalIncludeDirectories>" .. table.concat(include_paths, ";") .. "</AdditionalIncludeDirectories>", {plain = false})
  103. io.replace(vcxproj,
  104. "<AdditionalLibraryDirectories>.-</AdditionalLibraryDirectories>",
  105. "<AdditionalLibraryDirectories>" .. table.concat(lib_paths, ";") .. "</AdditionalLibraryDirectories>", {plain = false})
  106. if package:has_runtime("MT", "MTd") then
  107. -- Allow MT, MTd
  108. io.replace(vcxproj, "<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>", "<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>", {plain = true})
  109. io.replace(vcxproj, "<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>", "<RuntimeLibrary>MultiThreaded</RuntimeLibrary>", {plain = true})
  110. end
  111. -- Allow use another Win SDK
  112. io.replace(vcxproj, "<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>", "", {plain = true})
  113. -- Disable LTCG
  114. io.replace(vcxproj, "<WholeProgramOptimization>true</WholeProgramOptimization>", "", {plain = true})
  115. end
  116. -- Build & install .exe
  117. for _, target in ipairs({"../../apps/gperf/src/gperf_vs2022.vcxproj", "TAO_IDL_vs2022.sln"}) do
  118. local configs = { target }
  119. if target:match("TAO_IDL_vs2022.sln") then
  120. table.insert(configs, "/t:TAO_IDL_FE;TAO_IDL_BE;TAO_IDL_BE_VIS_A;TAO_IDL_BE_VIS_C;TAO_IDL_BE_VIS_E;TAO_IDL_BE_VIS_I;TAO_IDL_BE_VIS_O;TAO_IDL_BE_VIS_S;TAO_IDL_BE_VIS_U;TAO_IDL_BE_VIS_V;TAO_IDL_EXE")
  121. end
  122. local arch = package:is_arch("x64") and "x64" or "Win32"
  123. if package:is_arch("arm64") then
  124. arch = "ARM64"
  125. end
  126. local mode = package:is_debug() and "Debug" or "Release"
  127. table.insert(configs, "/p:Configuration=" .. mode)
  128. table.insert(configs, "/p:Platform=" .. arch)
  129. -- Wrap vstool so it would build for another vstools
  130. local msvc = import("core.tool.toolchain").load("msvc")
  131. local vs = msvc:config("vs")
  132. local vstool
  133. if vs == "2015" then vstool = "v140"
  134. elseif vs == "2017" then vstool = "v141"
  135. elseif vs == "2019" then vstool = "v142"
  136. elseif vs == "2022" then vstool = "v143"
  137. end
  138. table.insert(configs, "/p:PlatformToolset=" .. vstool)
  139. msbuild.build(package, configs)
  140. end
  141. os.cd("../..")
  142. os.cp("**.exe", package:installdir("bin"))
  143. os.cp("**.lib", package:installdir("lib"))
  144. os.trycp("**.dll", package:installdir("bin"))
  145. os.rm(path.join(package:installdir(), "bin", "PXI_Reset.exe"))
  146. os.rm(path.join(package:installdir(), "bin", "Reboot_Target.exe"))
  147. end)
  148. on_test(function (package)
  149. os.vrun("tao_idl -h")
  150. end)