aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-05 19:40:59 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-05 19:40:59 -0700
commit0822e67594211850b9e21c8860594a13737f95cb (patch)
treedec6031cbf96c4889bc9da11390d9ee4890e883c
parent7e79d9dae678b841a3682819610f0c6819437160 (diff)
downloadbun-0822e67594211850b9e21c8860594a13737f95cb.tar.gz
bun-0822e67594211850b9e21c8860594a13737f95cb.tar.zst
bun-0822e67594211850b9e21c8860594a13737f95cb.zip
such entitle
Former-commit-id: de26ae30116e3c13c48a710201a7da0817ffd9e5
-rw-r--r--Makefile13
-rw-r--r--entitlements.plist12
-rw-r--r--src/bundler.zig3
-rw-r--r--src/cli.zig57
-rw-r--r--src/css_scanner.zig80
5 files changed, 103 insertions, 62 deletions
diff --git a/Makefile b/Makefile
index 060d0bf38..cfaf71d3b 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,11 @@ build-obj:
sign-macos-x64:
gon sign.macos-x64.json
+sign-macos-aarch64:
+ gon sign.macos-aarch64.json
+
release-macos-x64: build-obj bun-link-lld-release sign-macos-x64
+release-macos-aarch64: build-obj bun-link-lld-release sign-macos-aarch64
api:
npm install; ./node_modules/.bin/peechy --schema src/api/schema.peechy --esm src/api/schema.js --ts src/api/schema.d.ts --zig src/api/schema.zig
@@ -122,6 +126,15 @@ bun-link-lld-release:
-flto \
-O3
+bun-link-lld-release-aarch64:
+ clang++ $(BUN_LLD_FLAGS) \
+ build/macos-aarch64/bun.o \
+ -o build/macos-aarch64/bun \
+ -Wl,-dead_strip \
+ -ftls-model=local-exec \
+ -flto \
+ -O3
+
# We do this outside of build.zig for performance reasons
# The C compilation stuff with build.zig is really slow and we don't need to run this as often as the rest
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
diff --git a/entitlements.plist b/entitlements.plist
new file mode 100644
index 000000000..d0754d039
--- /dev/null
+++ b/entitlements.plist
@@ -0,0 +1,12 @@
+<dict>
+ <key>com.apple.security.cs.allow-jit</key>
+ <true/>
+ <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
+ <true/>
+ <key>com.apple.security.cs.allow-dyld-environment-variables</key>
+ <true/>
+ <key>com.apple.security.cs.disable-library-validation</key>
+ <true/>
+ <key>com.apple.security.cs.disable-executable-page-protection</key>
+ <true/>
+ </dict> \ No newline at end of file
diff --git a/src/bundler.zig b/src/bundler.zig
index c4b296d34..484a25201 100644
--- a/src/bundler.zig
+++ b/src/bundler.zig
@@ -1832,7 +1832,8 @@ pub fn NewBundler(cache_files: bool) type {
&bundler.linker,
bundler.log,
);
- try css_writer.run(bundler.log, bundler.allocator);
+ var did_warn = false;
+ try css_writer.run(bundler.log, bundler.allocator, &did_warn);
output_file.size = css_writer.written;
var file_op = options.OutputFile.FileOperation.fromFile(file.handle, file_path.pretty);
diff --git a/src/cli.zig b/src/cli.zig
index edc209014..a6310022a 100644
--- a/src/cli.zig
+++ b/src/cli.zig
@@ -150,7 +150,7 @@ pub const Arguments = struct {
pub const ParamType = clap.Param(clap.Help);
- const params: [25]ParamType = brk: {
+ const params: [23]ParamType = brk: {
@setEvalBranchQuota(9999);
break :brk [_]ParamType{
clap.parseParam("--use <STR> Choose a framework, e.g. \"--use next\". It checks first for a package named \"bun-framework-packagename\" and then \"packagename\".") catch unreachable,
@@ -171,13 +171,13 @@ pub const Arguments = struct {
// clap.parseParam("--production   [not implemented] generate production code") catch unreachable,
clap.parseParam("--public-dir <STR> Top-level directory for .html files, fonts or anything external. Defaults to \"<cwd>/public\", to match create-react-app and Next.js") catch unreachable,
clap.parseParam("--tsconfig-override <STR> Load tsconfig from path instead of cwd/tsconfig.json") catch unreachable,
- clap.parseParam("-d, --define <STR>... Substitute K:V while parsing, e.g. --define process.env.NODE_ENV:development") catch unreachable,
+ clap.parseParam("-d, --define <STR>... Substitute K:V while parsing, e.g. --define process.env.NODE_ENV:\"development\". Values are parsed as JSON.") catch unreachable,
clap.parseParam("-e, --external <STR>... Exclude module from transpilation (can use * wildcards). ex: -e react") catch unreachable,
clap.parseParam("-h, --help Display this help and exit. ") catch unreachable,
clap.parseParam("-i, --inject <STR>... Inject module at the top of every file") catch unreachable,
- clap.parseParam("-l, --loader <STR>... Parse files with .ext:loader, e.g. --loader .js:jsx. Valid loaders: jsx, js, json, tsx (not implemented yet), ts (not implemented yet), css (not implemented yet)") catch unreachable,
- clap.parseParam("-o, --outdir <STR> Save output to directory (default: \"out\" if none provided and multiple entry points passed)") catch unreachable,
- clap.parseParam("-r, --resolve <STR> Determine import/require behavior. \"disable\" ignores. \"dev\" bundles node_modules and builds everything else as independent entry points") catch unreachable,
+ clap.parseParam("-l, --loader <STR>... Parse files with .ext:loader, e.g. --loader .js:jsx. Valid loaders: jsx, js, json, tsx, ts, css") catch unreachable,
+ // clap.parseParam("-o, --outdir <STR> Save output to directory (default: \"out\" if none provided and multiple entry points passed)") catch unreachable,
+ // clap.parseParam("-r, --resolve <STR> Determine import/require behavior. \"disable\" ignores. \"dev\" bundles node_modules and builds everything else as independent entry points") catch unreachable,
// clap.parseParam("-r, --resolve <STR> Determine import/require behavior. \"disable\" ignores. \"dev\" bundles node_modules and builds everything else as independent entry points") catch unreachable,
clap.parseParam("<POS>... ") catch unreachable,
@@ -235,7 +235,8 @@ pub const Arguments = struct {
std.os.exit(0);
}
- var output_dir = args.option("--outdir");
+ // var output_dir = args.option("--outdir");
+ var output_dir: ?string = null;
var define_keys = defines_tuple.keys;
var define_values = defines_tuple.values;
@@ -337,28 +338,28 @@ pub const Arguments = struct {
switch (comptime cmd) {
.BuildCommand => {
- if (args.option("--resolve")) |_resolve| {
- switch (ResolveMatcher.match(_resolve)) {
- ResolveMatcher.case("disable") => {
- opts.resolve = Api.ResolveMode.disable;
- },
- ResolveMatcher.case("bundle") => {
- opts.resolve = Api.ResolveMode.bundle;
- },
- ResolveMatcher.case("dev") => {
- opts.resolve = Api.ResolveMode.dev;
- },
- ResolveMatcher.case("lazy") => {
- opts.resolve = Api.ResolveMode.lazy;
- },
- else => {
- diag.name.long = "--resolve";
- diag.arg = _resolve;
- try diag.report(Output.errorWriter(), error.InvalidResolveOption);
- std.process.exit(1);
- },
- }
- }
+ // if (args.option("--resolve")) |_resolve| {
+ // switch (ResolveMatcher.match(_resolve)) {
+ // ResolveMatcher.case("disable") => {
+ // opts.resolve = Api.ResolveMode.disable;
+ // },
+ // ResolveMatcher.case("bundle") => {
+ // opts.resolve = Api.ResolveMode.bundle;
+ // },
+ // ResolveMatcher.case("dev") => {
+ // opts.resolve = Api.ResolveMode.dev;
+ // },
+ // ResolveMatcher.case("lazy") => {
+ // opts.resolve = Api.ResolveMode.lazy;
+ // },
+ // else => {
+ // diag.name.long = "--resolve";
+ // diag.arg = _resolve;
+ // try diag.report(Output.errorWriter(), error.InvalidResolveOption);
+ // std.process.exit(1);
+ // },
+ // }
+ // }
},
else => {},
}
diff --git a/src/css_scanner.zig b/src/css_scanner.zig
index 1415ac3e6..4dc6fa106 100644
--- a/src/css_scanner.zig
+++ b/src/css_scanner.zig
@@ -114,6 +114,8 @@ pub const Scanner = struct {
codepoint: CodePoint = -1,
approximate_newline_count: usize = 0,
+ did_warn_tailwind: bool = false,
+
pub fn init(log: *logger.Log, allocator: *std.mem.Allocator, source: *const logger.Source) Scanner {
return Scanner{ .log = log, .source = source, .allocator = allocator };
}
@@ -316,6 +318,18 @@ pub const Scanner = struct {
return text;
}
+ pub fn warnTailwind(scanner: *Scanner, start: usize) void {
+ if (scanner.did_warn_tailwind) return;
+ scanner.did_warn_tailwind = true;
+ scanner.log.addWarningFmt(
+ scanner.source,
+ logger.usize2Loc(start),
+ scanner.allocator,
+ "To use Tailwind with Bun, use the Tailwind CLI and import the processed .css file.\nLearn more: https://tailwindcss.com/docs/installation#watching-for-changes",
+ .{},
+ ) catch {};
+ }
+
pub fn next(
scanner: *Scanner,
comptime import_behavior: ImportBehavior,
@@ -495,46 +509,22 @@ pub const Scanner = struct {
switch (word[0]) {
'b' => {
if (strings.eqlComptime(word, "base")) {
- scanner.log.addWarningFmt(
- scanner.source,
- logger.Loc{ .start = @intCast(i32, start) },
- scanner.allocator,
- "Tailwind not supported yet, try @import \"tailwindcss/dist/base.css\";",
- .{},
- ) catch {};
+ scanner.warnTailwind(start);
}
},
'c' => {
if (strings.eqlComptime(word, "components")) {
- scanner.log.addWarningFmt(
- scanner.source,
- logger.Loc{ .start = @intCast(i32, start) },
- scanner.allocator,
- "Tailwind not supported yet, try @import \"tailwindcss/dist/components.css\";",
- .{},
- ) catch {};
+ scanner.warnTailwind(start);
}
},
'u' => {
if (strings.eqlComptime(word, "utilities")) {
- scanner.log.addWarningFmt(
- scanner.source,
- logger.Loc{ .start = @intCast(i32, start) },
- scanner.allocator,
- "Tailwind not supported yet, try @import \"tailwindcss/dist/utilities.css\";",
- .{},
- ) catch {};
+ scanner.warnTailwind(start);
}
},
's' => {
if (strings.eqlComptime(word, "screens")) {
- scanner.log.addWarningFmt(
- scanner.source,
- logger.Loc{ .start = @intCast(i32, start) },
- scanner.allocator,
- "Tailwind not supported yet, try @import \"tailwindcss/dist/screens.css\";",
- .{},
- ) catch {};
+ scanner.warnTailwind(start);
}
},
else => continue :toplevel,
@@ -897,7 +887,12 @@ pub fn NewWriter(
};
}
- pub fn scan(writer: *Writer, log: *logger.Log, allocator: *std.mem.Allocator) !void {
+ pub fn scan(
+ writer: *Writer,
+ log: *logger.Log,
+ allocator: *std.mem.Allocator,
+ did_warn_tailwind: *bool,
+ ) !void {
var scanner = Scanner.init(
log,
@@ -905,10 +900,17 @@ pub fn NewWriter(
writer.source,
);
+ scanner.did_warn_tailwind = did_warn_tailwind.*;
try scanner.next(.scan, @TypeOf(writer), writer, scanChunk);
+ did_warn_tailwind.* = scanner.did_warn_tailwind;
}
- pub fn append(writer: *Writer, log: *logger.Log, allocator: *std.mem.Allocator) !usize {
+ pub fn append(
+ writer: *Writer,
+ log: *logger.Log,
+ allocator: *std.mem.Allocator,
+ did_warn_tailwind: *bool,
+ ) !usize {
var scanner = Scanner.init(
log,
@@ -916,19 +918,30 @@ pub fn NewWriter(
writer.source,
);
+ scanner.did_warn_tailwind = did_warn_tailwind.*;
+
try scanner.next(.omit, @TypeOf(writer), writer, writeBundledChunk);
+ did_warn_tailwind.* = scanner.did_warn_tailwind;
+
return scanner.approximate_newline_count;
}
- pub fn run(writer: *Writer, log: *logger.Log, allocator: *std.mem.Allocator) !void {
+ pub fn run(
+ writer: *Writer,
+ log: *logger.Log,
+ allocator: *std.mem.Allocator,
+ did_warn_tailwind: *bool,
+ ) !void {
var scanner = Scanner.init(
log,
allocator,
writer.source,
);
+ scanner.did_warn_tailwind = did_warn_tailwind.*;
try scanner.next(.keep, @TypeOf(writer), writer, commitChunk);
+ did_warn_tailwind.* = scanner.did_warn_tailwind;
}
fn writeString(writer: *Writer, str: string, quote: Chunk.TextContent.Quote) !void {
@@ -1180,13 +1193,14 @@ pub fn NewBundler(
css.buildCtx = &this;
try this.addCSSImport(absolute_path);
+ var did_warn_tailwind: bool = false;
while (this.import_queue.readItem()) |item| {
const watcher_id = this.watcher.indexOf(item) orelse unreachable;
const watch_item = this.watcher.watchlist.get(watcher_id);
const source = try this.getSource(watch_item.file_path, watch_item.fd);
css.source = &source;
- try css.scan(log, allocator);
+ try css.scan(log, allocator, &did_warn_tailwind);
}
// This exists to identify the entry point
@@ -1222,7 +1236,7 @@ pub fn NewBundler(
try this.writeAll("/* ");
try this.writeAll(file_path);
try this.writeAll("*/\n");
- lines_of_code += try css.append(log, allocator);
+ lines_of_code += try css.append(log, allocator, &did_warn_tailwind);
}
try this.writer.done();