Platform.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. if (!isStaticBuild) {
  10. // test will be ignored
  11. print("# IGNORE_THIS_TEST");
  12. } else {
  13. var platform = WScript.Platform.OS;
  14. var arch = WScript.Platform.ARCH;
  15. var binaryPath = WScript.Platform.BINARY_PATH;
  16. // discard `ch` from path
  17. binaryPath = binaryPath.substr(0, binaryPath.lastIndexOf(path_sep));
  18. var makefile =
  19. "IDIR=" + WScript.Arguments[0] + "/lib/Jsrt \n\
  20. \n\
  21. LIBRARY_PATH=" + binaryPath + "/lib\n\
  22. PLATFORM=" + platform + "\n\
  23. ARCH=" + arch + "\n\
  24. LDIR=$(LIBRARY_PATH)/libChakraCoreStatic.a \n\
  25. \n\
  26. ifeq (darwin, ${PLATFORM})\n\
  27. \tifeq (ARM64, ${ARCH})\n\
  28. \t\tICU4C_LIBRARY_PATH ?= /opt/homebrew/opt/icu4c\n\
  29. \t\else\n\
  30. \t\tICU4C_LIBRARY_PATH ?= /usr/local/opt/icu4c\n\
  31. \tendif\n\
  32. \tCFLAGS=-lstdc++ -std=c++11 -I$(IDIR)\n\
  33. \tFORCE_STARTS=-Wl,-force_load,\n\
  34. \tFORCE_ENDS=\n\
  35. \tLIBS=-framework CoreFoundation -framework Security -lm -ldl -Wno-c++11-compat-deprecated-writable-strings \
  36. -Wno-deprecated-declarations -Wno-unknown-warning-option -o sample.o\n\
  37. \tLDIR+=$(ICU4C_LIBRARY_PATH)/lib/libicudata.a \
  38. $(ICU4C_LIBRARY_PATH)/lib/libicuuc.a \
  39. $(ICU4C_LIBRARY_PATH)/lib/libicui18n.a\n\
  40. else\n\
  41. \tCFLAGS=-lstdc++ -std=c++0x -I$(IDIR)\n\
  42. \tFORCE_STARTS=-Wl,--whole-archive\n\
  43. \tFORCE_ENDS=-Wl,--no-whole-archive\n\
  44. \tLIBS=-pthread -lm -ldl -licuuc -Wno-c++11-compat-deprecated-writable-strings \
  45. -Wno-deprecated-declarations -Wno-unknown-warning-option -o sample.o\n\
  46. endif\n\
  47. \n\
  48. testmake:\n\
  49. \t$(CC) sample.cpp $(CFLAGS) $(FORCE_STARTS) $(LDIR) $(FORCE_ENDS) $(LIBS)\n\
  50. \n\
  51. .PHONY: clean\n\
  52. \n\
  53. clean:\n\
  54. \trm sample.o\n";
  55. print(makefile)
  56. }