Platform.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Copyright (c) ChakraCore Project Contributors. All rights reserved.
  4. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  5. //-------------------------------------------------------------------------------------------------------
  6. var isWindows = !WScript.Platform || WScript.Platform.OS == 'win32';
  7. var path_sep = isWindows ? '\\' : '/';
  8. var isStaticBuild = WScript.Platform && WScript.Platform.LINK_TYPE == 'static';
  9. var sharedExtension = (WScript.Platform.OS == "darwin") ? ".dylib" : ".so";
  10. if (isStaticBuild) {
  11. // test will be ignored
  12. print("# IGNORE_THIS_TEST");
  13. } else {
  14. var platform = WScript.Platform.OS;
  15. var arch = WScript.Platform.ARCH;
  16. var binaryPath = WScript.Platform.BINARY_PATH;
  17. // discard `ch` from path
  18. binaryPath = binaryPath.substr(0, binaryPath.lastIndexOf(path_sep));
  19. var makefile =
  20. "IDIR=" + WScript.Arguments[0] + "/lib/Jsrt \n\
  21. \n\
  22. LIBRARY_PATH=" + binaryPath + "/\n\
  23. PLATFORM=" + platform + "\n\
  24. ARCH=" + arch + "\n\
  25. LDIR=$(LIBRARY_PATH)/libChakraCore" + sharedExtension + " \n\
  26. \n\
  27. ifeq (darwin, ${PLATFORM})\n\
  28. \tifeq (ARM64, ${ARCH})\n\
  29. \t\tICU4C_LIBRARY_PATH ?= /opt/homebrew/opt/icu4c\n\
  30. \t\else\n\
  31. \t\tICU4C_LIBRARY_PATH ?= /usr/local/opt/icu4c\n\
  32. \tendif\n\
  33. \tCFLAGS=-lstdc++ -std=c++11 -I$(IDIR)\n\
  34. \tFORCE_STARTS=-Wl,-force_load,\n\
  35. \tFORCE_ENDS=\n\
  36. \tLIBS=-framework CoreFoundation -framework Security -lm -ldl -Wno-c++11-compat-deprecated-writable-strings \
  37. -Wno-deprecated-declarations -Wno-unknown-warning-option -o sample.o\n\
  38. \tLDIR+=$(ICU4C_LIBRARY_PATH)/lib/libicudata.a \
  39. $(ICU4C_LIBRARY_PATH)/lib/libicuuc.a \
  40. $(ICU4C_LIBRARY_PATH)/lib/libicui18n.a\n\
  41. else\n\
  42. \tCFLAGS=-lstdc++ -std=c++0x -I$(IDIR)\n\
  43. \tFORCE_STARTS=-Wl,--whole-archive\n\
  44. \tFORCE_ENDS=-Wl,--no-whole-archive\n\
  45. \tLIBS=-pthread -lm -ldl -licuuc -Wno-c++11-compat-deprecated-writable-strings \
  46. -Wno-deprecated-declarations -Wno-unknown-warning-option -o sample.o\n\
  47. endif\n\
  48. \n\
  49. testmake:\n\
  50. \t$(CC) sample.cpp $(CFLAGS) $(FORCE_STARTS) $(LDIR) $(FORCE_ENDS) $(LIBS)\n\
  51. \n\
  52. .PHONY: clean\n\
  53. \n\
  54. clean:\n\
  55. \trm sample.o\n";
  56. print(makefile)
  57. }