# HG changeset patch # User William Welliver # Date 1624589381 14400 # Thu Jun 24 22:49:41 2021 -0400 # Node ID e7145d8c0ff0f590b52aad6ac1918e795863fd3d # Parent 155d36eb8dcc8824ea3eb64bc9776d25102765b1 add option to skip stub building, and add another SDK location diff --git a/mkapp.pike b/mkapp.pike --- a/mkapp.pike +++ b/mkapp.pike @@ -9,11 +9,13 @@ string framework_bundle = "Pike.framework"; -array sdk_locs = ({"/Developer/SDKs", "/SDKs", "/Developer"}); +array sdk_locs = ({"/Developer/SDKs", "/SDKs", "/Developer", "/Library/Developer/CommandLineTools/SDKs"}); + +int no_embedded_pike = 0; string gcc = "clang"; -string sdk = "MacOSX10.9.sdk"; -string cc_args = "-mmacosx-version-min=10.9 -isysroot ${SDK} -m32 -arch i386 -F."; +string sdk = "MacOSX10.14.sdk"; +string cc_args = "-mmacosx-version-min=10.10 -isysroot ${SDK} -F. -I/usr/local/include"; string ld_args = "-lobjc -lpthread -framework AppKit -framework Pike -framework System -framework Foundation"; int main(int argc, array(string) argv) @@ -36,6 +38,7 @@ { foreach(Getopt.find_all_options(argv,aggregate( ({"help",Getopt.NO_ARG,({"--help"}) }), + ({"no_embedded_pike",Getopt.NO_ARG,({"--no-embedding"}) }), ({"identifier",Getopt.HAS_ARG,({"--identifier"}) }), ({"gcc",Getopt.HAS_ARG,({"--with-gcc"}) }), ({"sdk",Getopt.HAS_ARG,({"--with-sdk"}) }), @@ -45,6 +48,9 @@ { switch(opt[0]) { + case "no_embedded_pike": + no_embedded_pike = 1; + break; case "identifier": identifier = opt[1]; break; @@ -103,7 +109,7 @@ { write("mkapp: generating application bundle for %s\n", app_name); - if(!file_stat(framework_bundle)) + if(!no_embedded_pike && !file_stat(framework_bundle)) { werror("mkapp: Pike framework %O does not exist. aborting.\n", framework_bundle); exit(2); @@ -120,21 +126,23 @@ Stdio.mkdirhier(app_name + ".app/Contents/Resources"); Stdio.mkdirhier(app_name + ".app/Contents/Frameworks"); - make_file(app_name + ".m", app_stub); + if(!no_embedded_pike) + make_file(app_name + ".m", app_stub); make_file(app_name + ".app/Contents/Resources/" + app_name + ".pike", pike_stub); make_file(app_name + ".app/Contents/PkgInfo", pkg_info); make_file(app_name + ".app/Contents/Info.plist", info_plist); - Process.system("cp -Rf \"" + framework_bundle + "\" \"" + app_name + ".app/Contents/Frameworks\""); + if(!no_embedded_pike) { + Process.system("cp -Rf \"" + framework_bundle + "\" \"" + app_name + ".app/Contents/Frameworks\""); - string my_cc_args = find_sdk(cc_args); - string my_ld_args = find_sdk(ld_args); + string my_cc_args = find_sdk(cc_args); + string my_ld_args = find_sdk(ld_args); - my_system(gcc + " " + my_cc_args + " -c '" + app_name + ".m' -o '" + app_name + ".o'"); + my_system(gcc + " " + my_cc_args + " -c '" + app_name + ".m' -o '" + app_name + ".o'"); // my_system(gcc + " " + my_cc_args + " -c method_getArgInfo.m -o '" + app_name + "_getArgInfo.o'"); - my_system(gcc + " " + my_cc_args + " '" + app_name + ".o' -o '" + app_name + ".app/Contents/MacOS/" + app_name + "' " + ld_args); - rm(app_name + ".o"); - + my_system(gcc + " " + my_cc_args + " '" + app_name + ".o' -o '" + app_name + ".app/Contents/MacOS/" + app_name + "' " + ld_args); + rm(app_name + ".o"); + } write("mkapp: Build complete.\n"); } @@ -162,7 +170,7 @@ if(file_stat(candidate)) { fqsdk = candidate; break; } } - if(!fqsdk) { werror("SDK " + sdk + " found in (" + sdk_locs*", " + ").\n"); exit(1);} + if(!fqsdk) { werror("SDK " + sdk + " not found in (" + sdk_locs*", " + ").\n"); exit(1);} write("mkapp: found SDK at %s\n", fqsdk); return replace(args, "${SDK}", fqsdk); @@ -295,7 +303,7 @@ sv = [i evalString: @\"add_module_path(\\\"modules\\\")\"]; free_svalue(sv); -sv2 = [i evalString: @\"master()->resolv(\\\"Public.ObjectiveC.module\\\")\"]; +sv2 = [i evalString: @\"master()->resolv(\\\"Public.ObjectiveC.Cocoa\\\")\"]; free_svalue(sv2); push_text(\"__APPPATH\"); @@ -346,6 +354,7 @@ Options: --help + --no-embedding don't build stub binary --version=bundle_version --identifier=bundle_identifier --framework=path_to_pike_framework